ljackson09
24-01-10, 15:39
Hi All,
i have some code which searches the api and pulls out the top 3 items from several categories which is working well, the only problem i have is that some of the top 3 are from stores which are currently on hold e.g choices UK, and when the link to the prduct is clicked it says sorry product is not in there database? but im not sure how to prevent choices from being included in the results
here is my code
#GET TOP 5 ITEMS FOR EACH CATEGORY
$AW_catid = $aw_id;
$AW_cat = $aw_name;
$oRefineBy = new stdClass();
$oRefineBy -> iId = 4;
$oRefineBy -> sName = 'Category';
$oRefineByDefinition = new stdClass();
$oRefineByDefinition -> sId = $AW_catid;
$oRefineByDefinition -> sName = $AW_cat;
$oRefineBy -> oRefineByDefinition = $oRefineByDefinition;
$returnedcolumns = array(iCategoryId, iMerchantId, sAwImageUrl, fStorePrice, sAwThumbUrl, sName,sAwImageUrl,sMerchantImageUrl,sMerchantThumb Url,sDescription,sBrand);
$booleansearch = array('sQuery'=> $keywords, 'oActiveRefineByGroup' => $oRefineBy, 'bAdult' => true, 'iLimit'=>3, 'sColumnToReturn' => $returnedcolumns, 'sSort'=>'popularity', 'sMode' => 'boolean');
$oResponse= $oClient->call('getProductList', $booleansearch);
foreach($oResponse->oProduct as $oProduct)
{
$img = htmlspecialchars($oProduct->sMerchantImageUrl);
$img2 = htmlspecialchars($oProduct->sAwThumbUrl);
$price = $oProduct->fPrice;
$link = htmlspecialchars($oProduct->sAwDeepLink);
$store = $oProduct->iMerchantId;
$catid = $oProduct->iCategoryId;
$desc = $oProduct->sDescription;
$merchantid = $oProduct->iMerchantId;//the id i am trying to get the store name for
#GET MERCHANT NAME
$merchantcolumns = array(iId,sName,sClickThroughUrl);
$merchantrows = array("sColumnToReturn" => $merchantcolumns, "iAdult" => 1);
$oResponse= $oClient->call('getMerchant', $merchantrows);
foreach($oResponse->oMerchant as $merchID)
{
if($merchID->iId == $merchantid)
{
$merchName = $merchID->sName;
$merchLink = htmlspecialchars($merchID->sClickThroughUrl);
}
}
?>
<div class="individual_top5">
<h3 class="individual_top5_headers"><?php print $oProduct->sName;?></h3>
<div class="individual_top5_images">
<img src='<?php echo $img2;?>' height='85px' alt='<?php echo $desc;?>' title='<?php echo $desc;?>' /></div>
<div class='buyitnow_container'>
<div class="buyitnow_store"><span class="bold red"><a href="<?php echo $link;?>">Buy it now</a></span><br />from <a href="<?php echo $merchLink?>" target="_self"> <?php echo $merchName."</a><br /> for £".$price;?></div>
</div>
<div class='compareit_container'>
<div class="compareit_link">OR <br />compare prices</div>
</div>
</div>
<?php
}
any help would be appreciated :)
thanks
Luke
i have some code which searches the api and pulls out the top 3 items from several categories which is working well, the only problem i have is that some of the top 3 are from stores which are currently on hold e.g choices UK, and when the link to the prduct is clicked it says sorry product is not in there database? but im not sure how to prevent choices from being included in the results
here is my code
#GET TOP 5 ITEMS FOR EACH CATEGORY
$AW_catid = $aw_id;
$AW_cat = $aw_name;
$oRefineBy = new stdClass();
$oRefineBy -> iId = 4;
$oRefineBy -> sName = 'Category';
$oRefineByDefinition = new stdClass();
$oRefineByDefinition -> sId = $AW_catid;
$oRefineByDefinition -> sName = $AW_cat;
$oRefineBy -> oRefineByDefinition = $oRefineByDefinition;
$returnedcolumns = array(iCategoryId, iMerchantId, sAwImageUrl, fStorePrice, sAwThumbUrl, sName,sAwImageUrl,sMerchantImageUrl,sMerchantThumb Url,sDescription,sBrand);
$booleansearch = array('sQuery'=> $keywords, 'oActiveRefineByGroup' => $oRefineBy, 'bAdult' => true, 'iLimit'=>3, 'sColumnToReturn' => $returnedcolumns, 'sSort'=>'popularity', 'sMode' => 'boolean');
$oResponse= $oClient->call('getProductList', $booleansearch);
foreach($oResponse->oProduct as $oProduct)
{
$img = htmlspecialchars($oProduct->sMerchantImageUrl);
$img2 = htmlspecialchars($oProduct->sAwThumbUrl);
$price = $oProduct->fPrice;
$link = htmlspecialchars($oProduct->sAwDeepLink);
$store = $oProduct->iMerchantId;
$catid = $oProduct->iCategoryId;
$desc = $oProduct->sDescription;
$merchantid = $oProduct->iMerchantId;//the id i am trying to get the store name for
#GET MERCHANT NAME
$merchantcolumns = array(iId,sName,sClickThroughUrl);
$merchantrows = array("sColumnToReturn" => $merchantcolumns, "iAdult" => 1);
$oResponse= $oClient->call('getMerchant', $merchantrows);
foreach($oResponse->oMerchant as $merchID)
{
if($merchID->iId == $merchantid)
{
$merchName = $merchID->sName;
$merchLink = htmlspecialchars($merchID->sClickThroughUrl);
}
}
?>
<div class="individual_top5">
<h3 class="individual_top5_headers"><?php print $oProduct->sName;?></h3>
<div class="individual_top5_images">
<img src='<?php echo $img2;?>' height='85px' alt='<?php echo $desc;?>' title='<?php echo $desc;?>' /></div>
<div class='buyitnow_container'>
<div class="buyitnow_store"><span class="bold red"><a href="<?php echo $link;?>">Buy it now</a></span><br />from <a href="<?php echo $merchLink?>" target="_self"> <?php echo $merchName."</a><br /> for £".$price;?></div>
</div>
<div class='compareit_container'>
<div class="compareit_link">OR <br />compare prices</div>
</div>
</div>
<?php
}
any help would be appreciated :)
thanks
Luke