2016-11-17 18 views
0

カタログ製品リストページで、複数の属性を持つMagento製品コレクションを並べ替える必要があります。私はまた、同様複数の属性を持つMagentoソートコレクション

$this->_collection->setOrder(array('price', 'price_plus_shipping'),Varien_Data_Collection::SORT_ORDER_DESC); 

私はこれらを並べ替える両方私に正確な結果を与えていない、その組み合わせが、ときにこのコードを試してみました。このコード

$this->_collection->setOrder('price', 'desc'); 
$this->_collection->setOrder('price_plus_shipping', 'desc'); 

を使用しています私はのみ使用しているときのように、両方別途使用している場合

その作業Fをprice_plus_shipping

伊根も

価格

そのまた、作業ファイル として、彼らは私に正確な結果を示しています。しかし、私はそれらを組み合わせて使用​​したい。 での価格私はをprice_plus_shipping で製品価格を持って、私は

、B、Cなど

答えて

1

のようなアルファベットを持っている私はあなたのアプローチに勤務し、結果を取得しています。 テキストタイプの属性 "price_plus_shipping"を作成しました。今app\design\frontend\[Package]\[Theme]\template\catalog\product\list.phtml

$_productCollection=$this->getLoadedProductCollection(); 
$_productCollection->clear(); 
$_productCollection=$_productCollection->addAttributeToSort('price', 'DESC'); 
$_productCollection=$_productCollection->addAttributeToSort('price_plus_shipping', 'ASC'); 
$_helper = $this->helper('catalog/output'); 

上の変更私はそれはあなたを助けることを願っています下に作られた

Visible on Product View Page on Front-end => Yes 
Used in Product Listing => Yes 
Used for Sorting in Product Listing => Yes 

+0

@OBAID この解決策を確認しましたか? –

0

Magento 1.9にsetOrderと複数の列で不具合があるようです。

$this->_collection->getSelect()->order(array('price desc', 'price_plus_shipping desc')); 
関連する問題