Question

I want to change cart sequence on cart page Price ascending wise. Please share a page link item collection for cart page.

Was it helpful?

Solution

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;
    }

}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top