mirakl / sdk-php-shop

Mirakl PHP SDK for sellers
29 stars 16 forks source link

Change discount price #19

Closed E-GOO closed 3 years ago

E-GOO commented 3 years ago

I am trying to update the price and discount price in a sale.

My question is the following:

$api = new ShopApiClient(_APIURL, $apiKey, $shopID);

$offer_array = array( 'product_id' => '8433268000277', 'product_id_type' => 'EAN', 'shop_sku' => 'NovaDecoLitleBL', 'quantity' => 20, 'price' => 700, 'discount-price' => 370, 'state_code' => 11, 'update_delete' => 'update' );

$request = new UpdateOffersRequest(); $request->setOffers(new UpdateOfferCollection(array($offer_array))); $result = $api->updateOffers($request);

But the discount-price is not changed

Does anyone know how it would be done?

Perixx-monkey commented 3 years ago

I also encountered the same problem

    $request->setOffers([
        [
            'product_id' => 'product_id',
            'shop_sku' => shop_sku',            
            'product_id_type' => 'SKU',
            'internal_description' => 'internal_description',
            'price' => '29.99',
            'discount-price' => '19.99',
            'quantity' => '0',
            'state_code' => 11,
            'update_delete' => 'update',
        ]
    ]);    

    $result = $api->updateOffers($request);

And the discount price has not been updated, while the price and quantity have been updated.

jreinke commented 3 years ago

Hello,

I think the problem is on the data format. The discount price must be specified like that:

$request->setOffers([
    [
        'product_id' => 'product_id',
        'shop_sku' => shop_sku',            
        'product_id_type' => 'SKU',
        'internal_description' => 'internal_description',
        'price' => '29.99',
        'discount' => [
            'price' => '19.99'
        ],
        'quantity' => '0',
        'state_code' => 11,
        'update_delete' => 'update',
    ]
]); 

Can you try and tell us if it is working please?

Perixx-monkey commented 3 years ago

Hi @jreinke,

Yes, after changing the structure, everything works. Thank you so much

'discount' => [
            'price' => '19.99'
        ],
jreinke commented 3 years ago

Thanks for your feedback.