Magento2: создание атрибута multi select категории с пользовательским источником
Для атрибута множественного выбора, вы можете добавить: Исходная модель: [VendorName] \ [ModuleName] \ Model \ Category \ Attribute \ Source \ Custom.php Внутренняя модель [VendorName] \ [ModuleName] \ Model \ Category \ Attribute \ Backend \ Custom.php input_renderer для html-области администратора [VendorName] \ [ModuleName] \ Block \ Adminhtml \ Category \ Helper \ Custom \ Options.php Install file[app/code/[VendorName]/[ModuleName]/Setup/InstallData.php] : <?php namespace [VendorName]\[ModuleName]\Setup; use Magento\Eav\Setup\EavSetup; use Magento\Eav\Setup\EavSetupFactory; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { private $eavSetupFactory; /** * Init * * @param EavSetupFactory $eavSetupFactory */ public function __construct(EavSetupFactory $eavSetupFactory) { $this->eavSetupFactory = $eavSetupFactory; } /** * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { /** @var EavSetup $eavSetup */ $eavSetup = $this->eavSetupFactory->create([‘setup’ => $setup]); /** * Add attributes to the eav/attribute */ $eavSetup->addAttribute( \Magento\Catalog\Model\Category::ENTITY, ‘multi_custom_attribute’, [ ‘type’ => ‘text’, ‘label’ => ‘Custom Attribute Description’, ‘input’ => ‘multiselect’, ‘required’ => false, ‘source’ => ‘[VendorName]\[ModuleName]\Model\Category\Attribute\Source\Custom’, ‘backend’… Читать далее »