0

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

2

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 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 at 12:42
  • `Vendor\Module` should be replaced with your new module name. – Priyank Mar 25 at 12:43
  • Small mistake from me. Thanks Its working fine. – Masud Shaikh Mar 25 at 12:43
  • I have added in default Magento_Checkout Module. It is working fine. – Masud Shaikh Mar 25 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.