public function getItems() { $this->genMd5Hash(); $this->removeOldRecords(); $items = $this->getItemsFromDB(); if ($items !== false) { return $items; } $service = new Services\FindingService(array('appId' => $this->config['production']['appId'], 'apiVersion' => $this->config['findingApiVersion'], 'globalId' => Constants\GlobalIds::US)); $request = new Types\FindItemsAdvancedRequest(); $request->keywords = $this->replaseSimbols(strtolower($this->queryText)); if (!empty($this->queryCategory)) { $request->categoryId = $this->queryCategory; // array($this->queryCategory); } else { $request->categoryId = array('6030'); } $itemFilter = new Types\ItemFilter(); $itemFilter->name = 'ListingType'; $itemFilter->value[] = 'AuctionWithBIN'; $itemFilter->value[] = 'FixedPrice'; $request->itemFilter[] = $itemFilter; if (isset($this->queryMinPrice)) { $request->itemFilter[] = new Types\ItemFilter(array('name' => 'MinPrice', 'value' => array($this->queryMinPrice))); } if (isset($this->queryMaxPrice)) { $request->itemFilter[] = new Types\ItemFilter(array('name' => 'MaxPrice', 'value' => array($this->queryMaxPrice))); } switch ($this->querySort) { case 0: $request->sortOrder = 'PricePlusShippingHighest'; break; case 1: $request->sortOrder = 'PricePlusShippingLowest'; break; } $request->paginationInput = new Types\PaginationInput(); $request->paginationInput->entriesPerPage = 100; $request->paginationInput->pageNumber = $this->queryPage; $response = $service->findItemsAdvanced($request); if ($response->ack !== 'Failure') { $this->pageCount = (int) $response->paginationOutput->totalPages; $arrayresp = $response->toArray(); if (!$this->isFill($arrayresp)) { $this->emptyResponse = true; return false; } $this->addToBD($arrayresp); return $this->getItemsFromDB(); } else { return false; } }
* Sort the results by current price. */ $request->sortOrder = 'CurrentPriceHighest'; /** * Limit the results to 10 items per page and start at page 1. */ $request->paginationInput = new Types\PaginationInput(); $request->paginationInput->entriesPerPage = 10; $request->paginationInput->pageNumber = 1; /** * Send the request to the findItemsByAdvanced service operation. * * For more information about calling a service operation, see: * http://devbay.net/sdk/guides/getting-started/#service-operation */ $response = $service->findItemsAdvanced($request); if (isset($response->errorMessage)) { foreach ($response->errorMessage->error as $error) { printf("%s: %s\n\n", $error->severity === Enums\ErrorSeverity::C_ERROR ? 'Error' : 'Warning', $error->message); } } /** * Output the result of the search. * * For more information about working with the service response object, see: * http://devbay.net/sdk/guides/getting-started/#response-object */ printf("%s items found over %s pages.\n\n", $response->paginationOutput->totalEntries, $response->paginationOutput->totalPages); echo "==================\nResults for page 1\n==================\n"; if ($response->ack !== 'Failure') { foreach ($response->searchResult->item as $item) {