I don't try to set price attribute during product import. Product is inserted into Magento catalog with its name, sku, description but price attribute is empty. The code I used is the following:

$product_model = Mage::getModel('catalog/product');
$productId = $product_model->getIdBySku($sku);
$categoriesIds = array($categoryId);
if (!$productId) {
    $qty = 1;
    try {
        $productId = $product_model->save()->getId();
        $product = $product_model->load($productId);
        $product->setIsInStock(1); //->isInStock(1)
    } catch(Exception $e) {
} else {


Can you help me, please? Thanks!!

3 Answers 3


As I think you added price two time and in first time there is no value in $ price. Please remove firset setPrice($price) and then try it will work.

  • I removed this row but price attribute is already empty
    – Federica
    Sep 9, 2016 at 10:52

Try with $product_model->setData('price', $price);

  • price isn't set..
    – Federica
    Sep 9, 2016 at 12:32
  • First debug whether you are receiving any amount in $price value or try with static value
    – mp196
    Sep 9, 2016 at 12:42
  • $price value arrives from a txt file.. I printed it and its value isn't empty..
    – Federica
    Sep 9, 2016 at 12:48
  • may be reading from text file is the issue it might be converting the price to string try using (float)$price
    – mp196
    Sep 9, 2016 at 12:53
  • the problem remains..
    – Federica
    Sep 9, 2016 at 13:22

Write below line in if block.


We need to set the store and website Id while importing products.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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