How to get price for configurable product Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?show different product price using observerCreate invoice and shipment in magento via cron based on store view and order ageExclude a specific categoryMagento: Adding block from observer programmaticallycatalog_product_load_before event gives getRequestedRouteName() errorcatalog_product_collection_load_after causing maximum nesting issue for configurable productsSet custom price of product when adding to cart code not workingHow to change dynamic attributes when simple product is selectedMagento 2 plugin change price of products that have a custom attribute with

Multi tool use
Multi tool use

What kind of display is this?

Complexity of many constant time steps with occasional logarithmic steps

Can smartphones with the same camera sensor have different image quality?

Writing Thesis: Copying from published papers

Active filter with series inductor and resistor - do these exist?

Need a suitable toxic chemical for a murder plot in my novel

Passing functions in C++

What did Darwin mean by 'squib' here?

Slither Like a Snake

Do working physicists consider Newtonian mechanics to be "falsified"?

Array/tabular for long multiplication

Am I ethically obligated to go into work on an off day if the reason is sudden?

I'm thinking of a number

How does modal jazz use chord progressions?

New Order #5: where Fibonacci and Beatty meet at Wythoff

Fishing simulator

When is phishing education going too far?

How to colour the US map with Yellow, Green, Red and Blue to minimize the number of states with the colour of Green

Why does tar appear to skip file contents when output file is /dev/null?

Why is "Captain Marvel" translated as male in Portugal?

How do I automatically answer y in bash script?

How to rotate it perfectly?

How can I protect witches in combat who wear limited clothing?

Estimate capacitor parameters



How to get price for configurable product



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?show different product price using observerCreate invoice and shipment in magento via cron based on store view and order ageExclude a specific categoryMagento: Adding block from observer programmaticallycatalog_product_load_before event gives getRequestedRouteName() errorcatalog_product_collection_load_after causing maximum nesting issue for configurable productsSet custom price of product when adding to cart code not workingHow to change dynamic attributes when simple product is selectedMagento 2 plugin change price of products that have a custom attribute with



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















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.



like



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();
$item->setProductMrp($price);

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();
$item->setProductMrp($price);

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.










share|improve this question
















bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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

















0















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.



like



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();
$item->setProductMrp($price);

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();
$item->setProductMrp($price);

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.










share|improve this question
















bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • 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













0












0








0








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.



like



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();
$item->setProductMrp($price);

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();
$item->setProductMrp($price);

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.










share|improve this question
















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.



like



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();
$item->setProductMrp($price);

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();
$item->setProductMrp($price);

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.







magento-1.9 configurable-product price event-observer






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 '16 at 12:34







Jatin Raikwar

















asked Mar 28 '16 at 6:35









Jatin RaikwarJatin Raikwar

224320




224320





bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 7 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • 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

















  • 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
















I think you need the price of simple products. simple products are variant of configurable product

– Moyed Ansari
Mar 28 '16 at 6:49





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





How can I get price for that @MoyedAnsari

– Jatin Raikwar
Mar 28 '16 at 7:05










2 Answers
2






active

oldest

votes


















0














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

endif;





share|improve this answer























  • 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


















0














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





share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f108176%2fhow-to-get-price-for-configurable-product%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














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

    endif;





    share|improve this answer























    • 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















    0














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

    endif;





    share|improve this answer























    • 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













    0












    0








    0







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

    endif;





    share|improve this answer













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

    endif;






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 28 '16 at 7:15









    Moyed AnsariMoyed Ansari

    1013




    1013












    • 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

















    • 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
















    Its not working. showing error Notice: Undefined variable: _product

    – Jatin Raikwar
    Mar 28 '16 at 12:25





    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





    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





    I call event as I putted code in question. Where should I put your code???

    – Jatin Raikwar
    Mar 29 '16 at 6:39













    0














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





    share|improve this answer



























      0














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





      share|improve this answer

























        0












        0








        0







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





        share|improve this answer













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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 14 '17 at 8:02









        Rajeev K TomyRajeev K Tomy

        14.6k54589




        14.6k54589



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f108176%2fhow-to-get-price-for-configurable-product%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            jP,Qh,PV1v6p,vbNvkx0V8wrlBIYxn9YR5Ue3yR3PIKRq 88,GH6DNOpHd8unuZM br9MzT TveVwDdTxn08u
            HJ,NtDG7VR731UMSfUx68Cn446 f1pl6HsWH,E3cHK2A YioaZ6jC8,T08qTPy9P sjLO4Ls

            Popular posts from this blog

            Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її

            Буцька Катерина Петрівна Зміст Біографія | Фільмографія | Дублювання та озвучення українською | Дублювання та озвучення російською | Озвучення реклами | Навігаційне менюперевірена109 змінвиправивши або дописавши її

            Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?