【问题标题】:Amazon MWS - Update product quantity亚马逊 MWS - 更新产品数量
【发布时间】:2013-11-27 12:46:31
【问题描述】:

我正在使用 amazon api 使用“_POST_INVENTORY_AVAILABILITY_DATA_”feedtype 来更新产品的数量,例如,

<?xml version="1.0" encoding="utf-8" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>$merchantID</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>$SKU</SKU>
<Quantity>8</Quantity>
</Inventory>
</Message>
</AmazonEnvelope>

<?xml version="1.0"?>
<SubmitFeedResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<SubmitFeedResult>
  <FeedSubmissionInfo>
    <FeedSubmissionId>6791310806</FeedSubmissionId>
    <FeedType>_POST_INVENTORY_AVAILABILITY_DATA_</FeedType>
    <SubmittedDate>2013-03-21T19:48:37+00:00</SubmittedDate>
    <FeedProcessingStatus>_SUBMITTED_</FeedProcessingStatus>
  </FeedSubmissionInfo>
</SubmitFeedResult>
<ResponseMetadata>
  <RequestId>fd07bf18-4f6a-4786-bdf9-9d4db50956d0</RequestId>
</ResponseMetadata>
</SubmitFeedResponse>

但是当我尝试一次更新 15k 或更多产品时,使用 magento 收集数量的产品在几个小时后也没有在亚马逊更新。这是正确的方法还是我需要使用任何其他方法?

谁能帮帮我?

提前致谢。

【问题讨论】:

    标签: php magento amazon-web-services


    【解决方案1】:

    尝试使用 _POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA_ feedtype 并在 https 请求的正文中发送 CSV 文件(制表符分隔)而不是 XML 文件。 csv 的第一行应该是:sku 价格数量(由制表符分隔),然后是包含值的行(由制表符分隔)。

    【讨论】:

    【解决方案2】:

    引用亚马逊 MWS API:

    每个 Feed 的大小限制为 2,147,483,647 字节 (2^31 -1)。如果你 有大量数据要提交,您应该提交较小的提要 通过分解数据超过 Feed 大小限制,或提交 Feed 过了一段时间。一种好的做法是提交带有 30,000 条记录/项目的大小限制或在一段时间内提交提要 时间,例如每隔几个小时。

    【讨论】:

      【解决方案3】:
      $feed = '<?xml version="1.0" encoding="utf-8" ?>
                  <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
                  <Header>
                    <DocumentVersion>1.01</DocumentVersion>
                    <MerchantIdentifier>AG7AH5X9UOHEC</MerchantIdentifier>
                    </Header>
                    <MessageType>Inventory</MessageType>
                   <Message>
                        <MessageID>1</MessageID>
                        <OperationType>Update</OperationType>
                      <Inventory>
                        <SKU>UK-BBD10002</SKU>
                        <Quantity>4</Quantity>
                        <FulfillmentLatency>15</FulfillmentLatency>
                        </Inventory>
                   </Message>
                  <Message>
                        <MessageID>2</MessageID>
                        <OperationType>Update</OperationType>
                          <Inventory>
                            <SKU>UK-BBD10003</SKU>
                            <Quantity>6</Quantity>
                            <FulfillmentLatency>14</FulfillmentLatency>
                        </Inventory>
                    </Message>
                  </AmazonEnvelope>';
      
                  $feedHandle = @fopen('php://temp', 'rw+');
                  fwrite($feedHandle, $feed);
                  rewind($feedHandle);
      
                  $param['AWSAccessKeyId']   = Configure::read('AWS_ACCESS_KEY'); 
                  $param['Action']           = 'SubmitFeed'; 
                  $param['SellerId']         = Configure::read('SELLER_ID'); 
                  $param['SignatureMethod']  = Configure::read('SIGNATURE_METHOD');  
                  $param['SignatureVersion'] = Configure::read('SIGNATURE_VERSION'); 
                  $param['Timestamp']        = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
                  $param['Version']          = '2009-01-01'; 
                  $param['FeedType']         = $FeedType;              
                  $param['FeedContent']      = stream_get_contents($feedHandle);
                  $param['ContentMd5']       = base64_encode(md5(stream_get_contents($feedHandle), true));    
      
                  $param['MarketplaceIdList.Id.1'] =  $MARKETPLACE_ID; //FR
                  //$param['MarketplaceIdList.Id.2'] =  'A1F83G8C2ARO7P'; //GB
      
      
                  ksort($param);
                  $MARKETPLACE_URL = 'mws.amazonservices.co.uk';  
                  $secret = Configure::read('SECRET_KEY');
      
                  $url = array();
                  foreach ($param as $key => $val) {
      
                      $key = str_replace("%7E", "~", rawurlencode($key));
                      $val = str_replace("%7E", "~", rawurlencode($val));
                      $url[] = "{$key}={$val}";
                  }
      
                  ksort($url);
      
                  $arr   = implode('&', $url);
      
                  $sign  = 'GET' . "\n";
                  $sign .= ''.$MARKETPLACE_URL.'' . "\n";
                  $sign .= '/Feeds/2009-01-01' . "\n";
                  $sign .= $arr;
      
                  $signature = hash_hmac("sha256", $sign, $secret, true);
                  $signature = urlencode(base64_encode($signature));
      
                  $link  = "https://".$MARKETPLACE_URL."/Feeds/2009-01-01?";
                  $link .= $arr . "&Signature=" . $signature;
      
                  $httpHeader = array();
                  $httpHeader[] = 'Content-Type: application/xml';
                  $httpHeader[] = 'Content-MD5: ' .  base64_encode(md5(stream_get_contents($feedHandle), true));
                  $httpHeader[] = 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'];
                  $httpHeader[] = 'Host: ' . $MARKETPLACE_URL;
                  ksort($httpHeader);
      
      
                  $ch = curl_init($link);
                  curl_setopt($ch, CURLOPT_HEADER, 1);
                  curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);      
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                     
                  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
                  $response = curl_exec($ch);
                  $info = curl_getinfo($ch);
                  curl_close($ch);
                  @fclose($feedHandle);
                  print_r($response);
                  exit;
      

      【讨论】:

        猜你喜欢
        • 2012-07-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-02
        • 1970-01-01
        • 1970-01-01
        • 2018-06-04
        • 1970-01-01
        相关资源
        最近更新 更多