For the last few days we have been banging our heads against the wall trying to figure out why when we tried to add configurable products from a Magento enterprise 1.11 store to Google Shopping using Magento’s core Google Shopping extension, they were all showing as out of stock in Google. After a great deal of digging and testing we finally got to the bottom of it and it appears to a bug in the extension.
The file: app/code/core/Mage/GoogleShopping/Model/Attribute/Availability.php uses the ‘isSalable’ function to determine whether a product is in or out of stock. If a value of 1 returned it sets the availability to ‘in stock’ and if it is null, it sets it as ‘out of stock’. This function works perfectly well normally but for some reason, when run within this extension, it always returns a null value for configurable products. We didn’t delve into why that is. Therefore, to get round this we decided to use a different function.
We commented out the line:
$value = $this->_googleAvailabilityMap[(int)$product->isSalable()];
and replaced it with:
$value = $this->_googleAvailabilityMap[(int)$stockItem->getIsInStock()];
This now checks to see if the item is in stock and does return a 1 if the item is in stock. This does not check whether the item is enabled, just whether it is in stock but this is good enough for us.
Hopefully if you have been banging your head against a wall as well, this will help.