本文整理汇总了PHP中CCatalog::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalog::Add方法的具体用法?PHP CCatalog::Add怎么用?PHP CCatalog::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalog
的用法示例。
在下文中一共展示了CCatalog::Add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$arFields = array("ACTIVE" => "Y", "FIELDS" => array('IBLOCK_SECTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'Y'), 'ACTIVE_FROM' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE_TO' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SORT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'NAME' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'PREVIEW_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'PREVIEW_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'PREVIEW_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'DETAIL_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'DETAIL_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'CODE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y')), 'TAGS' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_NAME' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'SECTION_DESCRIPTION_TYPE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => 'text'), 'SECTION_DESCRIPTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'SECTION_XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_CODE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y'))), "CODE" => "clothes_offers", "XML_ID" => $iblockCodeOffers);
$iblock->Update($IBLOCK_OFFERS_ID, $arFields);
}
if ($IBLOCK_CATALOG_ID) {
$iblockCode = "clothes_" . WIZARD_SITE_ID;
//IBlock fields
$iblock = new CIBlock();
$arFields = array("ACTIVE" => "Y", "FIELDS" => array('IBLOCK_SECTION' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'ACTIVE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'Y'), 'ACTIVE_FROM' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE_TO' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SORT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'NAME' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'PREVIEW_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'PREVIEW_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'PREVIEW_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'DETAIL_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'DETAIL_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'CODE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y')), 'TAGS' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_NAME' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'SECTION_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'SECTION_DESCRIPTION_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'SECTION_DESCRIPTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'SECTION_XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_CODE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y'))), "CODE" => "clothes", "XML_ID" => $iblockCode);
$iblock->Update($IBLOCK_CATALOG_ID, $arFields);
if ($IBLOCK_OFFERS_ID) {
$ID_SKU = CCatalog::LinkSKUIBlock($IBLOCK_CATALOG_ID, $IBLOCK_OFFERS_ID);
$rsCatalogs = CCatalog::GetList(array(), array('IBLOCK_ID' => $IBLOCK_OFFERS_ID), false, false, array('IBLOCK_ID'));
if ($arCatalog = $rsCatalogs->Fetch()) {
CCatalog::Update($IBLOCK_OFFERS_ID, array('PRODUCT_IBLOCK_ID' => $IBLOCK_CATALOG_ID, 'SKU_PROPERTY_ID' => $ID_SKU));
} else {
CCatalog::Add(array('IBLOCK_ID' => $IBLOCK_OFFERS_ID, 'PRODUCT_IBLOCK_ID' => $IBLOCK_CATALOG_ID, 'SKU_PROPERTY_ID' => $ID_SKU));
}
//create facet index
$index = \Bitrix\Iblock\PropertyIndex\Manager::createIndexer($IBLOCK_CATALOG_ID);
$index->startIndex();
$index->continueIndex(0);
$index->endIndex();
$index = \Bitrix\Iblock\PropertyIndex\Manager::createIndexer($IBLOCK_OFFERS_ID);
$index->startIndex();
$index->continueIndex(0);
$index->endIndex();
\Bitrix\Iblock\PropertyIndex\Manager::checkAdminNotification();
}
//user fields for sections
$arLanguages = array();
$rsLanguage = CLanguage::GetList($by, $order, array());
示例2: array
$IS_CATALOG = 'Y';
$arOffersFields = array('IBLOCK_ID' => $ID, 'SUBSCRIPTION' => $SUBSCRIPTION, 'YANDEX_EXPORT' => $YANDEX_EXPORT, 'VAT_ID' => $VAT_ID);
$boolFlag = $obCatalog->Update($ID, $arOffersFields);
if (false == $boolFlag) {
$bVarsFromForm = true;
if ($ex = $APPLICATION->GetException()) {
$strWarning .= $ex->GetString() . "<br>";
}
} else {
$boolNeedAgent = $YANDEX_EXPORT != $arCatalog['YANDEX_EXPORT'];
}
} else {
$arOffersFields = array('IBLOCK_ID' => $ID, 'SUBSCRIPTION' => $SUBSCRIPTION, 'YANDEX_EXPORT' => $YANDEX_EXPORT, 'VAT_ID' => $VAT_ID);
if (false == $arCatalog || 'P' == $arCatalog['CATALOG_TYPE']) {
if ($IS_CATALOG == 'Y') {
$boolFlag = $obCatalog->Add($arOffersFields);
}
if ($boolFlag && $arOffersFields['YANDEX_EXPORT'] == 'Y') {
$boolNeedAgent = true;
}
} else {
if ($IS_CATALOG == 'Y' || $SUBSCRIPTION == 'Y') {
$boolFlag = $obCatalog->Update($ID, $arOffersFields);
if ($boolFlag) {
$boolNeedAgent = $YANDEX_EXPORT != $arCatalog['YANDEX_EXPORT'];
}
} elseif ('Y' != $IS_CATALOG && 'Y' != $SUBSCRIPTION) {
$boolFlag = $obCatalog->Delete($ID);
if ($boolFlag) {
$boolNeedAgent == ('Y' == $arCatalog['YANDEX_EXPORT']);
}
示例3:
if (!CCatalog::Delete($arIBlockInfo['ID']))
{
$boolFlag = false;
$strWarning .= Loc::getMessage("CAT_DEL_CATALOG1").' '.$arIBlockInfo['INFO'].' '.Loc::getMessage("CAT_DEL_CATALOG2").".<br />";
}
else
{
$boolCatalogUpdate = true;
}
}
elseif ($arIBlockInfo['CATALOG']=="Y" || $arIBlockInfo['SUBSCRIPTION']=="Y" || 0 < $arIBlockInfo['PRODUCT_IBLOCK_ID'])
{
$boolAttr = $obCatalog->Add(array(
'IBLOCK_ID' => $arIBlockInfo['ID'],
'YANDEX_EXPORT' => $arIBlockInfo['YANDEX_EXPORT'],
'SUBSCRIPTION' => $arIBlockInfo['SUBSCRIPTION'],
'VAT_ID' => $arIBlockInfo['VAT_ID'],
'PRODUCT_IBLOCK_ID' => $arIBlockInfo['PRODUCT_IBLOCK_ID'],
'SKU_PROPERTY_ID' => $arIBlockInfo['SKU_PROPERTY_ID']
));
if (!$boolAttr)
{
$ex = $APPLICATION->GetException();
$strError = $ex->GetString();
$strWarning .= str_replace(
array('#PRODUCT#', '#ERROR#'),
array($arIBlockInfo['INFO'], $strError),
Loc::getMessage('CAT_IBLOCK_OFFERS_ERR_CAT_ADD')
).'<br />';
$strWarning .= Loc::getMessage(
'CAT_IBLOCK_OFFERS_ERR_CAT_ADD',
array(
示例4: cmlStartElement
function cmlStartElement($parser, $name, $attrs)
{
global $DB;
global $USER;
global $currentCatalog, $currentProduct, $currentProperty, $currentOffersList, $currentOffer;
global $arIBlockCache, $iBlockIDString, $arCMLCurrencies;
global $APPLICATION, $nameUTF, $IBLOCK_TYPE_ID, $strImportErrorMessage;
global $oIBlock, $cmlLoadCnts;
global $USE_TRANSLIT, $ADD_TRANSLIT;
global $boolIBlockTranslit, $boolTranslitElement, $boolTranslitSection, $arTranslitElement, $arTranslitSection;
static $SITE_ID = false;
if (false === $SITE_ID) {
$SITE_ID = 'ru';
$dbSite = CSite::GetByID($SITE_ID);
if (!$dbSite->Fetch()) {
$dbSite = CSite::GetList($by = 'sort', $order = 'asc');
$arSite = $dbSite->Fetch();
$SITE_ID = $arSite['ID'];
}
}
switch ($name) {
case $nameUTF["Catalog"]:
$currentCatalog = array();
if (in_array($nameUTF["ID"], array_keys($attrs))) {
$currentCatalog["ID"] = $attrs[$nameUTF["ID"]];
}
if (in_array($nameUTF["Name"], array_keys($attrs))) {
$currentCatalog["Name"] = $attrs[$nameUTF["Name"]];
}
if (in_array($nameUTF["Description"], array_keys($attrs))) {
$currentCatalog["Description"] = $attrs[$nameUTF["Description"]];
}
$boolVersion = true;
$dbIBlockList = CIBlock::GetList(array(), array("=TYPE" => $IBLOCK_TYPE_ID, "=XML_ID" => $currentCatalog["ID"], 'MIN_PERMISSION' => 'W'));
if ($arIBlock = $dbIBlockList->Fetch()) {
$arIBlock['VERSION'] = intval($arIBlock['VERSION']);
if (1 != $arIBlock['VERSION']) {
$bUpdate = true;
$boolVersion = false;
$res = false;
} else {
$bUpdate = true;
$currentCatalog["BID"] = $arIBlock["ID"];
$res = $oIBlock->Update($currentCatalog["BID"], array("NAME" => $currentCatalog["Name"], "DESCRIPTION" => $currentCatalog["Description"]));
}
} elseif ($USER->IsAdmin()) {
$bUpdate = false;
$arFields = array("ACTIVE" => "Y", "NAME" => $currentCatalog["Name"], "XML_ID" => $currentCatalog["ID"], "IBLOCK_TYPE_ID" => $IBLOCK_TYPE_ID, "LID" => $SITE_ID, "WORKFLOW" => "N", "VERSION" => 1);
if ('Y' == $USE_TRANSLIT && 'Y' == $ADD_TRANSLIT) {
$arFields['FIELDS'] = array('CODE' => array('DEFAULT_VALUE' => array('TRANSLITERATION' => 'Y')), 'SECTION_CODE' => array('DEFAULT_VALUE' => array('TRANSLITERATION' => 'Y')));
}
$currentCatalog["BID"] = $oIBlock->Add($arFields);
$res = $currentCatalog["BID"] > 0;
} else {
$res = false;
}
$cmlLoadCnts["CATALOG"]++;
if (!$res) {
$strImportErrorMessage .= str_replace("#ERROR#", $boolVersion ? $oIBlock->LAST_ERROR : GetMessage('CML_R_VERSION'), str_replace("#NAME#", "[" . $currentCatalog["BID"] . "] \"" . $currentCatalog["Name"] . "\" (" . $currentCatalog["ID"] . ")", str_replace("#ACT#", $bUpdate ? GetMessage("CML_R_EDIT") : GetMessage("CML_R_ADD"), GetMessage("CML_R_IBLOCK")))) . ".<br>";
$currentCatalog = false;
} else {
$boolIBlockTranslit = $USE_TRANSLIT;
$boolTranslitElement = false;
$boolTranslitSection = false;
$arTranslitElement = array();
$arTranslitSection = array();
if ('Y' == $boolIBlockTranslit) {
$boolOutTranslit = false;
$arIBlock = CIBlock::GetArrayByID($currentCatalog["BID"]);
if (isset($arIBlock['FIELDS']['CODE']['DEFAULT_VALUE'])) {
if ('Y' == $arIBlock['FIELDS']['CODE']['DEFAULT_VALUE']['TRANSLITERATION'] && 'Y' == $arIBlock['FIELDS']['CODE']['DEFAULT_VALUE']['USE_GOOGLE']) {
$boolOutTranslit = true;
}
}
if (isset($arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE'])) {
if ('Y' == $arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE']['TRANSLITERATION'] && 'Y' == $arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE']['USE_GOOGLE']) {
$boolOutTranslit = true;
}
}
if ($boolOutTranslit) {
$boolIBlockTranslit = 'N';
$strImportErrorMessage .= str_replace("#ERROR#", GetMessage('CATI_USE_CODE_TRANSLIT_OUT'), str_replace("#NAME#", "[" . $currentCatalog["BID"] . "] \"" . $currentCatalog["Name"] . "\" (" . $currentCatalog["ID"] . ")", str_replace("#ACT#", $bUpdate ? GetMessage("CML_R_EDIT") : GetMessage("CML_R_ADD"), GetMessage("CML_R_IBLOCK")))) . ".<br>";
$currentCatalog = false;
break;
}
if ('Y' == $boolIBlockTranslit) {
if (isset($arIBlock['FIELDS']['CODE']['DEFAULT_VALUE'])) {
$arTransSettings = $arIBlock['FIELDS']['CODE']['DEFAULT_VALUE'];
$boolTranslitElement = 'Y' == $arTransSettings['TRANSLITERATION'] ? true : false;
$arTranslitElement = array("max_len" => $arTransSettings['TRANS_LEN'], "change_case" => $arTransSettings['TRANS_CASE'], "replace_space" => $arTransSettings['TRANS_SPACE'], "replace_other" => $arTransSettings['TRANS_OTHER'], "delete_repeat_replace" => 'Y' == $arTransSettings['TRANS_EAT'] ? true : false, "use_google" => 'Y' == $arTransSettings['USE_GOOGLE'] ? true : false);
}
if (isset($arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE'])) {
$arTransSettings = $arIBlock['FIELDS']['SECTION_CODE']['DEFAULT_VALUE'];
$boolTranslitSection = 'Y' == $arTransSettings['TRANSLITERATION'] ? true : false;
$arTranslitSection = array("max_len" => $arTransSettings['TRANS_LEN'], "change_case" => $arTransSettings['TRANS_CASE'], "replace_space" => $arTransSettings['TRANS_SPACE'], "replace_other" => $arTransSettings['TRANS_OTHER'], "delete_repeat_replace" => 'Y' == $arTransSettings['TRANS_EAT'] ? true : false, "use_google" => 'Y' == $arTransSettings['USE_GOOGLE'] ? true : false);
}
}
}
$arIBlockCache[$currentCatalog["ID"]] = IntVal($currentCatalog["BID"]);
$iBlockIDString .= "," . IntVal($currentCatalog["BID"]);
//.........这里部分代码省略.........
示例5: ImportElementPrices
function ImportElementPrices($arXMLElement, &$counter, $arParent = false)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
static $catalogs = array();
$arElement = array("ID" => 0, "XML_ID" => $arXMLElement[$this->mess["IBLOCK_XML2_ID"]]);
$hashPosition = strrpos($arElement["XML_ID"], "#");
if ($this->use_offers && $hashPosition === false && !$this->force_offers && isset($this->PROPERTY_MAP["CML2_LINK"]) && isset($this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]])) {
$IBLOCK_ID = $this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]]["LINK_IBLOCK_ID"];
if (!isset($catalogs[$IBLOCK_ID])) {
$catalogs[$IBLOCK_ID] = true;
$rs = CCatalog::GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID));
if (!$rs->Fetch()) {
$obCatalog = new CCatalog();
$boolFlag = $obCatalog->Add(array("IBLOCK_ID" => $IBLOCK_ID, "YANDEX_EXPORT" => "N", "SUBSCRIPTION" => "N"));
if (!$boolFlag) {
if ($ex = $APPLICATION->GetException()) {
$this->LAST_ERROR = $ex->GetString();
}
return 0;
}
}
}
} else {
$IBLOCK_ID = $this->next_step["IBLOCK_ID"];
}
$obElement = new CIBlockElement();
$rsElement = $obElement->GetList(array("ID" => "asc"), array("=XML_ID" => $arElement["XML_ID"], "IBLOCK_ID" => $IBLOCK_ID), false, false, array("ID", "TMP_ID", "ACTIVE"));
$arDBElement = $rsElement->Fetch();
if ($arDBElement) {
$arElement["ID"] = $arDBElement["ID"];
}
if (isset($arXMLElement[$this->mess["IBLOCK_XML2_STORE_AMOUNT_LIST"]])) {
$arElement["STORE_AMOUNT"] = array();
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_STORE_AMOUNT_LIST"]] as $storeAmount) {
if (isset($storeAmount[$this->mess["IBLOCK_XML2_STORE_ID"]])) {
$storeXMLID = $storeAmount[$this->mess["IBLOCK_XML2_STORE_ID"]];
$amount = $this->ToFloat($storeAmount[$this->mess["IBLOCK_XML2_AMOUNT"]]);
$arElement["STORE_AMOUNT"][$storeXMLID] = $amount;
}
}
} elseif (isset($arXMLElement[$this->mess["IBLOCK_XML2_RESTS"]])) {
$arElement["STORE_AMOUNT"] = array();
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_RESTS"]] as $xmlRest) {
foreach ($xmlRest as $storeAmount) {
if (is_array($storeAmount)) {
if (isset($storeAmount[$this->mess["IBLOCK_XML2_ID"]])) {
$storeXMLID = $storeAmount[$this->mess["IBLOCK_XML2_ID"]];
$amount = $this->ToFloat($storeAmount[$this->mess["IBLOCK_XML2_AMOUNT"]]);
$arElement["STORE_AMOUNT"][$storeXMLID] = $amount;
}
} else {
if (strlen($storeAmount) > 0) {
$amount = $this->ToFloat($storeAmount);
$arElement["QUANTITY"] = $amount;
}
}
}
}
} elseif ($arParent && (array_key_exists($this->mess["IBLOCK_XML2_STORES"], $arXMLElement) || array_key_exists($this->mess["IBLOCK_XML2_STORE"], $arXMLElement))) {
$arElement["STORE_AMOUNT"] = array();
$rsStores = $this->_xml_file->GetList(array("ID" => "asc"), array("><LEFT_MARGIN" => array($arParent["LEFT_MARGIN"], $arParent["RIGHT_MARGIN"]), "NAME" => $this->mess["IBLOCK_XML2_STORE"]), array("ID", "ATTRIBUTES"));
while ($arStore = $rsStores->Fetch()) {
if (strlen($arStore["ATTRIBUTES"]) > 0) {
$info = unserialize($arStore["ATTRIBUTES"]);
if (is_array($info) && array_key_exists($this->mess["IBLOCK_XML2_STORE_ID"], $info) && array_key_exists($this->mess["IBLOCK_XML2_STORE_AMOUNT"], $info)) {
$arElement["STORE_AMOUNT"][$info[$this->mess["IBLOCK_XML2_STORE_ID"]]] = $this->ToFloat($info[$this->mess["IBLOCK_XML2_STORE_AMOUNT"]]);
}
}
}
}
if (isset($arElement["STORE_AMOUNT"])) {
$this->ImportStoresAmount($arElement["STORE_AMOUNT"], $arElement["ID"], $counter);
}
if ($arDBElement) {
$arProduct = array("ID" => $arElement["ID"]);
if (isset($arXMLElement[$this->mess["IBLOCK_XML2_PRICES"]])) {
$arElement["PRICES"] = array();
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_PRICES"]] as $price) {
if (isset($price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]]) && array_key_exists($price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]], $this->PRICES_MAP)) {
$price["PRICE"] = $this->PRICES_MAP[$price[$this->mess["IBLOCK_XML2_PRICE_TYPE_ID"]]];
$arElement["PRICES"][] = $price;
if (array_key_exists($this->mess["IBLOCK_XML2_MEASURE"], $price) && !isset($arProduct["MEASURE"])) {
$tmp = $this->convertBaseUnitFromXmlToPropertyValue($price[$this->mess["IBLOCK_XML2_MEASURE"]]);
if ($tmp["DESCRIPTION"] > 0) {
$arProduct["MEASURE"] = $tmp["DESCRIPTION"];
}
}
}
}
$arElement["DISCOUNTS"] = array();
if (isset($arXMLElement[$this->mess["IBLOCK_XML2_DISCOUNTS"]])) {
foreach ($arXMLElement[$this->mess["IBLOCK_XML2_DISCOUNTS"]] as $discount) {
if (isset($discount[$this->mess["IBLOCK_XML2_DISCOUNT_CONDITION"]]) && $discount[$this->mess["IBLOCK_XML2_DISCOUNT_CONDITION"]] === $this->mess["IBLOCK_XML2_DISCOUNT_COND_VOLUME"]) {
$discount_value = $this->ToInt($discount[$this->mess["IBLOCK_XML2_DISCOUNT_COND_VALUE"]]);
$discount_percent = $this->ToFloat($discount[$this->mess["IBLOCK_XML2_DISCOUNT_COND_PERCENT"]]);
if ($discount_value > 0 && $discount_percent > 0) {
$arElement["DISCOUNTS"][$discount_value] = $discount_percent;
}
}
//.........这里部分代码省略.........
示例6: array
"replace_space" => $arTransSettings['TRANS_SPACE'],
"replace_other" => $arTransSettings['TRANS_OTHER'],
"delete_repeat_replace" => ('Y' == $arTransSettings['TRANS_EAT'] ? true : false),
"use_google" => ('Y' == $arTransSettings['USE_GOOGLE'] ? true : false),
);
}
}
}
if ($bNewRecord_tmp) $STT_CATALOG_ADD++;
else $STT_CATALOG_UPDATE++;
$arCatalogs[$IBLOCK_XML_ID] = $IBLOCK_ID;
if(!CCatalog::GetByID($IBLOCK_ID))
CCatalog::Add(Array("IBLOCK_ID"=>$IBLOCK_ID));
$arProperties = array();
$ibp = new CIBlockProperty();
$props = $xCatNode->select_nodes("/".$nameUTF['Property']);
for($j=0, $intPropCount = count($props); $j<$intPropCount; $j++)
{
$xPropNode = $props[$j];
$PROP_XML_ID = $xPropNode->GetAttribute($nameUTF['ID']);
$PROP_TYPE = $xPropNode->GetAttribute($nameUTF['DataType']);
$PROP_MULTIPLE = ($xPropNode->GetAttribute($nameUTF['Multiple'])=="1"?"Y":"N");
$PROP_NAME = $xPropNode->GetAttribute($nameUTF['Name']);
$PROP_DEF = $xPropNode->GetAttribute($nameUTF['DefaultValue']);
示例7: ImportElementPrices
function ImportElementPrices($arXMLElement, &$counter)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
static $catalogs = array();
$arElement = array(
"ID" => 0,
"XML_ID" => $arXMLElement[GetMessage("IBLOCK_XML2_ID")],
);
$hashPosition = strrpos($arElement["XML_ID"], "#");
if (
$this->use_offers
&& $hashPosition === false
&& isset($this->PROPERTY_MAP["CML2_LINK"])
&& isset($this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]])
)
{
$IBLOCK_ID = $this->arProperties[$this->PROPERTY_MAP["CML2_LINK"]]["LINK_IBLOCK_ID"];
if (!isset($catalogs[$IBLOCK_ID]))
{
$catalogs[$IBLOCK_ID] = true;
$rs = CCatalog::GetList(array(),array("IBLOCK_ID" => $IBLOCK_ID));
if (!$rs->Fetch())
{
$obCatalog = new CCatalog();
$boolFlag = $obCatalog->Add(array(
"IBLOCK_ID" => $IBLOCK_ID,
"YANDEX_EXPORT" => "N",
"SUBSCRIPTION" => "N",
));
if (!$boolFlag)
{
if ($ex = $APPLICATION->GetException())
$this->LAST_ERROR = $ex->GetString();
return 0;
}
}
}
}
else
{
$IBLOCK_ID = $this->next_step["IBLOCK_ID"];
}
$obElement = new CIBlockElement;
$rsElement = $obElement->GetList(
Array("ID"=>"asc"),
Array("=XML_ID" => $arElement["XML_ID"], "IBLOCK_ID" => $IBLOCK_ID),
false, false,
Array("ID", "TMP_ID", "ACTIVE")
);
if($arDBElement = $rsElement->Fetch())
{
$arElement["ID"] = $arDBElement["ID"];
if(isset($arXMLElement[GetMessage("IBLOCK_XML2_PRICES")]))
{//Collect price information for future use
$arElement["PRICES"] = array();
foreach($arXMLElement[GetMessage("IBLOCK_XML2_PRICES")] as $price)
{
if(
isset($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")])
&& array_key_exists($price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")], $this->PRICES_MAP)
)
{
$price["PRICE"] = $this->PRICES_MAP[$price[GetMessage("IBLOCK_XML2_PRICE_TYPE_ID")]];
$arElement["PRICES"][] = $price;
}
}
$arElement["DISCOUNTS"] = array();
if(isset($arXMLElement[GetMessage("IBLOCK_XML2_DISCOUNTS")]))
{
foreach($arXMLElement[GetMessage("IBLOCK_XML2_DISCOUNTS")] as $discount)
{
if(
isset($discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")])
&& $discount[GetMessage("IBLOCK_XML2_DISCOUNT_CONDITION")] === GetMessage("IBLOCK_XML2_DISCOUNT_COND_VOLUME")
)
{
$discount_value = $this->ToInt($discount[GetMessage("IBLOCK_XML2_DISCOUNT_COND_VALUE")]);
$discount_percent = $this->ToFloat($discount[GetMessage("IBLOCK_XML2_DISCOUNT_COND_PERCENT")]);
if($discount_value > 0 && $discount_percent > 0)
$arElement["DISCOUNTS"][$discount_value] = $discount_percent;
}
}
}
}
if(isset($arXMLElement[GetMessage("IBLOCK_XML2_AMOUNT")]))
{
$arElementTmp = array();
$arElement["QUANTITY_RESERVED"] = 0;
if($arElement["ID"])
$arElementTmp = CCatalogProduct::GetById($arElement["ID"]);
if(is_array($arElementTmp) && !empty($arElementTmp) && isset($arElementTmp["QUANTITY_RESERVED"]))
$arElement["QUANTITY_RESERVED"] = $arElementTmp["QUANTITY_RESERVED"];
//.........这里部分代码省略.........
示例8: Add
public static function Add($arFields)
{
if (!CModule::IncludeModule('catalog')) {
return false;
}
self::$LAST_ERROR = '';
global $DB;
$tableName = CCrmCatalog::TABLE_NAME;
if (!self::CheckFields('ADD', $arFields, 0)) {
return false;
}
$DB->Add($tableName, $arFields, array(), '', false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__);
if (strlen($DB->db_Error) > 0) {
self::RegisterError($DB->db_Error);
return false;
}
// -------------- register in catalog module -------------->
$catalogId = $arFields['ID'];
$arFields = array('IBLOCK_ID' => $catalogId, 'CATALOG' => 'Y');
// get default vat
$defCatVatId = 0;
$dbVat = CCatalogVat::GetList(array('SORT' => 'ASC'));
if ($arVat = $dbVat->Fetch()) {
$defCatVatId = $arVat['ID'];
unset($arVat);
}
unset($dbVat);
$defCatVatId = intval($defCatVatId);
if ($defCatVatId > 0) {
$arFields['VAT_ID'] = $defCatVatId;
}
// add crm iblock to catalog
$CCatalog = new CCatalog();
$dbRes = $CCatalog->GetList(array(), array('ID' => $catalogId), false, false, array('ID'));
if (!$dbRes->Fetch()) {
if ($CCatalog->Add($arFields)) {
COption::SetOptionString('catalog', 'save_product_without_price', 'Y');
COption::SetOptionString('catalog', 'default_can_buy_zero', 'Y');
} else {
self::RegisterError(GetMessage('CRM_ERR_REGISTER_CATALOG'));
return false;
}
}
// <------------- register in catalog module --------------
return true;
}
示例9: CIBlock
}
//IBlock fields
$iblock = new CIBlock();
$arFields = array("ACTIVE" => "Y", "FIELDS" => array('IBLOCK_SECTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'Y'), 'ACTIVE_FROM' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE_TO' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SORT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'NAME' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'PREVIEW_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'PREVIEW_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'PREVIEW_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'DETAIL_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'DETAIL_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'CODE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y')), 'TAGS' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_NAME' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95, 'DELETE_WITH_DETAIL' => 'N', 'UPDATE_WITH_DETAIL' => 'N')), 'SECTION_DESCRIPTION_TYPE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => 'text'), 'SECTION_DESCRIPTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N', 'METHOD' => 'resample', 'COMPRESSION' => 95)), 'SECTION_XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SECTION_CODE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('UNIQUE' => 'Y', 'TRANSLITERATION' => 'Y', 'TRANS_LEN' => 100, 'TRANS_CASE' => 'L', 'TRANS_SPACE' => '_', 'TRANS_OTHER' => '_', 'TRANS_EAT' => 'Y', 'USE_GOOGLE' => 'Y'))), "CODE" => "furniture_offers", "XML_ID" => $iblockCode);
$iblock->Update($IBLOCK_OFFERS_ID, $arFields);
$iblockCodeFur = "furniture_" . WIZARD_SITE_ID;
$iblockTypeFur = "catalog";
$rsIBlockFur = CIBlock::GetList(array(), array("XML_ID" => $iblockCodeFur, "TYPE" => $iblockTypeFur));
if ($arIBlockFur = $rsIBlockFur->Fetch()) {
$ID_SKU = CCatalog::LinkSKUIBlock($arIBlockFur["ID"], $IBLOCK_OFFERS_ID);
}
$arCatalog = CCatalog::GetByID($IBLOCK_OFFERS_ID);
if ($arCatalog) {
CCatalog::Update($IBLOCK_OFFERS_ID, array('PRODUCT_IBLOCK_ID' => $arIBlockFur["ID"], 'SKU_PROPERTY_ID' => $ID_SKU));
} else {
CCatalog::Add(array('IBLOCK_ID' => $IBLOCK_OFFERS_ID, 'PRODUCT_IBLOCK_ID' => $arIBlockFur["ID"], 'SKU_PROPERTY_ID' => $ID_SKU));
}
$dbOfferProps = CIblock::GetProperties($IBLOCK_OFFERS_ID, array(), array());
while ($arOfferProps = $dbOfferProps->Fetch()) {
$arProps[$arOfferProps["XML_ID"]] = $arOfferProps["ID"];
}
$property_enums = CIBlockPropertyEnum::GetList(array(), array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "CODE" => "WIDTH"));
$arEnumIds = array();
while ($enum_fields = $property_enums->GetNext()) {
$arEnumIds[] = $enum_fields["ID"];
}
$dbElement = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $arIBlockFur["ID"], "XML_ID" => 56), false);
$arElement = $dbElement->Fetch();
$arOfferElements[] = array("PRODUCT" => array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "NAME" => GetMessage("CAT_OFFER_NAME_1"), "ACTIVE" => "Y", "PROPERTY_VALUES" => array($arProps["CML2_LINK"] => $arElement["ID"], $arProps["327"] => $arEnumIds[0], $arProps["329"] => GetMessage("CAT_OFFER_COLOR_1"))), "PRICE" => GetMessage("CAT_OFFER_PRICE_11"));
$arOfferElements[] = array("PRODUCT" => array("IBLOCK_ID" => $IBLOCK_OFFERS_ID, "NAME" => GetMessage("CAT_OFFER_NAME_1"), "ACTIVE" => "Y", "PROPERTY_VALUES" => array($arProps["CML2_LINK"] => $arElement["ID"], $arProps["327"] => $arEnumIds[1], $arProps["329"] => GetMessage("CAT_OFFER_COLOR_1"))), "PRICE" => GetMessage("CAT_OFFER_PRICE_12"));
$dbElement = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $arIBlockFur["ID"], "XML_ID" => 55), false);
示例10: CCatalog
} else {
$errMsg[] = Loc::getMessage('CRM_UPDATE_ERR_001');
return;
}
if (!empty($arCatalogId) && empty($errMsg)) {
$CCatalog = new CCatalog();
if ($CCatalog) {
foreach ($arCatalogId as $catalogId) {
$arFields = array('IBLOCK_ID' => $catalogId, 'CATALOG' => 'Y');
if ($defCatVatId > 0) {
$arFields['VAT_ID'] = $defCatVatId;
}
// add crm iblock to catalog
$dbRes = $CCatalog->GetList(array(), array('ID' => $catalogId), false, false, array('ID'));
if (!$dbRes->Fetch()) {
if ($CCatalog->Add($arFields)) {
COption::SetOptionString('catalog', 'save_product_without_price', 'Y');
COption::SetOptionString('catalog', 'default_can_buy_zero', 'Y');
} else {
$errMsg[] = Loc::getMessage('CRM_UPDATE_ERR_002');
return;
}
}
unset($dbRes);
}
// transfer crm products to catalog
if ($basePriceId > 0) {
if (COption::GetOptionString('crm', '~CRM_INVOICE_PRODUCTS_CONVERTED_12_5_7', 'N') !== 'Y') {
if ($DB->TableExists('b_crm_product') && $DB->TableExists('b_catalog_product') && $DB->TableExists('b_catalog_price') && $DB->TableExists('b_catalog_group')) {
// update iblock element xml_id
$local_err = 0;
示例11: iShopImportMetaData
//.........这里部分代码省略.........
{
$arIBlock["IBLOCK_TYPE_ID"] = $this->CheckIBlockType($IBLOCK_TYPE);
if(!$arIBlock["IBLOCK_TYPE_ID"])
return GetMessage("IBLOCK_XML2_TYPE_ADD_ERROR");
$arIBlock["GROUP_ID"] = array(2=>"R");
$arIBlock["LID"] = $this->CheckSites($IBLOCK_LID);
$arIBlock["ACTIVE"] = "Y";
$arIBlock["WORKFLOW"] = "N";
$arIBlock["CODE"] = DEFAULT_CATALOG_IBLOCK;
if (
$this->translit_on_add
&& !array_key_exists("CODE", $arIBlock)
)
{
$arIBlock["FIELDS"] = array(
"CODE" => array( "DEFAULT_VALUE" => array(
"TRANSLITERATION" => "Y",
"TRANS_LEN" => $this->translit_on_add["max_len"],
"TRANS_CASE" => $this->translit_on_add["change_case"],
"TRANS_SPACE" => $this->translit_on_add["replace_space"],
"TRANS_OTHER" => $this->translit_on_add["replace_other"],
"TRANS_EAT" => $this->translit_on_add["delete_repeat_replace"]? "Y": "N",
)),
"SECTION_CODE" => array( "DEFAULT_VALUE" => array(
"TRANSLITERATION" => "Y",
"TRANS_LEN" => $this->translit_on_add["max_len"],
"TRANS_CASE" => $this->translit_on_add["change_case"],
"TRANS_SPACE" => $this->translit_on_add["replace_space"],
"TRANS_OTHER" => $this->translit_on_add["replace_other"],
"TRANS_EAT" => $this->translit_on_add["delete_repeat_replace"]? "Y": "N",
)),
);
}
$arIBlock["ID"] = $obIBlock->Add($arIBlock);
if(!$arIBlock["ID"])
return $obIBlock->LAST_ERROR;
}
//Make this catalog
if($this->bCatalog && $this->next_step["bOffer"])
{
$obCatalog = new CCatalog();
$intParentID = $this->GetIBlockIdByCode(DEFAULT_CATALOG_IBLOCK);
if (0 < intval($intParentID) && $this->use_offers)
{
$mxSKUProp = $obCatalog->LinkSKUIBlock($intParentID,$arIBlock["ID"]);
if (!$mxSKUProp)
{
if ($ex = $APPLICATION->GetException())
{
$result = $ex->GetString();
return $result;
}
}
else
{
$rs = CCatalog::GetList(array(),array("IBLOCK_ID"=>$arIBlock["ID"]));
if($arOffer = $rs->Fetch())
{
$boolFlag = $obCatalog->Update($arIBlock["ID"],array('PRODUCT_IBLOCK_ID' => $intParentID,'SKU_PROPERTY_ID' => $mxSKUProp));
}
else
{
$boolFlag = $obCatalog->Add(array("IBLOCK_ID"=>$arIBlock["ID"], "YANDEX_EXPORT"=>"N", "SUBSCRIPTION"=>"N",'PRODUCT_IBLOCK_ID' => $intParentID,'SKU_PROPERTY_ID' => $mxSKUProp));
}
if (!$boolFlag)