Day: October 22, 2009

  • 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.

  • Zend Framework in Magento

    The library of Zend Framework included in Magento under lib folder is not the genuine Zend Framework. Although I don’t know why Magento did that, I do know:

    • If I replace Magento lib/Zend with genuine ZF, Magento throws errors.
    • If I put geninue ZF in php include_path, Magento appends it to its own include_path, and Magento runs into fussy status. I notice email facility stops working. There may be more functionalities affected.
    • I have loads of code extending Zend_Form. I was intended to reuse them in Magento without rewriting. However, Zend_Form depends on Zend_View, which is not handy in Magento.

    As one of caveats I’ve got from Magento, is whenever possible, avoid touching Zend classes directly.