If you want to change the default sorting of the ordered items on the order detail page, go ahead and override app/design/adminhtml/default/default/template/sales/order/view/items.phtml in your theme and replace
1 2 3 4 5 6 7 8 |
<?php $_items = $this->getItemsCollection() ?> <?php $i=0;foreach ($_items as $_item):?> <?php if ($_item->getParentItem()) continue; else $i++;?> <tbody class="<?php echo $i%2?'even':'odd' ?>"> <?php echo $this->getItemHtml($_item) ?> <?php echo $this->getItemExtraInfoHtml($_item) ?> </tbody> <?php endforeach; ?> |
with
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php $_items = $this->getItemsCollection() ?> <?php $_sortedItems = array(); ?> <?php foreach ($_items as $_item) : ?> <?php $_sortedItems[$_item->getSku()] = $_item;?> <?php endforeach;?> <?php ksort($_sortedItems); // This is where the sorting by SKU takes place ?> <?php $i=0;foreach ($_sortedItems as $_item):?> <?php if ($_item->getParentItem()) continue; else $i++;?> <tbody class="<?php echo $i%2?'even':'odd' ?>"> <?php echo $this->getItemHtml($_item) ?> <?php echo $this->getItemExtraInfoHtml($_item) ?> </tbody> <?php endforeach; ?> |
Done. If you open the detail page of an order with 2+ items, they should be sorted by SKU.
Sort order items by SKU
You want or need help implementing this solution? Maybe you did not find what you were looking for? Contact me and I will assist you with whatever Magento problem troubles you!