Beispiel #1
0
 /**
  * 抓取订单产品详细
  * @param number $OrderId 
  * @return array
  * @author czq
  */
 public function getOrderDetailLists($OrderId)
 {
     $service = new MarketplaceWebServiceOrders_Client(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, APPLICATION_NAME, APPLICATION_VERSION, $this->config);
     $request = new MarketplaceWebServiceOrders_Model_ListOrderItemsRequest();
     $request->setSellerId(MERCHANT_ID);
     $request->setAmazonOrderId($OrderId);
     $response = $service->listOrderItems($request);
     $listOrderItemsResult = $response->getListOrderItemsResult();
     $all_response = array();
     $all_response[] = $listOrderItemsResult;
     while ($listOrderItemsResult->isSetNextToken()) {
         $request = new MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenRequest();
         $request->setSellerId(MERCHANT_ID);
         $request->setNextToken($listOrderItemsResult->getNextToken());
         $response = $service->ListOrdersByNextToken($request);
         $listOrderItemsResult = $response->getListOrderItemsByNextTokenResult();
         $all_response[] = $listOrderItemsResult;
         //最大的请求权限为30个,每30个就sleep 60秒恢复
         if ($this->_requestTimes % 30 == 0) {
             sleep(60);
             $this->_requestTimes = 0;
         }
         $this->_requestTimes++;
     }
     return $all_response;
 }
Beispiel #2
0
 public function __construct($config)
 {
     $this->config = $config;
     $configFeed = $config;
     $configFeed['ServiceURL'] = "https://mws.amazonservices.es";
     $this->feedClient = \Ofertix\Mws\MwsClientFactory::getClient($configFeed);
     parent::__construct($config['aws_access_id'], $config['aws_access_secret'], $config['app_name'], $config['app_version'], array('ServiceURL' => "https://mws-eu.amazonservices.com/Orders/2013-09-01"));
 }
Beispiel #3
0
$listOrder = Mage::getBaseDir('lib') . DS . 'mws' . DS . 'src' . DS . 'MarketplaceWebServiceOrders' . DS . 'Model' . DS . 'ListOrdersRequest.php';
require_once $listOrder;
$clientFile = Mage::getBaseDir('lib') . DS . 'mws' . DS . 'src' . DS . 'MarketplaceWebServiceOrders' . DS . 'Client.php';
require_once $clientFile;
define('AWS_ACCESS_KEY_ID', Mage::getStoreConfig('paywithamazon/general/access_key'));
define('AWS_SECRET_ACCESS_KEY', Mage::getStoreConfig('paywithamazon/general/secret_key'));
define('APPLICATION_NAME', 'Order Gen');
define('APPLICATION_VERSION', 'v1.0');
define('MERCHANT_ID', Mage::getStoreConfig('paywithamazon/general/merchant_id'));
if (Mage::getStoreConfig('paywithamazon/general/sandbox_mode') == 1) {
    define('MARKETPLACE_ID', 'AXGTNDD750VEM');
} else {
    define('MARKETPLACE_ID', 'A3PY9OQTG31F3H');
}
$config = array('ServiceURL' => "https://mws.amazonservices.in/Orders/2013-09-01", 'ProxyHost' => null, 'ProxyPort' => -1, 'ProxyUsername' => null, 'ProxyPassword' => null, 'MaxErrorRetry' => 3);
$service = new MarketplaceWebServiceOrders_Client(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, APPLICATION_NAME, APPLICATION_VERSION, $config);
$LAST_PROCESSING = Mage::getStoreConfig('paywithamazon/general/last_reshipment_date');
if ($LAST_PROCESSING == '') {
    $days_ago = date('Y-m-d H:i:s', strtotime('-7 days', strtotime(date('Y-m-d H:i:s'))));
    Mage::getConfig()->saveConfig('paywithamazon/general/last_reshipment_date', $days_ago)->cleanCache();
    $LAST_PROCESSING = Mage::getStoreConfig('paywithamazon/general/last_reshipment_date');
}
$date = date('Y-m-d', strtotime($LAST_PROCESSING)) . 'T' . date('H:i:s', strtotime($LAST_PROCESSING)) . 'Z';
$request = new MarketplaceWebServiceOrders_Model_ListOrdersRequest();
$request->setSellerId(MERCHANT_ID);
$request->setLastUpdatedAfter($date);
$request->setMarketplaceId(MARKETPLACE_ID);
$request->setOrderStatus(array('0' => 'Unshipped', '1' => 'PartiallyShipped'));
try {
    $response = $service->ListOrders($request);
    $dom = new DOMDocument();