参考资料
feedType : https://github.com/amzn/selling-partner-api-docs/blob/main/references/feeds-api/feedtype-values.md
使用方法:https://developer-docs.amazon.com/sp-api/docs/feeds-api-v2021-06-30-reference
例:修改Price
1. 先创建 feedDocument
$params = array(
'contentType' => 'text/xml; charset=UTF-8',
);
$method = 'POST';
$path = '/feeds/2021-06-30/documents';
// 请求成功时,会返回:
$feedDocumentId;
$url;
2.上传 xml 文件内容
// XML
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">';
$xml .= '<Header>';
$xml .= '<DocumentVersion>1.01</DocumentVersion>';
$xml .= '<MerchantIdentifier>' . $merchant_id . '</MerchantIdentifier>';
$xml .= '</Header>';
$xml .= '<MessageType>Price</MessageType>';
$xml .= '<Message>';
$xml .= '<MessageID>1</MessageID>';
$xml .= '<Price>';
// SELLER SKU
$xml .= '<SKU>' . $amazon_seller_sku . '</SKU>';
// 售价
$xml .= '<StandardPrice currency="' . $currencyCode . '">1</StandardPrice>';
// 折扣价
$xml .= '<Sale>';
$xml .= '<StartDate>' . '2020-02-02T00:00:00Z' . '</StartDate>';
$xml .= '<EndDate>' . '2020-02-02T00:00:00Z' . '</EndDate>';
$xml .= '<SalePrice currency="' . $currencyCode . '">1</SalePrice>';
$xml .= '</Sale>';
$xml .= '</Price>';
$xml .= '</Message>';
// 同时修改多个时
$xml .= '<Message>';
$xml .= '<MessageID>2</MessageID>';
$xml .= '<Price>';
// SELLER SKU
$xml .= '<SKU>' . $listing['amazon_seller_sku'] . '</SKU>';
// 售价
$xml .= '<StandardPrice currency="' . $currencyCode . '">1</StandardPrice>';
// 折扣价
$xml .= '<Sale>';
$xml .= '<StartDate>' . '2020-02-02T00:00:00Z' . '</StartDate>';
$xml .= '<EndDate>' . '2020-02-02T00:00:00Z' . '</EndDate>';
$xml .= '<SalePrice currency="' . $currencyCode . '">1</SalePrice>';
$xml .= '</Sale>';
$xml .= '</Price>';
$xml .= '</Message>';
$xml .= '</AmazonEnvelope>';
$config = array(
'base_uri' => $url,
'headers' => array(
'Content-Type' => 'text/xml; charset=UTF-8'
),
'body' => $xml,
'http_errors' => false,
'verify' => false,
'timeout' => 1800
);
$client = new GuzzleHttp\Client($config);
$request = $client->request("PUT");
$body = $request->getBody()->getContents();
$httpCode = $request->getStatusCode();
'ack' => ($httpCode == 200) ? SUCCESS : FAILURE,
3.创建Feed
$params = array(
'feedType' => 'POST_PRODUCT_PRICING_DATA',
'marketplaceIds' => array($marketplace_id), // 市场ID
'inputFeedDocumentId' => $feedDocumentId
);
$method = 'POST';
$path = '/feeds/2021-06-30/feeds';