PDA

View Full Version : help getting the 5 most popular blu-ray dvds and books


ljackson09
21-01-10, 17:34
Hi All

i have this code
<?php
foreach ($category_list as $category => $sub_category)
{
switch($category)
{
case "DVD";
$aw_id = "240";
$aw_name = "DVDs";
$keywords = "-region 1";
break;
case "CD";
$aw_id = "241";
$aw_name = "Music";
$keywords = "";
break;
case "Video Games";
$aw_id = "579";
$aw_name = "-console -bundle";
$keywords = "-region 1";
break;
case "Blu-Ray";
$aw_id = "550";
$aw_name = "Blu-Ray";
$keywords = "-region 1";
break;
case "Books";
$aw_id = "538";
$aw_name = "Books";
$keywords = "";
break;
}

print "<div class='category_container'>";
print "<h2 class='category_header red'>$category</h2>";

#GET TOP 5 ITEMS FOR EACH CATEGORY
$AW_catid = $aw_id;
$AW_cat = $aw_name;
$keywords = "";
$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(sAwImageUrl, sAwThumbUrl, sName,sAwImageUrl,sMerchantImageUrl,sMerchantThumb Url,sDescription,sBrand,iMerchantId,iCategoryId);
$booleansearch = array('sQuery'=> $keywords, 'oActiveRefineByGroup' => $oRefineBy, 'bAdult' => true, 'iLimit'=>5, 'sColumnToReturn' => $returnedcolumns, 'sSort'=>'popularity', 'sMode' => 'boolean');
$oResponse= $oClient->call('getProductList', $booleansearch);
foreach($oResponse->oProduct as $oProduct)
{
$img = htmlspecialchars($oProduct->sMerchantImageUrl);
$img2 = htmlspecialchars($oProduct->sAwThumbUrl);
$desc = $oProduct->sDescription;?>
<div class="individual_top5">
<h3 class="individual_top5_headers"><?php print $oProduct->sName;?></h3>
<div class="individual_top5_images">
<?php
print "<img src='$img2' height='85px' alt='$desc' title='$desc' /></div>"?>
</div>
<?php
}

print "</div>";
}


I am trying to pull out the top 5 products from several categories and it works ok if i type in the keywords for a boolean search like so
$booleansearch = array('sQuery'=> '-region 1', 'oActiveRefineByGroup' => $oRefineBy, 'bAdult' => true, 'iLimit'=>5, 'sColumnToReturn' => $returnedcolumns, 'sSort'=>'popularity', 'sMode' => 'boolean');

but if i do this
$booleansearch = array('sQuery'=> $keywords, 'oActiveRefineByGroup' => $oRefineBy, 'bAdult' => true, 'iLimit'=>5, 'sColumnToReturn' => $returnedcolumns, 'sSort'=>'popularity', 'sMode' => 'boolean');

i get compleatly different results even though its doing the same thing, isnt it? why am i getting the two sets of data?

i really need to use the varible in there as i will be searching over 30 categories and cannot add all the -keywords for all the categories in the one query

can anyone please help me with this?
many thanks
Luke

ljackson09
22-01-10, 16:37
Sorted It!

was setting $keywords to "" just before the api call :(

thanks

ljackson09
22-01-10, 19:23
any ideas as to why i am unable to pull out the store name from the api which matches the merchantid pulled from the productlist call?

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 = $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
print $merchantid;

#GET MERCHANT NAME
$merchantcolumns = array(iId,sName,sStrapline,sDescription,sLogoUrl,s DisplayUrl,sClickThroughUrl,oDiscountCode);
$merchantrows = array("iId" => $merchantid, "sColumnToReturn" => $merchantcolumns, "iAdult" => 1);
$oResponse= $oClient->call('getMerchant', $merchantrows);
print $oResponse->oMerchant->sName;
foreach($oResponse->oMerchant as $details)
{
$merchName =$details->sName;//the store name
}

?>
<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 <?php echo $merchName/*echoing the store name*/." for &pound;".$price;?></div>
</div>

<div class='compareit_container'>
<div class="compareit_link">OR <br />compare prices</div>
</div>

</div>
<?php
}


thanks
Luke

ljackson09
24-01-10, 15:31
managed to sort it with a simple loop :)