Magento: Pass values from Block to template

There are many ways in Magento to pass values from Block to template. I think these two ways are neat:

Method 1:

in Block, $this->setVariableName($value);
and in template, $this->getVariableName();

Method 2:

in Block, $this->assign(‘variableName’, $value);
and in template, $variableName is ready to use.

Leave a Reply

Your email address will not be published. Required fields are marked *