1

I am stuck on overriding model class only in EE version.

My config.xml

<models>
        <pos>
            ...................
        </pos>
        <pos_mysql4>
            ....................
        </pos_mysql4>

        <sales>
            <rewrite>
                <order>DigitalCinema_Pos_Model_Sales_Taken</order>
                <order_invoice>DigitalCinema_Pos_Model_Sales_Order_Invoice</order_invoice>
                <order_pdf_invoice>DigitalCinema_Pos_Model_Sales_Order_Pdf_Invoice</order_pdf_invoice>
                <order_pdf_items_invoice_default>DigitalCinema_Pos_Model_Sales_Order_Pdf_Items_Invoice_Default</order_pdf_items_invoice_default>
            </rewrite>
        </sales>

        <bundle>
            <rewrite>
                <sales_order_pdf_items_invoice>DigitalCinema_Pos_Model_Bundle_Sales_Order_Pdf_Items_Invoice</sales_order_pdf_items_invoice>
            </rewrite>
        </bundle>

    </models>

and my DigitalCinema/Pos/Model/Sales/Taken.php

class DigitalCinema_Pos_Model_Sales_Taken extends Mage_Sales_Model_Order
{
     public function sendNewOrderEmail()
     {
         ........
     }

   ..............
}

Problem

See following line: <order>DigitalCinema_Pos_Model_Sales_Taken</order>

Only this one (sales_model_order.php) is not getting overridden. All others are working.

I can also confirm that it is working in community version.

Any help is much appreciated.

UPDATE 1

As Marius suggested, I have checked module conflict and can see there is another module rewriting same class. However, that module is not overwriting the class I am trying overwrite. Now, I have found this link. And would like to use Option 2. But it is not working. Now my Taken.php becomes as follows:

class DigitalCinema_Pos_Model_Sales_Taken extends Other_Module_Model_Order

Anything I am missing on this?

Adarsh Khatri
  • 8,360
  • 2
  • 25
  • 58
  • Check if you have an other module rewriteing the order model. Here is a small script that let's you do this: http://magento.stackexchange.com/a/1600/146 – Marius May 18 '15 at 06:47
  • @Marius That's good to know, but I have tested by editing core file order.php and it does executes. That means that particular function is not overwritten. – Adarsh Khatri May 18 '15 at 06:55
  • Just to make sure...did you clear the cache and disabled the compilation? – Marius May 18 '15 at 06:58
  • Yes, I have cleared cache and compilation is disabled at the moment. Thanks – Adarsh Khatri May 18 '15 at 07:00
  • Is your module loaded? Generate an parsing error in the config.xml by renaming the closing </config> to </blabla>. Site should blow up after cleaning config cache, with developer mode turned on. If not, check your modules file. Inject some logging into Mage_Core_Module_Config, loadModuleCache and related, if you don't see anything wrong with it. –  May 18 '15 at 07:18
  • @Melvyn Yes my module is loaded and can confirm that all other rewrite is taking effect. – Adarsh Khatri May 18 '15 at 23:21
  • @Marius Yes, there is another extension overwriting this class, but it hasn't overwriting the function. Now, how do I get over it? – Adarsh Khatri May 18 '15 at 23:41

1 Answers1

2

Based on the comments...the order model is overwritten by an other class.
You need to make your class extend the other class like you did

class DigitalCinema_Pos_Model_Sales_Taken extends Other_Module_Model_Order

and you make your module depend on the other module so yours is loaded after it.
For this, make your app/etc/modules/DigitalCinema_Pos.xml file look like this:

<?xml version="1.0"?>
<config>
    <modules>
        <DigitalCinema_Pos>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Other_Module />
                <Mage_Sales />
             </depends>
        </DigitalCinema_Pos>
    </modules>
</config>

clear the cache and it should work.

Marius
  • 197,939
  • 53
  • 422
  • 830
  • Thanks, I am wondering what will happen if Other_Module is disabled? Will site throw error? Is there a way to make it work automatically even if other_module is disabled or removed? – Adarsh Khatri May 19 '15 at 23:54