How to show description of the product in wishlist phtml file?

Aug 21st, 2018 2 min to read
Table of Contents

To Display description in wishlist you have to follow the steps given below:

Step 1

Create a new file wishlist_index_index.xml at location: <root>\app\design\frontend\Companyname\Packagename\Magento_Wishlist\layout\wishlist_index_index.xml

<referenceBlock name="customer.wishlist.items">
<block class="Companyname\Packagename\Block\Description" name="customer.wishlist.item.description" template="Magento_Wishlist::item/column/description.phtml" cacheable="false" after=""/>

Step 2

Create a new file description.phtml at location: <root>\app\design\frontend\Companyname\Packagename\Magento_Wishlist\templates\item\column\description.phtml

$item = $block->getItem(); 
$product = $item->getProduct(); 
<strong class="product-item-description"> 
<?php echo $block->escapeHtml($product->getDescription()) ?> 

Step 3

Create a new file Description.php at location: <root>\app\code\Companyname\Packagename\Block\Description.php

namespace Companyname\Packagename\Block;
class Description extends \Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info
    * @var \Magento\Catalog\Api\ProductRepositoryInterface 
protected $productRepository;

public function __construct(
\Magento\Catalog\Block\Product\Context $context,
\Magento\Framework\App\Http\Context $httpContext,
array $data = [],
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository
) {
$this->productRepository = $productRepository;
parent::__construct($context, $httpContext, $data);

public function getDescription()
$id = $this->getItem()->getProduct()->getId();
$product = $this->productRepository->getById($id);
return $product->getDescription();

Note:- Do not make changes in the core files, add it in your theme directory

Step 4

In layout file replace block class from Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info to Companyname\Packagename\Block\Description

After that in your template file, you can get product description using the code given below:

Finally, run the commands given below to make changes effective:

php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy en_US -f
php bin/magento cache:clean
php bin/magento cache:flush
we forecast

Post a Comment

We don’t write crap content which is uninteresting, found everywhere and does not make any sense. Following our DNA, we write and speak about next generation technology, platforms and possibilities of digital commerce.

* This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.