0

in my class shipping in the file app/code/community/Innnoexts/Core/Helper/shipping.phpp.

I want to call the method getMethods() in the file app/code/local/Collinsharper/Purolator/Model/Source/Method.php I wrote this code

$test = Collinsharper::getModel(Purolator/Source/Method);
        var_dump($test->getMethods());
        echo '<br>'

;

but, I got this error PHP Fatal error: Class 'Collinsharper' not found in /www/sites/mysite.com/files/html/app/code/community/Innoexts/Core/Helper/Shipping.php

could you help me to give me the right instruction to call this method?

thanks

2

Magento don't use Collinsharper::getModel(Purolator/Source/Method); type . factory pattern and factory method.There are lot issue on your module.You need to basic study on magento module structure.

Issue1:Magento factory call

Ii should be Mage:: instead of Collinsharper::

start the factory method Mage::

It function is call at Mage.php(magentodir/app)

Issue2:Magento modelprefix for a module

getModel(Purolator should not be this.It should be getModel("modelprefix/

Model Prefix is define at app/code/community/Innnoexts/Core/etc/config.xml under <global> tag

   <models>
        <modulePrefix><!-- guess that modulePrefix is your module model prefix -->
        <class>Innoexts_Core_Model</class>
        </modulePrefix>
    </models>

Magento model factory method look like:

Mage::getModel("modelprefix/modelsclass')

Note: Here Innoexts_Core is this path of module.

Issue3:Factory method model class

As you have want to call function of Method.php from app/code/local/Collinsharper/Purolator/Model/Source/Method then it Method.php class should be

  Collinsharper_Purolator_Model_Source_Method  

Then factory method is like

 Mage::getModel(modelPrefix/source_method)->getMethods();

Collinsharper_Purolator_Model is modelPrefix as config.xml define

and source_method emulate as Source_Method.

Please check at http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/

  • thanks amit, this is what I used: $puroMethods = Mage::getModel(Collinsharper_Purolator_Model_Source_Method)->getMethods(); – devopsmagento Apr 1 '15 at 19:46
  • no you canot use this – Amit Bera Apr 1 '15 at 19:47

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.