Can we show or display custom attribute like brand in sidebar wishlist? If yes then how?

enter image description here


Yes, we can display custom attribute in sidebar wishlist item.

  1. Override wishlist.php file into your module.

    vendor/magento/module-wishlist/CustomerData/Wishlist.php to


    I added one custom brand attribute in this file.

    Example: 'product_brand' => $product->getAttributeText("brand"),

    See screenshot

    enter image description here

  2. Add or Edit di.xml file app/code/[Vendor_Name]/[Module_Name]/etc/di.xml

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Wishlist\CustomerData\Wishlist" type="CsVikram\CustomAttribute\CustomerData\Wishlist" /> </config>

  1. Now you can get attribute value in sidebar.phtml template file. Please override this file in your theme from vendor. vendor/magento/module-wishlist/view/frontend/templates/sidebar.phtml to app/design/frontend/[Vendor_Name]/[Theme_Name]/Magento_Wishlist/templates/sidebar.phtml

    Example: <div class="brand-name"><span data-bind="text: product_brand"></span></div>

    enter image description here

    Please upgrade and clean cache. I hope it will work like my screenshot.

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.