Getting an Individual Product

To retrieve a single product based on Awins product ID, the code is as follows:

1
2
3
4
5
6
<?php
	define('API', 'PS');
	require_once('constants.inc.php');
	require_once('classes/class.ClientFactory.php');
	$oClient = ClientFactory::getClient(API_USERNAME, API_PASSWORD, API_USER_TYPE);
	?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$singleproduct= array('iProductId'=>43495938);
$oResponse= $oClient->call('getProduct', $singleproduct);
$image = $oResponse->oProduct->sAwImageUrl;
$categoryid = $oResponse->oProduct->iCategoryId;
$name = $oResponse->oProduct->sName;
$description = $oResponse->oProduct->sDescription;
$price = $oResponse->oProduct->fPrice;
$link = $oResponse->oProduct->sAwDeepLink;
$brand = $oResponse->oProduct->sBrand;
$deliverycost = $oResponse->oProduct->fDeliveryCost;
$merchant = $oResponse->oProduct->iMerchantId;
 
    echo "<h2>".$name."</h2>";
    echo "<a href=\"".$link."\"  title=\"".$name."\"><img src=\"".$image."\"/ style=\"float:left; margin:10px;border:0\" alt=\"".$name."  \"></a>";
    echo $description."<br/><br/><h5>&pound;".number_format($price,2,'.',',')."</h5>".$brand."<br/><br/>";
    echo "<a href=\"".$link."\">Click to see details</a>";
     ?>

The result from this query (new window)
Possible Fields returned from the call ‘getProduct’ are :

iId The product id
iCategoryId The category id this product belongs to
iMerchantId The merchant id this product belongs to
sMerchantProductId The product id on the merchant’s system
bAdult Is this an adult only product
bHotPick Is this a merchants ‘hot pick’
iUpc Universal Product Code
iEan European Article Number
sMpn Manufacturers Part Number
iIsbn International Standard Book Number
sName The name
sDescription The full description
sSpecification The specifications
sPromotion The promotional text
sBrand The brand
sModel The model
sAwDeepLink The deeplink with the tracking code
sAwThumbUrl The thumbnail image on AWin server
sAwImageUrl The full image on AWin server
sMerchantDeepLink Merchants deeplink with no tracking code
sMerchantThumbUrl The thumbnail image on Merchant server
sMerchantImageUrl The full image on Merchant server
sDeliveryTime Text stating product delivery time
fPrice The price
fStorePrice In Store Price
fRrpPrice RRP Price
fDeliveryCost The cost of delivery
bWebOffer Web only offer
bPreOrder For pre-order
sWarranty Product warranty

Comments

5 Comments on Getting an Individual Product

  1. emmfield on Sat, 5th Dec 2009 11:11 pm
  2. This site’s really really good man. It completely saved me as there isn’t much official documentation or examples, with little activity on the Shopwindow forums.

    I guess all the examples are API v2, right? I downloaded v3 of the API.

    Show by category ID works but the query and individual product doesn’t.

    Now you’ve gotten me started I’m gonna continue with what works in v3 and try to work from there. I’ll share some v3 tips with you if I come across them if you like. It’d be great to see more on here.

  3. apimonkey on Sun, 6th Dec 2009 12:12 pm
  4. I’ve just added the V3 version for an individual product here Single Product V3

  5. shopoftheworld on Sun, 16th Jan 2011 7:43 pm
  6. Hi
    Thansj for the site – as everyone seems to agree the AW site is not much use for docs onthe API

    Anyway I am trying to grab a complete set of products for a given merchant so I am using getMerchantProduct is a standard way.

    Is there a value i can pass to the sMerchantProductId parameter that will return all prods for that merchant (as i dont yet know the ID I cant pass that)

    I tried using a zero and it sort of works but i realise it is now just returning products that have a 0 in the ID – this works for some merchants that have products starting with 0 but for others it just selects a subset of products.

    The getProduct function also doesnt seem to have this feature

    here is my basic code then just for each through the array to extract values

    define('API', 'PS');
    $productID ='0';
    require_once ('constants.inc.php');
    require_once ('classes/class.ClientFactory.php');
    # Username and password constants are defined in constants.inc.php
    $oClient = ClientFactory::getClient();
    $returnedcolumns = array(sAwImageUrl,sDescription,sBrand,iMerchantId,iCategoryId,sMerchantProductId );

    $aParams1 = array(
    'iMerchantId' => $merchantID,
    'sMerchantProductId' => $productID,
    'sColumnToReturn' => $returnedcolumns
    );

    $oResponse = $oClient->call('getMerchantProduct', $aParams1);

    Can you help ?

    thanks
    s

  7. apimonkey on Sun, 16th Jan 2011 8:51 pm
  8. I tend not to use getMerchantProduct, as it’s kind of difficult to find the merchants productid, that’s if they’ve even set it.

    Instead, I go for the getProductList with a refinement of merchantid.


    $returnedcolumns = array(sAwImageUrl,sDescription,sBrand,iMerchantId,iCategoryId);
    $oRefineBy = new stdClass();
    $oRefineBy->iId = 3;
    $oRefineBy->sName = 'Merchant';
    $oRefineByDefinition = new stdClass();
    $oRefineByDefinition->sId = AWINMERCHANTID;
    $oRefineByDefinition->sName = '';
    $oRefineBy->oRefineByDefinition = $oRefineByDefinition;
    $oProductDisplayListParams = array($oRefineBy);
    $gettheproducts = array("sQuery" => "", "iAdult" => 1, "iLimit"=>10, "sColumnToReturn" => $returnedcolumns , "oActiveRefineByGroup" => $oProductDisplayListParams, "bIncludeTree" => true, "sSort" => popularity);
    $getproductlist= $oClient->call('getProductList', $gettheproducts);

    You can change the limit to a maximum of 100, then, using the iOffset you can get up to 1,000 products, or, if you sort the first 1,000 by price hi, then the second 1,000 by price lo, then 2,00.

    I’m sure you could be more creative in expanding the amount of records that can be returned.

  9. shopoftheworld on Mon, 17th Jan 2011 10:46 am
  10. thanks for the very prompt reply – i will give that a try today – S

Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

You must be logged in to post a comment.