Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon MWS Api SubmitFeed _POST_FLAT_FILE_INVLOADER_DATA_ incorrect template type error

I am working with the Amazon MWS PHP MarketplaceWebService PHP API to submit inventory feed data to Amazon.

https://docs.developer.amazonservices.com/en_US/feeds/Feeds_SubmitFeed.html

I can submit my generated inventory loader flat file manually via the seller central upload inventory gui without errors.

Submitting the same flat file using the SubmitFeed sample from the API I always get an "incorrect template type error".

My authentication and marketplace data are all correct.

Feed data is in $_feed and I am creating the feed datastream from the api with

$feedHandle = fopen('php://temp', 'rw+');
fwrite($feedHandle, $_feed);
rewind($feedHandle);

and submitting it with the example code from Amazon

$marketplaceIdArray = array("Id" => array(MARKETPLACE_ID));


$parameters = array (
  'Merchant' => MERCHANT_ID,
  'MarketplaceIdList' => $marketplaceIdArray,
  'FeedType' => '_POST_FLAT_FILE_INVLOADER_DATA_',
  'FeedContent' => $feedHandle,
  'PurgeAndReplace' => false,
  'ContentMd5' => base64_encode(md5(stream_get_contents($feedHandle), true)),
);

rewind($feedHandle);

$request = new \MarketplaceWebService_Model_SubmitFeedRequest($parameters);

$_result=$this->invokeSubmitFeed($service, $request);

The feed submits without errors, but I always get an incorrect template type error from Amazon when I check the submission status.

If I write the feed data to a seperate file, or take a copy of the stream and write that to a test file e.g.

// TEST copy submitted file to temp file
$copystream = fopen('/copystream.txt', 'w');
stream_copy_to_stream($streamHandle, $copystream);

I can confirm that the data used by the Amazon MWS API curl upload (in client.php) is correct, as I can also manually upload this test file (copystream.txt) via seller central without errors.

This problem is similar to the one posted here https://sellercentral.amazon.com/forums/message.jspa?messageID=2914605 from 2014 which suggests that the flat file headers used when posting via the API are not the same as those used when uploading the flat file via Amazon Seller Central.

I am using the headers from the default sample template from Amazon for the Beauty category:

TemplateType=beauty Version=2016.0324   The top 3 rows are for Amazon.com use only. Do not modify or delete the top 3 rows.                             Offer-Offer Information - These attributes are required to make your item buyable for customers on the site.                                                                    Dimensions-Product Dimensions - These attributes specify the size and weight of a product.                                                      Discovery-Item discovery information - These attributes have an effect on how customers can find your product on the site using browse or search.                           Images-Image Information - See Image Instructions tab for details.                  Fulfillment-Use these columns to provide fulfilment-related information for orders fulfilled either by Amazon (FBA) or by the Seller.   Variation-Variation information - Populate these attributes if your product is available in different variations (for example colour or wattage).               Ungrouped - These attributes create rich product listings for your buyers.                                                      
    Seller SKU  Item Name (aka Title)   Product Type    Product ID  Product ID Type Brand Name  Manufacturer    Manufacturer Part Number    Product Description Update Delete   Standard Price  Quantity    Fulfillment Latency Package Quantity    Number of Items Launch Date Release Date    Is Discontinued by Manufacturer Sale Price  Sale From Date  Sale End Date   Max Order Quantity  Max Aggregate Ship Quantity Can Be Gift Messaged    Is Gift Wrap Available? Product Tax Code    Merchant Shipping Group Item Display Weight Unit Of Measure Display Weight  Item Display Volume Unit Of Measure Display Volume  Display Length  Item Display Length Unit Of Measure Item Weight Unit Of Measure Item Weight Item Length Unit Of Measure Item Length Item Width  Item Height Website Shipping Weight Unit Of Measure Shipping Weight Recommended Browse Nodes    Key Product Features    Key Product Features    Key Product Features    Key Product Features    Key Product Features    Search Terms    Main Image URL  Swatch Image URL    Other Image URL Other Image URL Other Image URL Fulfillment Centre ID   Parentage   Parent SKU  Relationship Type   Variation Theme Ingredients Material Type   Item Form   Is Adult Product    Target Gender   Skin Type   Hair Type   Indications Directions  Size    Colour  Colour Map  Scent   Sun Protection Factor   Medicine Classification
    item_sku    item_name   feed_product_type   external_product_id external_product_id_type    brand_name  manufacturer    part_number product_description update_delete   standard_price  quantity    fulfillment_latency item_package_quantity   number_of_items product_site_launch_date    merchant_release_date   is_discontinued_by_manufacturer sale_price  sale_from_date  sale_end_date   max_order_quantity  max_aggregate_ship_quantity offering_can_be_gift_messaged   offering_can_be_giftwrapped product_tax_code    merchant_shipping_group_name    item_display_weight_unit_of_measure item_display_weight item_display_volume_unit_of_measure item_display_volume item_display_length item_display_length_unit_of_measure item_weight_unit_of_measure item_weight item_length_unit_of_measure item_length item_width  item_height website_shipping_weight_unit_of_measure website_shipping_weight recommended_browse_nodes    bullet_point1   bullet_point2   bullet_point3   bullet_point4   bullet_point5   generic_keywords    main_image_url  swatch_image_url    other_image_url1    other_image_url2    other_image_url3    fulfillment_center_id   parent_child    parent_sku  relationship_type   variation_theme ingredients material_type   item_form   is_adult_product    target_gender   skin_type   hair_type   indications directions  size_name   color_name  color_map   scent_name  sun_protection  medicine_classification
like image 304
paj Avatar asked Sep 02 '16 10:09

paj


1 Answers

According to

http://docs.developer.amazonservices.com/en_US/feeds/Feeds_FeedType.html#FeedType_Enumeration__ProductInventoryFeeds

The template file for feed type _POST_FLAT_FILE_INVLOADER_DATA_ is not the same as the templates available for download by Amazon Seller Central even though the api reports _POST_FLAT_FILE_INVLOADER_DATA_ as the feed type used by a manual seller central inventory file upload. Using one of these templates with _POST_FLAT_FILE_INVLOADER_DATA_ results in template errors returned by the Amazon API.

The solution is to use feed type _POST_FLAT_FILE_LISTINGS_DATA_ which accepts the standard seller central templates.

like image 199
paj Avatar answered Oct 11 '22 22:10

paj