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 saving product entity
 
jkramarz
Jr. Member
 
Total Posts:  4
Joined:  2011-08-25
 

Hi there,

I’m running something like Iceimport, but developed by myself.
Currently, I try to optimise products price&availability;updates and run into a problem.

Script is running in shell, on Magento 1.7.0.2 with OrganicInternet_SimpleConfigurableProducts installed, using PHP 5.3.14 cli from Zend Platform.

I’ve something like below in my class

private function updateProduct(&$product$p false){
        
if(!($p instanceof Mage_Catalog_Model_Product))
            
$p Mage::getModel('catalog/product')->load($product->getCatalogid());
        
$p->setPrice($product->getRetailPrice());
        
$stockData $p->getStockData();
        
$stockData['is_in_stock']=((int)$product->getAvailability() >= 0);
        
$stockData['qty']=$product->getAvailability();
        
$p->setStockData($stockData);
        
$p->save();
}
and some strange behaviour in Mage_Eav_Model_Entity_Abstract sometime occurs - on line 1180 of core/Mage/Eav/Model/Entity/Abstract.php $origData is sometimes non-traversable, because it’s just NULL, while $this->_origData is populated.

Does somebody know what is going on?

Regards,
Jakub Kramarz

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

Have you tried

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); //required to save product
 
Magento Community Magento Community
Magento Community
Magento Community
 
Ryan Sun _Kuafu
Guru
 
Total Posts:  317
Joined:  2008-11-14
FL
 

use

$p = new Catalog_Model_Product()
instead of
$p Mage::getMode('catalog/product')
to check if plugins do some wired things to product model
 
Magento Community Magento Community
Magento Community
Magento Community
 
jkramarz
Jr. Member
 
Total Posts:  4
Joined:  2011-08-25
 
kiatng - 05 October 2012 07:11 AM

Have you tried

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); //required to save product

Thank you, it works much better now.

Ryan Sun _Kuafu - 05 October 2012 07:38 AM

use

$p = new Catalog_Model_Product()
instead of
$p Mage::getMode('catalog/product')
to check if plugins do some wired things to product model

I’ve disabled OrganicInternet’s plugin overloading catalog/product, I’m getting from Mage::getMode(’catalog/product’) Mage_Catalog_Model_Product now. Thanks. By the way, I’m not sure of autoload in this case

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