1

I am inserting a simple product programmatically.

the price is displaying on the grid but not on the (admin)form when I try to edit the product price. it is displaying as zero

$new_product->setName($sortedData['description'])
                    ->setAttributeSetId(9)
                    ->setTypeId('simple') 
                    ->setCreatedAt(strtotime('now'))
                    ->setWebsiteIds(array(1))
                    ->setStatus(1)
                    ->setTaxClassId(1)
                    ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
                    ->setTag($sortedData['printer_compatibility'])
                    ->setCategoryIds($category)
                    ->setSupplierCode($sortedData['dynamic_supply_code'])
                    ->setSku($sortedData['dynamic_supply_code'])
                    ->setCostExTax($sortedData['reseller_price_ex_gst'])
                    ->setManufacturer($this->fetchManufacturerOption($sortedData['manufacturer_name']))
                    ->setColor($this->addAttributeValue('color', $sortedData['cartridge_type']))
                    ->setMarkUpPercentage(10)
                    ->setPrice($this->calculatePrice($sortedData['reseller_price_ex_gst'], 10))
                    ->setCustomPrice($this->calculatePrice($sortedData['reseller_price_ex_gst'], 10))
                    ->setOriginalCustomPrice($this->calculatePrice($sortedData['reseller_price_ex_gst'], 10))
                    //->setPricePerPage()
                    ->setManufacturerCode($sortedData['manufacturer_oem_code'])
                    ->setWeight($sortedData['product_weight'])
                    //->setPageYield($sortedData['cartridge_yield'])
                    ->setPageYield($this->filterPageYield($sortedData['cartridge_yield'], $sortedData['cartridge_type']))
                    ->setMediaGallery (array('images'=>array (), 'values'=>array ()))
                    ->addImageToMediaGallery(getcwd()."/images/{$sortedData['dynamic_supply_code']}.jpg", array('image','thumbnail','small_image'), false, false)
                    ->setCubicMeasurement($sortedData['cubic_measurement'])
                    ->setStockData(array(
                                    'use_config_manage_stock' => 0, //'Use config settings' checkbox
                                    'manage_stock'=>1, //manage stock
                                    'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
                                    'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
                                    'is_in_stock' => 1, //Stock Availability
                                    'qty' => $sortedData['stock_on_hand'] //qty
                                )
                    );

            $new_product->save();
2
  • try catalog reindexing Jul 27, 2015 at 8:12
  • already tried this. it did not work.
    – tom_cruz
    Jul 27, 2015 at 8:32

1 Answer 1

0

If you are doing this on the frontend (or in an sql/data install) you must initialize the Magento app as Admin, if you have flat_catalog option enabled on your store, maybe you are saving this data to: catalog_flat_{store_id} table and not in EAV tables, you should set the store_id too.

BTW Check reindex too.

3
  • I am doing a custom module on admin. everything is saved properly except for the price
    – tom_cruz
    Jul 27, 2015 at 8:37
  • Ok, try to save the product, then set the price and save again. Can you specify your magento version and index configuration? indexes works different in CE and EE
    – Max
    Jul 27, 2015 at 8:43
  • I am at CE 1.9 note that the price is displaying on the product grid. but when I click the product to edit the price.. it is displayed as zero
    – tom_cruz
    Jul 27, 2015 at 9:08

Your Answer

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

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