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?

asked Jan 10, 2018 at 18:26

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);
answered Jan 10, 2018 at 19:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.