title: Getting all items on Amazon Product API
body: <p>Amazon's Product API limits us to get only 10 items per page, and only 10 pages at a certain query.</p>
  
  <p>I have developed a code that would almost get all items;
  first, I have supplied a params that looks like this:</p>
  
  <pre><code>    $item_params = [
              "Service" =&gt; "AWSECommerceService",
              "Operation" =&gt; "ItemSearch",
              "AWSAccessKeyId"    =&gt; env('AWS_ACCESS_KEY_ID'),
              "AssociateTag"      =&gt; env('AWS_ASSOCIATE_TAG_ID'),
              "SearchIndex" =&gt; "HomeGarden",
              "ResponseGroup" =&gt; "ItemAttributes,SalesRank,Offers",
              "Sort" =&gt; "-price",
              "BrowseNode" =&gt; $item_params['BrowseNode'],
              "MaximumPrice" =&gt; $max_price,
              "MinimumPrice" =&gt; "0"
          ];
  </code></pre>
  
  <p>then, the code will get all items under that browse node (category), <strong>SORTED BY PRICE (desc)</strong> also by specifying the <strong>MAX and MIN Price</strong> of the items to limit the search.</p>
  
  <p>the pseudo-code (original code is too long)</p>
  
  <pre><code>function getProducts($item_params, $max_price = null){
  
      $products = //request to amazon
      foreach ($product as $key=&gt;$value){
         //add product to db
      }
  
      // if the total number of results on the query is not equal to zero, continue looping
      if (!$products-&gt;totalResults() == 0){
        $product = //get the first lowest priced item on the db
  
        $this-&gt;getProducts($item_params, $product-&gt;price);
      }
  </code></pre>
  
  <p>}</p>
  
  <p>however I am experiencing this scenario :</p>
  
  <p>Sample request output (assuming all items from amazon):</p>
  
  <pre><code>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 
  </code></pre>
  
  <p>wherein the products from n to n+120 are equal. This will create an infinite loop to my <code>getProducts</code> function. How can I avoid this? Knowing that only 10 items are returned on each request and only 10 pages.</p>