{"id":9872,"date":"2013-03-12T13:24:25","date_gmt":"2013-03-12T07:54:25","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=9872"},"modified":"2013-04-01T13:55:51","modified_gmt":"2013-04-01T08:25:51","slug":"how-to-add-dropdown-attribute-for-category","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-add-dropdown-attribute-for-category\/","title":{"rendered":"How to add dropdown attribute for category in magento"},"content":{"rendered":"<p>\nAdding attributes from admin is simple in magento. But this feature is only for products. Some times there is requirement to add custom attribute for category to customize magento. Following is the code to add dropdown attribute for category.\n<\/p>\n<p>[php]<br \/>\n&lt;?php<\/p>\n<p>$setup = new Mage_Eav_Model_Entity_Setup(&#8216;core_setup&#8217;);<\/p>\n<p>$setup-&gt;addAttribute(&#8216;catalog_category&#8217;, &#8216;category_color&#8217;, array(<br \/>\n    &#8216;group&#8217;         =&gt; &#8216;General&#8217;,<br \/>\n    &#8216;input&#8217;         =&gt; &#8216;select&#8217;,<br \/>\n    &#8216;type&#8217;          =&gt; &#8216;varchar&#8217;,<br \/>\n    &#8216;label&#8217;         =&gt; &#8216;Border Color&#8217;,<br \/>\n    &#8216;option&#8217;        =&gt; array (<br \/>\n                              &#8216;value&#8217; =&gt; array(&#8216;optionone&#8217;=&gt;array(0=&gt;&#8217;red&#8217;),&#8217;optiontwo&#8217;=&gt;array(0=&gt;&#8217;green&#8217;),<br \/>\n&#8216;optionthree&#8217;=&gt;array(0=&gt;&#8217;blue&#8217;),&#8217;optionfour&#8217;=&gt;array(0=&gt;&#8217;black&#8217;))<br \/>\n                       ),<\/p>\n<p>    &#8216;backend&#8217;        =&gt; &#8216;eav\/entity_attribute_backend_array&#8217;,<br \/>\n    &#8216;visible&#8217;       =&gt; 1,<br \/>\n    &#8216;required&#8217;      =&gt; 0,<br \/>\n    &#8216;user_defined&#8217; =&gt; 1,<br \/>\n    &#8216;global&#8217;        =&gt; Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,<br \/>\n));<br \/>\n$installer-&gt;endSetup();<br \/>\n?&gt;<br \/>\n[\/php]<\/p>\n<p>\nIf you want to add new tab in category page in admin then what you need to do is just replace following line.\n<\/p>\n<p>[php]<br \/>\n&#8216;group&#8217;         =&gt; &#8216;General&#8217;<br \/>\n[\/php]<\/p>\n<p>\nWith\n<\/p>\n<p>[php]<br \/>\n&#8216;group&#8217;         =&gt; &#8216;Your Custom Tab&#8217;<br \/>\n[\/php]<\/p>\n<p>\nHope this will help you \ud83d\ude42\n<\/p>\n<p>\n<br \/>\nRegards,<br \/>\nAmatya Trivedi<br \/>\namatya@intelligrape.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adding attributes from admin is simple in magento. But this feature is only for products. Some times there is requirement to add custom attribute for category to customize magento. Following is the code to add dropdown attribute for category. [php] &lt;?php $setup = new Mage_Eav_Model_Entity_Setup(&#8216;core_setup&#8217;); $setup-&gt;addAttribute(&#8216;catalog_category&#8217;, &#8216;category_color&#8217;, array( &#8216;group&#8217; =&gt; &#8216;General&#8217;, &#8216;input&#8217; =&gt; &#8216;select&#8217;, &#8216;type&#8217; [&hellip;]<\/p>\n","protected":false},"author":62,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[1],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/9872"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/62"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=9872"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/9872\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=9872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=9872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=9872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}