I want to create custom module, but I need to acquire variable from another module.

I've looked into their code and this variable is result of many different functions in different Models, which I would like to avoid including in my module.

Is it possible to request variable from specific line in Model from different module?

For example:

I am only interested in getting the value (from a Model within a module) of:

where $rates and $customMethod are not easily traceable (with my Magento knowledge), so I am wondering if there is an easier way of achieving this without copying all of the Models being used by the module.


2 Answers 2


If the module is active then You can call it from anywhere like this

$modelObj = Mage::getModel('Modulename/Modelname');


For this file app/code/local/Amasty/Table/Model/Carrier/Table.php you can call it this way Mage::getModel('table/carrier_table');

  • If call a Model that calls on other Models will everything execute as expected no matter from where I call it? Commented Apr 29, 2017 at 10:29
  • Also, if my Model path is: app/code/local/Amasty/Table/Model/Carrier/Table.php, I would call it by: Mage::getModel('Table/Table'); or do I also have to include the subfolder Carrier? Commented Apr 29, 2017 at 11:00
  • 1
    You can call it like this way Mage::getModel('table/carrier_table'); Commented Apr 29, 2017 at 11:13
  • Yes if you call a model from your code it is reasonable to expect that it works correctly. The only time you have to worry is if you happen to see code that doesn't follow the magento standards while poking around their code.
    – Brett
    Commented Apr 29, 2017 at 12:53
  • I think he needs a variable value from another model, if he calls with "getModel" he will get another instance. Commented Apr 29, 2017 at 18:15

Yes you can access models anywhere, however I am not sure what you mean about a specific line. You could access any item but not just that item (you would need to load the whole model).

  • Added some clarification. Commented Apr 29, 2017 at 10:26
  • You would need to load the whole model, even if you only want to use part of it.
    – tim.baker
    Commented Apr 29, 2017 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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