Skip to main content
replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
Source Link

During my research on question 2 module setup scripts dependence2 module setup scripts dependence I tested following: I tried to update already created category in module setup file (mysql4-install-0.1.0.php):

$installer = $this;
$installer->startSetup();
$defaultCategory = Mage::getModel('catalog/category')->load(3);
$defaultCategory->setData(array('cool_new_attribute' => 'cool_value', 'name' => 'test'))->save();
$installer->endSetup();

But this line creates new category instead of updating old category. And in system.log file appended following error trace:

exception 'Exception' with message '$_FILES array is empty' in Z:\home\magento.ce\www\lib\Varien\File\Uploader.php:467
Stack trace:
#0 Z:\home\magento.ce\www\lib\Varien\File\Uploader.php(149): Varien_File_Uploader->_setUploadFileId('thumbnail')
#1 Z:\home\magento.ce\www\app\code\core\Mage\Catalog\Model\Category\Attribute\Backend\Image.php(57): Varien_File_Uploader->__construct('thumbnail')
#2 [internal function]: Mage_Catalog_Model_Category_Attribute_Backend_Image->afterSave(Object(Mage_Catalog_Model_Category))
#3 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(657): call_user_func_array(Array, Array)
#4 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(1648): Mage_Eav_Model_Entity_Abstract->walkAttributes('backend/afterSa...', Array)
#5 Z:\home\magento.ce\www\app\code\core\Mage\Catalog\Model\Resource\Category.php(235): Mage_Eav_Model_Entity_Abstract->_afterSave(Object(Mage_Catalog_Model_Category))
#6 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(1124): Mage_Catalog_Model_Resource_Category->_afterSave(Object(Mage_Catalog_Model_Category))
#7 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Abstract.php(318): Mage_Eav_Model_Entity_Abstract->save(Object(Mage_Catalog_Model_Category))
#8 Z:\home\magento.ce\www\app\code\local\Test0\Test0\sql\test0_test0_setup\mysql4-install-0.1.0.php(13): Mage_Core_Model_Abstract->save()
#9 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(624): include('Z:\home\magento...')
#10 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '0.1.0')
#11 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('0.1.0')
#12 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#13 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#14 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()
#15 Z:\home\magento.ce\www\app\Mage.php(685): Mage_Core_Model_App->run(Array)
#16 Z:\home\magento.ce\www\index.php(93): Mage::run('', 'store')
#17 {main}

How I can update the category during module setup, or I am doing something wrong?

During my research on question 2 module setup scripts dependence I tested following: I tried to update already created category in module setup file (mysql4-install-0.1.0.php):

$installer = $this;
$installer->startSetup();
$defaultCategory = Mage::getModel('catalog/category')->load(3);
$defaultCategory->setData(array('cool_new_attribute' => 'cool_value', 'name' => 'test'))->save();
$installer->endSetup();

But this line creates new category instead of updating old category. And in system.log file appended following error trace:

exception 'Exception' with message '$_FILES array is empty' in Z:\home\magento.ce\www\lib\Varien\File\Uploader.php:467
Stack trace:
#0 Z:\home\magento.ce\www\lib\Varien\File\Uploader.php(149): Varien_File_Uploader->_setUploadFileId('thumbnail')
#1 Z:\home\magento.ce\www\app\code\core\Mage\Catalog\Model\Category\Attribute\Backend\Image.php(57): Varien_File_Uploader->__construct('thumbnail')
#2 [internal function]: Mage_Catalog_Model_Category_Attribute_Backend_Image->afterSave(Object(Mage_Catalog_Model_Category))
#3 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(657): call_user_func_array(Array, Array)
#4 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(1648): Mage_Eav_Model_Entity_Abstract->walkAttributes('backend/afterSa...', Array)
#5 Z:\home\magento.ce\www\app\code\core\Mage\Catalog\Model\Resource\Category.php(235): Mage_Eav_Model_Entity_Abstract->_afterSave(Object(Mage_Catalog_Model_Category))
#6 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(1124): Mage_Catalog_Model_Resource_Category->_afterSave(Object(Mage_Catalog_Model_Category))
#7 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Abstract.php(318): Mage_Eav_Model_Entity_Abstract->save(Object(Mage_Catalog_Model_Category))
#8 Z:\home\magento.ce\www\app\code\local\Test0\Test0\sql\test0_test0_setup\mysql4-install-0.1.0.php(13): Mage_Core_Model_Abstract->save()
#9 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(624): include('Z:\home\magento...')
#10 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '0.1.0')
#11 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('0.1.0')
#12 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#13 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#14 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()
#15 Z:\home\magento.ce\www\app\Mage.php(685): Mage_Core_Model_App->run(Array)
#16 Z:\home\magento.ce\www\index.php(93): Mage::run('', 'store')
#17 {main}

How I can update the category during module setup, or I am doing something wrong?

During my research on question 2 module setup scripts dependence I tested following: I tried to update already created category in module setup file (mysql4-install-0.1.0.php):

