$_SESSION["BX_CML2_EXPORT"] = array("PROPERTY_MAP" => false, "SECTION_MAP" => false, "PRICES_MAP" => false, "work_dir" => false, "file_dir" => false);
     if ($fp = fopen($ABS_FILE_NAME, "wb")) {
         if (strtolower(substr($ABS_FILE_NAME, -4)) == ".xml") {
             if (@mkdir($DIR_NAME = substr($ABS_FILE_NAME, 0, -4) . "_files", BX_DIR_PERMISSIONS)) {
             }
             $_SESSION["BX_CML2_EXPORT"]["work_dir"] = $WORK_DIR_NAME;
             $_SESSION["BX_CML2_EXPORT"]["file_dir"] = substr($DIR_NAME . "/", strlen($WORK_DIR_NAME));
         }
     } else {
         $arErrors[] = GetMessage("IBLOCK_CML2_FILE_ERROR");
     }
     $NS["STEP"]++;
 } elseif ($NS["STEP"] < 4) {
     if ($fp = fopen($ABS_FILE_NAME, "ab")) {
         $obExport = new CIBlockCMLExport();
         if ($obExport->Init($fp, $NS["IBLOCK_ID"], $NS["next_step"], true, $_SESSION["BX_CML2_EXPORT"]["work_dir"], $_SESSION["BX_CML2_EXPORT"]["file_dir"])) {
             if ($NS["DOWNLOAD_CLOUD_FILES"] === "N") {
                 $obExport->DoNotDownloadCloudFiles();
             }
             if ($NS["STEP"] == 1) {
                 $obExport->StartExport();
                 $obExport->StartExportMetadata();
                 $obExport->ExportProperties($_SESSION["BX_CML2_EXPORT"]["PROPERTY_MAP"]);
                 $NS["STEP"]++;
             } elseif ($NS["STEP"] == 2) {
                 $result = $obExport->ExportSections($_SESSION["BX_CML2_EXPORT"]["SECTION_MAP"], $start_time, $INTERVAL, $NS["SECTIONS_FILTER"], $_SESSION["BX_CML2_EXPORT"]["PROPERTY_MAP"]);
                 if ($result) {
                     $NS["SECTIONS"] += $result;
                 } else {
                     $obExport->EndExportMetadata();
                     $obExport->StartExportCatalog();
Ejemplo n.º 2
0
 protected function _exportIBlockXML($iblockCode)
 {
     if (!$this->_checkIBlockCode($iblockCode)) {
         return false;
     }
     $arIB =& $this->_arIBlockData[$iblockCode];
     self::deleteDirFilesEx($arIB['EXPORT_WORK_DIR_FULL_PATH'], true);
     unlink($arIB['XML_FILE_FULL_PATH']);
     $fpXmlFile = fopen($arIB['XML_FILE_FULL_PATH'], "ab");
     if (!$fpXmlFile) {
         echo "Can't create / open xml file \n";
         return false;
     }
     $start_time = time();
     $nextStep = array();
     $arSectionMap = false;
     $arPropertyMap = false;
     $arSectionFilter = array('IBLOCK_ID' => $arIB['IBLOCK_ID']);
     $arElementFilter = array('IBLOCK_ID' => $arIB['IBLOCK_ID']);
     $INTERVAL = 0;
     /**
      * @var CIBlockCMLExport $obExport
      */
     $obExport = new CIBlockCMLExport();
     if ($obExport->Init($fpXmlFile, $arIB['IBLOCK_ID'], $nextStep, true, $arIB['EXPORT_FULL_PATH'], $arIB['EXPORT_WORK_DIR'])) {
         // <КоммерческаяИнформация>
         $obExport->StartExport();
         // <Классификатор>
         $obExport->StartExportMetadata();
         // <Свойства>
         $obExport->ExportProperties($arPropertyMap);
         // </Свойства>
         // <Группы>
         $result = $obExport->ExportSections($arSectionMap, $start_time, $INTERVAL, $arSectionFilter);
         // </Группы>
         // </Классификатор>
         $obExport->EndExportMetadata();
         // <Каталог>
         $obExport->StartExportCatalog();
         // <Товары>
         $result = $obExport->ExportElements($arPropertyMap, $arSectionMap, $start_time, $INTERVAL, 0, $arElementFilter);
         // </Товары>
         // </Каталог>
         $obExport->EndExportCatalog();
         // </КоммерческаяИнформация>
         $obExport->EndExport();
     } else {
         echo "\nCan't initialize xml-export for \"{$arIB['IBLOCK_ID']}\".\n Perhaps Minimal access for IBlock lower than \"W\"\n";
     }
     if ($fpXmlFile) {
         fclose($fpXmlFile);
     }
 }
Ejemplo n.º 3
0
             ob_end_clean();
             echo GetMessage("CC_BCE1_PROGRESS_PRODUCT", array("#TOTAL#" => $_SESSION["BX_CML2_EXPORT"]["total"], "#COUNT#" => $_SESSION["BX_CML2_EXPORT"]["current"]));
             echo $c;
             $_SESSION["BX_CML2_EXPORT"]["next_step"] = $obExport->next_step;
         } else {
             ob_end_clean();
             $_SESSION["BX_CML2_EXPORT"] = array("zip" => $arParams["USE_ZIP"] && function_exists("zip_open"), "step" => 3, "next_step" => array(), "SECTION_MAP" => array(), "PROPERTY_MAP" => false, "PRICES_MAP" => false);
         }
     }
 }
 $arCatalog = false;
 if ($_SESSION["BX_CML2_EXPORT"]["step"] === 3) {
     $arCatalog = CCatalog::GetSkuInfoByProductID($arParams["IBLOCK_ID"]);
 }
 $obExport = new CIBlockCMLExport();
 if ($_SESSION["BX_CML2_EXPORT"]["step"] === 3 && $obExport->Init($fp, is_array($arCatalog) ? $arCatalog["IBLOCK_ID"] : $arParams["IBLOCK_ID"], $_SESSION["BX_CML2_EXPORT"]["next_step"], false, $work_dir = false, $file_dir = false, $bCheckPermissions = false, is_array($arCatalog) ? $arCatalog["PRODUCT_IBLOCK_ID"] : false)) {
     if (!array_key_exists("total", $_SESSION["BX_CML2_EXPORT"])) {
         $_SESSION["BX_CML2_EXPORT"]["total"] = CIBlockElement::GetList(array(), array("IBLOCK_ID" => is_array($arCatalog) ? $arCatalog["IBLOCK_ID"] : $arParams["IBLOCK_ID"], "ACTIVE" => "Y"), array());
         $_SESSION["BX_CML2_EXPORT"]["current"] = 0;
     }
     ob_start();
     $obExport->StartExport();
     ob_start();
     $obExport->StartExportMetadata();
     $obExport->ExportProperties($_SESSION["BX_CML2_EXPORT"]["PROPERTY_MAP"]);
     $obExport->ExportSections($_SESSION["BX_CML2_EXPORT"]["SECTION_MAP"], 0, 0);
     $obExport->EndExportMetadata();
     ob_end_clean();
     $obExport->StartExportCatalog();
     $result = $obExport->ExportElements($_SESSION["BX_CML2_EXPORT"]["PROPERTY_MAP"], $_SESSION["BX_CML2_EXPORT"]["SECTION_MAP"], $start_time, $arParams["INTERVAL"], $arParams["ELEMENTS_PER_STEP"]);
     if ($result) {
 function Export($documentId)
 {
     $work_dir = CTempFile::GetDirectoryName();
     CheckDirPath($work_dir);
     $file = "import";
     $file_name = $work_dir . $file . ".xml";
     $file_dir = $file . "_files/";
     $arcname = $work_dir . $file . '.tar.gz';
     if ($fp = fopen($file_name, "ab")) {
         $documentService = $this->workflow->GetService("DocumentService");
         $document = $documentService->GetDocument($documentId);
         $obExport = new CIBlockCMLExport();
         $step = array();
         $PROPERTY_MAP = array();
         $SECTION_MAP = array();
         if ($obExport->Init($fp, $document["IBLOCK_ID"], $step, true, $work_dir, $file_dir)) {
             $obExport->StartExport();
             $obExport->StartExportMetadata();
             $obExport->ExportProperties($PROPERTY_MAP);
             $obExport->ExportSections($SECTION_MAP, time(), 0);
             $obExport->EndExportMetadata();
             $obExport->StartExportCatalog(true, true);
             $obExport->ExportElements($PROPERTY_MAP, $SECTION_MAP, time(), 0, 0, array("SHOW_NEW" => "Y", "IBLOCK_ID" => $document["IBLOCK_ID"], "=ID" => $document["ID"]));
             $obExport->EndExportCatalog();
             $obExport->EndExport();
             fclose($fp);
             include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . '/modules/main/classes/general/tar_gz.php';
             $ob = new CArchiver($arcname);
             $res = $ob->Add('"' . $file_name . '"', false, $work_dir);
             if ($res) {
                 $res = $ob->Add('"' . $work_dir . $file_dir . '"', false, $work_dir);
             }
             if ($res) {
                 return $arcname;
             } else {
                 return '';
             }
         } else {
             return '';
         }
     } else {
         return '';
     }
 }
Ejemplo n.º 5
0
                $obExport->StartExport();
                $obExport->StartExportCatalog(false);
                $res = $obExport->ExportElements($PROPERTY_MAP, $SECTION_MAP, time(), 0, 15);
                $obExport->EndExportCatalog();
                $obExport->EndExport();
                fclose($fi);
            } while ($res > 0);
            $obExport->work_dir = $saved_work_dir;
            $obExport->file_dir = $saved_file_dir;
            unlink($ABS_FILE_NAME);
            $obExport->fp = $fp;
        } else {
            $obExport->ExportElements($PROPERTY_MAP, $SECTION_MAP, time(), 0);
        }
        $obExport->EndExportCatalog();
        $obExport->EndExport();
        //Prices
        if ($bCatalog) {
            $file = "/exp/" . sprintf("%03d", $arBlock["NUM"]) . "_" . $arBlock["TYPE"] . "_" . $arBlock["XML_ID"] . "-offers_ru.xml";
            $fo = fopen($_SERVER["DOCUMENT_ROOT"] . $file, "wb");
            $obExport = new CIBlockCMLExport();
            $obExport->Init($fo, $IBLOCK_ID, $next_step, true, "", "");
            $obExport->only_price = true;
            $obExport->StartExport();
            $obExport->StartExportCatalog(false);
            $obExport->ExportElements($PROPERTY_MAP, $SECTION_MAP, time(), 0);
            $obExport->EndExportCatalog();
            $obExport->EndExport();
        }
    }
}