Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design
Showing posts with label category attribute. Show all posts
Showing posts with label category attribute. Show all posts

Create new custom category attribute in Magento


There is no option in magento to add new custom category attribute. So if you want to add new category attribute in your magento you need to make some kind of code. Adding new custom attribute in magento using short code as following is short but not much more secure and proper way.

If you want to create new category attribute in proper way via module you can check my post
Adding Custom Category Attributes to Magento via Module


Magento create new custom category attribute

Copy and paste the following code in your header.phtml

require_once('app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Sales_Model_Mysql4_Setup;
$attribute  = array(
    'type' => 'int',
    'label'=> 'Your attribute label',
    'input' => 'text',
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible' => true,
    'required' => false,
    'user_defined' => true,
    'default' => "",
    'group' => "General Information"
);
$installer->addAttribute('catalog_category', 'your_attribute_code', $attribute);
$installer->endSetup();

Run your site once. After that remove this code from header.phtml
Your attribute is created.

its appear in your catalog->manage categories->General information tab

 

Copyright @ 2017 HKBlog.