0

As the title asks, how do I remove the "add to compare" button from a "new products" widget? Currently this is what's I'm seeing ... but only within this widget:

enter image description here

I've got the following XML in my theme's default.xml but the compare icon is still visible in the new products widget:

<referenceBlock name="catalog.compare.link" remove="true" />
<referenceBlock name="catalog.compare.sidebar" remove="true"/>
<referenceBlock name="catalogsearch.product.addto.compare" remove="true"/>
<referenceBlock name="category.product.addto.compare" remove="true"/>
<referenceBlock name="crosssell.product.addto.compare" remove="true" />
<referenceBlock name="related.product.addto.compare" remove="true" />
<referenceBlock name="upsell.product.addto.compare" remove="true" />
<referenceBlock name="view.addto.compare" remove="true" />
<referenceBlock name="catalog.compare.list" remove="true" />
5
  • Did you run all command after did that? Please run all commands with di:compile also. Sep 15, 2020 at 4:51
  • Yep ran all commands. It's only this one location where it's appearing. It's the "new products" widget so I was thinking maybe there's something I'm missing. Sep 15, 2020 at 9:30
  • Find the file of new product widget in the theme and remove compare code from it. Sep 15, 2020 at 10:01
  • Surely there's got to be an alternative way to do this than having to override the code. Sep 15, 2020 at 11:33
  • You need to find this in theme. And just remove the code. Sep 15, 2020 at 11:49

1 Answer 1

0

Open the following list of templates included Luma Magento 2 theme:

app\code\Magento\Catalog\view\frontend\templates\product\list\items.phtml
app\code\Magento\Catalog\view\frontend\templates\product\widget\new\content\new_grid.phtml
app\code\Magento\Catalog\view\frontend\templates\product\widget\new\content\new_list.phtml
app\code\Magento\CatalogWidget\view\frontend\templates\product\widget\content\grid.phtml
app\code\Magento\Reports\view\frontend\templates\widget\compared\content\compared_grid.phtml
app\code\Magento\Reports\view\frontend\templates\widget\compared\content\compared_list.phtml
app\code\Magento\Reports\view\frontend\templates\widget\viewed\content\viewed_grid.phtml
app\code\Magento\Reports\view\frontend\templates\widget\viewed\content\viewed_list.phtml

For each product list block please change

$showCompare = true;

to

$showCompare = false;

You can check your phtml file by enabling template path hint .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.