表catalog_product_index_price中缺少某些产品!


11

任何人都可以帮助我阐明Magento中的价格指数吗?我正在使用1.9版。
我的任务:将特色产品渲染到主页中。
我的解决方案:而不是创建名为“特色产品”的类别。我创建了一个属性“ is_featured”,因此只过滤该属性为true的产品即可获得预期的结果。
基于内置的小部件Mage_Catalog_Block_Product_Widget_New,我的函数用于获取定义的产品集合:

protected function _getProductCollection()
    {
        /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
        $collection = Mage::getResourceModel('catalog/product_collection');
        $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
        $collection = $this->_addProductAttributesAndPrices($collection)
            ->addStoreFilter()
            ->addAttributeToFilter('is_featured', array('eq' => true))
            ->setPageSize($this->getProductsCount())
            ->setCurPage(1);
        return $collection;
    }

结果:出现了一些产品,但缺少其他一些产品。在进行SQL调试时,我看到:

SELECT 
    `e`.*,
    `cat_index`.`position` AS `cat_index_position`,
    `price_index`.`price`,
    `price_index`.`tax_class_id`,
    `price_index`.`final_price`,
    IF(price_index.tier_price IS NOT NULL,
        LEAST(price_index.min_price,
                price_index.tier_price),
        price_index.min_price) AS `minimal_price`,
    `price_index`.`min_price`,
    `price_index`.`max_price`,
    `price_index`.`tier_price`,
    `at_is_featured`.`value` AS `is_featured`
FROM
    `catalog_product_entity` AS `e`
        INNER JOIN
    `catalog_category_product_index` AS `cat_index` ON cat_index.product_id = e.entity_id
        AND cat_index.store_id = '1'
        AND cat_index.visibility IN (2 , 4)
        AND cat_index.category_id = '2'
        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_entity_int` AS `at_is_featured` ON (`at_is_featured`.`entity_id` = `e`.`entity_id`)
        AND (`at_is_featured`.`attribute_id` = '210')
        AND (`at_is_featured`.`store_id` = 0)
WHERE
    (at_is_featured.value = '1')
LIMIT 6

问题在这里,catalog_category_product_index,此表中缺少某些产品?但是我不知道,为什么某些产品的索引会丢失?我已经尝试了很多次Re-Index而没有得到预期的结果!有人可以帮助我吗?非常感谢!


我正在处理同一个问题。运气好的话?
versalle88 '16

Answers:


2

如果价格指数中缺少某种产品,通常是因为该产品与当前网站没有关联。

要了解如何对产品建立索引,请运行价格索引器并在Mage_Catalog_Model_Resource_Product_Indexer_Price_Default::_prepareFinalPriceData()第285行附近调试查询(在prepare_catalog_product_index_select触发事件之后)

这是针对简单产品的。对于其他产品类型,其相应的索引器实现(的子类Mage_Catalog_Model_Resource_Product_Indexer_Abstract)相同。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.