1

I used the link http://www.magentocommerce.com/magento-connect/custom-attributes-4340.html and i can create customer attribute and also customer address attribute , but i can not create category attribute.

When i went throw the code i found in the "CategoryController.php", in the saveAction function wrote like bellow

            Mage::getSingleton('eav/config')
            ->getAttribute($this->_type, $attribute->getAttributeCode())
            ->setData('used_in_forms', $data['customer_form'])
            ->save();

When i print the $data by print_r($data['customer_form']), i could not find any 'customer_form' in the $data. So is there any alternative way to add the custom category attribute dynamically.

  • What is your exact problem? The attribute is not created (it doesn't exist in eav_attribute table), you can not save data in it, it doesn't show up in the backend? Something else? – Fabian Blechschmidt Sep 30 '13 at 8:08
  • Actually i created custom attribute . But when i edit or adding category under catalog, i cant find any custom attribute. – ranjitpradhan Sep 30 '13 at 9:04
2
$attributeUtility = Mage::getModel('core/setup');

$attributeUtility->addAttribute('catalog_category', 'attribute_code',
    array(
        'sort_order' => '0',
        'backend_type' => 'int',
        'input' => "boolean",
        'label' => 'Custom Attribute Label',
        'source_model' => 'eav/entity_attribute_source_boolean',
        'required' => '0',
        'user_defined' => false,
        'default_value' => '0',
        'unique' => '0',
        'note' => '',
        'global' => '1',
        'visible' => '1',
        'searchable' => '0',
        'filterable' => '0',
        'comparable' => '0',
        'visible_on_front' => '0',
        'html_allowed_on_front' => '1',
        'used_for_price_rules' => '0',
        'filterable_in_search' => '0',
        'used_in_product_listing' => '0',
        'used_for_sort_by' => '0',
        'configurable' => '0',
        'apply_to' => 'configurable',
        'visible_in_advanced_search' => '0',
        'position' => '0',
        'wysiwyg_enabled' => '0',
        'used_for_promo_rules' => true,
        'search_weight' => '1',
    )
);

You'll need to keep in mind that your 'source_model' needs to match a data type that makes sense for your attribute. The other values below do various things that need to be looked into for your implementation. The first parameter in the 'addAttribute' call is 'catalog_category' this maps out to a value from the database table eav_entity_type. For more information on EAV attributes see: Advanced ORM - by Alan Storm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.