{"id":659,"date":"2019-11-04T05:40:09","date_gmt":"2019-11-04T05:40:09","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/11\/04\/disable-compare-products-in-magento-2\/"},"modified":"2025-05-22T15:28:08","modified_gmt":"2025-05-22T09:58:08","slug":"disable-compare-products-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/disable-compare-products-in-magento-2\/","title":{"rendered":"How to Disable Compare Products in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2 offers a vast range of functionalities to make the most out of the platform. However, you may not need them all! It depends on the type of business and its requirements that you chose the features to include or not.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, there is a built-in feature to allow customers to compare the products. It is a very useful functionality if you are selling items like appliances, machines, software, etc for which the purchase decision depends on the features and price balance. In such cases, the customers need the \u201ccompare products\u201d feature to check the feasibility.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, if you are selling apparel, the purchase decision depends on the choice, liking, size availability, etc. and the customers do not need to compare two dress\u2019 features, isn\u2019t it!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unfortunately, the default functionality does not allow to simply <strong>disable compare products in Magento 2<\/strong>. So, I\u2019ve come up with a programmatic solution that allows to remove compare product functionality.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Disable Compare Products in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create <strong>default.xml<\/strong> file in <strong>Vendor\/Extension\/view\/frontend\/layout<\/strong>&nbsp;&nbsp;and copy the below code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\">\n    &lt;body>\n        &lt;referenceBlock name=\"catalog.compare.link\" remove=\"true\" \/>\n        &lt;referenceBlock name=\"catalog.compare.sidebar\" remove=\"true\"\/>\n        &lt;referenceBlock name=\"catalogsearch.product.addto.compare\" remove=\"true\"\/>\n        &lt;referenceBlock name=\"category.product.addto.compare\" remove=\"true\"\/>\n        &lt;referenceBlock name=\"crosssell.product.addto.compare\" remove=\"true\" \/>\n        &lt;referenceBlock name=\"related.product.addto.compare\" remove=\"true\" \/>\n        &lt;referenceBlock name=\"upsell.product.addto.compare\" remove=\"true\" \/>\n        &lt;referenceBlock name=\"view.addto.compare\" remove=\"true\" \/>\n    &lt;\/body>\n&lt;\/page><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Please share the above solution with the fellow developers via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2 offers a vast range of functionalities to make the most out of the platform. However, you may not need them all! It depends&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-659","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=659"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/659\/revisions"}],"predecessor-version":[{"id":15198,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/659\/revisions\/15198"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}