1

On our Magento site, we have it so it displays the SKU under the main product title, but if there are child listings, possibly for different configurations of the product' the sku isn't appearing. I cant seem to find any layout file associated with that child list, can anyone point me in the right direction to add the SKU to this Child Product List, An example of what I mean can be found here: https://i.imgur.com/uo11tYi.png

3
  • Do you want to add one more column for sku between Product name and sku? Aug 24 '18 at 8:53
  • I want to add a new line, under the product name in the list of child products for the sku, Just above the price. Aug 24 '18 at 9:00
  • Check my answer. Aug 24 '18 at 9:09
0

Copy the below file:

vendor/magento/module-grouped-product/view/frontend/templates/product/view/type/grouped.phtml

to your theme location like below:

app/design/frontend/Vendor/theme/Magento_GroupedProduct/templates/product/view/type/grouped.phtml

And find the below section in your grouped.phtml:

<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>

and replace with below code:

<td data-th="<?= $block->escapeHtml(__('Product Name')) ?>" class="col item">
    <strong class="product-item-name"><?= $block->escapeHtml($_item->getName()) ?></strong>
    <div class="sku"><?= $_item->getSku() ?></div>
    <?php if ($block->getCanShowProductPrice($_product)): ?>
        <?php if ($block->getCanShowProductPrice($_item)): ?>
            <?= /* @escapeNotVerified */ $block->getProductPrice($_item) ?>
        <?php endif; ?>
     <?php endif; ?>
</td>

Flush the cache and check.

11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.