2016-08-25 68 views
0

我已經在Magento 2.1添加了自定義的產品屬性和產品顯示屬性部分,但不能在我們創建產品自定義的產品屬性不管理目錄部分Magento的顯示2.1

Magento的目錄部分顯示以下是我用來創建屬性的代碼。

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); 

    /** 
    * Add attributes to the eav/attribute 
    */ 

    $eavSetup->addAttribute(
     \Magento\Catalog\Model\Product::ENTITY, 
     'test_author', 
     [ 
      'type' => 'int', 
      'backend' => '', 
      'frontend' => '', 
      'label' => 'Test Author', 
      'input' => '', 
      'class' => '', 
      'source' => '', 
      'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 
      'visible' => true, 
      'required' => false, 
      'user_defined' => false, 
      'default' => 0, 
      'searchable' => true, 
      'filterable' => true, 
      'comparable' => false, 
      'visible_on_front' => true, 
      'used_in_product_listing' => true, 
      'unique' => false, 
      'apply_to' => '' 
     ] 
    ); 

enter image description here

+0

在Magento 2.1,你需要添加ui_component顯示在目錄形式段自定義屬性 –

回答

0

你可以試試下面的代碼 -

/** @var EavSetup $eavSetup */ 
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); 
/** 
* Add attributes to the eav/attribute 
*/ 
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY, 
'test_author', 
[ 
'group' => 'General', 
'type' => 'int', 
'backend' => '', 
'frontend' => '', 
'label' => 'Test Author', 
'input' => 'textarea', 
'class' => '', 
'source' => '', 
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, 
'visible' => true, 
'required' => false, 
'user_defined' => true, 
'default' => '', 
'searchable' => false, 
'filterable' => false, 
'comparable' => false, 
'visible_on_front' => false, 
'used_in_product_listing' => true, 
'unique' => false, 
'apply_to' => 'simple,configurable,virtual,bundle,downloadable' 
] 
); 
相關問題