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


1 Answer 1


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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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