Magento 1: Get Final Price of Configurable Associated Product

Here I will show you how we can get the final price of an associated product which is associated with a configurable product.

<?php
$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();

Here above code is very simple to understand. Basically we have instances of both configurable product and associated product. Now we need to add Attribute Custom Options in configurable product instance in order to correctly retrieve the final price of associate product.

For that, we are looping through configurable attributes and prepare attribute options corresponding to the associated product (see the foreach loop section) and then add that information to configurable product ($product->addCustomOption()).

That’s it.

Rajeev K Tomy

263 thoughts on “Magento 1: Get Final Price of Configurable Associated Product

  1. Pingback: 2address
  2. Prescription Drug Information, Interactions & Side. Comprehensive side effect and adverse reaction information.
    ivermectin price
    Get here. Prescription Drug Information, Interactions & Side.

  3. drug information and news for professionals and consumers. Some are medicines that help people when doctors prescribe.
    https://lisinopril.science/# lisinopril 20 mg brand name
    Comprehensive side effect and adverse reaction information. earch our drug database.

  4. Get warning information here. Prescription Drug Information, Interactions & Side.
    https://nexium.top/# can i buy cheap nexium without prescription
    Get here. drug information and news for professionals and consumers.

  5. Comprehensive side effect and adverse reaction information. Medicament prescribing information.
    https://clomiphenes.online where can i buy cheap clomid without a prescription
    What side effects can this medication cause? Top 100 Searched Drugs.

  6. Great blog here! Additionally your website rather a lot up very fast! What host are you the usage of? Can I get your associate link for your host? I desire my website loaded up as fast as yours lol

  7. Im impressed. I dont think Ive met anyone who knows as much about this subject as you do. Youre truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog youve got here.

  8. Cool. I spent a long time looking for relevant content and found that your article gave me new ideas, which is very helpful for my research. I think my thesis can be completed more smoothly. Thank you.

  9. Can I just say what a relief to seek out someone who actually knows what theyre speaking about on the internet. You positively know find out how to bring a problem to mild and make it important. Extra individuals have to read this and perceive this side of the story. I cant believe youre not more in style because you positively have the gift.

  10. Hi there! I just wanted to ask if you ever have any trouble with hackers? My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no back up. Do you have any solutions to protect against hackers?

  11. Beneficial Blog! I had been simply just debating that there are plenty of screwy results at this issue you now purely replaced my personal belief. Thank you an excellent write-up.

  12. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here It’s always nice when you can not only be informed, but also entertained I’m sure you had fun writing this article.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top