2
votes

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
    }
}
4

4 Answers

0
votes

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

0
votes

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.

0
votes

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.

-2
votes

Rewrite tag should be follows: Cc_Adminhtml_Model_Sales_Order_Create