I’m on prestashop 8.1.2 and I’d like to create a custom order for displaying the products of an order in the backoffice.
I realized that this sorting was done in the handle() of the file srcAdapterOrderQueryHandlerGetOrderProductsForViewingHandler.php.
final class GetOrderProductsForViewingHandler extends AbstractOrderHandler implements GetOrderProductsForViewingHandlerInterface
{
public function handle(GetOrderProductsForViewing $query): OrderProductsForViewing
{
...
$sorter = new Sorter();
$products = $sorter->natural(
$products,
$query->getProductsSorting()->getValue(),
'product_reference',
'product_supplier_reference'
);
...
}
}
As you can see, the basic sorting is based on the product reference, then the supplier reference. For my part, everything will be calculated using personalisation fields and the value that is entered.
How would it be possible, using the module I created for this purpose, to override the sorting of products in my order ?
Override the Sorter class? Override the GetOrderProductsForViewingHandler class? But I don’t think this is possible in prestashop, as these are core files.
PS : I have to deliver this as a full module, so there’s no way for me to touch the prestashop core files.
Thank you in advance for your help!
ClemArds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.