mirakl / sdk-php-shop

Mirakl PHP SDK for sellers
30 stars 16 forks source link

UpdateOffersRequest does not work #34

Closed nsoft-dev closed 2 years ago

nsoft-dev commented 2 years ago

Hello,

when im using the UpdateOffersRequest, the quantity is not set in the shop, price too. The result is always with the import_id, so i think the json-data is correct.

is there any solution?

This is my current code: $url = "{$this->baseurl}/offers"; $header = array( "Authorization: {$this->apikey}", "Content-Type: application/json" ); $data = array( "update_delete" => "update", "state_code" => $Offer->state_code, "shop_sku" => $Offer->shop_sku, "quantity" => strval($Stock), "price" => $Offer->price, "product_id_type" => "EAN", "product_sku" => $Offer->product_sku ); $data = array( 'offers' => array( $data ) ); $api = new ShopApiClient($this->baseurl, $this->apikey); $request = new UpdateOffersRequest($data); $result = $api->updateOffers($request);

jreinke commented 2 years ago

Hello,

I think you have forgotten a level in your data array. Please try this code instead:

$request = new UpdateOffersRequest(array($data));
nsoft-dev commented 2 years ago

No this doesnt work. Result is Bad Request.

Here is the Code. I think, this is ok, because i get the response with "import_id". phpstorm64_wGOrWVh8ej

The $Offer is the original Response from API with these values.

jreinke commented 2 years ago

Ok the data seems valid indeed. Then, you should use the APIs OF02, OF03 and OF04 with the import id to see if something went wrong with your import.

nsoft-dev commented 2 years ago

Ok i have try this and i get this message with the OF02 Endpoint. UlrLCnlr8D

Is there any call maybe to accept this import?

jreinke commented 2 years ago

I see that the status is WAITING. Is is still the case if you execute the OF02 call again?

nsoft-dev commented 2 years ago

Oh really, when i do the requests again, i get this result. wyWtowbb8T

But now, where is the error? Oke, now i got the error-csv-file.

This returns: The product-id field is mandatory when product-id-type is filled

nsoft-dev commented 2 years ago

It works :)

Thanky you @jreinke I forgott the EAN Number to enter as product_id.

jreinke commented 2 years ago

Great! Thanks for your feedback.