2009-12-28 194 views
1
类别

最畅销的项目我使用这个代码在Magento打造最畅销的项目清单:Magento的商店 - 通过

http://bit.ly/6rzMXf

有谁知道这到底是怎么进行编辑,因此会表现出最好销售特定类别的商品?

谢谢!

+0

死链接,以便关闭。 – Kev 2011-07-01 00:53:03

回答

1

(链接已经死了。似乎是现在的工作。)

我不是专家,但,但我相信你想一个过滤器添加到产品收集。

在行:

$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); 
+0

该链接适用于我 – a1anm 2009-12-29 14:18:48

+0

现在适合我 – Laizer 2009-12-30 08:56:29