0

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.

  • 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

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.