Paginate order list by 15 items and sort by price ASC

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

Answers 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, ...])


Related Questions