mirakl / sdk-php-shop

Mirakl PHP SDK for sellers
30 stars 16 forks source link

set methods #6

Closed khanov26 closed 4 years ago

khanov26 commented 4 years ago

hi! how to use set methods correctly? for example, i try to set quantity using ShopOffer::setQuantity. but it doesn't seem to work. i check an offer quantity in maty admin panel and it doesn't change. maybe i should use another method (something like save method) to send request?

jreinke commented 4 years ago

Hello,

To update an offer quantity, you must use API OF24 like the following example:

use Mirakl\MMP\Shop\Client\ShopApiClient;
use Mirakl\MMP\Shop\Request\Offer\UpdateOffersRequest;

$api = new ShopApiClient('API_URL', 'API_KEY', 'SHOP_ID');

$request = new UpdateOffersRequest('SHOP_ID');
$request->setOffers([
    [
        'product_id' => '123',
        'shop_sku' => 'AAPL-CHASAW7852',
        'description' => 'offer description',
        'internal_description' => 'internal offer description',
        'price' => 99.00,
        'quantity' => '10',
        'state_code' => 11,
        'update_delete' => 'update',
    ]
]);

$result = $api->updateOffers($request);
// $result => @see \Mirakl\MMP\OperatorShop\Domain\Offer\Importer\OfferImportTracking