无论其他过滤器如何,都可以按属性对商店的所有商品进行排序

时间:2012-06-16 22:13:53

标签: php magento magento-1.6

我认为这很简单,因为Magento确实提供了一些很好的方法来做一些很酷的小技巧,但我需要做的就是让所有产品都有商店排序所有将按属性值列出的产品。我不会在url params中设置,而是设置为以编程方式在每次调用产品集合时添加排序。这是我第一次尝试的东西。在header.phtml中

$selected = isset($_GET['gender_orientation'])?$_GET['gender_orientation']:0;

$GenOr=Mage::getModel('core/cookie')->get('GenOr');
if(!$GenOr||$selected>0){
    Mage::getModel('core/cookie')->set('GenOr', $selected, null, null, null, null, null);
}
$selected=Mage::getModel('core/cookie')->get('GenOr');
if($selected>0){
    //Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('gender_orientation', $selected);
    $productcollection = Mage::getModel('catalog/product')->getCollection();
    $productcollection = $productcollection->addCategoryFilter(Mage::getModel('catalog/category')->load($currcategory),true);
    $productcollection = $productcollection->addAttributeToFilter('gender_orientation', $selected);
    //$collection->getSelect()->addAttributeToSort('name', 'ASC');
}

所以目标是我读取一个cookie(atm),然后尝试在完成任务之前应用该排序。我知道在示例中我将返回集合,但必须有一种方法可以满足所有人的需求。任何人都有想法..

杰里米

0 个答案:

没有答案
相关问题