currentstyle
24-08-09, 13:23
To display a single product with a number of related products below it, get the productID (it's shown here on these lines $getsingleproduct= array('iProductId' => 43139553 and $getrelatedproducts = array('iProductId' => 43139553 ) and then use this code, once again, a little bit of css styling, just to make it look nicer
<?
define('API', 'PS');
require_once('constants.inc.php');
require_once('classes/class.ClientFactory.php');
$oClient = ClientFactory::getClient();
$returnedcolumns = array(sAwImageUrl,sDescription,sBrand,iMerchantId, iCategoryId); // the columns to return in both our calls
$getsingleproduct= array('iProductId' => 43139553, "sColumnToReturn" => $returnedcolumns, "bAdult" => true); // the parameters for the single product call
$oGetProduct= $oClient->call('getProduct', $getsingleproduct); // the single product call
$gpsAwImageUrl = $oGetProduct->oProduct->sAwImageUrl;
$gpsName = $oGetProduct->oProduct->sName;
$gpsDescription = $oGetProduct->oProduct->sDescription;
$gpfPrice = $oGetProduct->oProduct->fPrice;
$gpsAwDeepLink = $oGetProduct->oProduct->sAwDeepLink;
$gpsBrand = $oGetProduct->oProduct->sBrand;
$getrelatedproducts = array('iProductId' => 43139553, "sColumnToReturn" => $returnedcolumns, "iLimit"=>20, "bAdult" => true); // the parameters for the related products call
$oResponseRelatedproducts= $oClient->call('getRelatedProducts', $getrelatedproducts); // the related products call
// the single product display
echo '<h2>'.$gpsName.'</h2><div><p>';
echo '<img src="'.$gpsAwImageUrl.'"/ style="float:left; margin:10px;" alt="'.$gpsName.'"/>';
echo $gpsDescription.'<br/><br/><h5>£'.number_format($gpfPrice,2,'.',',').'</h5>'.$gpsBrand.'<br/><br/';
echo '<a href="'.$gpsAwDeepLink.'">Click to see details</a></p></div>';
// the related products display
foreach($oResponseRelatedproducts->oProduct as $details){
$iId = $details->iId;
$iCategoryId = $details->iCategoryId;
$sName = $details->sName;
$sBrand = $details->sBrand;
$sAwThumbUrl = $details->sAwThumbUrl;
$fPrice = $details->fPrice;
echo '<a href="showproduct.php?productID='.$iId.'" title="'.$sName.'"><img src='.$sAwThumbUrl.' style="margin-right:16px; margin-bottom:10px; display:inline;" width="80" height="80" alt="'.$sName.'"></a>';
}
?>
<?
define('API', 'PS');
require_once('constants.inc.php');
require_once('classes/class.ClientFactory.php');
$oClient = ClientFactory::getClient();
$returnedcolumns = array(sAwImageUrl,sDescription,sBrand,iMerchantId, iCategoryId); // the columns to return in both our calls
$getsingleproduct= array('iProductId' => 43139553, "sColumnToReturn" => $returnedcolumns, "bAdult" => true); // the parameters for the single product call
$oGetProduct= $oClient->call('getProduct', $getsingleproduct); // the single product call
$gpsAwImageUrl = $oGetProduct->oProduct->sAwImageUrl;
$gpsName = $oGetProduct->oProduct->sName;
$gpsDescription = $oGetProduct->oProduct->sDescription;
$gpfPrice = $oGetProduct->oProduct->fPrice;
$gpsAwDeepLink = $oGetProduct->oProduct->sAwDeepLink;
$gpsBrand = $oGetProduct->oProduct->sBrand;
$getrelatedproducts = array('iProductId' => 43139553, "sColumnToReturn" => $returnedcolumns, "iLimit"=>20, "bAdult" => true); // the parameters for the related products call
$oResponseRelatedproducts= $oClient->call('getRelatedProducts', $getrelatedproducts); // the related products call
// the single product display
echo '<h2>'.$gpsName.'</h2><div><p>';
echo '<img src="'.$gpsAwImageUrl.'"/ style="float:left; margin:10px;" alt="'.$gpsName.'"/>';
echo $gpsDescription.'<br/><br/><h5>£'.number_format($gpfPrice,2,'.',',').'</h5>'.$gpsBrand.'<br/><br/';
echo '<a href="'.$gpsAwDeepLink.'">Click to see details</a></p></div>';
// the related products display
foreach($oResponseRelatedproducts->oProduct as $details){
$iId = $details->iId;
$iCategoryId = $details->iCategoryId;
$sName = $details->sName;
$sBrand = $details->sBrand;
$sAwThumbUrl = $details->sAwThumbUrl;
$fPrice = $details->fPrice;
echo '<a href="showproduct.php?productID='.$iId.'" title="'.$sName.'"><img src='.$sAwThumbUrl.' style="margin-right:16px; margin-bottom:10px; display:inline;" width="80" height="80" alt="'.$sName.'"></a>';
}
?>