平面表中缺少自定义属性

时间:2018-09-28 08:47:45

标签: attributes magento2 custom-attributes

Magento(2.2.4)不会将带有自定义源的自定义属性添加到平面表中。该属性在产品列表页面(类别)上不可用。在产品详细信息页面上将其显示。

$catalogEavSetup->addAttribute(Mage_Catalog_Model_Product::ENTITY, 
'energy_label', array(
    'label' => 'Energielabel',
    'type' => 'int',
    'input' => 'select',
    'used_in_product_listing' => true,
    'visible_on_front' => true, 
    'source' => 'Company\CustomCatalog\Source\EnergyLabel',
    'apply_to' => null,
    'filterable' => false,
    'attribute_model' => null,
    'backend' => null,
    'table' => null,
    'frontend' => null,
    'frontend_class' => null,
    'required' => 0,
    'user_defined' => 1,
    'default' => '',
    'unique' => 0,
    'note' => null,
    'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,

));

“ visible_on_front”和“ used_in_product_listing”都设置为true。 重新索引没有帮助。

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您的自定义源模型还必须实现以下功能:

getFlatColumns(),getFlatIndexes(),getFlatUpdateSelect($ store)

如果实现它们,则应在之后将属性添加到平面表中

php bin/magento indexer:reindex

相关问题