Hi
I have added two extrenal attributes (File Length and File SIze) in grouped Product Layout and i am trying to get data from Product Information but i am getting blank data for more info please find the attached image
Thanks
Somasekhar N
Solved! Go to Solution.
I hope you have associated the attribute with simple products also and calling the attribute in grouped.phtml
Magento_GroupedProduct\templates\product\view\type\grouped.phtml
You can get the values of your custom attribute like this $customattrib = $this->getProduct()->getResource()->getAttributeRawValue($_item->getId(),'attribute_code',$_item->getId());
Please check if it helps.
Hi Somasekhar,
I received your direct message about this issue. I came to look at your post, but it looks like the image you uploaded had an issue. Can you share the image through a file sharing service and post the link here?
Please find the attached image.
https://drive.google.com/open?id=1iKjHGbtyuHhqL3J9rKA50Hxme4-_uuLC
I hope you have associated the attribute with simple products also and calling the attribute in grouped.phtml
Magento_GroupedProduct\templates\product\view\type\grouped.phtml
You can get the values of your custom attribute like this $customattrib = $this->getProduct()->getResource()->getAttributeRawValue($_item->getId(),'attribute_code',$_item->getId());
Please check if it helps.
in that file where i have to add in below code.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/**
* Grouped product data template
*
* @var $block \Magento\Catalog\Block\Product\View\BaseImage
* @var $block \Magento\GroupedProduct\Block\Product\View\Type\Grouped
*/
?>
<?php $block->setPreconfiguredValue(); ?>
<?php $_product = $block->getProduct(); ?>
<?php $_associatedProducts = $block->getAssociatedProducts(); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
<div class="table-wrapper grouped">
<table class="table data grouped"
id="super-product-table"
data-mage-init='{ "Magento_GroupedProduct/js/product-ids-resolver": {} }'>
<caption class="table-caption"><?= /* @escapeNotVerified */ __('Grouped product items') ?></caption>
<thead>
<tr>
<th class="col item" scope="col" style="width: 25%;"><?= /* @escapeNotVerified */ __('Product Name') ?></th>
<th class="col item" scope="col" style="width: 25%;"><?= /* @escapeNotVerified */ __('File Length') ?></th>
<th class="col item" scope="col" style="width: 25%;"><?= /* @escapeNotVerified */ __('File Size(ISO)') ?></th>
<?php if ($_product->isSaleable()): ?>
<th class="col qty" scope="col"><?= /* @escapeNotVerified */ __('Qty') ?></th>
<?php endif; ?>
</tr>
</thead>
<?php if ($_hasAssociatedProducts): ?>
<?php foreach ($_associatedProducts as $_item): ?>
<tbody>
<tr>
<td data-th="<?= $block->escapeHtml(__('Product Name')) ?>" class="col item">
<strong class="product-item-name"><?= $block->escapeHtml($_item->getName()) ?></strong>
<?php if ($block->getCanShowProductPrice($_product)): ?>
<?php if ($block->getCanShowProductPrice($_item)): ?>
<?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
<?php endif; ?>
<?php endif; ?>
</td>
<td data-th="<?= $block->escapeHtml(__('File Length')) ?>" class="col item">
<strong class="product-item-name"><?= $block->escapeHtml($_item->getlength())?></strong>
</td>
<td data-th="<?= $block->escapeHtml(__('File Size(ISO)')) ?>" class="col item">
<strong class="product-item-name"><?= $block->escapeHtml($_item->getlength()) ?></strong>
</td>
<?php if ($_product->isSaleable()): ?>
<td data-th="<?= $block->escapeHtml(__('Qty')) ?>" class="col qty">
<?php if ($_item->isSaleable()) : ?>
<div class="control qty">
<input type="number"
name="super_group[<?= /* @escapeNotVerified */ $_item->getId() ?>]"
data-selector="super_group[<?= /* @escapeNotVerified */ $_item->getId() ?>]"
value="<?= /* @escapeNotVerified */ $_item->getQty() * 1 ?>"
title="<?= /* @escapeNotVerified */ __('Qty') ?>"
class="input-text qty"
data-validate="{'validate-grouped-qty':'#super-product-table'}"
data-errors-message-box="#validation-message-box"/>
</div>
<?php else: ?>
<div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
<span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
</div>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php if ($block->getCanShowProductPrice($_product)
&& $block->getCanShowProductPrice($_item)
&& trim($block->getProductPriceHtml(
$_item,
\Magento\Catalog\Pricing\Price\TierPrice:RICE_CODE
))): ?>
<tr class="row-tier-price">
<td colspan="2">
<?= $block->getProductPriceHtml(
$_item,
\Magento\Catalog\Pricing\Price\TierPrice:RICE_CODE
) ?>
</td>
</tr>
<?php endif; ?>
</tbody>
<?php endforeach; ?>
<?php else: ?>
<tbody>
<tr>
<td class="unavailable"
colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>">
<?= /* @escapeNotVerified */ __('No options of this product are available.') ?>
</td>
</tr>
</tbody>
<?php endif; ?>
</table>
</div>
<div id="validation-message-box"></div>