When creating attribute I notice that in magento2 no option for the select product type.
i.e I want my attribute will available for configurable product only.
But that attribute is visible for all simple product too.
Even I create a custom attribute when creating adding a configurable product.
When adding a simple product why that attribute is visible?
* How to create an attribute for configurable product only?
Best Answer
Yes , You can create specific attribute for specific product type programmatically.
Below i have created Boolean type of attribute for configurable product only.
You need to pass 'apply_to' parameter and its value as configurable
try below code in your InstallData.php file :
Note : Same way if you needed this for all types of product you need to pass all values in same parameters like : 'apply_to'=>'simple,configurable,bundle,grouped'