$feature = Mage::getResourceModel('catalog/product_collection');
Mage::getModel('catalog/layer')->prepareProductCollection($feature);
$feature->addAttributeToSort('created_at', 'desc');
$feature->addStoreFilter();
$feature->addAttributeToFilter('feature', array('eq' => 'Yes'));
//$feature->setPage(1, 6)->load();
I have the following code to filter custom attribute 'feature', some how the collection it return, it's not the same as 'feature' define in backend.
EDIT it spit out about 5-10 product, I can't find any correlation between them (sales? new?)
example
foreach($feature as $product) {
print_r($product['feature']); // return 0
print_r($product->getFeature()); // return 0
}
I reindex and cached is disable. how do I debug this?
this is $feature->getSelect(); hope this help.
SELECT `e`.*, `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`, `cat_index`.`position` AS `cat_index_position`, `at_feature`.`value` AS `feature` FROM `catalog_product_entity` AS `e` 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_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_entity_int` AS `at_feature` ON (`at_feature`.`entity_id` = `e`.`entity_id`) AND (`at_feature`.`attribute_id` = '133') AND (`at_feature`.`store_id` = 0) WHERE (at_feature.value = 'Yes') ORDER BY `e`.`created_at` desc