Symptoms
Google Shopping Content API stopped working in Magento, synchronization with Google Content timing out or hangs after clicking Submit button at Catalog > Google Content > Manage Items. The following error message is logged in error log:
Fatal error: Call to a member function getText() on a non-object in /app/code/core/Mage/GoogleShopping/Model/Service/Item.php on line 64
Cause
Google Content API for Shopping was changed recently with removing non-mandatory published attribute and ->getPublished() call on item returns null.
Solution
Edit app/code/core/Mage/GoogleShopping/Model/Service/Item.php line 64 by setting to $published = date();:
--- app/code/core/Mage/GoogleShopping/Model/Service/Item.php +++ app/code/core/Mage/GoogleShopping/Model/Service/Item.php @@ -61,7 +61,7 @@ ->convertProductToEntry($item->getProduct(), $entry); $entry = $service->insertItem($entry); - $published = $this->convertContentDateToTimestamp($entry->getPublished()->getText()); + $published = date(); $item->setGcontentItemId($entry->getId()) ->setPublished($published);
Please note, this is a workaround only, supposed to be fixed in the core code prior to next upgrade and overwritten during upgrade. So, the file is intentionally fixed in app/code/core/ instead of copying into app/code/local/.
If you wish this change to be preserved across upgrades, you need to copy the file into app/code/local/Mage/GoogleShopping/Model/Service/Item.php and change it there.