function catalog_offer_mutator_1c(&$arLoadOffer, &$xOfferNode) { global $arProperties; $sQuantity = $arLoadOffer['QUANTITY']; $newQuanity = 0; $priceTypeId = ''; if ($obPrice = $xOfferNode->SelectNodes('/Цены/Цена/ИдТипаЦены')) { $priceTypeId = $obPrice->textContent(); if ($priceTypeId != '') { $Store = new CCatalogStore(); $storeProd = new CCatalogStoreProduct(); $rsStore = $Store->GetList(array(), array('XML_ID' => $priceTypeId), false, false, array('*')); if ($arStore = $rsStore->Fetch()) { $storeId = $arStore['ID']; } else { $arFields = array("TITLE" => 'Store_' . $priceTypeId, "ACTIVE" => 'Y', "ADDRESS" => '-', "XML_ID" => $priceTypeId); $storeId = CCatalogStore::Add($arFields); } $storeProd->Add(array("PRODUCT_ID" => $arLoadOffer['ID'], "STORE_ID" => $storeId, "AMOUNT" => $sQuantity)); $rsStoreProd = $storeProd->GetList(array(), array('PRODUCT_ID' => $arLoadOffer['ID']), false, false, array('AMOUNT')); while ($arStore = $rsStoreProd->Fetch()) { $newQuanity = $newQuanity + $arStore['AMOUNT']; } if ($newQuanity > 0) { $arLoadOffer['QUANTITY'] = $newQuanity; } } } return $arLoadOffer; }
$value = (isset($_POST['allow_negative_amount']) && (string)$_POST['allow_negative_amount'] === 'Y' ? 'Y' : 'N'); Option::set('catalog', 'allow_negative_amount', $value, ''); } $strUseStoreControlBeforeSubmit = (string)Option::get('catalog', 'default_use_store_control'); $strUseStoreControl = (isset($_POST['use_store_control']) && (string)$_POST['use_store_control'] === 'Y' ? 'Y' : 'N'); if ($strUseStoreControlBeforeSubmit != $strUseStoreControl) { if ($strUseStoreControl == 'Y') { $countStores = (int)CCatalogStore::GetList(array(), array("ACTIVE" => 'Y'), array()); if ($countStores <= 0) { $arStoreFields = array("TITLE" => Loc::getMessage("CAT_STORE_NAME"), "ADDRESS" => " "); $newStoreId = CCatalogStore::Add($arStoreFields); if ($newStoreId) { CCatalogDocs::synchronizeStockQuantity($newStoreId); } else { $strWarning .= Loc::getMessage("CAT_STORE_ACTIVE_ERROR"); $strUseStoreControl = 'N'; } } else { $strWarning .= Loc::getMessage("CAT_STORE_SYNCHRONIZE_WARNING"); } }
function ImportStores($XML_STORES_PARENT) { $ID = 0; $arXMLStores = $this->_xml_file->GetAllChildrenArray($XML_STORES_PARENT); foreach ($arXMLStores as $arXMLStore) { $arStore = array("TITLE" => $arXMLStore[$this->mess["IBLOCK_XML2_NAME"]], "XML_ID" => $arXMLStore[$this->mess["IBLOCK_XML2_ID"]]); if (isset($arXMLStore[$this->mess["IBLOCK_XML2_STORE_ADDRESS"]])) { $arStore["ADDRESS"] = $arXMLStore[$this->mess["IBLOCK_XML2_STORE_ADDRESS"]][$this->mess["IBLOCK_XML2_VIEW"]]; } if (isset($arXMLStore[$this->mess["IBLOCK_XML2_STORE_DESCRIPTION"]])) { $arStore["DESCRIPTION"] = $arXMLStore[$this->mess["IBLOCK_XML2_STORE_DESCRIPTION"]]; } if (isset($arXMLStore[$this->mess["IBLOCK_XML2_STORE_CONTACTS"]]) && is_array($arXMLStore[$this->mess["IBLOCK_XML2_STORE_CONTACTS"]])) { $storeContact = array(); foreach ($arXMLStore[$this->mess["IBLOCK_XML2_STORE_CONTACTS"]] as $arContact) { if (is_array($arContact)) { $storeContact[] = $arContact[$this->mess["IBLOCK_XML2_VALUE"]]; } } if ($storeContact) { $arStore["PHONE"] = implode(", ", $storeContact); } } $rsStore = CCatalogStore::GetList(array(), array("XML_ID" => $arXMLStore[$this->mess["IBLOCK_XML2_ID"]])); $arIDStore = $rsStore->Fetch(); if (!$arIDStore) { $ID = CCatalogStore::Add($arStore); } else { $ID = CCatalogStore::Update($arIDStore["ID"], $arStore); } } if (!$ID) { return false; } return true; }
} elseif (strlen($isImage) > 0) { $errorMessage .= $isImage . "<br>"; } $arFields = array("TITLE" => isset($_POST['TITLE']) ? $_POST['TITLE'] : '', "SORT" => isset($_POST['CSTORE_SORT']) ? (int) $_POST['CSTORE_SORT'] : 0, "ACTIVE" => isset($_POST['ACTIVE']) && $_POST['ACTIVE'] == 'Y' ? 'Y' : 'N', "ADDRESS" => isset($_POST['ADDRESS']) ? $_POST['ADDRESS'] : '', "DESCRIPTION" => isset($_POST['DESCRIPTION']) ? $_POST['DESCRIPTION'] : '', "GPS_N" => isset($_POST['GPS_N']) ? $_POST['GPS_N'] : '', "GPS_S" => isset($_POST['GPS_S']) ? $_POST['GPS_S'] : '', "PHONE" => isset($_POST['PHONE']) ? $_POST['PHONE'] : '', "SCHEDULE" => isset($_POST['SCHEDULE']) ? $_POST['SCHEDULE'] : '', "XML_ID" => isset($_POST['XML_ID']) ? $_POST['XML_ID'] : '', "USER_ID" => $userId, "MODIFIED_BY" => $userId, "EMAIL" => isset($_POST["EMAIL"]) ? $_POST["EMAIL"] : '', "ISSUING_CENTER" => $ISSUING_CENTER, "SHIPPING_CENTER" => $SHIPPING_CENTER, "SITE_ID" => $_POST["SITE_ID"]); $USER_FIELD_MANAGER->EditFormAddFields($entityId, $arFields); if (intval($fileId) > 0) { $arFields["IMAGE_ID"] = intval($fileId); } elseif ($fileId === "NULL") { $arFields["IMAGE_ID"] = "null"; } $DB->StartTransaction(); if ($errorMessage == '') { if ($id > 0) { $res = CCatalogStore::Update($id, $arFields); } else { $res = CCatalogStore::Add($arFields); if ($res) { $id = (int) $res; } } if (!$res) { if ($ex = $APPLICATION->GetException()) { $errorMessage .= $ex->GetString() . "<br>"; } else { $errorMessage .= GetMessage('STORE_SAVE_ERROR') . '<br>'; } } else { $ufUpdated = $USER_FIELD_MANAGER->Update($entityId, $id, $arFields); } } if ($errorMessage == '') {
function ImportStores($XML_STORES_PARENT) { $this->next_step["XML_STORES_PARENT"] = $XML_STORES_PARENT; $ID = 0; $arXMLStores = $this->_xml_file->GetAllChildrenArray($XML_STORES_PARENT); foreach($arXMLStores as $arXMLStore) { $storeTitle = $arXMLStore[GetMessage("IBLOCK_XML2_NAME")]; $storeAddress = (isset($arXMLStore[GetMessage("IBLOCK_XML2_STORE_ADDRESS")])) ? $arXMLStore[GetMessage("IBLOCK_XML2_STORE_ADDRESS")] : ""; $storeDescription = (isset($arXMLStore[GetMessage("IBLOCK_XML2_STORE_DESCRIPTION")])) ? $arXMLStore[GetMessage("IBLOCK_XML2_STORE_DESCRIPTION")] : ""; $storeContacts = (isset($arXMLStore[GetMessage("IBLOCK_XML2_STORE_CONTACTS")])) ? $arXMLStore[GetMessage("IBLOCK_XML2_STORE_CONTACTS")] : ""; $rsStore = CCatalogStore::GetList(array(), array("XML_ID" => $arXMLStore[GetMessage("IBLOCK_XML2_ID")])); $arStore = array( "TITLE" => $storeTitle, "XML_ID" => $arXMLStore[GetMessage("IBLOCK_XML2_ID")], "ADDRESS" => $storeAddress, "DESCRIPTION" => $storeDescription, "PHONE" => $storeContacts, ); $arIDStore = $rsStore->Fetch(); if(!$arIDStore) { $ID = CCatalogStore::Add($arStore); } else { $ID = CCatalogStore::Update($arIDStore["ID"],$arStore); } } if(!$ID) return false; return true; }
$arFields = array("TITLE" => $TITLE, "ACTIVE" => $ACTIVE, "ADDRESS" => $ADDRESS, "DESCRIPTION" => $DESCRIPTION, "GPS_N" => $GPS_N, "GPS_S" => $GPS_S, "PHONE" => $PHONE, "SCHEDULE" => $SCHEDULE, "XML_ID" => $XML_ID, "USER_ID" => $userId, "MODIFIED_BY" => $userId); if (intval($fileId) > 0) { $arFields["IMAGE_ID"] = intval($fileId); } else { $arFields["IMAGE_ID"] = "null"; } $DB->StartTransaction(); if (strlen($errorMessage) == 0 && $ID > 0 && ($res = CCatalogStore::Update($ID, $arFields))) { $ID = $res; $DB->Commit(); if (strlen($_REQUEST["apply"]) <= 0) { LocalRedirect("/bitrix/admin/cat_store_list.php?lang=" . LANG . "&" . GetFilterParams("filter_", false)); } else { LocalRedirect("/bitrix/admin/cat_store_edit.php?lang=" . LANG . "&ID=" . $ID . "&" . GetFilterParams("filter_", false)); } } elseif (strlen($errorMessage) == 0 && $ID == 0 && ($res = CCatalogStore::Add($arFields))) { $ID = $res; $DB->Commit(); if (strlen($_REQUEST["apply"]) <= 0) { LocalRedirect("/bitrix/admin/cat_store_list.php?lang=" . LANG . "&" . GetFilterParams("filter_", false)); } else { LocalRedirect("/bitrix/admin/cat_store_edit.php?lang=" . LANG . "&ID=" . $ID . "&" . GetFilterParams("filter_", false)); } } else { if ($ex = $APPLICATION->GetException()) { $errorMessage .= $ex->GetString() . "<br>"; } $bVarsFromForm = true; $DB->Rollback(); } }
public function ImportStores($XML_STORES_PARENT) { $this->next_step["XML_STORES_PARENT"] = $XML_STORES_PARENT; $ID = 0; $storeContact = array(); $arXMLStores = $this->_xml_file->GetAllChildrenArray($XML_STORES_PARENT); foreach($arXMLStores as $arXMLStore) { $arStore = array( "TITLE" => $arXMLStore[GetMessage("IBLOCK_XML2_NAME")], "XML_ID" => $arXMLStore[GetMessage("IBLOCK_XML2_ID")], ); if(isset($arXMLStore[GetMessage("IBLOCK_XML2_STORE_ADDRESS")])) $arStore["ADDRESS"] = $arXMLStore[GetMessage("IBLOCK_XML2_STORE_ADDRESS")][GetMessage("IBLOCK_XML2_VIEW")]; if(isset($arXMLStore[GetMessage("IBLOCK_XML2_STORE_DESCRIPTION")])) $arStore["DESCRIPTION"] = $arXMLStore[GetMessage("IBLOCK_XML2_STORE_DESCRIPTION")]; if(isset($arXMLStore[GetMessage("IBLOCK_XML2_STORE_CONTACTS")]) && is_array($arXMLStore[GetMessage("IBLOCK_XML2_STORE_CONTACTS")])) { foreach($arXMLStore[GetMessage("IBLOCK_XML2_STORE_CONTACTS")] as $arContact) { if(is_array($arContact)) { $storeContact[] = $arContact[GetMessage("IBLOCK_XML2_VALUE")]; } } } if(!empty($storeContact)) $arStore["PHONE"] = implode(", ", $storeContact); $rsStore = CCatalogStore::GetList(array(), array("XML_ID" => $arXMLStore[GetMessage("IBLOCK_XML2_ID")])); $arIDStore = $rsStore->Fetch(); if(!$arIDStore) { $ID = CCatalogStore::Add($arStore); } else { $ID = CCatalogStore::Update($arIDStore["ID"], $arStore); } } if(!$ID) return false; return true; }
"EMAIL" => $_POST["EMAIL"], "ISSUING_CENTER" => $ISSUING_CENTER, "SHIPPING_CENTER" => $SHIPPING_CENTER, "SITE_ID" => $_POST["SITE_ID"] ); $USER_FIELD_MANAGER->EditFormAddFields($entityId, $arFields); if (intval($fileId) > 0) $arFields["IMAGE_ID"] = intval($fileId); elseif ($fileId === "NULL") $arFields["IMAGE_ID"] = "null"; $DB->StartTransaction(); if (strlen($errorMessage) == 0 && ($res = CCatalogStore::Update($id, $arFields) || ($id == 0 && $res = CCatalogStore::Add($arFields)))) { $id = $res; $ufUpdated = $USER_FIELD_MANAGER->Update($entityId, $id, $arFields); if ($ufUpdated) $DB->Query("UPDATE b_catalog_store SET DATE_MODIFY = ".$DB->CurrentTimeFunction()." WHERE ID = ".$id); $DB->Commit(); if (strlen($_REQUEST["apply"]) <= 0) LocalRedirect("/bitrix/admin/cat_store_list.php?lang=".LANG."&".GetFilterParams("filter_", false)); else LocalRedirect("/bitrix/admin/cat_store_edit.php?lang=".LANG."&ID=".$id."&".GetFilterParams("filter_", false)); } else