Is there any way to add the product image to the compare sidebar on the category page? I've tried the following (https://gist.github.com/rubenRP/002d06c7b8d6c6eb44d43e102f86ec38) however it doesn't seem to be working. I'm on Magento version 2.3.4.
Any help is greatly appreciated!
Hello @jazz_singh
Please follow the below steps:
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <referenceContainer name="sidebar.additional"> <block class="Magento\Framework\View\Element\Template" name="catalog.compare.sidebar" template="Vendor_Module::product/compare/sidebar.phtml"> <arguments> <argument name="jsLayout" xsi:type="array"> <item name="components" xsi:type="array"> <item name="compareProducts" xsi:type="array"> <item name="component" xsi:type="string">Magento_Catalog/js/view/compare-products</item> </item> </item> </argument> </arguments> </block> </referenceContainer> </page>
Note: After following the above 3 steps, clear cache and remove generate/code folder.
Hope it helps.
Hi @Sanjay Jethva,
I've done those steps before but I did them again and it's still not working, it breaks the compare sidebar - no product is loaded in. Do I need to add the module.xml/registration.php files to the module? I tried doing this before too but it didn't work.
Thanks.
Hey @jazz_singh again,
Are you implementing this code in a custom module or anywhere else?
Moreover, check if your plugin and sidebar.phtml are called properly using log
Thanks.
Hi @Sanjay Jethva,
Yeah, I'm creating a module which includes the files that you mentioned. The sidebar I'm using is the default 2.3.4 sidebar with the extra image line included.
Thanks!
Please check your custom module installation.
Also, when you check if the files plugins and sidebar.phtml are called properly, put log and check it's working in Magento 2.3.4.
Thanks.
Hi @Sanjay Jethva,
I've fixed the module and it's pulling the image correctly now.
Thanks for your quick replies!
Hi @jazz_singh can you share the solution I am trying to add Image to Compare Sidebar in Magento 2.4.5-p1 version