0
votes

I am getting started with Magento (1.9) CE. I am trying to write a small module that amends the behavior of two models:

  1. Mage_Sales_Model_Quote
  2. Mage_Sales_Model_Quote_Address

I have created my classes MyCompany_Sales_Model_Quote and MyCompany_Sales_Model_Quote_Address that extends those classes.

My folder structure looks like

MyCompany
 -> etc
   -> config.xml
 ->Sales
  -> Model
    -> Quote.php
    -> Quote
       -> Address.php

I have verified that:

  1. My module - MyCompany_Sales - shows up in Admin portal (Admin->System->Configuration->Advanced->Advanced)

  2. If I don't write custom module and simply copy those files from Magento core and copy under Local->Mage->Sales->Model, the changes seems to work. But I would like to keep a module to only change the behavior which I want to.

I have to come conclusion that the main problem is that the system is not picking up my new classes correctly. Here is my config xml to override those classes:

< ?xml version="1.0"?>
<config>
    <modules>
        <MyCompany_Sales>
            <version>0.1.0</version>
        </MyCompany_Sales>
    </modules>
    <global>
       <models>
          <sales>
              <rewrite>
                  <quote>MyCompany_Sales_Model_Quote</quote>
                  <quote_address>MyCompany_Sales_Model_Quote_Address</quote_address>
              </rewrite>
          </sales>
       </models>
    </global>
</config>

Any pointers on what I might be doing wrong would be greatly appreciated.

1

1 Answers

0
votes

I think there is problem with your directory structure. your directory structure should be like as below :

MyCompany (Namespace)
    -Sales (Modulename)
        - etc (Directory)
            -config.xml (Configuration File)
        - Model(Directory)
            -Quote.php(File)
            -Quote(Directory)
                -Address.php(File)