I am trying to create the product programatically, like this:

 $data0['name'] = 'Gundamz';
 $data0['sku'] = 'Gundamz123';
 $data0['weight'] = 2;
 $data0['status'] = 1;
 $data0['attribute_set_id'] = 4;
 $data0['tax_class_id'] = 0;
 $data0['visibility'] = 4;
 $data0['description'] = 'Gundam Blade';
 $data0['short_description'] = "Authentic Gundam Blade";
 $data0['price'] = "20033.32";

 $product = Mage::getModel('catalog/product');

but the price and weight always empty after I save the product.

Any idea, how to fix this ?


Both weight and price are decimals with a scale of 4.

Most likely it's not working because you are inserting them as strings instead of decimals. Try setting it by using:


In general it's better practice to use the setters instead of setData().

Detailed article: http://inchoo.net/magento/programming-magento/programatically-manually-creating-simple-magento-product/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.