I have a phtml file. I want to get the product short description by SKU.
I can use ObjectManager to do the work. But looks like this is not a proper way to do it.
Anyone can help with recommendation to replace ObjectManager method? Thanks!
<?= $block->getProductName($item->getProductId()) ?>
<?= $item->getProductId() ?>
<?= $item->getSku() ?>
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$currentproduct = $objectManager->create('MagentoCatalogModelProductRepository')->get($item->getSku());
echo $currentproduct ->getShortDescription();
?>
rest of the code
<?php
// @codingStandardsIgnoreFile
?>
<?php $helper = $this->helper('MagentoCatalogHelperOutput'); ?>
<?php /** @var $items MagentoSalesModelOrder */ $items = $block->getOrder(); ?>
<?php if ($items): ?>
<?php
foreach ($items as $item) {
$order = $item->getOrder();
}
?>
<div style="width:100%;padding:10px 0 20px 0;height:auto;min-height:360px" class="review-email-form-wrapper">
<p><?= /* @escapeNotVerified */ __('your purchased items:') ?></p>
<ul>
<?php /** @var $item MagentoSalesApiDataOrderItemInterface */ ?>
<?php foreach ($items as $item): ?>
<?php $productUrl=$block->getProductReviewUrl($item->getProductId()) ?>
<li>
<a href="<?= $escaper->escapeUrl($productUrl) ?>"><?= /* @escapeNotVerified */ $block->getProductName($item->getProductId()) ?></a>
</li>
<?php endforeach; ?>
</ul>
<p><?= /* @escapeNotVerified */ __('Thankyou for your feedback', $order->getStore()->getGroup()->getName()); ?></p>
</div>
<?php endif; ?>