0

I am trying to add a checkbox field with catalog category with following code but its not adding with category, when i change to text it works properly but not with checkbox .

$installer->addAttribute('catalog_category', 'disable_banner',  array(
    'type'     => 'int',
    'label'    => 'Disable Banner',
    'input'    => 'checkbox',
    'global'   => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'visible'           => true,
    'required'          => false,
    'user_defined'      => false,
    'default'           => 0
));

I found lots of tutorials for text fields but not for checkbox or radio button. Is it possible to add checkbox through custom module and if yes then what i am missing here.

Here is the tutorial I use for reference https://www.atwix.com/magento/add-category-attribute/

  • I added this and now i can see test field under general tab ( extra added ), how can I move this for general information tab and change lable to Disable banner. I tried with updateattribute in upgrade file but its not working – Vikram May 16 '16 at 11:56
5

Use below code:

<?php
$installer = $this;
$installer->startSetup();


$installer->addAttribute("catalog_category", "test",  array(
    "type"     => "int",
    "backend"  => "",
    "frontend" => "",
    "label"    => "test",
    "input"    => "checkbox",
    "class"    => "",
    "global"   => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    "visible"  => true,
    "required" => false,
    "user_defined"  => false,
    "default" => "0",
    "searchable" => false,
    "filterable" => false,
    "comparable" => false,

    "visible_on_front"  => false,
    "unique"     => false,
    "note"       => ""

    ));
$installer->endSetup();

enter image description here

EDIT

For update exciting category attribute. File name like mysql4-upgrade-0.0.1-0.0.2.php first 0.0.1 is current config.xml version and 0.0.2 new config.xml version

<?php
$installer = $this;
$installer->startSetup();

$installer->updateAttribute('catalog_category','test','label', 'Disable banner');

$installer->endSetup();
?>
  • I added this and now i can see test field under general tab ( extra added ), how can I move this for general information tab and change lable to Disable banner. I tried with updateattribute in upgrade file but its not working – Vikram May 16 '16 at 11:55
  • Update answer check it – Prashant Valanda May 16 '16 at 12:01

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.