Magento Google Product Feed

I’ve beeen working on producing a new google product feed, using the product data from a Magento database.

This has been made more complex because google requires additional attributes for clothes/shoes, and wants the data at colour/size level, including a unique image for every colour variation.

The code I’m developing iterates through the “live” products in certain categories. Pulling out the data and producing an RSS2 feed.

Most of the products are Configurable products, so in order to access the child products I used this code, which iterates through each child, and then gets the colour and size attribute values…

  #Get Configurable Product ($obj is the product from a collection)
  $product_tmp = Mage::getModel('catalog/product')->load($obj->entity_id);

  #Get Children
  $conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product_tmp);
  $col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
  foreach($col as $simple_product) {
    $attributes = $simple_product->getAttributes();
    foreach ($attributes as $attribute) {
      $value = $attribute->getFrontend()->getValue($simple_product);
      if ($value != "" && $attribute->getName() == 'color' && $value != "No") { 			
        echo "      " . $value . "\n"; 
        $thisColour = $value;
      if ($value != "" && $value != 'No' && strpos(strtolower($simple_product->getResource()->getAttribute($attribute->getName())->getFrontendLabel()), 'size')) { 
        echo "      " . $value . "\n"; 
        $thisSize = $value;