我已瀏覽了幾篇與排序相關的文章,並未提出所需的解決方案。Magento - 二級排序方式
我正在使用下面的代碼在類別視圖字段中對產品進行排序以覆蓋默認選項並按toolbar.phtml中的屬性進行排序。
<option value="<?php echo $this->getOrderUrl('name', 'asc') ?>"<?php if($this->isOrderCurrent('name')): ?> selected="selected"<?php endif; ?>>
NAME
</option>
<option value="<?php echo $this->getOrderUrl('short_description', 'asc') ?>"<?php if($this->isOrderCurrent('short_description')): ?> selected="selected"<?php endif; ?>>
FRAGRANCE
</option>
<option value="<?php echo $this->getOrderUrl('price', 'asc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>>
PRICE (Low to High)
</option>
<option value="<?php echo $this->getOrderUrl('price', 'desc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>
PRICE (High to Low)
</option>
(I錯誤地使用,而不是添加自定義香味屬性SHORT_DESCRIPTION屬性)
現在,我所需要的功能是,當這些每一個被使用,例如排序價格,我會就像它按照它已經做的價格進行排序,然後再由另一個自定義屬性「範圍」進行二次排序。所以如果它顯示所有3英鎊的產品,它顯示他們從每個範圍聚集在一起,而不是,現在似乎是隨機的。
這是我上次上臺的主要絆腳石,所以任何幫助將不勝感激。
我已經設法通過使用下面的行toolbar.php道路做出一點
if ($this->getCurrentOrder()) {
$this->_collection->setOrder(array($this->getCurrentOrder(), 'range'), $this->getCurrentDirection());
}
與唯一的問題是,它似乎通過一系列第一排序,而不是說價格,即所有範圍1按價格排序,然後範圍2按價格排序。當我需要它按價格訂購時,價格的子訂購
您是否嘗試過的第一個參數反轉兩個屬性? – blmage 2012-07-16 07:08:07
我確實,不幸的是它具有相同的效果。 @blmage – Xand94 2012-07-16 09:05:41