diff --git a/intaro.intarocrm/classes/general/ICMLLoader.php b/intaro.intarocrm/classes/general/ICMLLoader.php index cb5715c5..13181e37 100644 --- a/intaro.intarocrm/classes/general/ICMLLoader.php +++ b/intaro.intarocrm/classes/general/ICMLLoader.php @@ -22,7 +22,11 @@ class ICMLLoader { $categories = $this->GetCategories(); - $offers = $this->GetOffers(); + $newCategories = array(); + $offers = $this->GetOffers($newCategories); + foreach ($newCategories as $newCategory) { + $categories[] = $this->BuildCategory($newCategory); + } $this->PrepareFile(); @@ -141,8 +145,8 @@ class ICMLLoader { } - protected function GetOffers() - { + protected function GetOffers(&$newCategories) + { $offers = Array(); foreach ($this->iblocks as $key => $id) { @@ -205,12 +209,21 @@ class ICMLLoader { $rsOffers = CIBlockElement::GetList(array(), $arFilterOffer, false, false, $arSelectOffer); while ($arOffer = $rsOffers->GetNext()) { - $dbResCategories = CIBlockElement::GetElementGroups($arOffer['ID'], true); + $dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true); while ($arResCategory = $dbResCategories->Fetch()) { $categoriesString .= "" . $arResCategory["ID"] . "\n"; } - if ($categoriesString == '') - $categoriesString .= "" . ($this->mainSection + $id) . "\n"; + if ($categoriesString == '') { + + $catId = $this->mainSection + $id; + $categoriesString .= "" . ($catId) . "\n"; + + $category = array(); + $category['ID'] = $catId; + $category['NAME'] = 'Основная группа инфоблока ' . $iblock['IBLOCK_DB']['NAME']; + + $newCategories[$catId] = $category; + } $offer = CCatalogProduct::GetByID($arOffer['ID']); $arOffer['QUANTITY'] = $offer["QUANTITY"]; @@ -236,8 +249,17 @@ class ICMLLoader { while ($arResCategory = $dbResCategories->Fetch()) { $categoriesString .= "" . $arResCategory["ID"] . "\n"; } - if ($categoriesString == '') - $categoriesString .= "" . ($this->mainSection + $id) . "\n"; + if ($categoriesString == '') { + + $catId = $this->mainSection + $id; + $categoriesString .= "" . ($catId) . "\n"; + + $category = array(); + $category['ID'] = $catId; + $category['NAME'] = 'Основная группа инфоблока ' . $iblock['IBLOCK_DB']['NAME']; + + $newCategories[$catId] = $category; + } $offer = CCatalogProduct::GetByID($product['ID']); $product['QUANTITY'] = $offer["QUANTITY"]; diff --git a/intaro.intarocrm/export/export_setup.php b/intaro.intarocrm/export/export_setup.php index d0c92f81..1fafdeee 100644 --- a/intaro.intarocrm/export/export_setup.php +++ b/intaro.intarocrm/export/export_setup.php @@ -190,7 +190,7 @@ if ($STEP==1) if ($arIBlock['OLD_PROPERTY_SELECT'] == $prop["CODE"]){ echo " selected"; } else { - if ($arIBlock['OLD_PROPERTY_SELECT'] != "") { + if ($arIBlock['OLD_PROPERTY_SELECT'] == "") { if ($prop["CODE"] == "ARTICLE" || $prop["CODE"] == "ART" || $prop["CODE"] == "ARTNUMBER" )