In Magento Text swatches and Visual swatches works with select-type attributes. In normal case the input type is drop down list. to set the options as text swatches we need to set the field value
“frontend_input” : “swatch_text” for(text swatches) and “frontend_input” : “swatch_visual” (for visual swatches)
'attribute': {
'is_wysiwyg_enabled': false,
'is_html_allowed_on_front': false,
'used_for_sort_by': false,
'is_filterable': true,
'is_filterable_in_search': true,
'is_used_in_grid': true,
'is_visible_in_grid': false,
'is_filterable_in_grid': true,
'position': 0,
'apply_to': [],
'is_searchable': '1',
'is_visible_in_advanced_search': '0',
'is_comparable': '1',
'is_used_for_promo_rules': '0',
'is_visible_on_front': '1',
'used_in_product_listing': '1',
'is_visible': true,
'scope': 'global',
'attribute_code': label,
"entity_type_id": '4',
"frontend_input": "swatch_text",
'is_required': false,
'options': [{'label': '', 'value': ''}],
'is_user_defined': true,
'default_frontend_label': attributeLabelNew,
'backend_type': 'int',
'source_model': 'Magento\\Eav\\Model\\Entity\\Attribute\\Source\\Table',
'is_unique': '0',
'validation_rules': []
}
in result the website view will be:
