Magento • Google Content API for Shopping not syncing • Call to a member function getText() on a non-object

Article ID #1304
Revision: 1.5
Last update: 2013-01-28


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 



Google Content API for Shopping was changed recently with removing non-mandatory published attribute and ->getPublished() call on item returns null.


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();



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.

Did this article help you solve your issue?

Average rating: 5 (9 votes)

completely useless 1 2 3 4 5 most valuable

Tags: , , ,