需要:- 在产品列表中按价格从低到高和高到低排序 洋红色2.2.5
我们遵循这个图托但不起作用 在产品列表中按价格从低到高和高到低排序 洋红色2
有人帮我吗?
正如你提到的,我遵循了你发现的相同示例,它对我不起作用,我做了 aroundSetCollection 函数的小改动,它看起来像下面:
public function aroundSetCollection(
MagentoCatalogBlockProductProductListToolbar $subject,
Closure $proceed,
$collection
) {
$currentOrder = $subject->getCurrentOrder();
$result = $proceed($collection);
if($currentOrder) {
if($currentOrder == 'high_to_low') {
$collection->setOrder('price', 'desc');
} else if($currentOrder == 'low_to_high') {
$collection->setOrder('price', 'asc');
} else if ($currentOrder == 'created_at') {
$collection->setOrder('created_at', 'desc');
}
}
return $collection;
}