我的产品比较链接无效。这是在 Magento 1.9 中。
My issues are almost identical to this post ,除了清除索引不起作用。还有什么我可以尝试的吗?
问题如下:
当我在产品上单击“添加到比较”时,会出现一条消息,指出“某某产品已成功添加到比较列表”。
但是比较产品侧边栏显示“您没有要比较的项目。”
我可以告诉表 catalog_compare_item
正在填充正确的访问者 ID 和产品 ID,但是如果我执行 print_r($this->helper('catalog/product_compare') ->getItemCount())
在 template/catalog/product/compare/sidebar.phtml 中,返回“0”。
为什么侧边栏不显示要比较的产品?
最佳答案
从评论来看,您的 Magento 数据库似乎没有 report_compared_product_index 表。
导入以下 SQL 以在您的数据库中创建此表结构。
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`);
如果这有帮助,请告诉我。
关于php - Magento:比较产品链接不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31835529/