2011-12-28 120 views
0

我有兩個自定義屬性,一個叫'amz_prod_description',一個叫'upc'。訪問Magento自定義屬性

根據這一> http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/0_-_theming_in_magento/data_accessing_methods_from_within_various_scopes#accessing_the_value_of_a_product_s_custom_attribute

我應該能夠訪問他們倆$產品 - > getUpc()和$產品 - > getAmzProdDescription()其中$產品。在同一個交換機中,我正在使用這兩個。 'upc'屬性的變化效果很好,另一個根本無法正常工作,這真的讓你知道了什麼,因爲它們都使用Magento所要求的方法,並且使用相同的PHP函數。所以他們都在相同的背景下,等等。

幫幫我!? :\

這裏是我的實際代碼,它的價值>

case "{amazon_description}": 
      $description = $product->getAmzProdDescription(); 
      // I have tested, $description is not being set. I have changed the bottom return to just $description and it returns nothing. 
      if(strlen($description) > 1499) { 
       $amz_description = substr($description,0,1500) . "..."; 
      } else { 
       $amz_description = $description; 
      } 

      return $amz_description; 
     break; 

case "{upc}": 
      $upc = $product->getUpc(); 
      return $upc; 
     break; 
+2

$ product-> getData()是否顯示自定義屬性? – 2011-12-28 22:37:38

回答

3

有在Magento管理屬性管理一個標誌被稱爲「在前端的產品視圖頁面可見」。確保兩個屬性都設置爲「是」,否則該屬性將不會內置到getData數組中。這假定你的代碼在前端運行,儘管你沒有指定。

此外,請確保您重建索引並清空緩存存儲的緩存&。