Skip to content

Commit

Permalink
Update product stock
Browse files Browse the repository at this point in the history
  • Loading branch information
kg-bot committed Apr 12, 2019
1 parent 09c7789 commit 6a460c3
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/Models/Product.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
<?php
/**
* Created by PhpStorm.
* User: nts
* Date: 19.4.18.
* Time: 01.30
*/

namespace KgBot\Magento\Models;


use KgBot\Magento\Utils\Model;

class Product extends Model
{
protected $entity = 'products';
protected $primaryKey = 'sku';

public function updateStockItem( $data, $id = 1 )
{
$data = [
'stockItem' => $data,
];

return $this->request->handleWithExceptions( function () use ( $data, $id ) {

$response =
$this->request->client->put( "products/{$this->{urlencode($this->primaryKey)}}/stockItems/{$id}", [
'json' => $data,
] );

return $response;
} );
}
}

0 comments on commit 6a460c3

Please sign in to comment.