2

I am unable to overwrite the adminhtml model, can anyone help me out where I did wrong...

module XML

<?xml version="1.0"?> 
   <config> 
      <modules> 
        <Cc_Adminhtml> 
            <active>true</active> 
            <codePool>local</codePool> 
        </Cc_Adminhtml> 
      </modules> 
   </config>

config XML

<?xml version="1.0"?>
<config>
    <modules>
        <Cc_Adminhtml>
            <version>0.1.0</version>
        </Cc_Adminhtml>
    </modules>
    <global>
        <models>            
            <adminhtml>
                    <rewrite>
                        <sales_order_create>Cc_Adminhtml_Model_Create</sales_order_create>
                    </rewrite>
            </adminhtml>
        </models>
    </global>
</config> 

PHP file:

class Cc_Adminhtml_Model_Create extends Mage_Adminhtml_Model_Sales_Order_Create
{
    /**
     * Create new order
     *
     * @return Mage_Sales_Model_Order
     */
    public function createOrder()
    {
       // want to overwrite this method/function
    }
}
Vikas Pal
  • 81
  • 7

4 Answers4

0

If there are no typos in your file naming and not a cache problem, you need to check if you have extension that override the same model

ivantedja
  • 2,553
  • 1
  • 22
  • 22
  • I am using enterprise ver 1.11.0, and I have not used any extension its default magento. But I have overwrite the frontend sales model in separate module. do I need to combine both the module, Is it the problem? or whatelse will be the cause for not overwriting adminhtml model and block, Please help. – Vikas Pal Aug 17 '12 at 08:37
  • This should not cause problem ... just crosscheck your module is actually loaded ( coodPool, permission on the folders ... ) – WonderLand Aug 17 '12 at 10:06
  • when I enable the cache and overwrite the block file i.e. Cc_Html_Block_Sales_Order_Create_Search_Grid_Renderer_Product it is taking both core and local values but still model is not overwiting. Previously I disabled the cache. – Vikas Pal Aug 17 '12 at 10:14
  • 2
    If I am overwriting the method then it should take values fron local pool. – Vikas Pal Aug 17 '12 at 10:15
0

I have checked your code with 1.7 ce version. And its working as expected. Just make sure you have the following folder structure.

-app/code/local/Cc/Adminhtml/etc/config.xml
-app/code/local/Cc/Adminhtml/Model/Create.php
-app/etc/modules/Cc_Adminhtml.xml

I have tried to put exit in createOrder() method with some message to print and when I tried to click on submit order button its showing message while creating new order from adminpanel.

I can confirm that above code is working fine.

Kamal Joshi
  • 1,298
  • 3
  • 25
  • 45
-1

Your code is so magnificent. There is nothing wrong with your rewrite step.

if you shows all file contents on PHP file, then don't forget to add

<?php 

on the very start PHP file.

if it's added, then try to refresh all of your Magento Cache.

Josua Marcel C
  • 3,122
  • 6
  • 45
  • 87
-2

Rewrite tag should be follows: Cc_Adminhtml_Model_Sales_Order_Create

Ethan
  • 1