cancel
Showing results for 
Search instead for 
Did you mean: 

Help : Create Order and Customize Price For Configurable Product

SOLVED

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 take the price from the parent item.

Is there any way I can force the custom price

1 ACCEPTED SOLUTION

Accepted Solutions

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);

Its a working code.

Let me know if you are still facing the issue.

 

Thanks

View solution in original post

2 REPLIES 2

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);

Its a working code.

Let me know if you are still facing the issue.

 

Thanks

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

I just tried it and it's working. Thank you for your help @rahul Gupta