Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
configurable_attribute_with_source_model.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
10 $eavSetup = $objectManager->create(\Magento\Eav\Setup\EavSetup::class);
11 $eavSetup->addAttribute(
12  \Magento\Catalog\Model\Product::ENTITY,
13  'test_configurable_with_sm',
14  [
15  'group' => 'General',
16  'type' => 'varchar',
17  'backend' => '',
18  'frontend' => '',
19  'label' => 'Test configurable with source model',
20  'input' => 'select',
21  'source' => \Magento\Catalog\Model\Category\Attribute\Source\Mode::class,
22  'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
23  'visible' => true,
24  'required' => false,
25  'user_defined' => true,
26  'default' => '',
27  'searchable' => false,
28  'filterable' => false,
29  'comparable' => false,
30  'visible_on_front' => false,
31  'used_in_product_listing' => true,
32  'unique' => false,
33  'apply_to' => ''
34  ]
35 );
36 
37 $eavConfig = $objectManager->get(\Magento\Eav\Model\Config::class);
38 $eavConfig->clear();