private function checkOffers($product_id) { if (CCatalogSKU::IsExistOffers($product_id, $this->iblock_id)) { $arSelect = array("IBLOCK_ID", "ID", "CATALOG_GROUP_1"); $arFilter = array("PROPERTY_CML2_LINK" => $product_id, "ACTIVE" => "Y"); $res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect); if ($ob = $res->GetNextElement()) { $arFields = $ob->GetFields(); return $arFields['CATALOG_PRICE_1']; } } else { return false; } }
$arParams["ELEMENT_ID"] = $elementId['ID']; } } $siteId = \Bitrix\Main\Application::getInstance()->getContext()->getSite(); $quantity = 0; $productId = 0; $iblockId = 0; $arResult["IS_SKU"] = true; $lang = \Bitrix\Main\Application::getInstance()->getContext()->getLanguage(); if ($arParams["ELEMENT_ID"] <= 0) { ShowError(GetMessage("PRODUCT_NOT_EXIST")); return; } if ($this->StartResultCache()) { $arResult['STORES'] = array(); $isProductExistSKU = CCatalogSKU::IsExistOffers($arParams['ELEMENT_ID'], $iblockId); if ($isProductExistSKU) { $res = CIBlockElement::GetList(array(), array('ID' => $arParams['ELEMENT_ID']), false, false, array('ID', 'IBLOCK_ID')); if ($productInfo = $res->Fetch()) { $productId = $productInfo['ID']; $iblockId = $productInfo['IBLOCK_ID']; } $skuInfo = CCatalogSKU::GetInfoByProductIBlock($iblockId); $skuIterator = CIBlockElement::GetList(array('ID' => 'DESC'), array('IBLOCK_ID' => $skuInfo['IBLOCK_ID'], 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID'] => $productId), false, false, array('ID')); $productSku = array(); while ($sku = $skuIterator->Fetch()) { $amount = array(); $sum = 0; $filter = array('PRODUCT_ID' => $sku['ID']); if (!empty($arParams['STORES'])) { $filter['STORE_ID'] = $arParams['STORES'];
while ($arSet = $rsSets->Fetch()) { $arSet['OWNER_ID'] = (int)$arSet['OWNER_ID']; $arSet['ITEM_ID'] = (int)$arSet['ITEM_ID']; if ($arSet['OWNER_ID'] == $arSet['ITEM_ID'] && isset($arProductGroupIDs[$arSet['OWNER_ID']])) { $arProductGroupIDs[$arSet['OWNER_ID']] = true; } } } if (!empty($arProductIDs)) { $arProductKeys = array_keys($arProductIDs); foreach ($arProductKeys as &$intProductID) { $arProductIDs[$intProductID] = CCatalogSKU::IsExistOffers($intProductID, $IBLOCK_ID); if ($arProductIDs[$intProductID]) { $arRows['E'.$intProductID]->arRes['CATALOG_TYPE'] = CCatalogProduct::TYPE_SKU; if (!$showCatalogWithOffers) { $arRows['E'.$intProductID]->AddViewField('CATALOG_QUANTITY', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_QUANTITY_TRACE', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_WEIGHT', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_VAT_INCLUDED', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_PURCHASING_PRICE', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_MEASURE_RATIO', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_MEASURE', ' '); if (isset($arRows['E'.$intProductID]->aFields['CATALOG_QUANTITY']['edit'])) unset($arRows['E'.$intProductID]->aFields['CATALOG_QUANTITY']['edit']); if (isset($arRows['E'.$intProductID]->aFields['CATALOG_QUANTITY_TRACE']['edit']))
$amount = GetMessage("NOT_MUCH_GOOD"); } $arResult["STORES"][] = array_merge( array( 'ID' => $arProp["ID"], 'URL' => $storeURL, 'TITLE' => $storeName, 'PHONE' => $storePhone, 'SCHEDULE' => $storeSchedule, 'AMOUNT' => $amount, 'ELEMENT_ID' => $arProp["ELEMENT_ID"], ),$numAmount); } $isProductExistSKU = CCatalogSKU::IsExistOffers($arParams["ELEMENT_ID"]); $arResult["IS_SKU"] = false; if($isProductExistSKU) { $arSkuElements = $arSkuInfo = $arResultSkuId = array(); $intIBlockID = (int)CIBlockElement::GetIBlockByID($arParams["ELEMENT_ID"]); if($intIBlockID > 0) $arSkuInfo = CCatalogSKU::GetInfoByProductIBlock($intIBlockID); if(!empty($arSkuInfo) && is_array($arSkuInfo)) { $dbAllSkuElements = CIBlockElement::GetList( array(), array('IBLOCK_ID' => $arSkuInfo['IBLOCK_ID'], '=PROPERTY_'.$arSkuInfo['SKU_PROPERTY_ID'] => $arParams["ELEMENT_ID"]), false, false, array('ID')
$arCatalogItem = array( 'IBLOCK_ID' => $IBLOCK_ID, 'SECTION_ID' => $MENU_SECTION_ID, 'ID' => $ID, 'PRODUCT_ID' => (0 < $ID ? CIBlockElement::GetRealElement($ID) : 0) ); if ( $arShowTabs['catalog'] && file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/catalog/admin/templates/product_edit_validator.php") ) { // errors'll be appended to $strWarning; $boolSKUExists = false; if (CCatalogSKU::TYPE_FULL == $arMainCatalog['CATALOG_TYPE']) { $boolSKUExists = CCatalogSKU::IsExistOffers(($ID > 0 ? $ID : '-'.$str_TMP_ID), $IBLOCK_ID); } include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/catalog/admin/templates/product_edit_validator.php"); } if ($arShowTabs['product_set']) { CCatalogAdminProductSetEdit::setProductFormParams(array('TYPE' => CCatalogProductSet::TYPE_SET)); if (!CCatalogAdminProductSetEdit::checkFormValues($arCatalogItem)) { $strWarning .= implode('<br>', CCatalogAdminProductSetEdit::getErrors()); } } if ($arShowTabs['product_group']) { CCatalogAdminProductSetEdit::setProductFormParams(array('TYPE' => CCatalogProductSet::TYPE_GROUP)); if (!CCatalogAdminProductSetEdit::checkFormValues($arCatalogItem))
protected function checkFieldsToUpdate($intID, &$arFields) { global $DB; global $USER; $intCurrentUser = 0; if (CCatalog::IsUserExists()) { $intCurrentUser = (int) $USER->GetID(); } if ($intCurrentUser <= 0) { $intCurrentUser = false; } $strTimeFunc = $DB->GetNowFunction(); $arDefItem = self::getEmptyItemFields(); $arProductInSet = array(); $dblDiscountPercent = 0; $boolItems = false; $intID = (int) $intID; if ($intID <= 0) { self::$arErrors[] = array('id' => 'ID', 'text' => GetMessage('BT_CAT_SET_ERR_ID_IS_BAD')); } if (empty(self::$arErrors)) { $arCurrent = CCatalogProductSet::getSetByID($intID); if (empty($arCurrent)) { self::$arErrors[] = array('id' => 'ID', 'text' => GetMessage('BT_CAT_SET_ERR_ID_IS_BAD')); } } if (empty(self::$arErrors)) { self::clearFieldsForUpdate($arFields, $arCurrent['TYPE']); if (array_key_exists('ACTIVE', $arFields)) { $arFields['ACTIVE'] = 'N' != $arFields['ACTIVE'] ? 'Y' : 'N'; } if (array_key_exists('SORT', $arFields)) { $arFields['SORT'] = (int) $arFields['SORT']; if ($arFields['SORT'] <= 0) { $arFields['SORT'] = 100; } } $arFields['MODIFIED_BY'] = !array_key_exists('MODIFIED_BY', $arFields) ? 0 : (int) $arFields['MODIFIED_BY']; if ($arFields['MODIFIED_BY'] <= 0) { $arFields['MODIFIED_BY'] = $intCurrentUser; } $arFields['~TIMESTAMP_X'] = $strTimeFunc; } if (empty(self::$arErrors)) { $arProductInSet[$arCurrent['ITEM_ID']] = true; if (array_key_exists('ITEMS', $arFields)) { if (empty($arFields['ITEMS']) || !is_array($arFields['ITEMS'])) { self::$arErrors[] = array('id' => 'ITEMS', 'text' => GetMessage('BT_CAT_SET_ERR_ITEMS_IS_ABSENT')); } else { $arValidItems = array(); foreach ($arFields['ITEMS'] as &$arOneItem) { if (empty($arOneItem) || !is_array($arOneItem)) { continue; } if (array_key_exists('ID', $arOneItem)) { unset($arOneItem['ID']); } if (!array_key_exists('ITEM_ID', $arOneItem)) { continue; } $arOneItem['ITEM_ID'] = (int) $arOneItem['ITEM_ID']; if ($arOneItem['ITEM_ID'] <= 0) { continue; } if (isset($arProductInSet[$arOneItem['ITEM_ID']])) { self::$arErrors[] = array('id' => 'ITEM_ID', 'text' => GetMessage('BT_CAT_PRODUCT_SET_ERR_ITEM_ID_DUBLICATE')); continue; } $arProductInSet[$arOneItem['ITEM_ID']] = true; $intRowID = self::searchItem($arOneItem['ITEM_ID'], $arCurrent['ITEMS']); if (false === $intRowID) { $arOneItem = array_merge($arDefItem, $arOneItem); } else { $arOneItem['ID'] = $intRowID; } if (array_key_exists('SORT', $arOneItem)) { $arOneItem['SORT'] = (int) $arOneItem['SORT']; if ($arOneItem['SORT'] <= 0) { $arOneItem['SORT'] = 100; } } if (array_key_exists('QUANTITY', $arOneItem)) { $arOneItem['QUANTITY'] = doubleval($arOneItem['QUANTITY']); if (0 >= $arOneItem['QUANTITY']) { self::$arErrors[] = array('id' => 'QUANTITY', 'text' => self::TYPE_SET == $arFields['TYPE'] ? GetMessage('BT_CAT_PRODUCT_SET_ERR_QUANTITY_IS_BAD') : GetMessage('BT_CAT_PRODUCT_SET_ERR_QUANTITY_GROUP_IS_BAD')); continue; } } if (self::TYPE_SET == $arCurrent['TYPE']) { if (array_key_exists('MEASURE', $arOneItem)) { $arOneItem['MEASURE'] = (int) $arOneItem['MEASURE']; if ($arOneItem['MEASURE'] < 0) { $arOneItem['MEASURE'] = 0; } } if (array_key_exists('DISCOUNT_PERCENT', $arOneItem)) { if (false !== $arOneItem['DISCOUNT_PERCENT']) { $arOneItem['DISCOUNT_PERCENT'] = doubleval($arOneItem['DISCOUNT_PERCENT']); if (0 > $arOneItem['DISCOUNT_PERCENT'] || 100 < $arOneItem['DISCOUNT_PERCENT']) { self::$arErrors[] = array('id' => 'DISCOUNT_PERCENT', 'text' => GetMessage('BT_CAT_PRODUCT_SET_ERR_DISCOUNT_PERCENT_IS_BAD')); continue; } $dblDiscountPercent += $arOneItem['DISCOUNT_PERCENT']; } } else { if (false !== $intRowID) { if (false !== $arCurrent['ITEMS'][$intRowID]['DISCOUNT_PERCENT']) { $dblDiscountPercent += $arCurrent['ITEMS'][$intRowID]['DISCOUNT_PERCENT']; } } } } $arValidItems[] = $arOneItem; } unset($arOneItem); if (empty($arValidItems)) { self::$arErrors[] = array('id' => 'ITEMS', 'text' => GetMessage('BT_CAT_SET_ERR_EMPTY_VALID_ITEMS')); } else { $arFields['ITEMS'] = $arValidItems; $boolItems = true; } unset($arValidItems); if (100 < $dblDiscountPercent) { self::$arErrors[] = array('id' => 'DISCOUNT_PERCENT', 'text' => GetMessage('BT_CAT_PRODUCT_SET_ERR_ALL_DISCOUNT_PERCENT_IS_BAD')); } } } if (empty(self::$arErrors)) { $arProductList = array_keys($arProductInSet); if (!self::$disableCheckProduct) { if (!CCatalogProduct::CheckProducts($arProductList)) { self::$arErrors[] = array('id' => 'ITEMS', 'text' => GetMessage('BT_CAT_PRODUCT_SET_ERR_ITEMS_IS_NOT_PRODUCT')); } } if (empty(self::$arErrors) && self::TYPE_SET == $arFields['TYPE']) { if (CCatalogProductSet::isProductHaveSet($arProductList, self::TYPE_SET)) { self::$arErrors[] = array('id' => 'ITEMS', 'text' => GetMessage('BT_CAT_PRODUCT_SET_ERR_ITEMS_IS_SET')); } foreach ($arProductList as &$intOneID) { if (CCatalogSKU::IsExistOffers($intOneID)) { self::$arErrors[] = array('id' => 'ITEMS', 'text' => GetMessage('BT_CAT_PRODUCT_SET_ERR_ITEMS_IS_SKU')); break; } } unset($intOneID); } } } if (empty(self::$arErrors)) { if ($boolItems) { self::setItemFieldsForUpdate($arFields, $arCurrent); } } return empty(self::$arErrors); }
} elseif (0 >= $ID && !isset($_POST["IBLOCK_SECTION"]) && !CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "section_element_bind")) { $strWarning .= GetMessage("IBLOCK_ACCESS_DENIED_SECTION") . "<br>"; } elseif (!$customTabber->Check()) { if ($ex = $APPLICATION->GetException()) { $strWarning .= $ex->GetString(); } else { $strWarning .= "Error. "; } } else { if ($bCatalog) { $arCatalogItem = array('IBLOCK_ID' => $IBLOCK_ID, 'SECTION_ID' => $MENU_SECTION_ID, 'ID' => !$bCopy ? $ID : 0, 'PRODUCT_ID' => 0 < $ID && !$bCopy ? CIBlockElement::GetRealElement($ID) : 0); if ($arShowTabs['catalog'] && file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/catalog/admin/templates/product_edit_validator.php")) { // errors'll be appended to $strWarning; $boolSKUExists = false; if (CCatalogSKU::TYPE_FULL == $arMainCatalog['CATALOG_TYPE']) { $boolSKUExists = CCatalogSKU::IsExistOffers($ID > 0 && !$bCopy ? $ID : '-' . $str_TMP_ID, $IBLOCK_ID); } include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/catalog/admin/templates/product_edit_validator.php"; } if ($arShowTabs['product_set']) { CCatalogAdminProductSetEdit::setProductFormParams(array('TYPE' => CCatalogProductSet::TYPE_SET)); if (!CCatalogAdminProductSetEdit::checkFormValues($arCatalogItem)) { $strWarning .= implode('<br>', CCatalogAdminProductSetEdit::getErrors()); } } if ($arShowTabs['product_group']) { CCatalogAdminProductSetEdit::setProductFormParams(array('TYPE' => CCatalogProductSet::TYPE_GROUP)); if (!CCatalogAdminProductSetEdit::checkFormValues($arCatalogItem)) { $strWarning .= implode('<br>', CCatalogAdminProductSetEdit::getErrors()); } }
public static function getShowTabs($intIBlockID, $intID, &$arCatalog) { $intIBlockID = (int) $intIBlockID; if ($intIBlockID <= 0) { return false; } if (empty($arCatalog)) { $arCatalog = CCatalogSKU::GetInfoByIBlock($intIBlockID); } if (empty($arCatalog)) { return false; } $boolFeatureSet = CBXFeatures::IsFeatureEnabled('CatCompleteSet'); $arResult = array_fill_keys(self::getTabList(false), false); $strProductType = ''; if (isset($_REQUEST[self::$strMainPrefix . 'PRODUCT_TYPE'])) { $strProductType = (string) $_REQUEST[self::$strMainPrefix . 'PRODUCT_TYPE']; if ('' != $strProductType && !isset($arResult[$strProductType])) { $strProductType = ''; } } if ('' != $strProductType && !$boolFeatureSet) { if (self::TAB_SET == $strProductType || self::TAB_GROUP == $strProductType) { $strProductType = ''; } } if (0 < $intID) { $intProductID = CIBlockElement::GetRealElement($intID); $arResult[self::TAB_CATALOG] = CCatalogSKU::TYPE_CATALOG == $arCatalog['CATALOG_TYPE'] || CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE'] || CCatalogSKU::TYPE_OFFERS == $arCatalog['CATALOG_TYPE']; $arResult[self::TAB_SKU] = CCatalogSKU::TYPE_PRODUCT == $arCatalog['CATALOG_TYPE'] || CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE']; if (CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE']) { if (CCatalogSKU::IsExistOffers($intID, $intIBlockID) || CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE'] && self::TAB_SKU == $strProductType) { if ('Y' != COption::GetOptionString('catalog', 'show_catalog_tab_with_offers')) { $arResult[self::TAB_CATALOG] = false; } } else { $arResult[self::TAB_SKU] = false; } } if (CCatalogSKU::TYPE_PRODUCT != $arCatalog['CATALOG_TYPE']) { if ($boolFeatureSet) { if (CCatalogSKU::TYPE_OFFERS != $arCatalog['CATALOG_TYPE']) { $arResult[self::TAB_SET] = CCatalogProductSet::isProductHaveSet($intProductID, CCatalogProductSet::TYPE_SET) || self::TAB_SET == $strProductType; } $arResult[self::TAB_GROUP] = CCatalogProductSet::isProductHaveSet($intProductID, CCatalogProductSet::TYPE_GROUP) || self::TAB_GROUP == $strProductType; if ($arResult[self::TAB_SET]) { $arResult[self::TAB_CATALOG] = true; $arResult[self::TAB_SKU] = false; } } } } else { if ('' != $strProductType) { if (CCatalogSKU::TYPE_OFFERS == $arCatalog['CATALOG_TYPE']) { if (self::TAB_SET == $strProductType || self::TAB_SKU == $strProductType) { $strProductType = ''; } } } if ('' != $strProductType) { $arResult[$strProductType] = true; if (self::TAB_GROUP == $strProductType || self::TAB_SET == $strProductType) { $arResult[self::TAB_CATALOG] = true; } if (self::TAB_SKU == $strProductType && 'Y' == $arCatalog['CATALOG'] && 'Y' == COption::GetOptionString('catalog', 'show_catalog_tab_with_offers')) { $arResult[self::TAB_CATALOG] = true; } } else { $arResult[self::TAB_CATALOG] = CCatalogSKU::TYPE_CATALOG == $arCatalog['CATALOG_TYPE'] || CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE'] || CCatalogSKU::TYPE_OFFERS == $arCatalog['CATALOG_TYPE']; $arResult[self::TAB_SKU] = CCatalogSKU::TYPE_PRODUCT == $arCatalog['CATALOG_TYPE'] || CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE']; } } return $arResult; }
$dbCatalogProduct = CCatalogProduct::GetList(array(), array("ID" => $arCatalogProduct)); while($arCatalogProduct = $dbCatalogProduct->fetch()) $arCatalogProductResult[$arCatalogProduct["ID"]] = $arCatalogProduct; } foreach($arItemsResult as $productId => $arItems) { $arCatalogProduct = $arCatalogProductResult[$productId]; //only for store documents skip sets if($caller == "storeDocs" && isset($arCatalogProduct["TYPE"]) && $arCatalogProduct["TYPE"] == CCatalogProduct::TYPE_SET) continue; $row =& $lAdmin->AddRow($arItems["ID"], $arItems); $isProductExistSKU = false; if (!$boolSubscribe) $isProductExistSKU = CCatalogSKU::IsExistOffers($arItems["ID"]); $arResult = array(); if ($isProductExistSKU) { $arResult = GetProductSku($buyerId, $lid, $arItems["ID"], $arItems["NAME"], '', $arItems); $arSKUId = $arSKUPricesResult = array(); if (isset($arResult["SKU_ELEMENTS"]) && !empty($arResult["SKU_ELEMENTS"]) && is_array($arResult["SKU_ELEMENTS"])) { foreach($arResult["SKU_ELEMENTS"] as $sku) $arSKUId[] = $sku["ID"]; } foreach($arPrices as $price) { $dbPrice = CPrice::getList(array(), array('PRODUCT_ID' => $arSKUId, 'CATALOG_GROUP_ID' => $price['ID']), false, false, array('PRODUCT_ID', 'PRICE')); while($arPrice = $dbPrice->fetch())