Gönderiyi okuyorsunuz: Magento 2’de programlı olarak çoklu seçimli bir ürün özelliği nasıl oluşturulur?
ad alanı Sağlayıcı\Uzantı\Yapılandırma;
Magento\Eav\Setup\EavSetupFactory’yi kullanın;
Magento\Framework\Setup\InstallDataInterface’i kullanın;
Magento\Framework\Setup\ModuleContextInterface’i kullanın;
Magento\Framework\Setup\ModuleDataSetupInterface’i kullanın;
InstallData sınıfı InstallDataInterface’i uygular
{
özel $eavSetupFactory;
genel işlev __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
}
genel işlev kurulumu(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$configuration->startConfiguration();
$eavSetup = $this->eavSetupFactory->create([‘setup’ => $setup]);
$eavSetup->addAttribute(
\Magento\Katalog\Model\Ürün::ENTITY,
‘eway_option’,
[
‘group’ => ‘Groupe Name’,
‘label’ => ‘Multiselect Attribute’,
‘type’ => ‘text’,
‘input’ => ‘multiselect’,
‘source’ => ‘Vendor\Extension\Model\Config\Product\Extensionoption’,
‘required’ => false,
‘sort_order’ => 30,
‘global’ => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
‘used_in_product_listing’ => true,
‘backend’ => ‘Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend’,
‘visible_on_front’ => false
]
);
$install->endSetup();
}
}