Hot answers tagged

66

In Magento 2, you can actually now remove Compare products functionality via xml file. Compare products block is defined in vendor/magento/module-catalog/view/frontend/layout/default.xml and you can remove it by adding a default.xml file to your theme in: <theme_dir>/Magento_Catalog/layout/default.xml inside which you remove your block as following: ...


37

You can add following xml instruction to either your custom theme's default xml file which should be located at /app/design/frontend/Vendor/theme/Magento_Theme/layout/default.xml or to Magento_Catalog/layout/default.xml file in your custom theme: <referenceBlock name="catalog.compare.sidebar" remove="true"/> <referenceBlock name="view.addto....


32

I grepped the source for all compare blocks. For 2.3 this is the complete list. This will also remove the compare link from the header. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <!-- Remove compare --> &...


9

For messages to appear you need to call this in the controller before calling renderLayout() $this->initLayoutMessages('catalog/session'); This will tell Magento to display the messages set for a particular session type. The example above tells Magento to display the messages set for the catalog session. Other options are customer/session, core/session, ...


8

Try replacing $_helper->getListUrl() with $this->getUrl('catalog/product_compare/index') [EDIT] And make sure you have products in the comparison list.


8

Update your extended catalog_category_view.xml file and Find it at your extended theme path app/design/frontend/vendorname/themename/Magento_Catalog/layout/catalog_category_view.xml To remove compare from listing Page use this code <referenceBlock name="category.product.addto.compare" remove="true"/> I hope this will help you if not then let me ...


7

Disable Wishlist on Stores > Configuration > Customers > Wishlist and to disable the Compare function paste this lines below on Magento_Catalog/layout/default.xml of your theme. <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration....


7

As it stands I would say that this question is somewhat unanswerable - the reason that it uses the log tables is because it does. I really don't think that there was much rationale other than to say that Mage_Log has been present since 0.6B and that early efforts may have been to hook initial functionality on it; after some time the limitations probably came ...


6

Magento provide command line utility for it example php bin/magento module:disable -f Magento_Wishlist as Magento wishlist depend upon the other module as well so using without [-f] will not disable or enable the module and will display warning like after using command with [-f] flag will solve this issue please check the warning when you are using ...


6

It can be disabled from store > Configurations > Customers > Wish List> General options> Enabled: No.


6

As of 2.1 theres no way to disable the compare functionality in the Backend. The only thing you can do is via the theme: In your Magento_Catalog/layout/default.xml of your theme you need the following code to remove the sidebar: <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/...


6

protected $_productloader; protected $_compareItemFactory; protected $_catalogProductCompareList; public function __construct( \Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory, \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList, \Magento\Catalog\Model\ProductFactory $productloader ) { $this-&...


5

UPDATE: After a Magento 2 core update, klara's answer is now the best way to disable Compare functionality. Please read below ! To disable Wish List functionality, you need to go in the administration, under Stores > Configuration > Customers > Wish List and choose Enabled : No. To disable Compare functionality, there's no option in the administration. You ...


5

You can use the code that Magento uses in the clearAction() of the product compare controller and addapt it a little: $items = Mage::getResourceModel('catalog/product_compare_item_collection'); if (Mage::getSingleton('customer/session')->isLoggedIn()) { $items->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId()); }...


5

We need to override the block class Mage_Catalog_Block_Product_Compare_List and function getAttributes(), this way we have pre sorted array list of attributes instead of having to do the changes at template level. public function getAttributes() { if (is_null($this->_attributes)) { $this->_attributes = $this->getItems()->...


4

In order to add a product to compare you need the following url: <?php echo Mage::getBaseUrl() ?>index.php/catalog/product_compare/index/items/' + productID + '/uenc/' You can add multiple items to compare at the same time by creating a comma seperated string of the product id's. It would look something like this: <?php echo Mage::getBaseUrl() ?&...


4

For Magento 2.1.x Adding a default.xml file to your theme in: /Magento_Catalog/layout/default.xml <?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"> <body> <referenceBlock name="category.product.addto....


4

The name of the element is catalog.compare.link as defined in Magento/Catalog/view/frontend/layout/default.xml : <block class="Magento\Framework\View\Element\Template" name="catalog.compare.link" before="-" template="Magento_Catalog::product/compare/link.phtml"> <arguments> <argument name="...


4

there are many ways, simply use following from page where you want to remove app/code/design/YOUR_PACKAGE/YOUR_THEME/layout/local.xml <?xml version="1.0"?> <layout version="0.1.0"> <catalog_category_layered> <reference name="left"> <remove name="catalog.compare.sidebar" /> </reference> </...


4

Update your extended default.xml file and Find it at your extended theme path app/design/frontend/vendor-name/theme-name/Magento_Theme/layout/default.xml To remove compare from listing Page add this line of code <referenceBlock name="category.product.addto.compare" remove="true"/> This is how your default.xml will look like <?xml version="1.0"?&...


4

you need Magento_Catalog/layout/catalog_product_view.xml with the following code to remove the link on the product page: <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="view.addto.compare" remove="...


3

to disable the sidebar: <body> <referenceBlock name="catalog.compare.sidebar" remove="true"/> </body> to remove the "Add to compare" link on the product page you need to overwrite the Magento_Catalog/templates/product/view/addto.phtml file in your theme and remove the compare anchor there. This way you can keep the wishlist but ...


3

Not completely sure what you are wanting to do but the following should work well to loop through the items. $_productCollection = Mage::helper('catalog/product_compare')->getItemCollection(); foreach ($_productCollection as $product) { echo $product->getName(); } You can note that the Mage::helper('catalog/product_compare')->getItemCollection(...


3

hi you can get current customer/visitor by below code: Step1: get Compare product collection using resource model $items=Mage::getResourceModel('catalog/product_compare_item_collection') ->useProductItem(true) ->setStoreId(Mage::app()->getStore()->getId()); Step2: Then filter this collection by current visitor/ ...


3

The list of attribute which is showing in compare product list depend on Comparable on Front-end field (is_comparable) of this attribute ,if is_comparable fields is no then it cannot see this compare product list It manage from admin>Catalog>Attribute>Manage attribute> click on your attribute to see all the properties of the attribute. Here ...


3

This is an extension of other solutions provided here. Use the file /app/design/frontend/Vendor/theme/Magento_Theme/layout/default.xml and add the following <?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"> <body&...


3

In simple,you can do this Rewrite helper class Mage_Catalog_Helper_Product_Compare At that override class at getAddToCompareUrl add this condition if(!$this->_customerSession->isLoggedIn()){ return ''; } Rewrite class may be like this: <?php [ModuleNameSpace]_[ModuleName]_Helper_Catalog_Product_Compare extends ...


3

Count the item collection from helper: $this->helper('Magento\Catalog\Helper\Product\Compare')->getItemCollection()->count(); Retrieve compare list url: $this->helper('Magento\Catalog\Helper\Product\Compare')->getListUrl(); If we want to retrieve more information about items, we can build your own. A good sample here: vendor/magento/...


3

You can remove product from compare collection using below code: <a href="#" class="action tocompare" title="<?php echo $block->escapeHtml(__('Remove Compare')); ?>" aria-label="<?php echo $block->escapeHtml(__('Remove Compare')); ?>" data-post='<?php /* @escapeNotVerified */ echo $compareHelper->...


3

We can try with Plugin. We use Magento\Catalog\Helper\Product\Compare to get the current compared products. app/code/Company/Catalog/etc/frontend/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"> <type ...


Only top voted, non community-wiki answers of a minimum length are eligible