/** * static method * * @param array $ids The ids of the items to retrieve. * * @return array An array with id => GoogleBaseItem. */ function getGbaseItemsFromDb($ids) { global $db; if (!defined('TABLE_GOOGLEBASE')) { require_once dirname(realpath(__FILE__)) . '/../../languages/english/extra_definitions/googlebase.php'; } $query = "select gb.products_id as id, gb.googlebase_item_xml as item_xml\n from " . TABLE_GOOGLEBASE . " gb\n where gb.products_id in (" . implode(', ', $ids) . ")\n group by gb.products_id"; $result = $db->Execute($query); $items = array(); while (!$result->EOF) { $xmlp = new XmlParser(stripslashes($result->fields['item_xml'])); $data = $xmlp->GetData(); $item = new GoogleBaseItem(); $item->takeFromArray($data['entry']); $items[(int) $result->fields['id']] = $item; $result->MoveNext(); } return $items; }
/** * */ function _parseEntries() { if ($this->_response->hasErrors()) { return; } $pxml = $this->_response->getParsedXmlResponseBody(); /* $this->_updated = $pxml['xmldata']['feed']['updated']['VALUE']; $this->_title = $pxml['xmldata']['feed']['title']['VALUE']; */ $totalResults = (int) @$pxml['xmldata']['feed']['openSearch:totalResults']['VALUE']; if ($totalResults != 0) { if ($totalResults == 1) { $entries = array($pxml['xmldata']['feed']['entry']); } else { $entries = @$pxml['xmldata']['feed']['entry']; } foreach ($entries as $entry) { $item = new GoogleBaseItem(); $item->takeFromArray($entry); $this->_entries[] = $item; } } }