Magento custom item and default.phtml for email

Magento custom item and default.phtml for email

August 21, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento custom item and default.phtml for email

Customizing Magento Email Templates: A Comprehensive Guide

Handling custom email templates in Magento can be a complex task, especially when you want to create separate notifications for internal use without affecting the standard order confirmation emails sent to customers. In this guide, we’ll walk through the process of creating a unique email template that captures specific order details like SKU and quantity.

Understanding the Existing Email Templates

Magento uses default.phtml files located at ../default/store/template/email/order/items/order/default.phtml and ../default/store/template/email/order/items.phtml. These files are responsible for rendering the order items section in both admin and customer emails. However, modifying these core files is not recommended as it can lead to issues with updates.

Creating a Separate Email Template

To avoid tampering with the default files, we’ll create a completely new template that will be used only for internal notifications via an extension.

  1. Create a New Email Template

Navigate to app/design/frontend/<your_package>/<your_theme> and locate or create the following folders: template/email/order/items. Inside this folder, you should find the default.phtml file from step 2.

  1. Define Your Custom Layout

In your extension, define a new layout update XML file under app/code/local/<Your_Extension>/etc/layout.xml:

<layout version="1.0">
    <update handle="sales_email_order_items">
        <action method="setTemplate">
            <template>your_package/your_theme/email/order/items/default.phtml</template>
        </action>
    </update>
</layout>

Replace your_package and your_theme with the appropriate values.

  1. Create Your Custom PHTML File

The new default.phtml file should contain the logic to render the order items you need for your internal notifications. You can use the following code structure as a starting point:

<?php
/**
 * @var $this Mage_Core_Block_Template
 */
/**
 * @var $_order Mage_Sales_Model_Order
 */
$_order = $this->getData('order');

$items = $_order->getAllVisibleItems();
?>
  1. Extract the Necessary Order Data

To extract the SKU and quantity for each order item, you can use the following code within your loop over $items:

<?php foreach ($items as $item): ?>
    <tr>
        <td class="sku"><?php echo $this->escapeHtml($item->getSku()) ?></td>
        <td class="quantity"><?php echo $this->escapeHtml($item->getQtyOrdered()) ?></td>
    </tr>
<?php endforeach; ?>

Conclusion

Creating a separate email template for internal notifications in Magento allows you to maintain the integrity of the default order confirmation emails while providing additional information to your team. By following this approach, you avoid modifying core files and ensure that your changes remain compatible with future updates.

Remember to use proper version control techniques when working with Magento templates to prevent conflicts during upgrades or when collaborating with other developers. If you’re looking for more advanced customizations or need assistance with Magento extensions, feel free to contact us at Laravel Company for expert guidance and support.

Extensions Themes Admin Email

Our network