Public Member Functions | |
getFeed ($location=null, $storeId=null) | |
getItemStats ($id, $storeId=null) | |
getItemTypes ($targetCountry) | |
getAttributes ($type, $targetCountry) | |
Public Attributes | |
const | ITEM_TYPES_LOCATION = 'http://www.google.com/base/feeds/itemtypes' |
const | ITEMS_LOCATION = 'http://www.google.com/base/feeds/items' |
Protected Member Functions | |
_getEntryStats ($entry) |
Definition at line 34 of file Feed.php.
_getEntryStats | ( | $ | entry | ) | [protected] |
Return item stats array based on Zend Gdata Entry object
Zend_Gdata_Gbase_ItemEntry | $entry |
Definition at line 80 of file Feed.php.
00081 { 00082 $result = array(); 00083 00084 $draft = 'no'; 00085 if (is_object($entry->getControl()) && is_object($entry->getControl()->getDraft())) { 00086 $draft = $entry->getControl()->getDraft()->getText(); 00087 } 00088 $result['draft'] = ($draft == 'yes' ? 1 : 0); 00089 00090 $expirationDate = $entry->getGbaseAttribute('expiration_date'); 00091 if (isset($expirationDate[0]) && is_object($expirationDate[0])) { 00092 $result['expires'] = Mage::getSingleton('googlebase/service_item')->gBaseDate2DateTime($expirationDate[0]->getText()); 00093 } 00094 00095 return $result; 00096 }
getAttributes | ( | $ | type, | |
$ | targetCountry | |||
) |
Returns Google Base Attributes
string | $type Google Base Item Type | |
string | $targetCountry Two-letters country ISO code |
Definition at line 148 of file Feed.php.
00149 { 00150 $itemTypes = $this->getItemTypes($targetCountry); 00151 if (isset($itemTypes[$type]) && $itemTypes[$type] instanceof Varien_Object) { 00152 return $itemTypes[$type]->getAttributes(); 00153 } 00154 return array(); 00155 }
getFeed | ( | $ | location = null , |
|
$ | storeId = null | |||
) |
Google Base Feed Instance
string | $location | |
int | $storeId Store Id |
Definition at line 46 of file Feed.php.
00047 { 00048 $query = new Zend_Gdata_Query($location); 00049 return $this->getService($storeId)->getFeed($query); 00050 }
getItemStats | ( | $ | id, | |
$ | storeId = null | |||
) |
Retrieve Items Statistics
string | $id Google Base item ID (e.g. http://www.google.com/base/feeds/items/3613244304072139222 or 3613244304072139222) | |
int | $storeId Store Id |
Definition at line 61 of file Feed.php.
00062 { 00063 if (!stristr($id, 'http://')) { 00064 $id = self::ITEMS_LOCATION . '/' . $id; 00065 } 00066 try { 00067 $entry = $this->getService($storeId)->getGbaseItemEntry($id); 00068 return $this->_getEntryStats($entry); 00069 } catch (Exception $e) { 00070 return null; 00071 } 00072 }
getItemTypes | ( | $ | targetCountry | ) |
Returns Google Base recommended Item Types
string | $targetCountry Two-letters country ISO code |
Definition at line 104 of file Feed.php.
00105 { 00106 $locale = Mage::getSingleton('googlebase/config')->getCountryInfo($targetCountry, 'locale'); 00107 $location = self::ITEM_TYPES_LOCATION . '/' . $locale; 00108 00109 $feed = $this->getGuestService()->getFeed($location); 00110 00111 $itemTypes = array(); 00112 foreach ($feed->entries as $entry) { 00113 $type = $entry->extensionElements[0]->text; 00114 $item = new Varien_Object(); 00115 $item->setId($type); 00116 $item->setName($entry->title->text); 00117 $item->setLocation($entry->id->text); 00118 $itemTypes[$type] = $item; 00119 00120 $typeAttributes = $entry->extensionElements[1]->extensionElements; 00121 $attributes = array(); 00122 if (is_array($typeAttributes)) { 00123 foreach($typeAttributes as $attr) { 00124 $name = $attr->extensionAttributes['name']['value']; 00125 $type = $attr->extensionAttributes['type']['value']; 00126 $attribute = new Varien_Object(); 00127 $attribute->setId($name); 00128 $attribute->setName($name); 00129 $attribute->setType($type); 00130 $attributes[$name] = $attribute; 00131 } 00132 } 00133 ksort($attributes); 00134 $item->setAttributes($attributes); 00135 } 00136 ksort($itemTypes); 00137 $this->_itemTypes = $itemTypes; 00138 return $itemTypes; 00139 }
const ITEM_TYPES_LOCATION = 'http://www.google.com/base/feeds/itemtypes' |
const ITEMS_LOCATION = 'http://www.google.com/base/feeds/items' |