diff --git a/MoySkladICMLParser.php b/MoySkladICMLParser.php index d67b49f..e40715b 100644 --- a/MoySkladICMLParser.php +++ b/MoySkladICMLParser.php @@ -91,13 +91,8 @@ class MoySkladICMLParser $countAssortiment = count($assortiment); $categories = $this->parserFolder(); $countCategories = count($categories); - -<<<<<<< 4fa66768add0d2c93f587b1796cc4cdb5017d437 + if ($countCategories > 0) { -======= - if ($countAssortiment > 0) { - $categories = $this->parserFolder(); ->>>>>>> fix generating merchandise of excluded subcategories, Adding new functionality $assortiment = $this->deleteProduct($categories, $assortiment); } else { return; @@ -273,11 +268,17 @@ class MoySkladICMLParser foreach ($response['rows'] as $assortiment) { - if (!empty($assortiment['modificationsCount']) || - $assortiment['meta']['type'] == 'service' || + if (!empty($assortiment['modificationsCount']) || $assortiment['meta']['type'] == 'consignment') { continue; } + + if ($assortiment['meta']['type'] == 'service' && !isset($this->options['service'])) + { + if (!isset($this->options['service']) || !$this->options['service']) { + continue; + } + } if ($ignoreNoCategoryOffers === true) { @@ -336,14 +337,10 @@ class MoySkladICMLParser 'name' => $assortiment['name'], 'productName'=> isset($assortiment['product']['name']) ? $assortiment['product']['name'] : $assortiment['name'], - 'weight' => isset($assortiment['weight']) ? - $assortiment['weight'] : - $assortiment['product']['weight'], 'code' => isset($assortiment['code']) ? (string) $assortiment['code'] : '', 'xmlId' => !empty($assortiment['product']['externalCode']) ? ($assortiment['product']['externalCode'] . '#' . $assortiment['externalCode']) : $assortiment['externalCode'], - 'url' => !empty($assortiment['product']['meta']['uuidHref']) ? $assortiment['product']['meta']['uuidHref'] : ( @@ -352,8 +349,14 @@ 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'])) { -<<<<<<< 4fa66768add0d2c93f587b1796cc4cdb5017d437 if (!empty($assortiment['attributes'])) { $products[$assortiment['id']]['customFields'] = $this->getCustomFields($assortiment['attributes']); } elseif (!empty($assortiment['product']['attributes'])){ @@ -365,34 +368,22 @@ class MoySkladICMLParser $products[$assortiment['id']]['barcodes'] = $assortiment['barcodes']; } elseif (!empty($assortiment['product']['barcodes'])){ $products[$assortiment['id']]['barcodes'] = $assortiment['product']['barcodes']; -======= - 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 (!empty($assortiment['product']['barcodes'])){ - $products[$assortiment['id']]['barcodes'] = $assortiment['product']['barcodes']; - } elseif (!empty($assortiment['barcodes'])){ - $products[$assortiment['id']]['barcodes'] = $assortiment['barcodes']; ->>>>>>> fix generating merchandise of excluded subcategories, Adding new functionality + 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($this->options['loadPurchasePrice']) && $this->options['loadPurchasePrice'] === true) { if (isset($assortiment['buyPrice']['value'])) { $products[$assortiment['id']]['purchasePrice'] = (((float)$assortiment['buyPrice']['value']) / 100); } elseif (isset($assortiment['product']['buyPrice']['value'])) { $products[$assortiment['id']]['purchasePrice'] = (((float)$assortiment['product']['buyPrice']['value']) / 100); -<<<<<<< 4fa66768add0d2c93f587b1796cc4cdb5017d437 } else { $products[$assortiment['id']]['purchasePrice'] = 0; } -======= - } - $products[$assortiment['id']]['purchasePrice'] = 0; ->>>>>>> fix generating merchandise of excluded subcategories, Adding new functionality } if (isset($assortiment['salePrices'][0]['value']) && $assortiment['salePrices'][0]['value'] != 0) { @@ -554,12 +545,8 @@ class MoySkladICMLParser if (!empty($product['customFields']['dimensions'])){ $this->icmlAdd($offerXml, 'dimensions', $product['customFields']['dimensions']); } -<<<<<<< 4fa66768add0d2c93f587b1796cc4cdb5017d437 -======= ->>>>>>> fix generating merchandise of excluded subcategories, Adding new functionality if (!empty($product['customFields']['param'])){ - foreach($product['customFields']['param'] as $param){ $art = $this->icmlAdd($offerXml, 'param', $param['value']); $art->addAttribute('code', $param['code']); @@ -591,7 +578,7 @@ class MoySkladICMLParser $art->addAttribute('name', 'Артикул'); } - if ($product['weight']) { + if (isset($product['weight'])) { if (isset($this->options['tagWeight']) && $this->options['tagWeight'] === true) { $wei = $this->icmlAdd($offerXml, 'weight', $product['weight']); } else { @@ -608,26 +595,18 @@ class MoySkladICMLParser } if ($product['vendor']) { -<<<<<<< 4fa66768add0d2c93f587b1796cc4cdb5017d437 $this->icmlAdd($offerXml, 'vendor', $product['vendor']); -======= - $this->icmlAdd($offerXml, 'vendor', $product['vendor']); ->>>>>>> fix generating merchandise of excluded subcategories, Adding new functionality } if (isset($product['image']['imageUrl']) && !empty($this->options['imageDownload']['pathToImage']) && !empty($this->options['imageDownload']['site'])) { -<<<<<<< 4fa66768add0d2c93f587b1796cc4cdb5017d437 $imgSrc = $this->saveImage($product['image']); if (!empty($imgSrc)){ $this->icmlAdd($offerXml, 'picture', $this->saveImage($product['image'])); } -======= - $this->icmlAdd($offerXml, 'picture', $this->saveImage($product['image'])); ->>>>>>> fix generating merchandise of excluded subcategories, Adding new functionality } } @@ -866,23 +845,13 @@ class MoySkladICMLParser } } -<<<<<<< 4fa66768add0d2c93f587b1796cc4cdb5017d437 if (isset($this->options['customFields']['paramTag'])) { -======= - if (isset($this->options['customFields']['dimensions'])) { ->>>>>>> fix generating merchandise of excluded subcategories, Adding new functionality if ($this->options['customFields']['paramTag']) { foreach ($this->options['customFields']['paramTag'] as $paramTag){ $paramTag = explode('#',$paramTag); - foreach($attributes as $attribute) { - if ($attribute['id'] == $paramTag[1]) { -<<<<<<< 4fa66768add0d2c93f587b1796cc4cdb5017d437 $result['param'][] = array('code' => $paramTag[0],'name' => $attribute['name'], 'value'=> htmlspecialchars($attribute['value'])); -======= - $result['param'][] = array('code' => $paramTag[0],'name' => $attribute['name'], 'value'=> $attribute['value']); ->>>>>>> fix generating merchandise of excluded subcategories, Adding new functionality } } } diff --git a/README.md b/README.md index b273ef9..9cf5610 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,9 @@ e) При необходимости включения в генерацию а * `tagWeight` - передача веса в теге `weight` вместо `param`. Единица измерения - килограмм. Формат: положительное число с точностью 0.001 (или 0.000001, в зависимости от настройки RetailCRM "Точность веса": граммы или миллиграммы соответственно), разделитель целой и дробной части - точка. Указывается в свойствах товара сервиса Мой Склад. -<<<<<<< 4fa66768add0d2c93f587b1796cc4cdb5017d437 + * `loadPurchasePrice` - установка данной опции со значением `true` включает в генерацию закупочные цены. По умолчанию закупочные цены для товаров не генерируются. +* `service` - установка данного ключа со значение `true` добавляет в генерацию каталога услуги, созданные в сервисе Мой Склад. * `customFields` - массив для указания для генерации габаритов (dimensions) и дополнительных параметров товаров. Включает в себя следующие опции: * `dimensions` - массив с одним или тремя значениями, содержащий id пользовательских полей товара в МС. При указании 3 полей должен соблюдаться порядок 'Длина,Ширина,Высота'. Пример заполнения: @@ -102,16 +103,7 @@ e) При необходимости включения в генерацию а ]` Id пользовательских свойств товара можно получить, совершив GET-запрос к api МС по адресу `https://online.moysklad.ru/api/remap/1.1/entity/product/metadata`, используя для запроса ваш логин и пароль, используемый для генерации каталога. -======= -* `'loadPurchasePrice'` - установка данной опции со значением `true` включает в генерацию закупочные цены. По умолчанию закупочные цены для товаров не генерируются. -*`customFields` - массив для указания для генерации габаритов (dimensions) и дополнительных параметров товаров. Включает в себя следующие опции: - * `dimensions` - массив с одним или тремя значениями, содержащий id пользовательских полей товара в МС. При указании 3 полей должен соблюдаться порядок 'Длина,Ширина,Высота'. Если -для генерации планируется использовать одно поле, то нужно использовать дополнительный параметр `separate` в котором вы должны указать какой разделитель используется в поле между -значениями на стороне МС. - * `paramTag` - массив со значениями,складывающимися из кода, который должен использоваться для генерации данного дополнительного параметра и id пользовательского поля товара. Заполняется с разделетелем "#" следующим образом: -'{произвольный_код_латиницей}#{id_пользовательского_свойства_товара}'. -Id пользовательских свойств товара можно получить, совершив GET-запрос к api МС по адресу `https://online.moysklad.ru/api/remap/1.1//entity/product/metadata`, используя для запроса ваш логин и пароль, используемый для генерации каталога. ->>>>>>> fix generating merchandise of excluded subcategories, Adding new functionality + Необходимые id будут указаны внутри индекса "attributes". Все доступные опции не обязательны для использования