Skip to content

Commit

Permalink
Merge pull request #21 from hasanuzn/master
Browse files Browse the repository at this point in the history
Ürün bilgileri güncelleme eklendi.
  • Loading branch information
ismail0234 authored Aug 24, 2022
2 parents 3bb6bb8 + 27e050e commit c20c327
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions IS/PazarYeri/Trendyol/Helper/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function getApiUrl($requestData)
}

$apiUrl = str_replace('{supplierId}', $this->apiSupplierId, $apiUrl);
if ($this->method == 'POST' || !is_array($requestData) || count($requestData) <= 0) {
if ($this->method == 'POST' || $this->method == 'PUT' || !is_array($requestData) || count($requestData) <= 0) {
return $apiUrl;
}

Expand Down Expand Up @@ -248,7 +248,7 @@ public function getResponse($query, $data, $authorization = true)
$header[] = 'Authorization: Basic ' . $this->authorization();
}

if ($this->method == 'POST') {
if ($this->method == 'POST' || $this->method == 'PUT') {
$header[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData));
Expand Down
39 changes: 39 additions & 0 deletions IS/PazarYeri/Trendyol/Services/ProductService.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,45 @@ public function createProducts($data = array())
return $this->getResponse($query, $data);
}

/**
* Ürün bilgilerini güncellemek için kullanılır. (Fiyat ve stok güncellemek için updatePriceAndInventory fonksiyonu kullanılmalıdır)
*
*
* @param array $data
* @return array
* @throws TrendyolException
*/
public function updateProducts($data = array())
{
$this->setApiUrl('https://api.trendyol.com/sapigw/suppliers/{supplierId}/v2/products');
$this->setMethod("PUT");
$query = array(
'items'=> array(
'barcode' => '',
'title' => '',
'productMainId' => '',
'brandId' => '',
'categoryId' => '',
'quantity' => '',
'stockCode' => '',
'dimensionalWeight' => '',
'description' => '',
'currencyType' => '',
'listPrice' => '',
'salePrice' => '',
'cargoCompanyId' => '',
'deliveryDuration' => '',
'images' => '',
'vatRate' => '',
'shipmentAddressId' => '',
'returningAddressId' => '',
'attributes' => ''
),
);

return $this->getResponse($query, $data);
}

/**
* Trendyol'a aktarılan ve onaylanan ürünlerin fiyat ve stok bilgileri eş zamana yakın güncellenir. Stok ve fiyat bligilerini istek içerisinde ayrı ayrı gönderebilirsiniz.
*
Expand Down

0 comments on commit c20c327

Please sign in to comment.