entfernen zu Vergleichsliste hinzufügen Magento 2

On the homepage of our shop, under “Best-Selling Products”, the “Add to Compare” function needs to be removed. We inserted the following code snippets into our .xml file

\app\design\frontend\theme-name\default\Magento_Theme\layout\default.xml

:

<referenceBlock name="view.addto.compare" remove="true" />

<referenceBlock name="category.product.addto.compare" remove="true" >

<referenceBlock name="related.product.addto.compare" remove="true" />

<referenceBlock name="upsell.product.addto.compare" remove="true" />

<referenceBlock name="catalog.compare.link" remove="true"/>

<referenceBlock name="catalog.compare.sidebar" remove="true"/>

 

However, this did not remove the function from the homepage. (see https://magento.stackexchange.com/questions/212883/how-to-remove-add-to-compare-links-in-magento-2-2-0 )       ,

 

To do this, an override must be created for the following file: \vendor\magento\module-catalog-widget\view\frontend\templates\product\widget\content\grid.phtml.

We place it under:  \app\design\frontend\theme-name\default\Magento_CatalogWidget\templates\product\widget\content\

It is very important that the folder is named Magento_CatalogWidget and not Magento_Catalog_Widget .              

In the override, we set the “showCompare” variable to “false”:

$showCompare = false; 

To see the changes on the homepage, the “Full Page” and “Block” caches must be cleared.