Adding new category attribute in Magento 2

Magewallet | Magento 2 Extensions, Themes & Solutions

Adding new category attribute in Magento 2

Sometimes you need to extend functionality of Magento 2 categories. In this article I would like to show you how to add a new custom category attribute. Let’s say, this attribute is needed to display/hide some content on the category page.

Now let’s write our installation script under Setup folder. I’ve included comments within to guide you along. Note that the custom variable I’m adding is called hide_this_category. This attribute will be used for hide particular category from menu.

In this case I’ve added a Boolean field that will be stored in used as Yes/No, but you can change this according to your requirement.

Lets check code to add custom category attribute.

Please setup this installation script with your extension and run upgrade command via command line. If things didn’t work out, check to see if the installation script actually ran and make sure that you cleared your cache and double-check your installation script filename, path and version number with Magento 2 extension structure.

Enjoy Cool stuff with Magewallet!!

admin

Leave Comment

Newsletter

Latest Tweets