I am using the following SDK to work with the SP API.
I am trying to upload inventory (stock) data. I believe it's done using the JSON you see me sending . When triggering this, I get back a document ID etc, which I think you then use to look up the status of that uploaded data.
Note: I have checked Amazon directly too (seller central), to check for stock changes and nothing is changing.
However, I am unclear how you continue to use this SDK to look up the status and see whether what I uploaded was successful etc.
Note: If anyone is aware of how to upload stock data without using the SDK and an easier means, happy to try anything!
*The JSON payload I am sending was suggested to me by someone else. It's unclear if I need to be sending parts like the attributes
and productType
. I suspect once I can look up the status of what I uploaded, maybe it'll tell me what I am missing or incorrect etc.
use SellingPartnerApi\SellingPartnerApi;
use SellingPartnerApi\Enums\Endpoint;
use SellingPartnerApi\Seller\FeedsV20210630\Dto\CreateFeedDocumentSpecification;
use SellingPartnerApi\Seller\FeedsV20210630\Dto\CreateFeedSpecification;
use SellingPartnerApi\Seller\FeedsV20210630\Responses\CreateFeedDocumentResponse;
public function send_stock_to_amazon( $data ) {
$connector = SellingPartnerApi::seller(
clientId: defined('LWA_CLIENT_ID') ? LWA_CLIENT_ID : '',
clientSecret: defined('LWA_CLIENT_SECRET') ? LWA_CLIENT_SECRET : '',
refreshToken: defined('LWA_REFRESH_TOKEN') ? LWA_REFRESH_TOKEN : '',
endpoint: Endpoint::EU, // Or Endpoint::EU, Endpoint::FE, Endpoint::NA_SANDBOX, etc.
);
$feedType = 'JSON_LISTINGS_FEED';
$feedsApi = $connector->feedsV20210630();
// Create feed document
$contentType = CreateFeedDocumentResponse::getContentType($feedType);
$createFeedDoc = new CreateFeedDocumentSpecification($contentType);
$createDocumentResponse = $feedsApi->createFeedDocument($createFeedDoc);
$feedDocument = $createDocumentResponse->dto();
$feedContents = json_encode([
"header" => [
"sellerId" => "XXXXXXXXXX",
"version" => "2.0",
"issueLocale" => "en_US"
],
"messages" => [
[
"messageId" => 1,
"sku" => "592932GE",
"operationType" => "PARTIAL_UPDATE",
"productType" => "BATTERY",
"attributes" => [
"fulfillment_availability" => [
[
"fulfillment_channel_code" => "DEFAULT",
"quantity" => 2,
"lead_time_to_ship_max_days" => "5"
]
]
]
]
]
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
try {
$feedDocument->upload($feedType, $feedContents);
}
catch (\Exception $e) {
echo "Error: " . $e->getResponse()->getBody()->getContents();
}
// Check if the feed document has been processed.
$createFeedSpecification = new CreateFeedSpecification(
marketplaceIds: ['XXXXXXXXX'],
inputFeedDocumentId: $feedDocument->feedDocumentId,
feedType: $feedType,
);
// TODO - Check feed status.
}
The result of: $feedDocument->upload($feedType, $feedContents);
is like so:
feedDocumentId: "amzn1.tortuga.4.eu.b546cc55-b6d1-459d-8469-05e6fdefea9a.T35xxxxx"
url: "https://tortuga-prod-eu.s3-eu-west-1.amazonaws.com/b546cc55-b6d1-459d-8469-05e6fdefea9a.amzn1.tortuga.4.eu.T351S9........."
*I have redacted some parts above with xxxx
for security.