2016-09-20 113 views
0

我用一個代碼以添加類別選擇框修改頁面,該頁面可以正常工作和我所選擇的值保存當我保存類,代碼是在這裏Magento的類別屬性不能訪問

$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); 
$setup->addAttribute('catalog_category', 'leasing', array(
'group'   => 'General Information', 
'type'  => 'int', 
'label' => 'Lease', 
'input' => 'select', 
'source' => 'eav/entity_attribute_source_boolean', 
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
'required' => false, 
'default' => 1, 
'user_defined' => 1, 
'default' => 0 
)); 

enter image description here

但是當我嘗試在前端產品詳細信息頁面上獲取上述選擇框的保存值時,它不起作用,並在我使用var_dump時顯示「NULL」。我已經嘗試過索引但沒有運氣。

這裏是我使用的代碼。

$catid = Mage::registry('current_category') ? Mage::registry('current_category')->getId() : null; 
$category = Mage::getModel('catalog/category')->load($catid); 
echo $category ->getLeasing(); 
echo $category ->getData('leasing'); 

任何人都知道如何解決這個問題,非常感謝

回答

0

類別扁平索引需要被刷新,當你添加自定義屬性,因爲平板類標誌默認情況下,通常設置爲yes。

系統>索引管理>重新索引數據