I have configurable products like

enter image description here

I created observer and I got the price

Default price is for 1kg but customer can change the weight and flavor.

When customer changes weight and flavor price changes.


enter image description here

enter image description here

I created observer in that I have code like

public function saveProductMrpInOrder(Varien_Event_Observer $observer) {
        $order = $observer->getEvent()->getOrder();
        foreach($order->getAllItems() as $item) {
            $price = Mage::getModel('catalog/product')->load($item->getId())->getPrice();
      return $this;

    public function saveProductMrpInInvoice(Varien_Event_Observer $observer) {
        $invoice = $observer->getEvent()->getInvoice();
        foreach($invoice->getAllItems() as $item) {
            $price = Mage::getModel('catalog/product')->load($item->getProductId())->getPrice();
      return $this;

    public function saveProductMrpInShipment(Varien_Event_Observer $observer)
        $shipment = $observer->getEvent()->getShipment();
        foreach($shipment->getAllItems() as $item) {               
            $product = Mage::getModel('catalog/product')->load($item->getProductId());
            $price = $product->getPrice();
            $item->product_mrp = $price;

But in that I am getting default price which is for 1kg

But I want price for product according to attributes selected

How can I get that price.

Hope you understand.

  • I think you need the price of simple products. simple products are variant of configurable product – Moyed Ansari Mar 28 '16 at 6:49
  • How can I get price for that @MoyedAnsari – Jatin Raikwar Mar 28 '16 at 7:05

Try this

if($_product->getTypeId() == "configurable"):
    $conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
    $simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
    foreach($simple_collection as $simple_product){
        echo $simple_product->getSku() . " - " . $simple_product->getName() . " - " . Mage::helper('core')->currency($simple_product->getPrice()) . "<br>";
  • Its not working. showing error Notice: Undefined variable: _product – Jatin Raikwar Mar 28 '16 at 12:25
  • where do you get product collection ? – Moyed Ansari Mar 28 '16 at 13:36
  • I call event as I putted code in question. Where should I put your code??? – Jatin Raikwar Mar 29 '16 at 6:39

From your question, it is not sure in which context you need to get the configurable product price.

In any context what you are missing is, you need to populate custom attribute options of the configurable product. After that, when you call getFinalPrice() on your configurable product instance you will get the correct price.

For more details, you can refer my blog post here. It shows how can populate custom attribute options of the configurable product if we have both configurable product and corresponding associated product.

For quick reference, I am adding the code snippet here.

$product        = Mage::getModel('catalog/product')->load(357); //configurable product
$optProduct     = Mage::getModel('catalog/product')->load(282); //associated simple product
$confAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
$pdtOptValues   = array();
foreach ($confAttributes as $attribute) {
    $attrCode    = $attribute['attribute_code'];
    $attrId      = $attribute['attribute_id'];
    $optionValue = $optProduct->getData($attrCode);
    $pdtOptValues[$attrId] = $optionValue;
$product->addCustomOption('attributes', serialize($pdtOptValues));
echo $product->getFinalPrice();

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.