Check lowest price being offered on amazon and then decrease our price based on an increment value we have stored in the oscommerce products table for that item we will have an upper price cieling and lower price floor the lowest and highest the item will sell for. and then the increment amount for example 3 cents the script will run through all the items we have selling on amazon which are also in the oscommerce site and check for the lowest price. It will then change our price on amazon to be $0.0X below that current price
and some code is here
<?php
require('includes/application_top.php');
tep_set_time_limit(0);
//Amazon MWS setup
include_once ('MarketplaceWebServiceOrders/.config.inc.php');
require(DIR_WS_FUNCTIONS.'amazon.php');
$serviceUrl = "http://ift.tt/1nHjodS";
$config = array (
'ServiceURL' => $serviceUrl,
'ProxyHost' => null,
'ProxyPort' => -1,
'ProxyUsername' => null,
'ProxyPassword' => null,
'MaxErrorRetry' => 3,
);
$service = new MarketplaceWebServiceProducts_Client(
AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY,
APPLICATION_NAME,
APPLICATION_VERSION,
$config
);
$request = new marketplaceWebServiceProducts_Model_GetLowestOfferListingsForASINRequest();
$request->setSellerId(MERCHANT_ID);
$asin_list = new MarketplaceWebServiceProducts_Model_ASINListType();
$asin_list->setASIN(array('ASINcode'));
$request->setASINList($asin_list);
$request->setMarketplaceId(MARKETPLACE_ID);
// object or array of parameters
invokeGetLowestOfferListingsForASIN($service, $request);
function invokeGetLowestOfferListingsForASIN(MarketplaceWebServiceProducts_Interface $service, $request)
{
try {
$response = $service->GetLowestOfferListingsForASIN($request);
$dom = new DOMDocument();
$dom->loadXML($response->toXML());
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$xml_data = $dom->saveXML();
$dom->loadXML($xml_data);
$otherOfferXml = simplexml_load_string($xml_data);
foreach($otherOfferXml as $offers)
{
// Skipping last RequestID section
if(!isset($offers["status"]))
continue;
// Checking if the API returned any error then continue to next SKU
if($offers["status"] != "Success")
continue;
$asin = (String) $offers->Product->Identifiers->MarketplaceASIN->ASIN;
// Going through all ASIN's offers to get price
$seller_counter = 0;
$others_response_data[$asin] = "";
foreach($offers->Product->LowestOfferListings->LowestOfferListing as $offers_list)
{
$others_response_data[$asin][$seller_counter]["LandedPrice"] = (String) $offers_list->Price->LandedPrice->Amount;
$others_response_data[$asin][$seller_counter]["ListingPrice"] = (String) $offers_list->Price->ListingPrice->Amount;
$others_response_data[$asin][$seller_counter]["Shipping"] = (String) $offers_list->Price->Shipping->Amount;
$others_response_data[$asin][$seller_counter]["Fulfillment"] = $fulfillment_channel;
$others_response_data[$asin][$seller_counter]["SKU"] = $asin_array[$asin]["sku"];
$others_response_data[$asin][$seller_counter]["AZN_ASIN"] = $asin;
$seller_counter++;
}
}
} catch (MarketplaceWebServiceProducts_Exception $ex) {
echo("Caught Exception: " . $ex->getMessage() . "\n");
echo("Response Status Code: " . $ex->getStatusCode() . "\n");
echo("Error Code: " . $ex->getErrorCode() . "\n");
echo("Error Type: " . $ex->getErrorType() . "\n");
echo("Request ID: " . $ex->getRequestId() . "\n");
echo("XML: " . $ex->getXML() . "\n");
echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
}
}
?>
Aucun commentaire:
Enregistrer un commentaire