cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 create Text Swatch programmatically

Magento 2 create Text Swatch programmatically

Hello Everyone,

 

I want to create product text swatch attribute through install data.

here i used this code:

 

$eavSetup->addAttribute(
                \Magento\Catalog\Model\Product::ENTITY, 'ccream', [
            'group' => 'CakeAttributes',
            'type' => 'int',
            'backend' => '',
            'frontend' => '',
            'label' => 'Cream',
            'input' => 'swatch_text',
            'note' => 'Cream',
            'class' => '',
            'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
            'visible' => true,
            'required' => false,
            'user_defined' => true,
            'default' => '0',
            'searchable' => false,
            'filterable' => false,
            'comparable' => false,
            'visible_on_front' => true,
            'used_in_product_listing' => true,
            'unique' => false,
            'option' => [
                'values' => ['FRESH','BUTTER'],
            ]
                ]
        );

I am getting only value in description as shown in image below in admin

ccream   Product Attributes   Attributes   Stores   Magento Admin.png

How can i get values in ADMIN and DESCRIPTION both, Can anyone help me please.

 

 

 

Magento Developer
Ankita Biswas