SimilarityLookup

Want to find similar products? Then the SimilarityLookup operation is what you are looking for. This operation returns up-to 10 random products that customers who have bought the specified product(s) have also bought. This operation is very useful when you want to display suggested products based on an article/review’s content.

If for example you were running a book review website than you may find it useful to use the SimilarityLookup operation to output a widget of suggested books to your readers. Below is a short snippet of looking up similar products based on 2 books (A maximum of 10 products can be entered as the seed of this operation).

// Setup and Configure API
$api = new AmazonProductAPI();
... //set public,private, and associate key/id

// Setup Request
$request = new AmazonProduct_Request();
$request->Operation = AmazonProduct_Operation::SIMILARITY_LOOKUP;
$request->ItemId = "0756404738,0765341530";

// Send Request
$response = $api->search( $request );

// verify and use the response
if( $response->isSuccess() ) {
    foreach( $response->Items as $item ) {
        //consume Item
        echo $item->ItemAttributes->Title;
    }
}

There are a few options you want to familiarize yourself with when doing a SimilarityLookup

Setting the Operation to SimilarityLookup

The operation is set by the Operation variable of the AmazonProduct_Request object. You could pass in the string “SimilarityLookup” or use the SIMILARITY_LOOKUP constants provided in the AmazonProduct_Operation class.

$request->Operation = "SimilarityLookup";

$request->Operation = AmazonProduct_Operation::SIMILARITY_LOOKUP;

Setting the Product IDs

To specify the product(s) that you want to use as your seed you utilize the ItemId variable. The SimilarityLookup operation supports a comma delimited list of up to 10 products.
$request->ItemId = “0756404738,0765341530”;

* Please note to use strings when dealing with IDs as if you use an int Amazon will not find the product as 756404738 is not the same as 0756404738.

Setting the SimilarityType

By default the SimilarityLookup will return products that are similarities for all the products you entered. However if you want to return products that are similar to any of the seeded products and does not need to be for all then you can change the SimilarityType to Random from Intersection. These strings are also defined as constants in the AmazonProduct_SimilarityType class.

$request->SimilarityType = AmazonProduct_SimilarityType::RANDOM;

Specifying your desired response types

The SimilarityLookup operation returns by default a product’s ASIN, DetailPageURL, Manufacturer, ProductGroup, and ItemAttributes (including Title). However if you wanted to return the product’s images or other data you can specify that in the ResponseGroup variable by providing a comma delimited list of response groups.

$request->ResponseGroup = "MEDIUM," . AmazonProduct_ResponseGroup::IMAGES;

Full ItemLookup Documentation

To review the full set of options that can be utilized when performing an SimilarityLookup please visit the SimilarityLookup page of the Amazon Product Advertising API.

Comments & Questions

Add Your Comment