Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Problem with Mage_Catalog_Model_Category->save() function in 0.8.1724
 
webfxmasta
Jr. Member
 
Total Posts:  15
Joined:  2008-02-29
 

I get an error when trying to use the following code in the new version: 0.8.1724:

Mage::app('base');
    
$category Mage::getModel('catalog/category')
        ->
setStoreId(0)
        ->
load(null)
        ->
addData($data);
    
    
$category->setAttributeSetId($category->getDefaultAttributeSetId());
    
$category->save();
(Code is from example given in this post.)

The Error:
Fatal error: Uncaught exception ‘Mage_Core_Exception’ with message ‘Invalid store requested: “base”.’ in C:\wamp\www\app\Mage.php:356 Stack trace:
#0 C:\wamp\www\app\code\core\Mage\Core\Model\App.php(494): Mage::throwException(’Invalid store r...’)
#1 C:\wamp\www\app\code\core\Mage\Catalog\Model\Resource\Eav\Mysql4\Collection\Abstract.php(48): Mage_Core_Model_App->getStore()
#2 C:\wamp\www\app\code\core\Mage\Catalog\Model\Resource\Eav\Mysql4\Collection\Abstract.php(66): Mage_Catalog_Model_Resource_Eav_Mysql4_Collection_Abstract->getStoreId()
#3 C:\wamp\www\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(848): Mage_Catalog_Model_Resource_Eav_Mysql4_Collection_Abstract->_getLoadAttributesSelect(’catalog_categor...’)
#4 C:\wamp\www\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php(689): Mage_Eav_Model_Entity_Collection_Abstract->_loadAttributes(false, false)
#5 C:\wamp\www\app\code\core\Mage\Catalog\Model\Resource\Eav\Mysql4\Category\Collection.php(138): Mage_Eav_Model_Entity_Collection_Abstract->load(f in C:\wamp\www\app\Mage.php on line 356

Any help would be appreciated.
Thanks in advance.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dirk
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2008-02-21
 

You have to call

Mage::app('default');

instead of

Mage::app('base');

since version 0.8.1724

 
Magento Community Magento Community
Magento Community
Magento Community
 
webfxmasta
Jr. Member
 
Total Posts:  15
Joined:  2008-02-29
 

Thanks! I’ll try that.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top