Open jpnathannew opened 7 years ago
Has v2 been deprecated? If I remember right I chose v2 even though v3 was out because it was a cleaner and easier to use API. If v2 is being deprecated though we should update it, and try to do so without breaking BC with this library. Care to give it a shot and submit a PR @jpnathannew?
Hi @fillup ,
I have Updated V2 to V3 price feed. But I am not able to update the regular product price update. Its always showing
Error executing command: Client error response [url] https://marketplace.walmartapis.com/v3/price [status code] 400 [reason phrase] Bad Request
I am using https://marketplace.walmartapis.com/v3/price URL to update the price Src/price.php I have added the following code
public function updatePrice($updateDetails)
{
// if(!is_numeric($productPrice)){
// throw new \Exception("productPrice must be numeric",1448480746);
// }
$schema = [
'/Price/pricingList/pricing/currentPrice/value' => [
'attributes' => [
'currency', 'amount'
],
],
];
$a2x = new A2X($updateDetails, $schema);
$xml = $a2x->asXml();
//file_put_contents(TMP . 'result2.xml', $xml);
//$file = new PostFile('file', $xml, 'file.xml', ['Content-Type' => 'text/xml']);
//exit;
// if ( ! isset($updateDetails['Price']['itemIdentifier']['sku'])) {
// throw new \Exception("The element ['Price']['itemIdentifier']['sku'] must be set", 1470529425);
// }
$this->update([
'price' => $xml,
]);
}
Price Description page I have added the following code.
<?php return [
'baseUrl' => 'https://marketplace.walmartapis.com',
'apiVersion' => 'v3',
'operations' => [
'Update' => [
'httpMethod' => 'POST',
'uri' => '/{ApiVersion}/price',
'responseModel' => 'Result',
'data' => [
'xmlRoot' => [
'name' => 'price',
],
],
'parameters' => [
'ApiVersion' => [
'required' => true,
'type' => 'string',
'location' => 'uri',
],
'Content-type' => [
'required' => true,
'type' => 'string',
'location' => 'header',
'default' => 'application/xml',
],
'Accept' => [
'required' => true,
'type' => 'string',
'location' => 'header',
'default' => 'application/xml',
],
'price' => [
'required' => true,
'type' => 'string',
'location' => 'body',
],
],
],
]
My request XML
<?xml version="1.0" encoding="UTF-8"?>
<Price>
<itemIdentifier>
<sku>B00GMHRU62</sku>
</itemIdentifier>
<pricingList>
<pricing>
<currentPrice>
<value currency="USD" amount="6500.00"></value>
</currentPrice>
</pricing>
</pricingList>
</Price>
Can you please help me to update the V3 price update code.
Thanks, Nathan
Hello Everyone,
I made a new method for updating the prices and when I'm using, it is showing me the error of 429 too many requests..Below is my code please have a look at it...Any help will be appreciated
def update_price(self,items,limit):
print("itemsss",items)
headers = {
'Content-Type': "application/xml"
}
url = self.connection.base_url % 'feeds?feedType=%s?limit=%s' %(self.feedType,limit)
response = self.connection.send_request(
method='POST',
url=url,
body=self.get_payload_prices(items),
request_headers=headers
)
print("responseeeeeeeeeeeeeee",response,response.content)
return response
def get_payload_prices(self, item):
root = ElementMaker(
nsmap={'gmp': 'http://walmart.com/'}
)
response_prices = etree.tostring(
root.PriceFeed(
E.PriceHeader(E('version', '1.5')),
*[E.Price(
E(
'itemIdentifier',
E('sku', item['sku'])
),
E(
'pricingList',
E(
'pricing',
# E(
# 'currentPrice',
# E(
# 'value',
# **{
# 'currency': item['currency'],
# 'amount': item['amount']
# }
# )
# ),
# E('currentPriceType', item['priceType']),
E(
'comparisonPrice',
E(
'value',
**{
'currency': item['currency'],
'amount': str(item.get('amount'))
}
)
),
# E(
# 'priceDisplayCode',
# **{
# 'submapType': item['displayCode']
# }
# ),
)
)
)]
), xml_declaration=True, encoding='utf-8'
)
print("response_pricesresponse_prices",response_prices)
return response_prices
Dear team, Hope you are doing great.
Right now the price update in V2 version in SDK. Walmart launched V3 version for update a price. Can you update it to V3 version
https://developer.walmartapis.com/#update-a-price---v3-endpoint
Thanks, Nathan.