The Modules
“Simple Google Shopping allows you to export in a few minutes a valid and well structured data flow of your products from your Magento web-site to your Google Merchant account.”
“With Simple Configurable Products, the price for configurable products is taken directly from the associated simple products rather than the configurable product itself.”

The Problem
There are several Magento modules out there that deal with the pricing of configurable and bundle product should you wish to calculate the display price using the combined price of the associated products. By using one of these modules your frontend is sorted but what happens to your google feed? Obviously you want to display the same prices within google search results as you do on your website. By customising the Simple Google Shopping module the result is easily achieved.
One of our client’s site is set up so that every product has a regular and a special price the latter being the one they sell the products at. This does not cause any issue when adding the price to the XML feed for simple products but because both the bundle and configurable products are built out of simple products when we try to get the price using either the default attributes that come with the feed module or the conventional getPrice() function we get either 0 or the sum of the regular price of the simple products as value for the price attribute.

A Workaround
Without going into too much detail (an excellent documentation can be found on the feed module’s website) I will show you a quick workaround to solve the problem by modifying the XML product pattern under Google Shopping in the Admin section of the site (one more time, you will need the Simple Google Shopping (by Wyomind) module installed and there is a chance that you are already using one of the modules out there for the configurable product pricing, we took advantage of the one called Simple Configurable Product (by Organic Internet & Mobile) which allows you to build up configurable products out of simple ones):


getTypeId() == "configurable"){
  	$_price = 0;
	$_config_product = Mage::getModel('catalog/product')->load($product->getId());
	$_helper = new OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Product_Type_Configurable_Price;
	$_price = (float)$_helper->getFinalPrice(1,$_config_product);
	$_price *= 1.2;
	$_price = number_format($_price,2,'.',' ');
	return $_price;
} else if($product->getTypeId() == 'bundle'){
	$bundled_product = new Mage_Catalog_Model_Product();
    	$bundled_product->load($product->getId());

    	$selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection(
        	$bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product
    	);

   	$_prices = array();
if($product->getTypeId() == "configurable"){
  	$_price = 0;
	$_config_product = Mage::getModel('catalog/product')->load($product->getId());
	$_helper = new OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Product_Type_Configurable_Price;
	$_price = (float)$_helper->getFinalPrice(1,$_config_product);
	$_price *= 1.2;
	$_price = number_format($_price,2,'.',' ');
	return $_price;
} else if($product->getTypeId() == 'bundle'){
	$bundled_product = new Mage_Catalog_Model_Product();
    	$bundled_product->load($product->getId());

    	$selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection(
        		$bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product
    	);

	$_prices = array();
    	$_price = 0;

    	foreach($selectionCollection as $option)  	{
		$_thisPrice = Mage::getModel('bundle/product_price')->getSelectionPrice($bundled_product, $option);
		$_thisOptionId = $option->getData('option_id');

		if($_prices[$_thisOptionId]){
			if($_thisPrice < $_prices[$_thisOptionId]) {
				$_prices[$_thisOptionId] = $_thisPrice;
			}
		} else {
			$_prices[$_thisOptionId] = $_thisPrice;
		}
	}

	foreach($_prices as $_aPrice){
			$_price += $_aPrice;
	}

    	return $_price*1.2;
} else {
return "{special_price}";
}?>
GBP

The above is an excerpt from the shopping feed more precisely the part where we tell Google about the price of the product. The code is divided into three cases:
– configurable product
– bundle product
– other (in our case it means simple product)
The feed module allows us to use php code when setting the value for a tag as long as the code is placed between the php opening and closing (shorthand)tags. Also we are offered a $product object by default which is suitable for getting basic product related attributes but not detailed enough to calculate the price based on the related products’ special prices. Hence, we need to load a full product instance first then we loop through the related products, get the lowest prices per categories and add them together to get the lowest price our product can be sold at. This algorithm is valid for both configurable and bundle product types. (For simple product we simply use the {special_price} special attribute supplied by the feed module itself.) However, you may have noticed that for configurable products we don’t loop through the associated products. It is because the module we use for building configurable products out of simple products gives us the modified version (the original is available from the core) of the getFinalPrice() funtion so to keep our code as simple as possible we use that instead of searching for related products and finding the lowest price. The function does just the same for us. For bundle products we are not in luck, just have to take the longer route to find out the prices.
Before we return the price we multiply it by 1.2 to get a VAT included price. This is hardcoded for the time being but you could get the amount of VAT the same way as Magento does it when displaying VAT included prices.
Simple as that.