1

I'm extending custom module. One of the functions using dynamic models load, based on input param

$reportProcessor = Mage::getSingleton(
    'amreports_reports/' . $data['report_type']
);

If I creating my new $data['report_type'], I need to add a new model. How can I do this for existing module?

0

In /app/etc/modules/Your_Module.xml

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

In /app/code/local/Your/Module/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
        <modules>
                <Your_Module>
                        <version>1.0.0</version>
                </Your_Module>
        </modules>
        <global>
                <models>
                    <your_module>
                       <class>Your_Module_Model</class>
                    </your_module>
                </models>
        </global>
</config>

In /app/code/local/Your/Module/Model/Extend.php

<?php
class Your_Module_Model_Extend extends Custom_Module_Model_Someclass {
    public function fromCustomModule() {
        // your code here
    }
}

The terms Your, Module, and Extend are arbitrary, and you can change them, but Custom_Module_Model_Someclass must be the existing model of the custom extension that you are trying to modify.

1
  • Thank you, but unfortunatelly it's not what I'm looking for. I need to "implement" model to custom module. I'll try to explain. In my case, I'm calling model in custom module, which isn't exists and I want to add this model in my module without rewriting function, which call this "virtual" model.
    – Andrew Sh
    Nov 16 '17 at 3:10
0

I had some task as in question.

I'm working with Magento 1.9.2

I tried direct define new model in my module that not exists in "base" custom module. And it worked.

For question it will similar

config.xml

 <amreports_reports>
    <rewrite>
       <my_model_name>My_Model_Class</my_model_name>
    </rewrite>
 <amreports_reports>

And now is possible use

$reportProcessor = Mage::getSingleton('amreports_reports/my_model_name')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.