Amazon SP API 拉取产品详情和修改产品属性
2023-08-31 18:37 天心PHP 阅读(937) 评论(1) 编辑 收藏 举报
1.获取产品详情 getListingsItem
View Code
View Code
View Code
GET /listings/2021-08-01/items/{sellerId}/{sku}
$result = $requestReport->applicationreport($account->merchant_id,strtolower($account->site),'/listings/2021-08-01/items/'.$account->merchant_id.'/'.$sku.'?marketplaceIds='.$account->market_place_id.'&includedData=summaries,attributes,issues,offers,fulfillmentAvailability,procurement',['marketplaceIds'=>$account->market_place_id],"",'GET');
得到结果:
Array ( [sku] => 10USKST-230718FBA [summaries] => Array ( [0] => Array ( [marketplaceId] => ATVPDKIKX0DER [asin] => B0CC62RGB8 [productType] => POWER_CONVERTER [conditionType] => new_new [status] => Array ( [0] => BUYABLE [1] => DISCOVERABLE ) [itemName] => DC Voltage Regulator, 36V 48V 60V to 12V 3A DC-DC Step-Down Converter Buck Power Supply Module Voltage Regulator for Car Auto Vehicle Motor [createdDate] => 2023-07-18T11:32:06.849Z [lastUpdatedDate] => 2023-07-18T11:32:12.251Z [mainImage] => Array ( [link] => https://m.media-amazon.com/images/I/31XVMGrcmwL.jpg [height] => 500 [width] => 500 ) ) ) [attributes] => Array ( [purchasable_offer] => Array ( [0] => Array ( [currency] => USD [our_price] => Array ( [0] => Array ( [schedule] => Array ( [0] => Array ( [value_with_tax] => 12.99 ) ) ) ) [marketplace_id] => ATVPDKIKX0DER ) ) [cpsia_cautionary_statement] => Array ( [0] => Array ( [value] => no_warning_applicable [marketplace_id] => ATVPDKIKX0DER ) ) [country_of_origin] => Array ( [0] => Array ( [value] => CN [marketplace_id] => ATVPDKIKX0DER ) ) [merchant_shipping_group] => Array ( [0] => Array ( [value] => legacy-template-id [marketplace_id] => ATVPDKIKX0DER ) ) [item_name] => Array ( [0] => Array ( [language_tag] => en_US [value] => DC Voltage Regulator, 36V 48V 60V to 12V 3A DC-DC Step-down Converter Buck Power Supply Module Voltage Regulator for Car Auto Vehicle Motor [marketplace_id] => ATVPDKIKX0DER ) ) [fulfillment_availability] => Array ( [0] => Array ( [fulfillment_channel_code] => DEFAULT [quantity] => 999 [marketplace_id] => ATVPDKIKX0DER ) ) [list_price] => Array ( [0] => Array ( [currency] => USD [value] => 12.99 [marketplace_id] => ATVPDKIKX0DER ) ) [manufacturer] => Array ( [0] => Array ( [language_tag] => en_US [value] => KSTEE [marketplace_id] => ATVPDKIKX0DER ) ) [item_type_keyword] => Array ( [0] => Array ( [value] => power-converters [marketplace_id] => ATVPDKIKX0DER ) ) [condition_type] => Array ( [0] => Array ( [value] => new_new [marketplace_id] => ATVPDKIKX0DER ) ) [number_of_items] => Array ( [0] => Array ( [value] => 1 [marketplace_id] => ATVPDKIKX0DER ) ) [bullet_point] => Array ( [0] => Array ( [language_tag] => en_US [value] => High quality DC-DC reverse converter: Ensures reliable and efficient conversion of DC voltage, providing a stable power supply for your devices. [marketplace_id] => ATVPDKIKX0DER ) ) [warranty_description] => Array ( [0] => Array ( [language_tag] => en_US [value] => / [marketplace_id] => ATVPDKIKX0DER ) ) [product_description] => Array ( [0] => Array ( [language_tag] => en_US [value] => Easy to use: connect the input cable to the power supply, and the output wire to the using device. The wiring diagram is posted on the back of the buck converter. Please do not open, and do not reverse the input and output connectors until the circuit and connections are complete. Two input wires = red wire (positive) + black wire (negative). Two output wires = yellow wire (positive) + black wire (negative). Specifications: Material: aluminum alloy + PC circuit board Input voltage range: 24/36/48V (20-60V) Output voltage: 12V Output current: 3A Output power: maximum 36W Conversion efficiency: more than 90% Static energy consumption: less than 10mA No-load adjustment rate: 1% Load adjustment rate: 5% Working temperature: -25℃-80℃ Power cord length: about 13cm Protection class: IP68 Product size: 58*25*21mm Product weight: 40g Wiring mode: input red wire +, black wire - output yellow wire +, black wire - Notes: Due to the different monitor and light effect, the actual color of the item might be slightly different from the color showed on the pictures. Please allow 1-3mm measuring deviation due to manual measurement. Thank you for your understanding! Packing List: 1 x Power module [marketplace_id] => ATVPDKIKX0DER ) ) [brand] => Array ( [0] => Array ( [language_tag] => en_US [value] => KSTEE [marketplace_id] => ATVPDKIKX0DER ) ) [supplier_declared_dg_hz_regulation] => Array ( [0] => Array ( [value] => not_applicable [marketplace_id] => ATVPDKIKX0DER ) ) [supplier_declared_has_product_identifier_exemption] => Array ( [0] => Array ( [value] => 1 [marketplace_id] => ATVPDKIKX0DER ) ) [main_product_image_locator] => Array ( [0] => Array ( [media_location] => https://m.media-amazon.com/images/I/516nLkkIR9L.jpg [marketplace_id] => ATVPDKIKX0DER ) ) [other_product_image_locator_1] => Array ( [0] => Array ( [media_location] => https://m.media-amazon.com/images/I/61MlybelXTL.jpg [marketplace_id] => ATVPDKIKX0DER ) ) [other_product_image_locator_2] => Array ( [0] => Array ( [media_location] => https://m.media-amazon.com/images/I/71CIOmquX2L.jpg [marketplace_id] => ATVPDKIKX0DER ) ) [other_product_image_locator_3] => Array ( [0] => Array ( [media_location] => https://m.media-amazon.com/images/I/71DJ81pt6pL.jpg [marketplace_id] => ATVPDKIKX0DER ) ) [other_product_image_locator_4] => Array ( [0] => Array ( [media_location] => https://m.media-amazon.com/images/I/713zp2sR3SL.jpg [marketplace_id] => ATVPDKIKX0DER ) ) [other_product_image_locator_5] => Array ( [0] => Array ( [media_location] => https://m.media-amazon.com/images/I/71awuIxXDAL.jpg [marketplace_id] => ATVPDKIKX0DER ) ) [other_product_image_locator_6] => Array ( [0] => Array ( [media_location] => https://m.media-amazon.com/images/I/713+tWrmibL.jpg [marketplace_id] => ATVPDKIKX0DER ) ) [other_product_image_locator_7] => Array ( [0] => Array ( [media_location] => https://m.media-amazon.com/images/I/71DJ81pt6pL.jpg [marketplace_id] => ATVPDKIKX0DER ) ) ) [issues] => Array ( ) [offers] => Array ( [0] => Array ( [marketplaceId] => ATVPDKIKX0DER [offerType] => B2C [price] => Array ( [currency] => USD [currencyCode] => USD [amount] => 12.99 ) ) [1] => Array ( [marketplaceId] => ATVPDKIKX0DER [offerType] => B2B [price] => Array ( [currency] => USD [currencyCode] => USD [amount] => 12.59 ) ) ) [fulfillmentAvailability] => Array ( [0] => Array ( [fulfillmentChannelCode] => DEFAULT [quantity] => 999 ) ) [procurement] => Array ( ) )
2.获取ProductTpye目录 searchDefinitionsProductTypes GET /definitions/2020-09-01/productTypes
文档地址:https://developer-docs.amazon.com/sp-api/docs/product-type-definitions-api-v2020-09-01-reference
$result = $requestReport->applicationreport($account->merchant_id,strtolower($account->site),'/definitions/2020-09-01/productTypes?marketplaceIds='.$account->market_place_id,['marketplaceIds'=>$account->market_place_id],"",'GET');
结果:
Array ( [productTypes] => Array ( [0] => Array ( [name] => 3D_PRINTER [marketplaceIds] => Array ( [0] => ATVPDKIKX0DER ) ) [1] => Array ( [name] => ABDOMINAL_EXERCISER [marketplaceIds] => Array ( [0] => ATVPDKIKX0DER ) ) ... ) )
3.获取 获取ProductTpye详细目录 getDefinitionsProductType GET /definitions/2020-09-01/productTypes/{productType}
$producttpye 来自第二部的获取数据 里面的 name
$result = $requestReport->applicationreport($account->merchant_id,strtolower($account->site),'/definitions/2020-09-01/productTypes/'.$producttpye.'?marketplaceIds='.$account->market_place_id,['marketplaceIds'=>$account->market_place_id],"",'GET');
结果:
Array ( [metaSchema] => Array ( [link] => Array ( [resource] => https://selling-partner-definitions-prod-iad.s3.amazonaws.com/schema/amazon-product-type-definition-meta-schema-v1.json/rZ%252F2Yep0np022S38ZdEiNQ%253D%253D?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEAkaCXVzLWVhc3QtMSJHMEUCIAwVmYVqeDKwmiHvctEfIbvkWfQFDGvnHmabcIGXxbcMAiEA5n0Zmmsg%2Fub1do6p1KJrFjKs5aTumhRCXuV9cpEI8Ecq0gQI0v%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARADGgw1MzU3ODk4MjM4MDgiDJ5%2BUiBVWnHGEq7xAiqmBGqMKfFEPGKgokcoKnDlEJ2VT1xzEdcTRkF5ottwl7rxuiy%2BsEVWX0e%2FDpIQNgFtfyPA3PbT7IXWeMxCm1lCRrUmXt3Q6jELGGSLFbw1wSnvkNFyI8MT0EM7tN1wK4%2FbwvU387d526TVYma4qneYu2X2k1iOaim3QllidoSLOu%2BW8rW8LiPzc7NYXVH3FVSnbNO35vAThysL0XXhmWngCQRlzwux%2Fpau2niCS1U0hG6AjFfh7YWuREs0OId6sp6RGj3VuCnaDUa3xxEmfp7KxSZzbUv9%2FOLFfCCY0lItH32aip%2BeqnNkg6gFJiGqrndgjPIddnYH9bHZLSiw5Eeh%2Bt0S%2BkphBTnqTd4WS0CZmK3pARbkn%2FNSTSDRH0pf4KNJ7uxhMlSK191YJurSawQsMrVv7jIIc9mnTmpT19%2Fc5v7DlInUUVdqIEv58YorkiRZGeijQTlGExabiFEf49Xd2z7atRmmpsnmD4zVy1sfTL%2FfG75NEWCKLW%2BeFmZaDtack398U0DMWOWrP%2BPuXh3Fa3OHgtwGxhC4kXAhz2vpiNE8n%2Ba1%2BmEpB956qzG%2BkIx%2FnDdh9FFX79bUnU2vIOmww5e8Quw6xMvj3eUQJGkyMFjYYvbJdXTp4OsblmFQqNt9pUHGLOdAdwt196%2B%2BdJmVlF6QxLKK%2F298v23hIzzT1PRe5fqfdVe51STegjXXKFWiBWQarVnNqzL6QM16gqwelLuEipd8Pcow%2BJvBpwY6pwFJk33urpnk1quw02YMqrua84cc%2F0btLT3LNVe7SjDrcuGdg%2FZo1cOtTwVN%2FnJOHmwNBg0F3lt5OStNpMYLXTPrHfDp%2FIczP3pHqIKUfXvi7K87zJnIb9gP9Hv9csgwlNLIFjAA1NSrbvqWm4Q08E4QJqXha%2BZa0WH7VvDnUrN%2FouiwPOX1e%2FuHjs1JQRHmBd%2B9LkAnw5gJoNreUn2kJWRPWACs1d5rUA%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230831T102310Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=ASIAXZP4P45ALKFW4ZU7%2F20230831%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=e92fd0d464341dae4857e99460b5dda02e19bca06ebb560d0f15a12eaef9c696 [verb] => GET ) [checksum] => rZ/2Yep0np022S38ZdEiNQ== ) [schema] => Array ( [link] => Array ( [resource] => https://selling-partner-definitions-prod-iad.s3.amazonaws.com/schema/POWER_CONVERTER.json/PdCwEwMlTmRAw1Si3vXZkg%253D%253D?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEAkaCXVzLWVhc3QtMSJHMEUCIAwVmYVqeDKwmiHvctEfIbvkWfQFDGvnHmabcIGXxbcMAiEA5n0Zmmsg%2Fub1do6p1KJrFjKs5aTumhRCXuV9cpEI8Ecq0gQI0v%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARADGgw1MzU3ODk4MjM4MDgiDJ5%2BUiBVWnHGEq7xAiqmBGqMKfFEPGKgokcoKnDlEJ2VT1xzEdcTRkF5ottwl7rxuiy%2BsEVWX0e%2FDpIQNgFtfyPA3PbT7IXWeMxCm1lCRrUmXt3Q6jELGGSLFbw1wSnvkNFyI8MT0EM7tN1wK4%2FbwvU387d526TVYma4qneYu2X2k1iOaim3QllidoSLOu%2BW8rW8LiPzc7NYXVH3FVSnbNO35vAThysL0XXhmWngCQRlzwux%2Fpau2niCS1U0hG6AjFfh7YWuREs0OId6sp6RGj3VuCnaDUa3xxEmfp7KxSZzbUv9%2FOLFfCCY0lItH32aip%2BeqnNkg6gFJiGqrndgjPIddnYH9bHZLSiw5Eeh%2Bt0S%2BkphBTnqTd4WS0CZmK3pARbkn%2FNSTSDRH0pf4KNJ7uxhMlSK191YJurSawQsMrVv7jIIc9mnTmpT19%2Fc5v7DlInUUVdqIEv58YorkiRZGeijQTlGExabiFEf49Xd2z7atRmmpsnmD4zVy1sfTL%2FfG75NEWCKLW%2BeFmZaDtack398U0DMWOWrP%2BPuXh3Fa3OHgtwGxhC4kXAhz2vpiNE8n%2Ba1%2BmEpB956qzG%2BkIx%2FnDdh9FFX79bUnU2vIOmww5e8Quw6xMvj3eUQJGkyMFjYYvbJdXTp4OsblmFQqNt9pUHGLOdAdwt196%2B%2BdJmVlF6QxLKK%2F298v23hIzzT1PRe5fqfdVe51STegjXXKFWiBWQarVnNqzL6QM16gqwelLuEipd8Pcow%2BJvBpwY6pwFJk33urpnk1quw02YMqrua84cc%2F0btLT3LNVe7SjDrcuGdg%2FZo1cOtTwVN%2FnJOHmwNBg0F3lt5OStNpMYLXTPrHfDp%2FIczP3pHqIKUfXvi7K87zJnIb9gP9Hv9csgwlNLIFjAA1NSrbvqWm4Q08E4QJqXha%2BZa0WH7VvDnUrN%2FouiwPOX1e%2FuHjs1JQRHmBd%2B9LkAnw5gJoNreUn2kJWRPWACs1d5rUA%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230831T102310Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=ASIAXZP4P45ALKFW4ZU7%2F20230831%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=dcda73448cd8cea32c004d6a831d2043ce81419b1c4408b6c9d3838d1eae5fd2 [verb] => GET ) [checksum] => PdCwEwMlTmRAw1Si3vXZkg== ) [requirements] => LISTING [requirementsEnforced] => ENFORCED [propertyGroups] => Array ( [offer] => Array ( [title] => Offer [description] => Product Offer [propertyNames] => Array ( [0] => skip_offer [1] => fulfillment_availability [2] => map_policy [3] => purchasable_offer [4] => condition_type [5] => condition_note [6] => list_price [7] => product_tax_code [8] => merchant_release_date [9] => merchant_shipping_group [10] => max_order_quantity [11] => gift_options [12] => main_offer_image_locator [13] => other_offer_image_locator_1 [14] => other_offer_image_locator_2 [15] => other_offer_image_locator_3 [16] => other_offer_image_locator_4 [17] => other_offer_image_locator_5 ) ) [images] => Array ( [title] => Images [description] => Provide media content, such as product images [propertyNames] => Array ( [0] => main_product_image_locator [1] => other_product_image_locator_1 [2] => other_product_image_locator_2 [3] => other_product_image_locator_3 [4] => other_product_image_locator_4 [5] => other_product_image_locator_5 [6] => other_product_image_locator_6 [7] => other_product_image_locator_7 [8] => other_product_image_locator_8 [9] => swatch_product_image_locator ) ) [shipping] => Array ( [title] => Shipping [description] => Information to determine shipping and storage of your product (e.g., package dimensions, weight, volume) [propertyNames] => Array ( [0] => item_dimensions [1] => item_package_dimensions [2] => item_package_weight ) ) [variations] => Array ( [title] => Variations [description] => Variations that product will use [propertyNames] => Array ( [0] => parentage_level [1] => child_parent_sku_relationship [2] => variation_theme ) ) [safety_and_compliance] => Array ( [title] => Safety & Compliance [description] => Information to indicate product compliance, hazardous materials, and legal and safety warnings (e.g., lithium batteries, choking hazards, Consumer Product Safety Information Act (CPSIA)) [propertyNames] => Array ( [0] => country_of_origin [1] => warranty_description [2] => batteries_required [3] => batteries_included [4] => battery [5] => num_batteries [6] => number_of_lithium_metal_cells [7] => number_of_lithium_ion_cells [8] => lithium_battery [9] => supplier_declared_dg_hz_regulation [10] => ghs [11] => hazmat [12] => safety_data_sheet_url [13] => item_weight [14] => required_product_compliance_certificate [15] => legal_compliance_certifications [16] => california_proposition_65 [17] => cpsia_cautionary_statement [18] => includes_rechargable_battery [19] => pesticide_marking [20] => fcc_radio_frequency_emission_compliance [21] => regulatory_compliance_certification ) ) [product_identity] => Array ( [title] => Product Identity [description] => Information to uniquely identify your product (e.g., UPC, EAN, GTIN, Product Type, Brand) [propertyNames] => Array ( [0] => item_name [1] => brand [2] => externally_assigned_product_identifier [3] => merchant_suggested_asin [4] => supplier_declared_has_product_identifier_exemption [5] => item_type_keyword [6] => model_number [7] => manufacturer ) ) [product_details] => Array ( [title] => Product Details [description] => Information and characteristics to describe the product to support search, browse and detail page content (e.g., bullets, product features, model, style name) [propertyNames] => Array ( [0] => handmade_classification [1] => product_description [2] => bullet_point [3] => generic_keyword [4] => style [5] => number_of_items [6] => item_package_quantity [7] => color [8] => part_number [9] => input_voltage [10] => product_site_launch_date [11] => output_voltage [12] => plug [13] => control_method ) ) ) [locale] => en_US [marketplaceIds] => Array ( [0] => ATVPDKIKX0DER ) [productType] => POWER_CONVERTER [productTypeVersion] => Array ( [version] => UAAAAAAAAAAAAAAAAlYD2to6_90e59oHOR0VU9tBm30g= [latest] => 1 [releaseCandidate] => ) )
4. 修改产品属性 patchListingsItem PATCH /listings/2021-08-01/items/{sellerId}/{sku}
//里面的 productType 必须和产品的 相对应
$data = '{ "productType":"POWER_CONVERTER", "patches":[ { "op":"replace", "path":"/attributes/item_name", "value":[ { "value": "NEW DC Voltage Regulator, 36V 48V 60V to 12V 3A DC-DC Step-down Converter Buck Power Supply Module Voltage Regulator for Car Auto Vehicle Motor", "language_tag": "en_US", "marketplace_id": "'.$account->market_place_id.'" } ] } ] }'; $result = $requestReport->applicationreportnew($account->merchant_id,strtolower($account->site),'/listings/2021-08-01/items/'.$account->merchant_id.'/'.$sku.'?marketplaceIds='.$account->market_place_id.'&issueLocale=en_US',"",$data,'PATCH');
结果:(立马生效的)
Array ( [0] => 200 [1] => Array ( [sku] => 10USKST-230718FBA [status] => ACCEPTED [submissionId] => 4acca712155642e9887f085a701a999f [issues] => Array ( ) ) )
再举例一个 修改五点(有几个五点必须全部传参,不然例如原来有5个五点,修改只传一个,则会用一个覆盖5个五点)
$data = '{ "productType":"POWER_CONVERTER", "patches":[ { "op":"replace", "path":"/attributes/bullet_point", "value":[ { "value": "NEW High quality DC-DC reverse converter: Ensures reliable and efficient conversion of DC voltage, providing a stable power supply for your devices.", "language_tag": "en_US", "marketplace_id": "'.$account->market_place_id.'" } ] } ] }'; $result = $requestReport->applicationreportnew($account->merchant_id,strtolower($account->site),'/listings/2021-08-01/items/'.$account->merchant_id.'/'.$sku.'?marketplaceIds='.$account->market_place_id.'&issueLocale=en_US',"",$data,'PATCH');
结果:
Array ( [0] => 200 [1] => Array ( [sku] => 10USKST-230718FBA [status] => ACCEPTED [submissionId] => 1626db311f4e41f199fcff3754314eb0 [issues] => Array ( ) ) )
修改关键字 generic_keyword
$data = '{ "productType":"POWER_CONVERTER", "patches":[ { "op":"replace", "path":"/attributes/generic_keyword", "value":[ { "value": "NEW DC Voltage Regulator, 36V 48V 60V to 12V 3A DC-DC Step-down Converter Buck Power Supply Module Voltage Regulator for Car Auto Vehicle Motor", "language_tag": "en_US", "marketplace_id": "'.$account->market_place_id.'" } ] } ] }'; $result = $requestReport->applicationreportnew($account->merchant_id,strtolower($account->site),'/listings/2021-08-01/items/'.$account->merchant_id.'/'.$sku.'?marketplaceIds='.$account->market_place_id.'&issueLocale=en_US',"",$data,'PATCH');
结果:
Array ( [0] => 200 [1] => Array ( [sku] => 10USKST-230718FBA [status] => ACCEPTED [submissionId] => 0fa020bbc3a649dc9f79374ac2a7afd5 [issues] => Array ( ) ) )
查看修改的结果 可以用 1.获取产品详情 getListingsItem