Magento Link: Compare Products Broken

My product comparison link does not work. This is in Magento 1.9.

My problems are almost identical to this post , except that index cleanup did not work. Is there anything else I can try?

Here are the problems:

When I click "Add to compare" on a product, a message appears stating that "such and such a product has been successfully added to the comparison list".

However, the Product Comparison sidebar shows "You have no items to compare."

I can say that the catalog_compare_item table is populated with the correct visitor identifier and product identifier, but if I do print_r($this->helper('catalog/product_compare')->getItemCount()) in the template / directory / product / comparison / sidebar. phtml, returns "0".

Why doesn't the sidebar show product comparison?

+6
source share
3 answers

From the comments, it looks like your Magento DB does not have a report_compared_product_index table.

Import the following SQL to create this table structure in your database.

 CREATE TABLE IF NOT EXISTS `report_compared_product_index` ( `index_id` bigint(20) unsigned NOT NULL COMMENT 'Index Id', `visitor_id` int(10) unsigned DEFAULT NULL COMMENT 'Visitor Id', `customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer Id', `product_id` int(10) unsigned NOT NULL COMMENT 'Product Id', `store_id` smallint(5) unsigned DEFAULT NULL COMMENT 'Store Id', `added_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Added At' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Reports Compared Product Index Table' AUTO_INCREMENT=1 ; ALTER TABLE `report_compared_product_index` ADD PRIMARY KEY (`index_id`), ADD UNIQUE KEY `UNQ_REPORT_COMPARED_PRODUCT_INDEX_VISITOR_ID_PRODUCT_ID` (`visitor_id`,`product_id`), ADD UNIQUE KEY `UNQ_REPORT_COMPARED_PRODUCT_INDEX_CUSTOMER_ID_PRODUCT_ID` (`customer_id`,`product_id`), ADD KEY `IDX_REPORT_COMPARED_PRODUCT_INDEX_STORE_ID` (`store_id`), ADD KEY `IDX_REPORT_COMPARED_PRODUCT_INDEX_ADDED_AT` (`added_at`), ADD KEY `IDX_REPORT_COMPARED_PRODUCT_INDEX_PRODUCT_ID` (`product_id`); 

Let me know if this helps.

+7
source

Step 1. Verify that your database has a report_compared_product_index table.

Step 2: flushing the cache and performing indexing

Step 3: Go to the following URL

 app\code\core\Mage\Catalog\Helper\Product\Compare.php 

Find the following function

 public function calculate($logout = false) 

and commenting on the code below:

  // first visit // if (!$this->_catalogSession->hasCatalogCompareItemsCount() && !$this->_customerId) { // $count = 0; // } else { /** @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Compare_Item_Collection */ $collection = Mage::getResourceModel('catalog/product_compare_item_collection') ->useProductItem(true); if (!$logout && $this->_customerSession->isLoggedIn()) { $collection->setCustomerId($this->_customerSession->getCustomerId()); } elseif ($this->_customerId) { $collection->setCustomerId($this->_customerId); } else { $collection->setVisitorId($this->_logVisitor->getId()); } /* Price data is added to consider item stock status using price index */ $collection->addPriceData(); $this->_productVisibility->addVisibleInSiteFilterToCollection($collection); $count = $collection->getSize(); // } $this->_catalogSession->setCatalogCompareItemsCount($count); return $this; 

Let me know if you have any other request.

thanks

Sagar

+1
source

fooobar.com/questions/992071 / ... this is work for me. and saved my day, a bunch of thanks, although I think it might be necessary with the redefinition of the local code maybe? but so far so good. thanks

0
source

All Articles