private function insertAttributes($text, Ess_M2ePro_Model_Magento_Product $magentoProduct) { preg_match_all("/#([a-zA-Z_0-9]+?)#/", $text, $matches); if (!count($matches[0])) { return $text; } $search = array(); $replace = array(); foreach ($matches[1] as $attributeCode) { $value = $magentoProduct->getAttributeValue($attributeCode); if (!is_array($value) && $value != '') { if ($attributeCode == 'description') { $value = $this->normalizeDescription($value); } elseif ($attributeCode == 'weight') { $value = (double) $value; } elseif (in_array($attributeCode, array('price', 'special_price'))) { $value = round($value, 2); $storeId = $magentoProduct->getProduct()->getStoreId(); $store = Mage::app()->getStore($storeId); $value = $store->formatPrice($value, false); } $search[] = '#' . $attributeCode . '#'; $replace[] = $value; } else { $search[] = '#' . $attributeCode . '#'; $replace[] = ''; } } $text = str_replace($search, $replace, $text); return $text; }
public function getAttributeValue($attributeCode) { $cacheKey = array(__METHOD__, func_get_args()); if ($this->isCacheEnabled && !is_null($cacheResult = $this->getCache()->getData($cacheKey))) { return $cacheResult; } return $this->getCache()->setData($cacheKey, parent::getAttributeValue($attributeCode)); }