1

Magento はクールな小さなトリックを実行するいくつかの優れた方法を提供しているので、これは簡単だと思いましたが、私がする必要があるのは、属性値によってリストされるすべての製品をストアでソートすることだけです。私は url パラメータに基づいていませんが、製品コレクションの呼び出しごとにプログラムで並べ替えを追加するように設定します。これが私が最初の試みとして持っているものです。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) を読み取ってから、何かが行われる前に並べ替えを適用しようとすることです。例ではコレクションを返していることはわかっていますが、すべてをすべてにする方法が必要です。誰でもアイデアを持っています..

ジェレミー

4

0 に答える 0