私はすべての有効化された製品と無効化された製品を取得しようとしていますが、このコードを使用しています:
/*$categoryId = 3; // a category id that you can get from admin
$category = Mage::getModel('catalog/category')->load($categoryId);
$collection = Mage::getModel('catalog/product')
->getCollection()
->addCategoryFilter($category)
->addAttributeToSelect('*')
->addAttributeToFilter('status', array('gt' => 0))
->load();
$categoryId = 3; // a category id that you can get from admin
$category = Mage::getModel('catalog/category')->load($categoryId);*/
上記のコードは、有効な製品のみをもたらします。
ステータス フィルターにコメントすることで、有効な製品のみという同じ結果が得られます。
/*$collection = Mage::getModel('catalog/product')
->getCollection()
->addCategoryFilter($category)
->addAttributeToSelect('*')
//->addAttributeToFilter('status', array('gt' => 0))
->load();*/
それはまだ有効な製品のみをもたらします。しかし、カテゴリチェックをコメントすると、すべての製品が表示されます:(誰か助けてくれますか?
ノート:
このクエリについてよくわからない人のために、 Status Enabled = 1とStatus Disabled = 2をお伝えしましょう。
したがって、ステータスがゼロより大きい場合、有効な製品と無効な製品の両方が表示されるはずですが、そうではありません。それで何か考えはありますか???
私はコードを編集し、
$collection = Mage::getModel('catalog/category')->load(3)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToSort('entity_id', 'ASC');
die((string) $collection->getSelect());
そして、これはこのクエリをもたらします:
SELECT `e`.*, `cat_index`.`position` AS `cat_index_position` 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.category_id='3' ORDER BY `e`.`entity_id` ASC