0

I'm trying to add a custom attribute to the category page. It will already show up but I only want to have the values Yes/No in it. Unfortunately there is always an empty, preselected value. So actually 3 values. I can't get rid of it! Can anyone point me in the right direction that only YES/No shows up? Preferably with "No" preselected. Thank you so much

<?php
    $installer = $this;
    $installer->startSetup();
    $attribute  = array(
    'label'             => 'Show in Parent Category',
    'type'              => 'int',
    'input'             => 'select',
    'default'            => 0,
    'sort_order'         => 2,
    'group'          => 'General Information',
    'backend'           => 'eav/entity_attribute_source_table',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible'           => true,
    'required'          => false,
    'user_defined'      => true,
    'searchable'        => false,
    'filterable'        => false,
    'comparable'        => false,
    'visible_on_front'  => false,
    'visible_in_advanced_search' => false,
    'unique'            => false,
    'option'             => array (
                            'values' => 
                                array (
                                    '1' => 'Yes',
                                    '0' => 'No'
                                )
                            )
    );
    $installer->addAttribute('catalog_category', 'show_in_parent_category', $attribute);
    $installer->endSetup();
?>
1

Remove this in your definition:

'backend'           => 'eav/entity_attribute_source_table'

And add this

'source'           => 'eav/entity_attribute_source_boolean'

Also remove the option element.

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.