1

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?

Edit:
For example:

I am only interested in getting the value (from a Model within a module) of:
$rates[$customMethod->getId()]['time'],

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.

1

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

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

EDIT

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? – Jurģis Toms Liepiņš Apr 29 '17 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? – Jurģis Toms Liepiņš Apr 29 '17 at 11:00
  • 1
    You can call it like this way Mage::getModel('table/carrier_table'); – Kingshuk Deb Apr 29 '17 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 Apr 29 '17 at 12:53
  • I think he needs a variable value from another model, if he calls with "getModel" he will get another instance. – Phoenix128_RiccardoT Apr 29 '17 at 18:15
0

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. – Jurģis Toms Liepiņš Apr 29 '17 at 10:26
  • You would need to load the whole model, even if you only want to use part of it. – tim.baker Apr 29 '17 at 11:24

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.