3

我有一个设置为Filterable (with results)in的属性Use In Layered Navigation。我已经重新索引、清除缓存,甚至关闭了平面表,但我无法让它显示在过滤器上。

我已经在catalog_product_index_eav表格中找到了所有其他可过滤的属性 ID,但我的却不见了。

我已经跟踪了这个查询,在该查询中Mage_Catalog_Model_Layer_Filter_Attribute::_getItemsData()检查给定属性有多少产品。如果为空,则不显示属性

SELECT 
    `warehousecheckout_warehouses_idx`.`value`,
    COUNT(warehousecheckout_warehouses_idx.entity_id) AS `count`
FROM `catalog_product_flat_11` AS `e`
INNER JOIN `catalog_category_product_index` AS `cat_index`
    ON cat_index.product_id=e.entity_id
    AND cat_index.store_id=11
    AND cat_index.visibility IN(2, 4)
    AND cat_index.category_id='11'
INNER JOIN `catalog_product_index_price` AS `price_index`
    ON price_index.entity_id = e.entity_id AND price_index.website_id = '1'
    AND price_index.customer_group_id = 0
INNER JOIN `catalog_product_index_eav` AS `warehousecheckout_warehouses_idx`
    ON warehousecheckout_warehouses_idx.entity_id = e.entity_id
    AND warehousecheckout_warehouses_idx.attribute_id = '198' -- attr id i want to filter by
    AND warehousecheckout_warehouses_idx.store_id = '11'
GROUP BY `warehousecheckout_warehouses_idx`.`value`;

但是没有行,attribute_id = '198'因此该属性永远不会显示。为什么这个属性没有被索引?它是通过安装脚本创建的,而不是通过管理员创建的,因此可能在某处遗漏了某个值。

4

2 回答 2

1

对此没有直接的答案。走这条路 :

删除其他条件并触发此查询并检查是否获得结果,然后添加一个 where 条件并继续,直到找到导致所需行被消除的 where 条件。

我看到的是:warehousecheckout_warehouses_idx.entity_id = e.entity_id AND warehousecheckout_warehouses_idx.attribute_id = '198' -- attr id 我想过滤 AND warehousecheckout_warehouses_idx.store_id = '11'

也和 cat_index.category_id='11'

还有更多,但类别 ID 或商店 ID 应该是原因。

于 2013-05-14T02:47:15.770 回答
1

我能够手动在 eav 表中创建条目

insert into catalog_product_index_eav
select entity_id, attribute_id, 1, value
from catalog_product_entity_varchar
where attribute_id = 198;

insert into catalog_product_index_eav_idx
select entity_id, attribute_id, 1, value
from catalog_product_entity_varchar
where attribute_id = 198;

您必须为每个商店视图执行此操作。

于 2013-06-07T20:05:46.110 回答