【问题标题】:Magento category attribute can't accessMagento 类别属性无法访问
【发布时间】:2016-09-20 09:00:49
【问题描述】:

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

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

但是当我尝试在前面的产品详细信息页面上获取上述选择框的保存值时,它不起作用并在我使用 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');

谁知道怎么解决这个问题,非常感谢

【问题讨论】:

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


    【解决方案1】:

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

    系统 > 索引管理 > 重新索引数据

    【讨论】:

      猜你喜欢
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      • 2015-11-21
      • 2014-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多