Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我们如何在magento中获得顶级产品_Magento - Fatal编程技术网

我们如何在magento中获得顶级产品

我们如何在magento中获得顶级产品,magento,Magento,我希望获得顶级产品的集合,而不是作为一个阵列 我遵循了本教程:- 但它会返回产品数组,我需要结果作为产品集合 我使用的代码是:- $_productCollection = Mage::getResourceModel('reports/product_collection') ->addAttributeToSelect('*') ->setVisibility(array(2,3,4))

我希望获得顶级产品的集合,而不是作为一个阵列

我遵循了本教程:-

但它会返回产品数组,我需要结果作为产品集合

我使用的代码是:-

 $_productCollection = Mage::getResourceModel('reports/product_collection')
                   ->addAttributeToSelect('*')
                   ->setVisibility(array(2,3,4))
                   ->setPageSize($productCount);

$_productCollection->joinField('rating_summary', 'review/review_aggregate', 'rating_summary', 'entity_pk_value=entity_id',  array('entity_type' => 1, 'store_id' => Mage::app()->getStore()->getId()), 'left');                
$_productCollection->setOrder('rating_summary', 'desc');
但我面临的问题是,这段代码会产生致命错误:

在非对象和分页符上调用成员函数getRatingSummary

有什么建议吗

$collection = Mage::getModel('catalog/product')->getCollection();

$collection->joinField('rating_summary', 'review/review_aggregate', 'rating_summary', 'entity_pk_value=entity_id',  array('entity_type' => 1, 'store_id' => Mage::app()->getStore()->getId()), 'left');                
$collection->setOrder('rating_summary', 'desc')->setPage(1, 5);

我已经用我上面粘贴的代码更新了我上面的问题。你确定在获取上述产品评级时它不会中断吗?你知道我为什么会遇到上述代码的问题吗?你把getRatingSummary称为什么?我在list.phtml中获取此集合…此文件使用代码echo$this->getReviewSummaryHTML$_产品,'list_short_summary';这就是它断裂的地方。