I'm making a setupscript in Magento 1.7 CE to move some category data from one attribute to another. The script is working, but somehow it only saves on store view scope (just store view id 1), although I explicitly tell it to save on admin scope.
My current code:
<?php
$installer = $this;
$installer->startSetup();
$categories = Mage::getResourceModel('catalog/category_collection')
->addAttributeToSelect('description')
->addAttributeToSelect('text_onder')
->addAttributeToFilter('description_position', 0)
->setStoreId(0)
->addFieldToFilter('entity_id', 93)
;
$resource = Mage::getModel('catalog/category')->getResource();
foreach ($categories as $category) {
$object = new Varien_Object(array(
'entity_id' => $category->getId(),
'description' => '',
'text_onder' => $category->getDescription(),
'store_id' => 0
));
$resource->saveAttribute($object, 'text_onder');
$resource->saveAttribute($object, 'description');
}
$installer->endSetup();
The filter on entity id is just for testing of course.
The attribute text_onder was created like this:
$installer->addAttribute('catalog_category', "text_onder", array(
'group' => 'General Information',
'type' => 'text',
'input' => 'textarea',
'label' => 'Tekst onder',
'visible' => 1,
'required' => 0,
'user_defined' => 0,
'searchable' => 0,
'filterable' => 0,
'comparable' => 0,
'visible_on_front' => 1,
'visible_in_advanced_search' => 1,
'is_html_allowed_on_front' => 1,
'is_configurable' => 0,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'wysiwyg_enabled' => true,
));