I want to change cart sequence on cart page Price ascending wise. Please share a page link item collection for cart page.
You can use plugin for this
di.xml
<type name="Magento\Quote\Model\Quote">
<plugin name="append_order_by" type="Vendor\Module\Plugin\Quote" sortOrder="10" />
</type>
Vendor\Module\Plugin\Quote.php
<?php
namespace Vendor\Module\Plugin;
class Quote
{
public function afterGetItemsCollection($subject, $collection)
{
$select = $collection->getSelect();
$select->order('price ASC');
//$select->order('row_total ASC'); // If you want to set as per row total
return $collection;
}
}
-
I have got the error: Plugin class Magento\Checkout\Plugin\Quote doesn't exist – Masud Shaikh Mar 25 '19 at 12:40
-
You need to create a new module for same or place this code in your existing custom module if you have. – Priyank Mar 25 '19 at 12:42
-
-
-
I have added in default Magento_Checkout Module. It is working fine. – Masud Shaikh Mar 25 '19 at 12:44