cancel
Showing results for 
Search instead for 
Did you mean: 

How can I override the core sales order model class ?

How can I override the core sales order model class ?

I want edit  sendNewOrderEmail()  function from  Mage_Sales_Model_Order class . I want achieve following task as,

 

1. Need to set different template for new order email on the basis of product type.

 

EX . If product type is  downloadable need to send downloadbale template.

If product is simple need to send simple email template for logged in users.

 

How Do I achieve?

 

Any Help... Thanks in advance....

1 REPLY

Re: How can I override the core sales order model class ?

To send different order confirmation email depending on specific criteria you would either have to :

  1. Rewrite sendNewOrderEmail() in Mage_Sales_Model_Order and add logic to check the template
  2. Disable magento "order confirmation email" in system config, then create a custom module to send your email by coping logic from sendNewOrderEmail() using event/observer
  3. For simple text changes, you could use template logic {{if order.customer_group_id}} or {{depend order.customer_group_id}} but they seem to only evaluate true/false condition, therefore for more advance logic you could include a block

{{block type='core/template' area='frontend' template='sales/custom_logic.phtml' order=$order}}

In custom_logic.phtml

<?php $order = $this->getOrder() if($order->getCustomerGroupId() == 1){ ///do ....
OpenSource Expert | OpenSource Technologies | www.opensourcetechnologies.com
Magento plugins released: http://www.opensourcetechnologies.com/product/product-category/magento-extensions