0

I need to do sort by price and paginate by 15 items for order list history page, can anyone help?

1

To customize it properly, follow the 2 steps:

1, create a afterGetOrders plugin to Magento\Sales\Block\Order\History, in this plugin , check if $result->isLoaded(), if not, $result->setOrder('grand_total', 'desc') or 'asc' (you don't want to change query on loaded collection)

2, as the way pager is inserted in the layout in magento, it does not give you an opportunity to do DI as expected, so instead, to change pagination, we create a beforeSetNameInLayout plugin to \Magento\Theme\Block\Html\Pager, and if parameter $name == 'sales.order.history.pager', we call $subject->setAvailableLimit([15 => 15, 20 => 20, ...])

3
  • In which file we can do those changes pls? Jun 30 at 7:35
  • You would want to create a custom module and create the 2 plugins as I mentioned. If you wanted to modify core magento files directly (strongly not recommended), then you will find the methods in the class files I mentioned
    – Ryan Sun
    Jul 1 at 14:06
  • Thank you,Do you have an idea how to change text in toolbar amount only in order history page? Jul 2 at 12:04

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.