It is possible to sort Email order confirmation by sku in both customer email notification and Admin email notification

magento.stackexchange https://magento.stackexchange.com/questions/318056

Question

I am on the m2 site. In order confirmation email I am getting SKU. But I need that SKU sort by ASC. Could someone assist me with this? Thanks in advance.

I have overridden the below file in my theme to get SKU in order confirmation email. vendor/magento/module-sales/view/frontend/templates/email/items.phtml

Was it helpful?

Solution

Override the file vendor/magento/module-sales/view/frontend/templates/email/items.phtml in your theme add below code.

$_items = $_order->getAllItems(); $sortSKU = array(); foreach ($_items as $item) { $sortSKU[$item->getSku()] = $item; } ksort($sortSKU);

And Insted of
foreach ($_items as $_item) use foreach ($sortSKU as $_item)

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