我必须在不同的文件中反复使用一些变量。
$_product = $this->getProduct();
$_helper = $this->helper('catalog/output');
$_productType = $_product->getTypeID();
$_productName = $_helper->productAttribute($_product, $_product->getName(), 'name');
$_manufacturer = $_product->getAttributeText('manufacturer');
$_decor = $_product->getAttributeText('decor');
$_serie = $_product->getAttributeText('serie');
$originalImageWidth = $this->helper('catalog/image')->init($_product, 'image')->getOriginalWidth();
$originalImageHeight = $this->helper('catalog/image')->init($_product, 'image')->getOriginalHeight();
$originalImageRelation = $originalImageWidth / $originalImageHeight;
所有这些,我需要/templates/catalog/product/view.phtml
和/templates/catalog/product/type/grouped.phtml
以及templates/catalog/product/media.phtml
。
有没有办法在中央文件中收集它并在所有这些地方重复使用?