任何人都可以帮助我阐明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