Exeu/Amazon-ECS-PHP-Library — Issue #23: Question about Price
Author: adslgeek
Created: 2011-11-26 09:07:02+00:00
State: open

Hey there,

This is a deceptively simple question - I have been trying to add the price, and have attempted that by changing my display function by adding:

//if there is a price show it
if (isset($result['Medium']['Amount'] )) {
echo "". $result['Medium']['Amount']."";
}

This is my copy of the function - any ideas what I am missing?

'''	private function getAmazonModule() {

if($this->prod['name'] !="") {
//find what we are searching for - could also come from a GET if you wanted.
$search = $this->man['name']." ".$this->prod['name'];
$category = "PCHardware";

//Amazon account settings
define('AWS_API_KEY', 'AKIAILR632MKQJ6MTCWA');
define('AWS_API_SECRET_KEY', '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');
define('AWS_ASSOCIATE_ID', 'wholesdirect-20');

require 'amazonecs.class.php';

//declare the amazon ECS class
$amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'co.uk', AWS_ASSOCIATE_ID);

//tell the amazon class that we want an array, not an object
$amazonEcs->setReturnType(AmazonECS::RETURN_TYPE_ARRAY);

//create the amazon object (array)
$response = $amazonEcs->category($category)->responseGroup('Medium,Images,Offers')->search($search);

//check that there are items in the response
if (isset($response['Items']['Item']) ) {

//loop through each item
foreach ($response['Items']['Item'] as $result) {

//check that there is a ASIN code - for some reason, some items are not
//correctly listed. Im sure there is a reason for it, need to check.
if (isset($result['ASIN'])) {

//store the ASIN code in case we need it
$asin = $result['ASIN'];

//check that there is a URL. If not - no need to bother showing
//this one as we only want linkable items
if (isset($result['DetailPageURL'])) {

//set up a container for the details - this could be a DIV
echo '

';

//create the URL link
echo '';

// if there is a title - show it
if (isset($result['ItemAttributes']['Title'])) {
echo $result['ItemAttributes']['Title'] . "
";
}
//if there is a small image - show it (Alternatively could be simplified to	)
if (isset($result['SmallImage']['URL'] )) {
echo "";
}
//if there is a price show it
if (isset($result['Medium']['Amount'] )) {
echo "". $result['Medium']['Amount']."";
}

//close the table etc
echo "

";
}
}
}
}
}
}