Magento的商店 - 通过
答
(链接已经死了。似乎是现在的工作。)
我不是专家,但,但我相信你想一个过滤器添加到产品收集。
在行:
$products = Mage::getResourceModel('reports/product_collection')
->addOrderedQty()
->addAttributeToSelect('*')
->setStoreId($storeId)
->addStoreFilter($storeId);
您想添加一个过滤器类别。我假设你正在寻找一个静态类别,而不是来自上下文或用户输入的动态内容。下面的代码替换上面的代码 - 从类别编号中加载类别对象,然后应用过滤器。我认为它应该工作。
$catNum = 7; //The number of the category you want to load
$category = Mage::getModel('catalog/category')->load($catNum);
$products = Mage::getResourceModel('reports/product_collection')
->addOrderedQty()
->addAttributeToSelect('*')
->setStoreId($storeId)
->addStoreFilter($storeId)
->addCategoryFilter($category);
死链接,以便关闭。 – Kev 2011-07-01 00:53:03