php - Creating a new product in magento -


i started magento development , starting hang of it. found examples on how create new product , code:

$p2 = mage::getmodel('catalog/product'); $p2->setsku('art002'); $p2->setattributesetid(2); $p2->setprice(20); $p2->save(); 

is supposed that. however, when running code, takes forever (cpu usage peaks 100%) , never finishes.

i had same issue updating product, got working this:

mage::getsingleton('catalog/product_action')     ->updateattributes(array($product->getid()), array('price'=>10), 1); 

but fail see how use create new product.

(background: trying create interface module wms, need able upload/update products, update stock.)

i repeated code on test machine, couldn't reproduce problem. think need change index mode 'update on save' 'update when scheduled', in admin >> system >> advanced >> index management


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -