Advertisement
Guest User

Allegro - zamiana doSearch na nowe doGetItemsList

a guest
Jul 7th, 2015
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.34 KB | None | 0 0
  1.         static function search($tekst, $kategoria, $woj)
  2.         {
  3.                 //zapytanie po starym api, dla referencji
  4.  
  5. /*              $search_request = array(
  6.                         "sessionHandle" => allegro::$session,
  7.                         "searchQuery" => array(
  8.                         "searchString" => $tekst,
  9.                         "searchCategory" => $kategoria)
  10.                         );
  11.  
  12.                 if($woj != 0)
  13.                         $seach_request["searchQuery"]["searchState"] = $woj;
  14.  
  15.                 return allegro::$soapClient->doSearch($search_request); */
  16.  
  17.         //koniec starego zapytania
  18.  
  19.  
  20.                 //sprawdzić kategorię - jeśli 0 to olać.
  21.  
  22.                 $filters = array();
  23.  
  24.                 if($kategoria != 0)
  25.                 {
  26.                         //searchCategory
  27.                         array_push($filters, array(
  28.                                 "filterId" => "category",
  29.                                 "filterValueId" => array($kategoria)
  30.                                 ));
  31.                 }
  32.  
  33.                 //searchString
  34.                 array_push($filters, array(
  35.                                 "filterId" => "search",
  36.                                 "filterValueId" => array($tekst))
  37.                                 );
  38.  
  39.                 //nowe api nie umie w województwa jeśli szukamy po całym allegro                                                                                                                                                              -.-
  40.                 if($woj != 0 && $kategoria != 0)
  41.                 {
  42.                         //searchState
  43.                         array_push($filters, array(
  44.                                 "filterId" => "state",
  45.                                 "filterValueId" => array($woj))
  46.                                 );
  47.                 }
  48.  
  49.                 $new_search_request = array(
  50.                         "countryId" => ALLEGRO_COUNTRY,
  51.                         "webapiKey" => ALLEGRO_KEY,
  52.                         "filterOptions" => $filters
  53.                 );
  54.  
  55.  
  56.                 $test =  allegro::$soapClient->doGetItemsList($new_search_request);
  57.  
  58.                 return allegro::resultTranslator($test);
  59.         /* resultTranslator tłumaczy wynik funkcji na stare api,
  60.         http://pastebin.com/3zVx05re */
  61.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement