1
0
mirror of synced 2024-11-25 14:56:09 +03:00

At now categories load from IB of product

This commit is contained in:
m.korolev 2013-09-04 12:20:33 +04:00
parent f684763ea9
commit a3a72718f8
2 changed files with 31 additions and 9 deletions

View File

@ -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 .= "<categoryId>" . $arResCategory["ID"] . "</categoryId>\n";
}
if ($categoriesString == '')
$categoriesString .= "<categoryId>" . ($this->mainSection + $id) . "</categoryId>\n";
if ($categoriesString == '') {
$catId = $this->mainSection + $id;
$categoriesString .= "<categoryId>" . ($catId) . "</categoryId>\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 .= "<categoryId>" . $arResCategory["ID"] . "</categoryId>\n";
}
if ($categoriesString == '')
$categoriesString .= "<categoryId>" . ($this->mainSection + $id) . "</categoryId>\n";
if ($categoriesString == '') {
$catId = $this->mainSection + $id;
$categoriesString .= "<categoryId>" . ($catId) . "</categoryId>\n";
$category = array();
$category['ID'] = $catId;
$category['NAME'] = 'Основная группа инфоблока ' . $iblock['IBLOCK_DB']['NAME'];
$newCategories[$catId] = $category;
}
$offer = CCatalogProduct::GetByID($product['ID']);
$product['QUANTITY'] = $offer["QUANTITY"];

View File

@ -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" )