Below is my code in question. I will list a few things below it.

if ($product->getTypeId() == 'configurable') {
    $child = $product->getTypeInstance(true)->getProductByAttributes($params['super_attribute'], $product);
    $product = $child;
$message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
$response['status'] = 'SUCCESS';
$response['message'] = $message;
$topCart = $this->getLayout()->getBlock('topCart')->toHtml();
$response['topCart'] = $topCart;
$response['image'] = (string)Mage::helper('catalog/image')->init($product, 'thumbnail');
$response['name'] = $product->getname();
$response['price'] = Mage::helper('core')->formatPrice($product->getPrice(), true);

When $product is a simple product outright, there is no issue. The functions $product->getname(), $product->getPrice(), and init($product, 'thumbnail'), all return valid results.

When $product is found to be configurable, it's child product replaces it. I can then get the name, thumbnail but when I call the getprice function I get no results.

I don't understand why this would be. Anyone out there care to elucidate?

  • what value is given by $product->getPrice() – Amit Bera Oct 21 '14 at 15:41
  • @AmitBera When it is removed from the formatprice() it is returning nothing. Within formatprice I am getting 0.00. However, like I said, this only happens when the product is the child of a configurable product. When it is a simple product outright it is working as intended. – hownowbrowncow Oct 21 '14 at 15:44

Mage_Catalog_Model_Product_Type_Configurable::getProductByAttributes uses Mage_Catalog_Model_Product_Type_Configurable::getUsedProductCollection to load items, this collection does not load the price from eav. So you have to load the product:

$child = $product->getTypeInstance(true)->getProductByAttributes($params['super_attribute'], $product);
$product = Mage::getModel('catalog/product')->load($child->getId());

Now use $product->getFinalPrice(), this also implemets catalog price rules etc.


  • $product->getFinalPrice() still returns $0.00. – hownowbrowncow Oct 22 '14 at 12:25
  • Hei, i edit my preview post, try this. worked on a local test. Regards – Stefan Bothner Oct 22 '14 at 12:50
  • You are 'the man' Stefan. – hownowbrowncow Oct 22 '14 at 13:01

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.