I created attribute in Magento 2 using install script. By this code.
namespace Custom\Features\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;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory;
class InstallData implements InstallDataInterface
{
private $eavSetupFactory;
private $attributeSetFactory;
private $attributeSet;
private $categorySetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory, AttributeSetFactory $attributeSetFactory, CategorySetupFactory $categorySetupFactory )
{
$this->eavSetupFactory = $eavSetupFactory;
$this->attributeSetFactory = $attributeSetFactory;
$this->categorySetupFactory = $categorySetupFactory;
}
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{ // TO CREATE PRODUCT ATTRIBUTE
if (version_compare($context->getVersion(), '1.0.6') < 0) {
$setup->startSetup();
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'feature_1',
[
'group' => 'Autosettings',
'type' => 'varchar',
'label' => 'Feature 1',
'input' => 'text',
'frontend' => '',
'required' => false,
'global' => 1,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => null,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => true,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => '',
'note' => 'Feature 1'
]
);
$setup->endSetup();
}
}
}
Now I want create some attribute in catalog using Upgrade.
How to process same with another attribute in catalog using upgrade script.