0

I've created a custom attribute programmatically by a resource setup script:

/** @var $installer Mage_Catalog_Model_Resource_Setup */
$installer->addAttribute('catalog_category', 'some_attr', array(
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'group' => 'Display Settings',
    'input_renderer' => 'some/renderer',
    'input' => 'select',
    'label' => 'some label',
    'note' => 'some note',
    'required' => false,
    'sort_order' => 200,
    'source' => 'catalog/category_attribute_source_page',
    'type' => 'int',
));

The problem is with saving value to the created attribute. When I want to save any value to the category on a store scope the value is not saved. But when I first save the value on the global scope, then on the store scope everything works as expected - after that I can change the global scope value back to blank and the store scope is still working.

So I guess some kind of "initialization of the attribute" is executing when saving the global scope, but why is that? Did I do something wrong?

1 Answer 1

0

Unexpectedly I've found a solution by myself.

Explicitly setting is_visible_on_front to true and user_defined to false fixed the problem.

For that I've created an upgrade script which includes:

$installer->updateAttribute('catalog_category', 'some_attr', 'is_visible_on_front', true);
$installer->updateAttribute('catalog_category', 'some_attr', 'user_defined', false);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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