Our team has been recently working on a pretty complex bespoke e-commerce website based on a Magento platform. One amongst the many extensions we decided to use during a development was a very popular ‘Simple Configurable Products‘ extension by Organic Internet, which helped us cover some of the functionality required around configurable products.

The extension seemed to be working very well until we enabled a magento built-in wishlist functionality and noticed that some products prices behave unpredictably when added to cart from a wishlist.  The problem was the SCP method of handling configurable products prices. I did research the problem and noticed that many people are facing the same issue and no one really has a solution – so decided to find it by myself . After some digging in the code of the extension I finally found that getFinalPrice($qty=null, $product) method in OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Product_Type_Configurable_Price class was always returning the lowest price from all the product’s options, regardless which option has been chosen. So when Magento was processing add to cart request called from a wishlist, it always ended up being added with the cheapest possible option of that product (which sometimes was quite a bargain 🙂 .

I noticed that it can be fixed by checking if the BuyRequest object has been passed to getFinalPrice() along with the product’s object. If it has, then just always return the price of the option defined it. So if it comes to code you just need to add a few lines at the very top of getFinalPrice():

$buyRequest = $product->getCustomOption('info_buyRequest');
if ($buyRequest) {
$options = $product->getCustomOption('info_buyRequest')->getItem()->getOptionByCode('simple_product')->getData();
$productId = $options["product_id"];
$childProduct = Mage::getModel('catalog/product')->load($productId);
return $childProduct->getPrice();
}

so it looks like:

public function getFinalPrice($qty=null, $product) {
$buyRequest = $product->getCustomOption('info_buyRequest');
if ($buyRequest) {
$options = $product->getCustomOption('info_buyRequest')->getItem()->getOptionByCode('simple_product')->getData();
$productId = $options["product_id"];
$childProduct = Mage::getModel('catalog/product')->load($productId);
return $childProduct->getPrice();
}
$childProduct = $this->getChildProductWithLowestPrice($product, "finalPrice");
if (!$childProduct) {
$childProduct = $this->getChildProductWithLowestPrice($product, "finalPrice", false);
}
if ($childProduct) {
$fp = $childProduct->getFinalPrice();
} else {
return false;
}
$product->setFinalPrice($fp);
return $fp;
}

I have created a pull-request on SCP’s GitHub repository so hopefully the patch will be included with the extension soon. In the meantime I hope you found this post helpful!

BTW. The GitHub’s extension version (0.82) seems to by much more up to date than the one hosted on Magento Connect (0.7) so it’s preferable to us this one.