0
我將使用一個產品集合,但是當我使用id加載一個產品時20 Magento返回一個SQL查詢。爲什麼magento在加載集合中返回查詢
代碼:
$products = Mage::getModel('catalog/product')->getCollection();
$products
->addAttributeToFilter('status',array('eq' => 1))
->addAttributeToSelect('name')
->addAttributeToSelect('sku')
->addAttributeToSelect('price')
->setPageSize(6);
echo $products->load(20)->getname();
SQL查詢:
SELECT `e`.*, IF(at_status.value_id > 0, at_status.value, at_status_default.value) AS `status` FROM `catalog_product_entity` AS `e` INNER JOIN `catalog_product_entity_int` AS `at_status_default` ON (`at_status_default`.`entity_id` = `e`.`entity_id`) AND (`at_status_default`.`attribute_id` = '96') AND `at_status_default`.`store_id` = 0 LEFT JOIN `catalog_product_entity_int` AS `at_status` ON (`at_status`.`entity_id` = `e`.`entity_id`) AND (`at_status`.`attribute_id` = '96') AND (`at_status`.`store_id` = 1) WHERE (IF(at_status.value_id > 0, at_status.value, at_status_default.value) = 1) LIMIT 6