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
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;
I have configurable products like
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
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
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.
add a comment |
I have configurable products like
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
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
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
add a comment |
I have configurable products like
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
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
I have configurable products like
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
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
magento-1.9 configurable-product price event-observer
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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;
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
add a comment |
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();
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
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
add a comment |
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;
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
add a comment |
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;
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;
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
add a comment |
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
add a comment |
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();
add a comment |
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();
add a comment |
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();
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();
answered Oct 14 '17 at 8:02
Rajeev K TomyRajeev K Tomy
14.6k54589
14.6k54589
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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