How to get Object of custom block?
-
13-12-2019 - |
Question
I have created a Block class as this
class Sb_AddressManager_Block_Address_Edit extends Mage_Customer_Block_Address_Edit {....}
and its path is
/www/abc/app/code/local/Sb/AddressManager/Block/Address/Edit.php
now I need its obj to use its functions in an other class
class Sb_Fs_Model_Order extends Mage_Sales_Model_Order {...}
whose path is
/www/abc/app/code/local/Sb/Fs/Model/Order.php
How should I do this?
Solution
You want to call the block function from model. Try the below code
Mage::getBlockSingleton('<your-block-alise>/address_edit')->yourFunction();
Note : Calling the block from model is not recommended.If you are going to use a same function in Block and Model. Place that function in Helper and call where ever you want
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange