Magento类别属性无法访问

时间:2016-09-20 09:00:50

标签: php sql magento magento-1.9 entity-attribute-value

我使用代码在类别修改页面上添加选择框,它正常工作,当我保存类别时,我选择的值会保存,代码在这里

$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');

任何人都知道如何解决这个问题,非常感谢

1 个答案:

答案 0 :(得分:0)

添加自定义属性时需要刷新类别平面索引,因为默认情况下平面类别标志通常设置为“是”。

系统>索引管理> Reindex数据