Magento Block construct - use _construct or __construct? -
i little bit confused. read alan storm's excellent article magento block lifecycle methods , far understand 1 should using protected _construct()
method initialize block. in case want set right block template. assume should using
protected function _construct() { parent::_construct(); $this->settemplate('stenik/qaforum/forum.phtml'); }
however, when @ blocks of of core magento modules, seem use php __construct method it. example mage_poll_block_poll
, mage_productalert_block_price
, mage_rating_block_entity_detailed
, mage_review_block_form
although both ways work, i'd know right way it.
it's academic, right way it® override magento constructor i.e. _construct
requested core team in mage_core_block_abstract
:
/** * internal constructor, called real constructor * * please override 1 instead of overriding real __construct constructor * */ protected function _construct() { /** * please override 1 instead of overriding real __construct constructor */ }
Comments
Post a Comment