cancel
Showing results for 
Search instead for 
Did you mean: 

Help : Create Order and Customize Price For Configurable Product

Help : Create Order and Customize Price For Configurable Product

Hello Everyone,

 

I have managed to create an order with simple and configurable products but I encountered an issue when I wanted to add a custom price. It worked for the simple product but not for the configurable one.

I'm using the code below 

$product = Mage::getModel('catalog/product')->load($productDetails["product_id"]);
if($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE){
	$config = new Varien_Object([
			'product' => $productDetails["product_id"],
			'qty' => $productDetails["qty"],
			'super_attribute' => $productDetails["attributes"],
	]);
}
$quote->addProduct($product, $config)
           ->setOriginalCustomPrice($productDetails["custom_price"])
           ->setCustomPrice($productDetails["custom_price"])
	   ->setIsSuperMode(true);

 

What I think is that I do define the custom price for the simple item but since it's configurable Magento always takes the price from the parent item.

Is there any way I can force the custom price

1 REPLY 1

Re: Help : Create Order and Customize Price For Configurable Product

@ayoubmoumg2deb Instead of setting the custom price on quote, you can set the item on quote and then set the custom price on item.
I have done the similiar type of work while adding product to cart.Please take the reference from the below code.

 

$item    = $observer->getEvent()->getQuoteItem();  //instead of this you can get the current item from quote

$item->setCustomPrice($discountedPrice);
$item->setOriginalCustomPrice($discountedPrice);
$item->getProduct()->setIsSuperMode(true);

It's a working code.

Let me know if you are still facing the issue.

 

Thanks