$installer = $this;
$installer->startSetup();
$defaultCategory = Mage::getModel('catalog/category')->load(3);
$defaultCategory->setData(array('cool_new_attribute' => 'cool_value', 'name' => 'test'))->save();
$installer->endSetup();

But this line creates new category instead of updating old category. And in system.log file appended following error trace:

exception 'Exception' with message '$_FILES array is empty' in Z:\home\magento.ce\www\lib\Varien\File\Uploader.php:467
Stack trace:
#0 Z:\home\magento.ce\www\lib\Varien\File\Uploader.php(149): Varien_File_Uploader->_setUploadFileId('thumbnail')
#1 Z:\home\magento.ce\www\app\code\core\Mage\Catalog\Model\Category\Attribute\Backend\Image.php(57): Varien_File_Uploader->__construct('thumbnail')
#2 [internal function]: Mage_Catalog_Model_Category_Attribute_Backend_Image->afterSave(Object(Mage_Catalog_Model_Category))
#3 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(657): call_user_func_array(Array, Array)
#4 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(1648): Mage_Eav_Model_Entity_Abstract->walkAttributes('backend/afterSa...', Array)
#5 Z:\home\magento.ce\www\app\code\core\Mage\Catalog\Model\Resource\Category.php(235): Mage_Eav_Model_Entity_Abstract->_afterSave(Object(Mage_Catalog_Model_Category))
#6 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(1124): Mage_Catalog_Model_Resource_Category->_afterSave(Object(Mage_Catalog_Model_Category))
#7 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Abstract.php(318): Mage_Eav_Model_Entity_Abstract->save(Object(Mage_Catalog_Model_Category))
#8 Z:\home\magento.ce\www\app\code\local\Test0\Test0\sql\test0_test0_setup\mysql4-install-0.1.0.php(13): Mage_Core_Model_Abstract->save()
#9 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(624): include('Z:\home\magento...')
#10 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '0.1.0')
#11 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('0.1.0')
#12 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#13 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#14 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()
#15 Z:\home\magento.ce\www\app\Mage.php(685): Mage_Core_Model_App->run(Array)
#16 Z:\home\magento.ce\www\index.php(93): Mage::run('', 'store')
#17 {main}

How I can update the category during module setup, or I am doing something wrong?

Source Link
mageUz
  • 6.2k
  • 3
  • 30
  • 52

Category update during module installation

During my research on question 2 module setup scripts dependence I tested following: I tried to update already created category in module setup file (mysql4-install-0.1.0.php):

$installer = $this;
$installer->startSetup();
$defaultCategory = Mage::getModel('catalog/category')->load(3);
$defaultCategory->setData(array('cool_new_attribute' => 'cool_value', 'name' => 'test'))->save();
$installer->endSetup();

But this line creates new category instead of updating old category. And in system.log file appended following error trace:

exception 'Exception' with message '$_FILES array is empty' in Z:\home\magento.ce\www\lib\Varien\File\Uploader.php:467
Stack trace:
#0 Z:\home\magento.ce\www\lib\Varien\File\Uploader.php(149): Varien_File_Uploader->_setUploadFileId('thumbnail')
#1 Z:\home\magento.ce\www\app\code\core\Mage\Catalog\Model\Category\Attribute\Backend\Image.php(57): Varien_File_Uploader->__construct('thumbnail')
#2 [internal function]: Mage_Catalog_Model_Category_Attribute_Backend_Image->afterSave(Object(Mage_Catalog_Model_Category))
#3 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(657): call_user_func_array(Array, Array)
#4 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(1648): Mage_Eav_Model_Entity_Abstract->walkAttributes('backend/afterSa...', Array)
#5 Z:\home\magento.ce\www\app\code\core\Mage\Catalog\Model\Resource\Category.php(235): Mage_Eav_Model_Entity_Abstract->_afterSave(Object(Mage_Catalog_Model_Category))
#6 Z:\home\magento.ce\www\app\code\core\Mage\Eav\Model\Entity\Abstract.php(1124): Mage_Catalog_Model_Resource_Category->_afterSave(Object(Mage_Catalog_Model_Category))
#7 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Abstract.php(318): Mage_Eav_Model_Entity_Abstract->save(Object(Mage_Catalog_Model_Category))
#8 Z:\home\magento.ce\www\app\code\local\Test0\Test0\sql\test0_test0_setup\mysql4-install-0.1.0.php(13): Mage_Core_Model_Abstract->save()
#9 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(624): include('Z:\home\magento...')
#10 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '0.1.0')
#11 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('0.1.0')
#12 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#13 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#14 Z:\home\magento.ce\www\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()
#15 Z:\home\magento.ce\www\app\Mage.php(685): Mage_Core_Model_App->run(Array)
#16 Z:\home\magento.ce\www\index.php(93): Mage::run('', 'store')
#17 {main}

How I can update the category during module setup, or I am doing something wrong?