Magento calls

Magento

Using block, models, helpers and other magento specific structures, is a little bit different from other PHP frameworks/platforms. In this article i show how to use these structures by calling them in other modules/places.

So, for calling a model structure in magento you can use this function:

$model = Mage::getModel('catalog/product'); //basically say create an instance of Mage_Catalog_Model_Product class

For calling a helper you say something like that:

$cartHelper = Mage::helper('checkout/cart'); //basically say create an instance of Mage_Checkout_Helper_Cart class

For create instance of block is a little bit tricky because we need to create a block structure through layout, like this:

$block = Mage::app()->getLayout()->createBlock('core/template'); //basically say create an instance of Mage_Core_Block_Template class

Add comment
 
 
 

Comments