Validation
Installation
$ composer require highsidelabs/amazon-feed-validatorValidators
JSON Schema Validator
use SellingPartnerApi\FeedTransformer\Transformer;
use SellingPartnerApi\FeedTransformer\FeedTypes\Product;
use SellingPartnerApi\FeedValidator\JsonSchemaValidator;
use SellingPartnerApi\SellingPartnerApi;
$feedPath = 'path/to/POST_PRODUCT_DATA.xml';
$marketplaceId = 'ATVPDKIKX0DER'; // US Selling Partner API marketplace ID
$json = Transformer::fromFile(
Product::$feedType,
$feedPath,
$marketplaceId,
[ /* options */ ]
);
// The JsonSchemaValidator needs your Selling Partner API credentials to retrieve the
// JSON Schema document from Amazon on your behalf
$sellerConnector = SellingPartnerApi::seller(
clientId: 'amzn1.application-oa2-client.asdfqwertyuiop...',
clientSecret: 'amzn1.oa2-cs.v1.1234567890asdfghjkl...',
refreshToken: 'Atzr|IwEBIA...',
endpoint: Endpoint::NA, // Or Endpoint::EU, Endpoint::FE, Endpoint::NA_SANDBOX, etc.
);
$jsonValidator = new JsonSchemaValidator($sellerConnector, $marketplaceId);
$validationErrors = $jsonValidator->validate(Product::$feedType, $json);
if ($validationErrors === []) {
// Write the converted data out to a file to be sent to Amazon
$jsonFeedPath = 'path/to/new/feed.json';
file_put_contents($jsonFeedPath, json_encode($json));
} else {
// Handle the validation errors
}Amazon Validator
Fixing validation errors
Xpaths in validation error messages
Last updated