How to sort a product list widget using the price attribute in ascending or descending order?
![Loading...](http://magento-store.tridhya.com/static/version1721131780/frontend/Tridhya/Marketplace/en_US/images/loader-1.gif)
![How to sort a product list widget using the price attribute in ascending or descending order?](http://magento-store.tridhya.com/media/mageplaza/blog/post/t/i/time_spent-1.jpg)
Add plugin code in etc/frontend/di.xml:
Create plugin “ProductsListPlugin” and add below code in it
getSelect()->reset(\Zend_Db_Select::ORDER);
$result->addAttributeToSort('price', 'ASC'); // Or DESC for descending order
return $result;
}
}
March 15, 2023 | View: 424