马根托:如何将数据传递给子布局块


Magento: How do I pass data to a child layout block?

在product/view.phtml中,我调用了getChildHtml('my_block')?>,它输出一个我写的phtml文件。我希望该文件显示产品图像,但当我调用$this->getProduct()时,我得到了null!如何将产品(或任何其他数据)传递给子块?或者以其他方式提供它?

如果您当前在产品显示页面上,我建议使用当前的产品注册表值。这可以加载,而不是$This->getProduct(),如下所示:

Mage::registry('current_product');