Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 2
order email blank if {{layout handle="sales_email_order_items” order=$order}}
 
Tobbe
Jr. Member
 
Total Posts:  7
Joined:  2007-11-16
 

Edited: Reread the first post again and saw that you already had checked the solution I provided. But leave it if someone wants to try this.

-------

I had the same problem due to an old sales.xml file in my layout folder overriding the default one.

The correct one have a section for the emails in it (se below). I just removed mine frontend\mysite\default\layout\sales.xml file, so the default one gets used instead and it worked fine.

<!--
Email layouts section
-->
    <
sales_email_order_items>
        <
block type="sales/order_email_items" name="items" template="email/order/items.phtml">
            <
action method="addItemRender"><type>default</type><block>sales/order_email_items_order_default</block><template>email/order/items/order/default.phtml</template></action>
            <
action method="addItemRender"><type>grouped</type><block>sales/order_email_items_order_grouped</block><template>email/order/items/order/default.phtml</template></action>
        </
block>
    </
sales_email_order_items>

    <
sales_email_order_invoice_items>
        <
block type="sales/order_email_invoice_items" name="items" template="email/order/invoice/items.phtml">
            <
action method="addItemRender"><type>default</type><block>sales/order_email_items_default</block><template>email/order/items/invoice/default.phtml</template></action>
            <
action method="addItemRender"><type>grouped</type><block>sales/order_email_items_grouped</block><template>email/order/items/invoice/default.phtml</template></action>
        </
block>
    </
sales_email_order_invoice_items>

    <
sales_email_order_shipment_items>
        <
block type="sales/order_email_shipment_items" name="items" template="email/order/shipment/items.phtml">
            <
action method="addItemRender"><type>default</type><block>sales/order_email_items_default</block><template>email/order/items/shipment/default.phtml</template></action>
        </
block>
    </
sales_email_order_shipment_items>

    <
sales_email_order_creditmemo_items>
        <
block type="sales/order_email_creditmemo_items" name="items" template="email/order/creditmemo/items.phtml">
            <
action method="addItemRender"><type>default</type><block>sales/order_email_items_default</block><template>email/order/items/creditmemo/default.phtml</template></action>
            <
action method="addItemRender"><type>grouped</type><block>sales/order_email_items_grouped</block><template>email/order/items/creditmemo/default.phtml</template></action>
        </
block>
    </
sales_email_order_creditmemo_items>
 
Magento Community Magento Community
Magento Community
Magento Community
 
stereoscott
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2009-03-18
New York, NY
 

We have a store running 1.4.1.1 and trying to preview an order with this email variable:

{{layout handle="sales_email_order_items" order=$order}}
would cause the preview to fail.

I noticed the invoice email would not fail, and it had a very similar code block. I looked at the source code for the included order items block in the invoice email:

// in sales.xml

    <sales_email_order_invoice_items>
        <
block type="sales/order_email_invoice_items" name="items" template="email/order/invoice/items.phtml">
...

See that the block type is sales/order_email_invoice_items. So, lets go inside code/core/Mage/Sales/Order/Email/Invoice/Items.php. There I see this method:

class Mage_Sales_Block_Order_Invoice_Items extends Mage_Sales_Block_Items_Abstract
{
    
/**
     * Retrieve current order model instance
     *
     * @return Mage_Sales_Model_Order
     */
    
public function getOrder()
    
{
        
return Mage::registry('current_order');
    
}
...

Ahh, look at that! This block has a function called getOrder… but the block used in our order confirmation does not. So, the goal is to extend the block used in our order confirmation email to list the order items so that it returns the order (or at least returns something that doesn’t break your email template if no order can be found). But what if somewhere Magento is adding the order to our block in some way that isn’t immediately obvious to us? What if in our live environment calling getOrder on our block actually returns the order, but it’s just our email preview that breaks? I explored other Block classes to see how they return the current order, and I found this function in Mage_Adminhtml_Block_Sales_Order_Abstract:

/**
     * Retrieve available order
     *
     * @return Mage_Sales_Model_Order
     */
    public function getOrder()
    
{
        
if ($this->hasOrder()) {
            
return $this->getData('order');
        
}
        
if (Mage::registry('current_order')) {
            
return Mage::registry('current_order');
        
}
        
if (Mage::registry('order')) {
            
return Mage::registry('order');
        
}
        Mage
::throwException(Mage::helper('sales')->__('Cannot get order instance'));
    
}

This looks a little better. We try to get the ‘order’ out of our block, but if that’s not there, we search the registry for ‘current_order’ and then just ‘order’.

Lets update our local code and add a method like this to our Mage_Sales_Block_Order_Email_Items class. There are a few ways to do this, but the LEAST RECOMMENDED way is just to edit the core magento source… that is bad, because if you ever upgrade your store your changes will be lost.

Instead, you should extend your local code by either one of two ways… there are details here http://alanstorm.com/magento_upgrade_rewrite_override but I decided that it was such a small change I would just copy the file (and relative file path) to my app/code/local/Mage/Sales/Block/Order/Email/Items.php file. Here is what my final version looks like:

<?php
// put this is app/code/local/Mage/Sales/Block/Order/Email/Items.php and clear your cache
/**
 * Sales Order Email order items
 *
 * @category   Mage
 * @package    Mage_Sales
 * @author     Magento Core Team <core@magentocommerce.com>
 */
class Mage_Sales_Block_Order_Email_Items extends Mage_Sales_Block_Items_Abstract
{
  
/**
   * Retrieve current order model instance
   * Added this to local version so email templates would work and not fail in admin preview.
   *
   * @return Mage_Sales_Model_Order
   */
   
public function getOrder()
   
{
       
if ($this->hasOrder()) {
           
return $this->getData('order');
       
elseif (Mage::registry('current_order')) {
           
return Mage::registry('current_order');
       
elseif (Mage::registry('order')) {
           
return Mage::registry('order');
       
}

       
return null// uh oh!
   
}
}

Clear your cache and retry the email preview for your order confirmation email. If all goes well, the error should be gone.

Cheers,
Scott

 
Magento Community Magento Community
Magento Community
Magento Community
 
blabal233
Jr. Member
 
Total Posts:  4
Joined:  2012-01-27
 

Hi,

i got the same error in the order email in the mail are no buyed items. But i didnt have the folder app/code/local/Mage/Sales .
I am yousing magento 1.6.2.0 with a template from the internet. I looked everywear but i cant find a solution that suits for me to see any items in the order email with the variables {{layout handle="sales_email_order_items" order=$order}} anyone here has an hint or a tip. Thanks for any help. What do I wrong?

now I activated the loggin in magento and saw the following in the system.log:

2012-03-18T13:31:54+00:00 ERR (3): Notice: Undefined index: handle in /usr/www/users/koksen/shop/app/code/core/Mage/Core/Model/Email/Template/Filter.php on line 214

Looks like an error in the Filter.php?? Has anyone any idea to fix this?

Thanks a lot

JJ

 
Magento Community Magento Community
Magento Community
Magento Community
 
blabal233
Jr. Member
 
Total Posts:  4
Joined:  2012-01-27
 

oh I am so happy I found the error and the solution was my failure. I had a misconfig in the sales.xml

thanks anyway

jj

 
Magento Community Magento Community
Magento Community
Magento Community
 
dariusp
Jr. Member
 
Total Posts:  1
Joined:  2012-10-08
 

I had the same problem that there was no product list in new order email. Magento version 1.7.0.2.

I’ve found a solution for it. Just remove line #15 from app/locale/your_locale/template/email/sales/order_new.phtml and order_new_guest.phtml

Line looks that:

"layout handle=\"sales_email_order_items\" order=$order":"Order Items Grid",
 
Magento Community Magento Community
Magento Community
Magento Community
 
blueeyes416
Jr. Member
 
Total Posts:  4
Joined:  2012-02-15
 

Hi guys I am running 1.7.0 and I have tried the tip below however I still don’t see any items ordered. Is there perhaps another way of fixing this, I have literally tried everything!!!!! I don’t understand why nothing is being passed in that parameter?! Oh btw I have cleared cache after doing the tip below and still no action.

Please helpppp!!!!!!!

dariusp - 08 October 2012 09:55 PM

I had the same problem that there was no product list in new order email. Magento version 1.7.0.2.

I’ve found a solution for it. Just remove line #15 from app/locale/your_locale/template/email/sales/order_new.phtml and order_new_guest.phtml

Line looks that:

"layout handle=\"sales_email_order_items\" order=$order":"Order Items Grid",
 
Magento Community Magento Community
Magento Community
Magento Community
 
Online Selling Ltd
Jr. Member
 
Total Posts:  14
Joined:  2009-03-22
 

I had the same problem due to an old sales.xml file in my layout folder overriding the default one.

This solved the problem I was having, thank you! I couldn’t get the order totals to appear, but it turns out the theme I was using was using a sales.xml file which didn’t include the necessary code. I merged some of the code from the base sales.xml file and now it’s working. Thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
info348
Jr. Member
 
Total Posts:  2
Joined:  2011-04-14
 

For those who haven’t got it working with solutions posted above, here is what we did. Thanks to blabal233.

Error is due to excluding -order & returns- in footer. Go to app/design/frontend/base/default/layout/sales.xml
Find:
<default>
<reference name="footer_links"><!---
<block type="sales/guest_links" name="return_link"/>
<action method="addLinkBlock"><blockName>return_link</blockName></action>--->
</reference>
</default>

And change to:
<default>
<reference name="footer_links">
<block type="sales/guest_links" name="return_link"/>
<action method="addLinkBlock"><blockName>return_link</blockName></action>
</reference>
</default>

This did the trick for us.

 
Magento Community Magento Community
Magento Community
Magento Community
 
info348
Jr. Member
 
Total Posts:  2
Joined:  2011-04-14
 

For those who haven’t got it working with solutions posted above, here is what we did. Thanks to blabal233.

Error is due to excluding -order & returns- in footer. Go to app/design/frontend/base/default/layout/sales.xml
Find:
<default>
<reference name="footer_links"><!---
<block type="sales/guest_links" name="return_link"/>
<action method="addLinkBlock"><blockName>return_link</blockName></action>--->
</reference>
</default>

And change to:
<default>
<reference name="footer_links">
<block type="sales/guest_links" name="return_link"/>
<action method="addLinkBlock"><blockName>return_link</blockName></action>
</reference>
</default>

This did the trick for us.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageBuzz
Member
 
Avatar
Total Posts:  32
Joined:  2013-08-19
 

I got this problem on a client side. However, when I used our server, the email was good. So maybe it is related to server problem, too.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 2