php - Getting all items on Amazon Product API -


amazon's product api limits 10 items per page, , 10 pages @ query.

i have developed code items; first, have supplied params looks this:

    $item_params = [             "service" => "awsecommerceservice",             "operation" => "itemsearch",             "awsaccesskeyid"    => env('aws_access_key_id'),             "associatetag"      => env('aws_associate_tag_id'),             "searchindex" => "homegarden",             "responsegroup" => "itemattributes,salesrank,offers",             "sort" => "-price",             "browsenode" => $item_params['browsenode'],             "maximumprice" => $max_price,             "minimumprice" => "0"         ]; 

then, code items under browse node (category), sorted price (desc) specifying max , min price of items limit search.

the pseudo-code (original code long)

function getproducts($item_params, $max_price = null){      $products = //request amazon     foreach ($product $key=>$value){        //add product db     }      // if total number of results on query not equal zero, continue looping     if (!$products->totalresults() == 0){       $product = //get first lowest priced item on db        $this->getproducts($item_params, $product->price);     } 

}

however experiencing scenario :

sample request output (assuming items amazon):

asin(unique id) | price   1     |  201 2     |  194 3     |  195 . . n     | 33 n+1   | 33 n+2   | 33 .     n+120 | 33 n+121 | 34 n+122 | 35  

wherein products n n+120 equal. create infinite loop getproducts function. how can avoid this? knowing 10 items returned on each request , 10 pages.

how can avoid this?

i don't think can using price. have divide search multiple sub-searches using additional keywords. example, if you're searching "laptop", instead searches on "laptop asus", "laptop dell", etc.

you can filter on browse node ids, if results come multiple browse nodes, can 2 or more searches.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -