Добавление генерации услуг в каталоге (#51)
* Добавление генерации услуг в каталоге товаров * Добавление генерации услуг в каталоге
This commit is contained in:
parent
4fa66768ad
commit
364dce15d6
@ -91,7 +91,7 @@ class MoySkladICMLParser
|
|||||||
$countAssortiment = count($assortiment);
|
$countAssortiment = count($assortiment);
|
||||||
$categories = $this->parserFolder();
|
$categories = $this->parserFolder();
|
||||||
$countCategories = count($categories);
|
$countCategories = count($categories);
|
||||||
|
|
||||||
if ($countCategories > 0) {
|
if ($countCategories > 0) {
|
||||||
$assortiment = $this->deleteProduct($categories, $assortiment);
|
$assortiment = $this->deleteProduct($categories, $assortiment);
|
||||||
} else {
|
} else {
|
||||||
@ -268,11 +268,17 @@ class MoySkladICMLParser
|
|||||||
|
|
||||||
foreach ($response['rows'] as $assortiment) {
|
foreach ($response['rows'] as $assortiment) {
|
||||||
|
|
||||||
if (!empty($assortiment['modificationsCount']) ||
|
if (!empty($assortiment['modificationsCount']) ||
|
||||||
$assortiment['meta']['type'] == 'service' ||
|
|
||||||
$assortiment['meta']['type'] == 'consignment') {
|
$assortiment['meta']['type'] == 'consignment') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($assortiment['meta']['type'] == 'service' && !isset($this->options['service']))
|
||||||
|
{
|
||||||
|
if (!isset($this->options['service']) || !$this->options['service']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($ignoreNoCategoryOffers === true) {
|
if ($ignoreNoCategoryOffers === true) {
|
||||||
|
|
||||||
@ -331,14 +337,10 @@ class MoySkladICMLParser
|
|||||||
'name' => $assortiment['name'],
|
'name' => $assortiment['name'],
|
||||||
'productName'=> isset($assortiment['product']['name']) ?
|
'productName'=> isset($assortiment['product']['name']) ?
|
||||||
$assortiment['product']['name'] : $assortiment['name'],
|
$assortiment['product']['name'] : $assortiment['name'],
|
||||||
'weight' => isset($assortiment['weight']) ?
|
|
||||||
$assortiment['weight'] :
|
|
||||||
$assortiment['product']['weight'],
|
|
||||||
'code' => isset($assortiment['code']) ? (string) $assortiment['code'] : '',
|
'code' => isset($assortiment['code']) ? (string) $assortiment['code'] : '',
|
||||||
'xmlId' => !empty($assortiment['product']['externalCode']) ?
|
'xmlId' => !empty($assortiment['product']['externalCode']) ?
|
||||||
($assortiment['product']['externalCode'] . '#' . $assortiment['externalCode']) :
|
($assortiment['product']['externalCode'] . '#' . $assortiment['externalCode']) :
|
||||||
$assortiment['externalCode'],
|
$assortiment['externalCode'],
|
||||||
|
|
||||||
'url' => !empty($assortiment['product']['meta']['uuidHref']) ?
|
'url' => !empty($assortiment['product']['meta']['uuidHref']) ?
|
||||||
$assortiment['product']['meta']['uuidHref'] :
|
$assortiment['product']['meta']['uuidHref'] :
|
||||||
(
|
(
|
||||||
@ -347,6 +349,13 @@ class MoySkladICMLParser
|
|||||||
''
|
''
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isset($assortiment['weight'])) {
|
||||||
|
$products[$assortiment['id']]['weight'] = $assortiment['weight'];
|
||||||
|
} elseif (isset($assortiment['product']['weight'])) {
|
||||||
|
$products[$assortiment['id']]['weight'] = $assortiment['product']['weight'];
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($this->options['customFields'])) {
|
if (isset($this->options['customFields'])) {
|
||||||
if (!empty($assortiment['attributes'])) {
|
if (!empty($assortiment['attributes'])) {
|
||||||
$products[$assortiment['id']]['customFields'] = $this->getCustomFields($assortiment['attributes']);
|
$products[$assortiment['id']]['customFields'] = $this->getCustomFields($assortiment['attributes']);
|
||||||
@ -361,7 +370,13 @@ class MoySkladICMLParser
|
|||||||
$products[$assortiment['id']]['barcodes'] = $assortiment['product']['barcodes'];
|
$products[$assortiment['id']]['barcodes'] = $assortiment['product']['barcodes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->options['loadPurchasePrice']) && $this->options['loadPurchasePrice'] === true) {
|
if (!empty($assortiment['product']['attributes'])) {
|
||||||
|
$products[$assortiment['id']]['customFields'] = $this->getCustomFields($assortiment['product']['attributes']);
|
||||||
|
} elseif (!empty($assortiment['attributes'])){
|
||||||
|
$products[$assortiment['id']]['customFields'] = $this->getCustomFields($assortiment['attributes']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->options['loadPurchasePrice']) && $this->options['loadPurchasePrice'] === true) {
|
||||||
if (isset($assortiment['buyPrice']['value'])) {
|
if (isset($assortiment['buyPrice']['value'])) {
|
||||||
$products[$assortiment['id']]['purchasePrice'] = (((float)$assortiment['buyPrice']['value']) / 100);
|
$products[$assortiment['id']]['purchasePrice'] = (((float)$assortiment['buyPrice']['value']) / 100);
|
||||||
} elseif (isset($assortiment['product']['buyPrice']['value'])) {
|
} elseif (isset($assortiment['product']['buyPrice']['value'])) {
|
||||||
@ -532,7 +547,6 @@ class MoySkladICMLParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($product['customFields']['param'])){
|
if (!empty($product['customFields']['param'])){
|
||||||
|
|
||||||
foreach($product['customFields']['param'] as $param){
|
foreach($product['customFields']['param'] as $param){
|
||||||
$art = $this->icmlAdd($offerXml, 'param', $param['value']);
|
$art = $this->icmlAdd($offerXml, 'param', $param['value']);
|
||||||
$art->addAttribute('code', $param['code']);
|
$art->addAttribute('code', $param['code']);
|
||||||
@ -564,7 +578,7 @@ class MoySkladICMLParser
|
|||||||
$art->addAttribute('name', 'Артикул');
|
$art->addAttribute('name', 'Артикул');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($product['weight']) {
|
if (isset($product['weight'])) {
|
||||||
if (isset($this->options['tagWeight']) && $this->options['tagWeight'] === true) {
|
if (isset($this->options['tagWeight']) && $this->options['tagWeight'] === true) {
|
||||||
$wei = $this->icmlAdd($offerXml, 'weight', $product['weight']);
|
$wei = $this->icmlAdd($offerXml, 'weight', $product['weight']);
|
||||||
} else {
|
} else {
|
||||||
@ -835,9 +849,7 @@ class MoySkladICMLParser
|
|||||||
if ($this->options['customFields']['paramTag']) {
|
if ($this->options['customFields']['paramTag']) {
|
||||||
foreach ($this->options['customFields']['paramTag'] as $paramTag){
|
foreach ($this->options['customFields']['paramTag'] as $paramTag){
|
||||||
$paramTag = explode('#',$paramTag);
|
$paramTag = explode('#',$paramTag);
|
||||||
|
|
||||||
foreach($attributes as $attribute) {
|
foreach($attributes as $attribute) {
|
||||||
|
|
||||||
if ($attribute['id'] == $paramTag[1]) {
|
if ($attribute['id'] == $paramTag[1]) {
|
||||||
$result['param'][] = array('code' => $paramTag[0],'name' => $attribute['name'], 'value'=> htmlspecialchars($attribute['value']));
|
$result['param'][] = array('code' => $paramTag[0],'name' => $attribute['name'], 'value'=> htmlspecialchars($attribute['value']));
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,9 @@ e) При необходимости включения в генерацию а
|
|||||||
* `tagWeight` - передача веса в теге `weight` вместо `param`. Единица измерения - килограмм.
|
* `tagWeight` - передача веса в теге `weight` вместо `param`. Единица измерения - килограмм.
|
||||||
Формат: положительное число с точностью 0.001 (или 0.000001, в зависимости от настройки RetailCRM "Точность веса": граммы или миллиграммы соответственно), разделитель целой и дробной части - точка.
|
Формат: положительное число с точностью 0.001 (или 0.000001, в зависимости от настройки RetailCRM "Точность веса": граммы или миллиграммы соответственно), разделитель целой и дробной части - точка.
|
||||||
Указывается в свойствах товара сервиса Мой Склад.
|
Указывается в свойствах товара сервиса Мой Склад.
|
||||||
|
|
||||||
* `loadPurchasePrice` - установка данной опции со значением `true` включает в генерацию закупочные цены. По умолчанию закупочные цены для товаров не генерируются.
|
* `loadPurchasePrice` - установка данной опции со значением `true` включает в генерацию закупочные цены. По умолчанию закупочные цены для товаров не генерируются.
|
||||||
|
* `service` - установка данного ключа со значение `true` добавляет в генерацию каталога услуги, созданные в сервисе Мой Склад.
|
||||||
* `customFields` - массив для указания для генерации габаритов (dimensions) и дополнительных параметров товаров. Включает в себя следующие опции:
|
* `customFields` - массив для указания для генерации габаритов (dimensions) и дополнительных параметров товаров. Включает в себя следующие опции:
|
||||||
* `dimensions` - массив с одним или тремя значениями, содержащий id пользовательских полей товара в МС. При указании 3 полей должен соблюдаться порядок 'Длина,Ширина,Высота'.
|
* `dimensions` - массив с одним или тремя значениями, содержащий id пользовательских полей товара в МС. При указании 3 полей должен соблюдаться порядок 'Длина,Ширина,Высота'.
|
||||||
Пример заполнения:
|
Пример заполнения:
|
||||||
@ -101,6 +103,7 @@ e) При необходимости включения в генерацию а
|
|||||||
]`
|
]`
|
||||||
|
|
||||||
Id пользовательских свойств товара можно получить, совершив GET-запрос к api МС по адресу `https://online.moysklad.ru/api/remap/1.1/entity/product/metadata`, используя для запроса ваш логин и пароль, используемый для генерации каталога.
|
Id пользовательских свойств товара можно получить, совершив GET-запрос к api МС по адресу `https://online.moysklad.ru/api/remap/1.1/entity/product/metadata`, используя для запроса ваш логин и пароль, используемый для генерации каталога.
|
||||||
|
|
||||||
Необходимые id будут указаны внутри индекса "attributes".
|
Необходимые id будут указаны внутри индекса "attributes".
|
||||||
Все доступные опции не обязательны для использования
|
Все доступные опции не обязательны для использования
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user