1

我正在用magento开发一个网站。

现在我正在尝试以特定顺序订购我的产品展示。

为此,我添加了一个名为“display_order”的属性并链接到属性集(一般)。然后我在我的每个产品中手动添加了订单。

这些是我使用的代码。我的产品具有不同的属性集。

第一

$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->addAttributeToSelect('*');
$_productCollection->addAttributeToFilter('display_order', array('gt' => 0));
$_helper = $this->helper('catalog/output');

第二个

$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->addAttributeToSelect('*');
$_productCollection->addAttributeToSort('display_order', 'ASC');
$_helper = $this->helper('catalog/output'); 

我按排序顺序获取产品,但有一个小问题,它仅基于相似的属性集进行排序。

IE; 具有相同属性集的产品先排序,然后再对具有相同属性集的其他产品进行排序,依此类推..

所以我没有按照“display_order”的顺序得到正确的顺序

有没有办法完全按照我给出的顺序得到它,而不考虑产品所在的属性集。

请帮我。

提前致谢。

——蒂宾·马修

4

2 回答 2

4

Mangeto 中更改产品显示顺序的默认方法是:

  1. 目录 > 类别 > 管理类别

  2. 在左侧栏中单击要编辑的类别。

  3. 单击右侧列上的类别产品选项卡。

  4. 在此处更改排序顺序。

参考

于 2013-08-14T07:12:12.397 回答
0

对于前端使用此代码,我在这里创建了自定义属性“product_sort_order”。

$website_id = Mage::app()->getWebsite()->getId();
$storeId =  Mage::app()->getStore()->getId();            
$collection = Mage::getModel('catalog/product')
   ->setStoreId($storeId)
   ->getCollection() 
   ->addAttributeToSelect('*') 
   ->addWebsiteFilter($website_id)
   ->addAttributeToFilter('type_id', array('eq' => 'simple'));
$collection->getSelect()->limit(6);
$collection->addAttributeToSort('product_sort_order', Varien_Data_Collection::SORT_ORDER_DESC);
于 2015-09-30T05:59:12.970 回答