0

I want get sku

<?php echo __('Product code') . ": " . $item->getSku(); ?>

This is my code, it not work

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php
/** @var \Magento\Wishlist\Block\Customer\Wishlist\Items $block */
$columns = $block->getColumns();
?>

<div class="products-grid wishlist">
    <?php if (count($block->getItems())) : ?>
    <ol class="product-items">
        <?php foreach ($block->getItems() as $item) : ?>
        <li data-row="product-item" class="product-item" id="item_<?= $block->escapeHtmlAttr($item->getId()) ?>">
            <div class="product-item-info" data-container="product-grid">
                <?php foreach ($columns as $column) : ?>
                <?= $column->setItem($item)->toHtml();?>
                <?php endforeach; ?>
            </div>
            <div class="product-sku">
                <?php echo __('Product code') . ": " . $item->getSku(); ?>
            </div>
        </li>
        <?php endforeach; ?>
    </ol>
    <?php else : ?>
    <div class="message info empty">
        <span><?= $block->escapeHtml(__('This Wish List has no Items')) ?></span>
    </div>
    <?php endif; ?>
</div>

<?php foreach ($columns as $column) : ?>
<?= $column->getAdditionalHtml() ?>
<?php endforeach; ?>

In product enter image description here

1

1 Answer 1

0

Please call it like below. It will work for sure.

<?php echo __('Product code') . ": " . $item->getProduct()->getSku(); ?>

Please check screen shot:- https://prnt.sc/16f6gn0

Cheers!

1
  • 1
    It work, Thank you
    – HuanTH
    Jun 23, 2021 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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