1.3 =============================================== 1.4 $counter["CRC"]++; 1.5 1.6 $arXMLElement = $this->_xml_file->GetAllChildrenArray($arParent); 1.7 + $hashPosition = strrpos($arXMLElement[GetMessage("IBLOCK_XML2_ID")], "#"); 1.8 1.9 if(!$this->next_step["bOffer"] && $this->use_offers) 1.10 { 1.11 - $p = strrpos($arXMLElement[GetMessage("IBLOCK_XML2_ID")], "#"); 1.12 - if($p !== false) 1.13 + if($hashPosition !== false) 1.14 { 1.15 $this->next_step["XML_LAST_ID"] = $arParent["ID"]; 1.16 continue; 1.17 =============================================== 1.18 } 1.19 else 1.20 { 1.21 - if($this->next_step["bOffer"] && !$this->use_offers) 1.22 - $ID = $this->ImportElementPrices($arXMLElement, $counter); 1.23 + $this->arFileDescriptionsMap = array(); 1.24 + //offers.xml 1.25 + if ($this->next_step["bOffer"]) 1.26 + { 1.27 + //We have only one information block 1.28 + if (!$this->use_offers) 1.29 + $ID = $this->ImportElementPrices($arXMLElement, $counter); 1.30 + //We have separate offers iblock and there is element price 1.31 + elseif ($hashPosition === false) 1.32 + $ID = $this->ImportElementPrices($arXMLElement, $counter); 1.33 + //It's an offer in offers iblock 1.34 + else 1.35 + $ID = $this->ImportElement($arXMLElement, $counter, $bWF, $arParent); 1.36 + } 1.37 + //import.xml 1.38 else 1.39 + { 1.40 $ID = $this->ImportElement($arXMLElement, $counter, $bWF, $arParent); 1.41 + } 1.42 } 1.43 1.44 if($ID) 1.45 =============================================== 1.46 1.47 function ImportElementPrices($arXMLElement, &$counter) 1.48 { 1.49 + /** @global CMain $APPLICATION */ 1.50 + global $APPLICATION; 1.51 + static $catalogs = array(); 1.52 + 1.53 $arElement = array( 1.54 "ID" => 0, 1.55 "XML_ID" => $arXMLElement[GetMessage("IBLOCK_XML2_ID")], 1.56 ); 1.57 1.58 + $hashPosition = strrpos($arElement["XML_ID"], "#"); 1.59 + if ($hashPosition === false) 1.60 + { 1.61 + $IBLOCK_ID = $this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]]["LINK_IBLOCK_ID"]; 1.62 + 1.63 + if (!isset($catalogs[$IBLOCK_ID])) 1.64 + { 1.65 + $catalogs[$IBLOCK_ID] = true; 1.66 + 1.67 + $rs = CCatalog::GetList(array(),array("IBLOCK_ID" => $IBLOCK_ID)); 1.68 + if (!$rs->Fetch()) 1.69 + { 1.70 + $obCatalog = new CCatalog(); 1.71 + $boolFlag = $obCatalog->Add(array( 1.72 + "IBLOCK_ID" => $IBLOCK_ID, 1.73 + "YANDEX_EXPORT" => "N", 1.74 + "SUBSCRIPTION" => "N", 1.75 + )); 1.76 + if (!$boolFlag) 1.77 + { 1.78 + if ($ex = $APPLICATION->GetException()) 1.79 + $this->LAST_ERROR = $ex->GetString(); 1.80 + return 0; 1.81 + } 1.82 + } 1.83 + } 1.84 + } 1.85 + else 1.86 + { 1.87 + $IBLOCK_ID = $this->next_step["IBLOCK_ID"]; 1.88 + } 1.89 + 1.90 $obElement = new CIBlockElement; 1.91 $rsElement = $obElement->GetList( 1.92 Array("ID"=>"asc"), 1.93 - Array("=XML_ID" => $arElement["XML_ID"], "IBLOCK_ID" => $this->next_step["IBLOCK_ID"]), 1.94 + Array("=XML_ID" => $arElement["XML_ID"], "IBLOCK_ID" => $IBLOCK_ID), 1.95 false, false, 1.96 Array("ID", "TMP_ID", "ACTIVE") 1.97 ); 1.98 =============================================== 1.99 $arElement["PRICES"] = array(); 1.100 foreach($arXMLElement[GetMessage("IBLOCK_XML2_PRICES")] as $price) 1.101 { 1.102 - if(isset($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")]) && array_key_exists($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")], $this->PRICES_MAP)) 1.103 + if( 1.104 + isset($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")]) 1.105 + && array_key_exists($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")], $this->PRICES_MAP) 1.106 + ) 1.107 { 1.108 $price["PRICE"] = $this->PRICES_MAP[$price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")]]; 1.109 $arElement["PRICES"][] = $price; 1.110 - 1.111 } 1.112 } 1.113 1.114 =============================================== 1.115 { 1.116 if( 1.117 isset($discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")]) 1.118 - && $discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")]===GetMessage("IBLOCK_XML2_DISCOUNT_COND_VOLUME") 1.119 + && $discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")] === GetMessage("IBLOCK_XML2_DISCOUNT_COND_VOLUME") 1.120 ) 1.121 { 1.122 $discount_value = $this->ToInt($discount[GetMessage("IBLOCK_XML2_DISCOUNT_COND_VALUE")]); 1.123 =============================================== 1.124 $arProduct["QUANTITY"] = $arElement["QUANTITY"]; 1.125 1.126 //Get weight from element traits 1.127 - $rsWeight = CIBlockElement::GetProperty($this->next_step["IBLOCK_ID"], $arElement["ID"], array(), array("ID"=>$this->PROPERTY_MAP["CML2_TRAITS"])); 1.128 + $rsWeight = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array(), array("CODE" => "CML2_TRAITS")); 1.129 while($arWeight = $rsWeight->Fetch()) 1.130 { 1.131 if($arWeight["DESCRIPTION"] == GetMessage("IBLOCK_XML2_WEIGHT")) 1.132 =============================================== 1.133 1.134 //Check if all the taxes exists in BSM catalog 1.135 $arTaxMap = array(); 1.136 - $rsTaxProperty = CIBlockElement::GetProperty($this->next_step["IBLOCK_ID"], $arElement["ID"], "sort", "asc", array("CODE" => "CML2_TAXES")); 1.137 + $rsTaxProperty = CIBlockElement::GetProperty($IBLOCK_ID, $arElement["ID"], array("sort" => "asc"), array("CODE" => "CML2_TAXES")); 1.138 while($arTaxProperty = $rsTaxProperty->Fetch()) 1.139 { 1.140 if(