Импорт
Метод API, который позволяет загрузить свои товары в конструктор из файла в формате csv или в формате YML(Yandex Markup Language)
Импорт товаров
Описание
POST
https://api.lpmotor.ru/v1/shop/product/import
Headers
Request Body
{
"job_id": 0
}
Примеры
export products_csv=$(cat products.csv | base64)
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X POST "https://api.lpmotor.ru/v1/shop/product/import" \
-d "{\"data_file\": \"${products_csv}\",\"site_id\":11111,\"file_type\":\"csv\"}"
<?php
$data = [
'site_id': 11111,
'file_type': "csv",
'data_file': base64_encode(file_get_contents('products.csv')),
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.lpmotor.ru/v1/shop/product/import');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
[
'Host: api.lpmotor.ru',
'X-Api-User-Id: ' . $userId,
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
'Accept: application/json',
]
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->post(
'/v1/shop/product/import',
[
'json' => [
'data_file' => base64_encode(file_get_contents('products.csv')),
'site_id' => $siteId,
'file_type' => 'csv',
],
]
);
$statusCode = $response->getStatusCode();
Last updated