How to create an attribute set in Magento 2 pro-grammatically?

how to create an attribute set in magento 2

Usually we used to create attribute sets from the admin panel. By navigate to Stores ->Attributes -> Attribute-set . When it comes to move different staging and development environment we want to create the attribute set repeatedly. To reduce the repeating time we can create the attribute set programatically in our custom module.

I used to manage a custom module to update the attributes progrmatically for every projects i am involving to. Recently while developing a custom module for providing free gifts. I want to show only free gifts product while creating the gift rules. So i decided to create the Free Gifts Attribute set with the module. Lets see how can achieve this. We want to create a custom module for this with InstallData.php inside the Setup directory.

That’s it. This is pretty simple straight forward method where any one can simple understand. Hope this will help you to minimize the time for repeatedly creating the same attribute sets in different environments during the development process.

That’s it. Have a nice day.Enjoy coding , Learn , Experience , Teach and Help.

Leave a Reply

Your email address will not be published. Required fields are marked *