Search code examples
phpamazon-mwsapai-io

Amazon Product API: Setting Multiple Keyword


I am using ApaiIO API for PHP and I am using following code to pull item list but it is not pulling items. When I put either hadoop or Java it fetches then.

$apaiIO = new ApaiIO($conf);

$search = new Search();
$search->setCategory('Books');
$search->setCondition('All');
$search->setKeywords('Hadoop Java');

Solution

  • the query is an intersection, not an union

    it does not retryeve "any of hadoop and java" but items with "both hadoop and java", maybe none

    I solved a similar situation by merging the results of 2 queryes:

    function searchAmazon($keywords){
    ..... //preamble code
    $apaiIO = new ApaiIO($conf);
    
    $search = new Search();
    ... //setting and filters
    $search->setKeywords($keywords);
    ... //retrieve it and put it in an array or similar    
    ... //blabla return
    }
    
    
    $products1=searchAmazon($keyword1);
    
    $products2=searchAmazon($keyword2);
    
    $products=merge($products1,$products2);//use some merge algorithm of your choice