TransWikia.com

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

Magento Asked by M2 Dev on October 1, 2021

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

One Answer

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)

Correct answer by M2 Dev on October 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP