function PreGenerateExport($profile_id) { global $DB; $profile_id = intval($profile_id); if ($profile_id <= 0) { return false; } $ar_profile = CCatalogExport::GetByID($profile_id); if (!$ar_profile || 'Y' == $ar_profile['NEED_EDIT']) { return false; } if ($ar_profile["DEFAULT_PROFILE"] != "Y") { parse_str($ar_profile["SETUP_VARS"]); } CCatalogDiscountSave::Disable(); $strFile = CATALOG_PATH2EXPORTS . $ar_profile["FILE_NAME"] . "_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $strFile)) { $strFile = CATALOG_PATH2EXPORTS_DEF . $ar_profile["FILE_NAME"] . "_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $strFile)) { return false; } } @(include $_SERVER["DOCUMENT_ROOT"] . $strFile); CCatalogDiscountSave::Enable(); CCatalogExport::Update($profile_id, array("=LAST_USE" => $DB->GetNowFunction())); return "CCatalogExport::PreGenerateExport(" . $profile_id . ");"; }
public static function PreGenerateImport($profile_id) { global $DB; $profile_id = (int) $profile_id; if ($profile_id <= 0) { return false; } $ar_profile = CCatalogImport::GetByID($profile_id); if (!$ar_profile || 'Y' == $ar_profile['NEED_EDIT']) { return false; } $strFile = CATALOG_PATH2IMPORTS . $ar_profile["FILE_NAME"] . "_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $strFile)) { $strFile = CATALOG_PATH2IMPORTS_DEF . $ar_profile["FILE_NAME"] . "_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $strFile)) { CCatalogDiscountSave::Enable(); return false; } } $bFirstLoadStep = true; if (!defined("CATALOG_LOAD_NO_STEP")) { define("CATALOG_LOAD_NO_STEP", true); } $strImportErrorMessage = ""; $strImportOKMessage = ""; $bAllDataLoaded = true; $arSetupVars = array(); $intSetupVarsCount = 0; if ('Y' != $ar_profile["DEFAULT_PROFILE"]) { parse_str($ar_profile["SETUP_VARS"], $arSetupVars); if (!empty($arSetupVars) && is_array($arSetupVars)) { $intSetupVarsCount = extract($arSetupVars, EXTR_SKIP); } } global $arCatalogAvailProdFields; $arCatalogAvailProdFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_ELEMENT); global $arCatalogAvailPriceFields; $arCatalogAvailPriceFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_CATALOG); global $arCatalogAvailValueFields; $arCatalogAvailValueFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_PRICE); global $arCatalogAvailQuantityFields; $arCatalogAvailQuantityFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_PRICE_EXT); global $arCatalogAvailGroupFields; $arCatalogAvailGroupFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_SECTION); global $defCatalogAvailProdFields; $defCatalogAvailProdFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_ELEMENT); global $defCatalogAvailPriceFields; $defCatalogAvailPriceFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_CATALOG); global $defCatalogAvailValueFields; $defCatalogAvailValueFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_PRICE); global $defCatalogAvailQuantityFields; $defCatalogAvailQuantityFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_PRICE_EXT); global $defCatalogAvailGroupFields; $defCatalogAvailGroupFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_SECTION); global $defCatalogAvailCurrencies; $defCatalogAvailCurrencies = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_CURRENCY); CCatalogDiscountSave::Disable(); include $_SERVER["DOCUMENT_ROOT"] . $strFile; CCatalogDiscountSave::Enable(); CCatalogImport::Update($profile_id, array("=LAST_USE" => $DB->GetNowFunction())); return "CCatalogImport::PreGenerateImport(" . $profile_id . ");"; }
$arSelectedFields[] = "DETAIL_TEXT_TYPE"; } $arSelectedFields[] = "LOCK_STATUS"; $arSelectedFields[] = "WF_NEW"; $arSelectedFields[] = "WF_STATUS_ID"; $arSelectedFields[] = "DETAIL_PAGE_URL"; $arSelectedFields[] = "SITE_ID"; $arSelectedFields[] = "CODE"; $arSelectedFields[] = "EXTERNAL_ID"; $arSelectedFields[] = "NAME"; $arSelectedFields[] = "XML_ID"; $arSelectedFields[] = "IBLOCK_ID"; $arDiscountCoupons = array(); $arSku = array(); $OfferIblockId = ""; CCatalogDiscountSave::Disable(); $arCatalogProductResult = array(); $arPricesResult = array(); $arCatalogProduct = $arItemsResult = $arPricesResult = array(); while ($arItems = $dbResultList->Fetch()) { $arCatalogProduct[] = $arItems["ID"]; $arItems['DETAIL_PAGE_URL'] = CIBlock::ReplaceDetailUrl($arItems['DETAIL_PAGE_URL'], $arItems, false, "E"); $arItemsResult[$arItems['ID']] = $arItems; } if (!empty($arCatalogProduct)) { foreach ($arPrices as $price) { $dbPrice = CPrice::GetList(array(), array('PRODUCT_ID' => $arCatalogProduct, 'CATALOG_GROUP_ID' => $price['ID']), false, false, array('PRODUCT_ID', 'PRICE')); while ($arPrice = $dbPrice->fetch()) { $arPricesResult[$price['ID']][$arPrice["PRODUCT_ID"]] = $arPrice["PRICE"]; } }
function CatalogGetPriceTable($ID) { global $USER; $ID = (int) $ID; if ($ID <= 0) { return false; } $arResult = array(); $arPriceGroups = array(); $cacheKey = LANGUAGE_ID . "_" . $USER->GetGroups(); if (isset($GLOBALS["CATALOG_PRICE_GROUPS_CACHE"]) && is_array($GLOBALS["CATALOG_PRICE_GROUPS_CACHE"]) && isset($GLOBALS["CATALOG_PRICE_GROUPS_CACHE"][$cacheKey]) && is_array($GLOBALS["CATALOG_PRICE_GROUPS_CACHE"][$cacheKey])) { $arPriceGroups = $GLOBALS["CATALOG_PRICE_GROUPS_CACHE"][$cacheKey]; } else { $dbPriceGroupsList = CCatalogGroup::GetList(array("SORT" => "ASC"), array("CAN_ACCESS" => "Y", "LID" => LANGUAGE_ID), array("ID", "NAME_LANG", "SORT"), false, array("ID", "NAME_LANG", "CAN_BUY", "SORT")); while ($arPriceGroupsList = $dbPriceGroupsList->Fetch()) { $arPriceGroups[] = $arPriceGroupsList; $GLOBALS["CATALOG_PRICE_GROUPS_CACHE"][$cacheKey][] = $arPriceGroupsList; } } if (empty($arPriceGroups)) { return false; } $arBorderMap = array(); $arPresentGroups = array(); $bMultiQuantity = False; $dbPrice = CPrice::GetList(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC", "SORT" => "ASC"), array("PRODUCT_ID" => $ID), false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "QUANTITY_FROM", "QUANTITY_TO", "ELEMENT_IBLOCK_ID", "SORT")); while ($arPrice = $dbPrice->Fetch()) { CCatalogDiscountSave::Disable(); $arDiscounts = CCatalogDiscount::GetDiscount($ID, $arPrice["ELEMENT_IBLOCK_ID"], $arPrice["CATALOG_GROUP_ID"], $USER->GetUserGroupArray(), "N", SITE_ID, array()); CCatalogDiscountSave::Enable(); $discountPrice = CCatalogProduct::CountPriceWithDiscount($arPrice["PRICE"], $arPrice["CURRENCY"], $arDiscounts); $arPrice["DISCOUNT_PRICE"] = $discountPrice; if (array_key_exists($arPrice["QUANTITY_FROM"] . "-" . $arPrice["QUANTITY_TO"], $arBorderMap)) { $jnd = $arBorderMap[$arPrice["QUANTITY_FROM"] . "-" . $arPrice["QUANTITY_TO"]]; } else { $jnd = count($arBorderMap); $arBorderMap[$arPrice["QUANTITY_FROM"] . "-" . $arPrice["QUANTITY_TO"]] = $jnd; } $arResult[$jnd]["QUANTITY_FROM"] = DoubleVal($arPrice["QUANTITY_FROM"]); $arResult[$jnd]["QUANTITY_TO"] = DoubleVal($arPrice["QUANTITY_TO"]); if (DoubleVal($arPrice["QUANTITY_FROM"]) > 0 || DoubleVal($arPrice["QUANTITY_TO"]) > 0) { $bMultiQuantity = True; } $arResult[$jnd]["PRICE"][$arPrice["CATALOG_GROUP_ID"]] = $arPrice; } $numGroups = count($arPriceGroups); for ($i = 0; $i < $numGroups; $i++) { $bNeedKill = True; for ($j = 0, $intCount = count($arResult); $j < $intCount; $j++) { if (!array_key_exists($arPriceGroups[$i]["ID"], $arResult[$j]["PRICE"])) { $arResult[$j]["PRICE"][$arPriceGroups[$i]["ID"]] = False; } if ($arResult[$j]["PRICE"][$arPriceGroups[$i]["ID"]] != false) { $bNeedKill = False; } } if ($bNeedKill) { for ($j = 0, $intCount = count($arResult); $j < $intCount; $j++) { unset($arResult[$j]["PRICE"][$arPriceGroups[$i]["ID"]]); } unset($arPriceGroups[$i]); } } return array("COLS" => $arPriceGroups, "MATRIX" => $arResult, "MULTI_QUANTITY" => $bMultiQuantity ? "Y" : "N"); }
/** * @param array $arParams * @return array|false */ public static function GetProductData($arParams) { $adminSection = defined('ADMIN_SECTION') && ADMIN_SECTION === true; if (!isset($arParams['QUANTITY']) || (double) $arParams['QUANTITY'] <= 0) { $arParams['QUANTITY'] = 0; } $arParams['RENEWAL'] = isset($arParams['RENEWAL']) && $arParams['RENEWAL'] == 'Y' ? 'Y' : 'N'; $arParams['CHECK_QUANTITY'] = isset($arParams['CHECK_QUANTITY']) && $arParams["CHECK_QUANTITY"] == 'N' ? 'N' : 'Y'; $arParams['CHECK_PRICE'] = isset($arParams['CHECK_PRICE']) && $arParams['CHECK_PRICE'] == 'N' ? 'N' : 'Y'; $arParams['CHECK_COUPONS'] = isset($arParams['CHECK_COUPONS']) && $arParams['CHECK_COUPONS'] == 'N' ? 'N' : 'Y'; $arParams['CHECK_DISCOUNT'] = isset($arParams['CHECK_DISCOUNT']) && $arParams['CHECK_DISCOUNT'] == 'N' ? 'N' : 'Y'; $arParams['SELECT_QUANTITY_TRACE'] = isset($arParams['SELECT_QUANTITY_TRACE']) && $arParams['SELECT_QUANTITY_TRACE'] == 'Y' ? 'Y' : 'N'; $arParams['BASKET_ID'] = (string) (isset($arParams['BASKET_ID']) ? $arParams['BASKET_ID'] : '0'); $arParams['USER_ID'] = isset($arParams['USER_ID']) ? (int) $arParams['USER_ID'] : 0; if ($arParams['USER_ID'] < 0) { $arParams['USER_ID'] = 0; } $arParams['SITE_ID'] = isset($arParams['SITE_ID']) ? $arParams['SITE_ID'] : false; $strSiteID = $arParams['SITE_ID']; $arParams['CURRENCY'] = isset($arParams['CURRENCY']) ? Currency\CurrencyManager::checkCurrencyID($arParams['CURRENCY']) : false; if ($arParams['CURRENCY'] === false) { $arParams['CURRENCY'] = CSaleLang::GetLangCurrency($strSiteID ? $strSiteID : SITE_ID); } $productID = (int) $arParams['PRODUCT_ID']; $quantity = (double) $arParams['QUANTITY']; $intUserID = (int) $arParams['USER_ID']; global $USER, $APPLICATION; $arResult = array(); if ($adminSection) { if (!($userGroups = static::getHitCache('USER_GROUPS', $intUserID))) { $userGroups = self::getUserGroups($intUserID); static::setHitCache('USER_GROUPS', $intUserID, $userGroups); } if (empty($userGroups)) { return $arResult; } if (!($arProduct = static::getHitCache('IBLOCK_ELEMENT_PERM_N', $productID))) { $dbIBlockElement = CIBlockElement::GetList(array(), array('ID' => $productID, 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')); if ($arProduct = $dbIBlockElement->GetNext()) { static::setHitCache('IBLOCK_ELEMENT_PERM_N', $productID, $arProduct); } unset($dbIBlockElement); } if (empty($arProduct) || !is_array($arProduct)) { return $arResult; } if (!($iblockRights = static::getHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID']))) { if ($iblockRights = CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'RIGHTS_MODE')) { static::setHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID'], $iblockRights); } } $extRights = $iblockRights == 'E'; if ($intUserID == 0) { if ($extRights) { $elementRights = new CIBlockElementRights($arProduct['IBLOCK_ID'], $arProduct['ID']); $readList = $elementRights->GetRights(array('operations' => array('element_read'))); $disable = true; if (!empty($readList) && is_array($readList)) { foreach ($readList as &$row) { if ($row['GROUP_CODE'] == 'G2') { $disable = false; break; } } unset($row); } unset($readList, $elementRights); if ($disable) { return $arResult; } unset($disable); } else { $groupRights = CIBlock::GetGroupPermissions($arProduct['IBLOCK_ID']); if (empty($groupRights) || !isset($groupRights[2]) || $groupRights[2] < 'R') { return $arResult; } unset($groupRights); } } else { if ($extRights) { $proxyUserPermissionKey = $productID . "|" . $intUserID; if (!($arUserRights = static::getHitCache('USER_RIGHT', $proxyUserPermissionKey))) { if ($arUserRights = CIBlockElementRights::GetUserOperations($productID, $intUserID)) { static::setHitCache('USER_RIGHT', $proxyUserPermissionKey, $arUserRights); } } if (empty($arUserRights) || !isset($arUserRights['element_read'])) { return $arResult; } unset($arUserRights); } else { static $permissions = array(); if (empty($permissions[$arProduct['IBLOCK_ID'] . "_" . $intUserID])) { $permissions[$arProduct['IBLOCK_ID'] . "_" . $intUserID] = CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID); } if ($permissions < 'R') { return $arResult; } } } unset($extRights); } else { $userGroups = $USER->GetUserGroupArray(); if (!($arProduct = static::getHitCache('IBLOCK_ELEMENT_PERM_Y', $productID))) { $dbIBlockElement = CIBlockElement::GetList(array(), array('ID' => $productID, 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'CHECK_PERMISSIONS' => 'Y', 'MIN_PERMISSION' => 'R'), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL')); if ($arProduct = $dbIBlockElement->GetNext()) { static::setHitCache('IBLOCK_ELEMENT_PERM_Y', $productID, $arProduct); } unset($dbIBlockElement); } if (empty($arProduct) || !is_array($arProduct)) { return $arResult; } } if (!isset(self::$catalogList[$arProduct['IBLOCK_ID']])) { self::$catalogList[$arProduct['IBLOCK_ID']] = Catalog\CatalogIblockTable::getList(array('select' => array('IBLOCK_ID', 'SUBSCRIPTION'), 'filter' => array('=IBLOCK_ID' => $arProduct['IBLOCK_ID'])))->fetch(); } if (empty(self::$catalogList[$arProduct['IBLOCK_ID']]) || !is_array(self::$catalogList[$arProduct['IBLOCK_ID']])) { return $arResult; } if (self::$catalogList[$arProduct['IBLOCK_ID']]['SUBSCRIPTION'] == 'Y') { $quantity = 1; } if (!($arCatalogProduct = static::getHitCache('CATALOG_PRODUCT', $productID))) { $rsProducts = CCatalogProduct::GetList(array(), array('ID' => $productID), false, false, array('ID', 'CAN_BUY_ZERO', 'QUANTITY_TRACE', 'QUANTITY', 'WEIGHT', 'WIDTH', 'HEIGHT', 'LENGTH', 'BARCODE_MULTI', 'TYPE')); if ($arCatalogProduct = $rsProducts->Fetch()) { static::setHitCache('CATALOG_PRODUCT', $productID, $arCatalogProduct); } unset($rsProducts); } if (!empty($arCatalogProduct) && is_array($arCatalogProduct)) { $dblQuantity = doubleval($arCatalogProduct["QUANTITY"]); $boolQuantity = 'Y' != $arCatalogProduct["CAN_BUY_ZERO"] && 'Y' == $arCatalogProduct["QUANTITY_TRACE"]; if ($arParams["CHECK_QUANTITY"] == "Y" && $boolQuantity && 0 >= $dblQuantity) { $APPLICATION->ThrowException(Loc::getMessage("CATALOG_NO_QUANTITY_PRODUCT", array("#NAME#" => htmlspecialcharsbx($arProduct["~NAME"]))), "CATALOG_NO_QUANTITY_PRODUCT"); return $arResult; } } else { $APPLICATION->ThrowException(Loc::getMessage("CATALOG_ERR_NO_PRODUCT"), "CATALOG_NO_QUANTITY_PRODUCT"); return $arResult; } if ($arParams["CHECK_PRICE"] == "Y") { $productHash = array('MODULE' => 'catalog', 'PRODUCT_ID' => $productID, 'BASKET_ID' => $arParams['BASKET_ID']); $arCoupons = array(); if ($arParams['CHECK_COUPONS'] == 'Y') { $arCoupons = DiscountCouponsManager::getForApply(array(), $productHash, true); if (!empty($arCoupons)) { $arCoupons = array_keys($arCoupons); } } if ($adminSection) { if ($intUserID > 0) { CCatalogDiscountSave::SetDiscountUserID($intUserID); } else { CCatalogDiscountSave::Disable(); } } $currentVatMode = CCatalogProduct::getPriceVatIncludeMode(); $currentUseDiscount = CCatalogProduct::getUseDiscount(); CCatalogProduct::setUseDiscount($arParams['CHECK_DISCOUNT'] == 'Y'); CCatalogProduct::setPriceVatIncludeMode(true); CCatalogProduct::setUsedCurrency($arParams['CURRENCY']); $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $userGroups, $arParams['RENEWAL'], array(), $adminSection ? $strSiteID : false, $arCoupons); if (empty($arPrice)) { if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, $userGroups)) { $quantity = $nearestQuantity; $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $userGroups, $arParams['RENEWAL'], array(), $adminSection ? $strSiteID : false, $arCoupons); } } CCatalogProduct::clearUsedCurrency(); CCatalogProduct::setPriceVatIncludeMode($currentVatMode); CCatalogProduct::setUseDiscount($currentUseDiscount); unset($userGroups, $currentUseDiscount, $currentVatMode); if ($adminSection) { if ($intUserID > 0) { CCatalogDiscountSave::ClearDiscountUserID(); } else { CCatalogDiscountSave::Enable(); } } if (empty($arPrice)) { return $arResult; } $arDiscountList = array(); if (empty($arPrice['DISCOUNT_LIST']) && !empty($arPrice['DISCOUNT']) && is_array($arPrice['DISCOUNT'])) { $arPrice['DISCOUNT_LIST'] = array($arPrice['DISCOUNT']); } if (!empty($arPrice['DISCOUNT_LIST'])) { $appliedCoupons = array(); foreach ($arPrice['DISCOUNT_LIST'] as &$arOneDiscount) { $arOneList = array('ID' => $arOneDiscount['ID'], 'NAME' => $arOneDiscount['NAME'], 'COUPON' => '', 'COUPON_TYPE' => '', 'USE_COUPONS' => isset($arOneDiscount['USE_COUPONS']) ? $arOneDiscount['USE_COUPONS'] : 'N', 'MODULE_ID' => isset($oneDiscount['MODULE_ID']) ? $oneDiscount['MODULE_ID'] : 'catalog', 'TYPE' => $arOneDiscount['TYPE'], 'VALUE' => $arOneDiscount['VALUE'], 'VALUE_TYPE' => $arOneDiscount['VALUE_TYPE'], 'MAX_VALUE' => $arOneDiscount['VALUE_TYPE'] == Catalog\DiscountTable::VALUE_TYPE_PERCENT ? $arOneDiscount['MAX_DISCOUNT'] : 0, 'CURRENCY' => $arOneDiscount['CURRENCY'], 'HANDLERS' => isset($arOneDiscount['HANDLERS']) ? $arOneDiscount['HANDLERS'] : array()); if (!empty($arOneDiscount['COUPON'])) { $arOneList['USE_COUPONS'] = 'Y'; $arOneList['COUPON'] = $arOneDiscount['COUPON']; $arOneList['COUPON_TYPE'] = $arOneDiscount['COUPON_ONE_TIME']; $appliedCoupons[] = $arOneDiscount['COUPON']; } $arDiscountList[] = $arOneList; } unset($arOneList, $arOneDiscount); if (!empty($appliedCoupons)) { $resultApply = DiscountCouponsManager::setApplyByProduct($productHash, $appliedCoupons); } unset($resultApply, $appliedCoupons); } if (empty($arPrice['PRICE']['CATALOG_GROUP_NAME'])) { if (!empty($arPrice['PRICE']['CATALOG_GROUP_ID'])) { $priceName = self::getPriceTitle($arPrice['PRICE']['CATALOG_GROUP_ID']); if ($priceName != '') { $arPrice['PRICE']['CATALOG_GROUP_NAME'] = $priceName; } unset($priceName); } } } else { $vatRate = 0.0; if (!($arVAT = static::getHitCache('VAT_INFO', $productID))) { $rsVAT = CCatalogProduct::GetVATInfo($productID); if ($arVAT = $rsVAT->Fetch()) { static::setHitCache('VAT_INFO', $productID, $arVAT); } unset($rsVAT); } if (!empty($arVAT) && is_array($arVAT)) { $vatRate = (double) $arVAT['RATE'] * 0.01; } } $arResult = array("NAME" => $arProduct["~NAME"], "CAN_BUY" => "Y", "DETAIL_PAGE_URL" => $arProduct['~DETAIL_PAGE_URL'], "BARCODE_MULTI" => $arCatalogProduct["BARCODE_MULTI"], "WEIGHT" => (double) $arCatalogProduct['WEIGHT'], "DIMENSIONS" => serialize(array("WIDTH" => $arCatalogProduct["WIDTH"], "HEIGHT" => $arCatalogProduct["HEIGHT"], "LENGTH" => $arCatalogProduct["LENGTH"])), "TYPE" => $arCatalogProduct["TYPE"] == CCatalogProduct::TYPE_SET ? CCatalogProductSet::TYPE_SET : null); if ($arParams['SELECT_QUANTITY_TRACE'] == "Y") { $arResult["QUANTITY_TRACE"] = $arCatalogProduct["QUANTITY_TRACE"]; } if ($arParams["CHECK_QUANTITY"] == "Y") { $arResult["QUANTITY"] = $boolQuantity && $dblQuantity < $quantity ? $dblQuantity : $quantity; } else { $arResult["QUANTITY"] = $arParams["QUANTITY"]; } if ($arParams["CHECK_QUANTITY"] == "Y" && $boolQuantity && $dblQuantity < $quantity) { $APPLICATION->ThrowException(Loc::getMessage("CATALOG_QUANTITY_NOT_ENOGH", array("#NAME#" => htmlspecialcharsbx($arProduct["~NAME"]), "#CATALOG_QUANTITY#" => $arCatalogProduct["QUANTITY"], "#QUANTITY#" => $quantity)), "CATALOG_QUANTITY_NOT_ENOGH"); } if ($arParams['CHECK_PRICE'] == 'Y') { $arResult['PRODUCT_PRICE_ID'] = $arPrice['PRICE']['ID']; $arResult['NOTES'] = $arPrice['PRICE']['CATALOG_GROUP_NAME']; $arResult['VAT_RATE'] = $arPrice['PRICE']['VAT_RATE']; $arResult['DISCOUNT_NAME'] = ''; $arResult['DISCOUNT_COUPON'] = ''; $arResult['DISCOUNT_LIST'] = array(); if (empty($arPrice['RESULT_PRICE']) || !is_array($arPrice['RESULT_PRICE'])) { $arPrice['RESULT_PRICE'] = CCatalogDiscount::calculateDiscountList($arPrice['PRICE'], $arParams['CURRENCY'], $arDiscountList, true); } $arResult['BASE_PRICE'] = $arPrice['RESULT_PRICE']['BASE_PRICE']; $arResult['PRICE'] = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE']; $arResult['CURRENCY'] = $arPrice['RESULT_PRICE']['CURRENCY']; $arResult['DISCOUNT_PRICE'] = $arPrice['RESULT_PRICE']['DISCOUNT']; if (isset($arPrice['RESULT_PRICE']['PERCENT'])) { $arResult['DISCOUNT_VALUE'] = $arPrice['RESULT_PRICE']['PERCENT'] > 0 ? $arPrice['RESULT_PRICE']['PERCENT'] . '%' : 0; } else { $arResult['DISCOUNT_VALUE'] = $arPrice['RESULT_PRICE']['DISCOUNT_VALUE']; } if (!empty($arDiscountList)) { $arResult['DISCOUNT_LIST'] = $arDiscountList; } if (!empty($arPrice['DISCOUNT'])) { $arResult['DISCOUNT_NAME'] = '[' . $arPrice['DISCOUNT']['ID'] . '] ' . $arPrice['DISCOUNT']['NAME']; if (!empty($arPrice['DISCOUNT']['COUPON'])) { $arResult['DISCOUNT_COUPON'] = $arPrice['DISCOUNT']['COUPON']; } if (empty($arResult['DISCOUNT_LIST'])) { $arResult['DISCOUNT_LIST'] = array($arPrice['DISCOUNT']); } } } else { $arResult['VAT_RATE'] = $vatRate; } $arResult["VAT_INCLUDED"] = "Y"; return $arResult; }
public static function GetItemPrices($IBLOCK_ID, $arCatalogPrices, $arItem, $bVATInclude = true, $arCurrencyParams = array(), $USER_ID = 0, $LID = SITE_ID) { $arPrices = array(); if (empty($arCatalogPrices) || !is_array($arCatalogPrices)) { return $arPrices; } global $USER; static $arCurUserGroups = array(); static $strBaseCurrency = ''; if (self::$catalogIncluded === null) self::$catalogIncluded = \Freetrix\Main\Loader::includeModule('catalog'); if (self::$catalogIncluded) { $USER_ID = intval($USER_ID); $intUserID = $USER_ID; if (0 >= $intUserID) $intUserID = $USER->GetID(); if (!isset($arCurUserGroups[$intUserID])) { $arUserGroups = (0 < $USER_ID ? CUser::GetUserGroup($USER_ID) : $USER->GetUserGroupArray()); CatalogClearArray($arUserGroups); $arCurUserGroups[$intUserID] = $arUserGroups; } else { $arUserGroups = $arCurUserGroups[$intUserID]; } $boolConvert = false; $strCurrencyID = ''; if (isset($arCurrencyParams['CURRENCY_ID']) && !empty($arCurrencyParams['CURRENCY_ID'])) { $boolConvert = true; $strCurrencyID = $arCurrencyParams['CURRENCY_ID']; } if (!$boolConvert && '' == $strBaseCurrency) $strBaseCurrency = CCurrency::GetBaseCurrency(); $strMinCode = ''; $boolStartMin = true; $dblMinPrice = 0; $strMinCurrency = ($boolConvert ? $strCurrencyID : $strBaseCurrency); CCatalogDiscountSave::Disable(); foreach($arCatalogPrices as $key => $value) { if($value["CAN_VIEW"] && strlen($arItem["CATALOG_PRICE_".$value["ID"]]) > 0) { // get final price with VAT included. if ($arItem['CATALOG_VAT_INCLUDED'] != 'Y') { $arItem['CATALOG_PRICE_'.$value['ID']] *= (1 + $arItem['CATALOG_VAT'] * 0.01); } // so discounts will include VAT $arDiscounts = CCatalogDiscount::GetDiscount( $arItem["ID"], $arItem["IBLOCK_ID"], array($value["ID"]), $arUserGroups, "N", $LID, array() ); $discountPrice = CCatalogProduct::CountPriceWithDiscount( $arItem["CATALOG_PRICE_".$value["ID"]], $arItem["CATALOG_CURRENCY_".$value["ID"]], $arDiscounts ); // get clear prices WO VAT $arItem['CATALOG_PRICE_'.$value['ID']] /= (1 + $arItem['CATALOG_VAT'] * 0.01); $discountPrice /= (1 + $arItem['CATALOG_VAT'] * 0.01); $vat_value_discount = $discountPrice * $arItem['CATALOG_VAT'] * 0.01; $vat_discountPrice = $discountPrice + $vat_value_discount; $vat_value = $arItem['CATALOG_PRICE_'.$value['ID']] * $arItem['CATALOG_VAT'] * 0.01; $vat_price = $arItem["CATALOG_PRICE_".$value["ID"]] + $vat_value; if ($boolConvert && $strCurrencyID != $arItem["CATALOG_CURRENCY_".$value["ID"]]) { $strOrigCurrencyID = $arItem["CATALOG_CURRENCY_".$value["ID"]]; $dblOrigNoVat = $arItem["CATALOG_PRICE_".$value["ID"]]; $dblNoVat = CCurrencyRates::ConvertCurrency($dblOrigNoVat, $strOrigCurrencyID, $strCurrencyID); $dblVatPrice = CCurrencyRates::ConvertCurrency($vat_price, $strOrigCurrencyID, $strCurrencyID); $dblVatValue = CCurrencyRates::ConvertCurrency($vat_value, $strOrigCurrencyID, $strCurrencyID); $dblDiscountValueNoVat = CCurrencyRates::ConvertCurrency($discountPrice, $strOrigCurrencyID, $strCurrencyID); $dblVatDiscountPrice = CCurrencyRates::ConvertCurrency($vat_discountPrice, $strOrigCurrencyID, $strCurrencyID); $dblDiscountValueVat = CCurrencyRates::ConvertCurrency($vat_value_discount, $strOrigCurrencyID, $strCurrencyID); $arPrices[$key] = array( 'ORIG_VALUE_NOVAT' => $dblOrigNoVat, "VALUE_NOVAT" => $dblNoVat, "PRINT_VALUE_NOVAT" => CCurrencyLang::CurrencyFormat($dblNoVat, $strCurrencyID, true), 'ORIG_VALUE_VAT' => $vat_price, "VALUE_VAT" => $dblVatPrice, "PRINT_VALUE_VAT" => CCurrencyLang::CurrencyFormat($dblVatPrice, $strCurrencyID, true), 'ORIG_VATRATE_VALUE' => $vat_value, "VATRATE_VALUE" => $dblVatValue, "PRINT_VATRATE_VALUE" => CCurrencyLang::CurrencyFormat($dblVatValue, $strCurrencyID, true), 'ORIG_DISCOUNT_VALUE_NOVAT' => $discountPrice, "DISCOUNT_VALUE_NOVAT" => $dblDiscountValueNoVat, "PRINT_DISCOUNT_VALUE_NOVAT" => CCurrencyLang::CurrencyFormat($dblDiscountValueNoVat, $strCurrencyID, true), "ORIG_DISCOUNT_VALUE_VAT" => $vat_discountPrice, "DISCOUNT_VALUE_VAT" => $dblVatDiscountPrice, "PRINT_DISCOUNT_VALUE_VAT" => CCurrencyLang::CurrencyFormat($dblVatDiscountPrice, $strCurrencyID, true), 'ORIG_DISCOUNT_VATRATE_VALUE' => $vat_value_discount, 'DISCOUNT_VATRATE_VALUE' => $dblDiscountValueVat, 'PRINT_DISCOUNT_VATRATE_VALUE' => CCurrencyLang::CurrencyFormat($dblDiscountValueVat, $strCurrencyID, true), 'ORIG_CURRENCY' => $strOrigCurrencyID, "CURRENCY" => $strCurrencyID, ); } else { $strPriceCurrency = $arItem["CATALOG_CURRENCY_".$value["ID"]]; $arPrices[$key] = array( "VALUE_NOVAT" => $arItem["CATALOG_PRICE_".$value["ID"]], "PRINT_VALUE_NOVAT" => CCurrencyLang::CurrencyFormat($arItem["CATALOG_PRICE_".$value["ID"]], $strPriceCurrency, true), "VALUE_VAT" => $vat_price, "PRINT_VALUE_VAT" => CCurrencyLang::CurrencyFormat($vat_price, $strPriceCurrency, true), "VATRATE_VALUE" => $vat_value, "PRINT_VATRATE_VALUE" => CCurrencyLang::CurrencyFormat($vat_value, $strPriceCurrency, true), "DISCOUNT_VALUE_NOVAT" => $discountPrice, "PRINT_DISCOUNT_VALUE_NOVAT" => CCurrencyLang::CurrencyFormat($discountPrice, $strPriceCurrency, true), "DISCOUNT_VALUE_VAT" => $vat_discountPrice, "PRINT_DISCOUNT_VALUE_VAT" => CCurrencyLang::CurrencyFormat($vat_discountPrice, $strPriceCurrency, true), 'DISCOUNT_VATRATE_VALUE' => $vat_value_discount, 'PRINT_DISCOUNT_VATRATE_VALUE' => CCurrencyLang::CurrencyFormat($vat_value_discount, $strPriceCurrency, true), "CURRENCY" => $arItem["CATALOG_CURRENCY_".$value["ID"]], ); } $arPrices[$key]["ID"] = $arItem["CATALOG_PRICE_ID_".$value["ID"]]; $arPrices[$key]["CAN_ACCESS"] = $arItem["CATALOG_CAN_ACCESS_".$value["ID"]]; $arPrices[$key]["CAN_BUY"] = $arItem["CATALOG_CAN_BUY_".$value["ID"]]; $arPrices[$key]['MIN_PRICE'] = 'N'; if ($bVATInclude) { $arPrices[$key]['VALUE'] = $arPrices[$key]['VALUE_VAT']; $arPrices[$key]['PRINT_VALUE'] = $arPrices[$key]['PRINT_VALUE_VAT']; $arPrices[$key]['DISCOUNT_VALUE'] = $arPrices[$key]['DISCOUNT_VALUE_VAT']; $arPrices[$key]['PRINT_DISCOUNT_VALUE'] = $arPrices[$key]['PRINT_DISCOUNT_VALUE_VAT']; } else { $arPrices[$key]['VALUE'] = $arPrices[$key]['VALUE_NOVAT']; $arPrices[$key]['PRINT_VALUE'] = $arPrices[$key]['PRINT_VALUE_NOVAT']; $arPrices[$key]['DISCOUNT_VALUE'] = $arPrices[$key]['DISCOUNT_VALUE_NOVAT']; $arPrices[$key]['PRINT_DISCOUNT_VALUE'] = $arPrices[$key]['PRINT_DISCOUNT_VALUE_NOVAT']; } if (roundEx($arPrices[$key]['VALUE'], 2) == roundEx($arPrices[$key]['DISCOUNT_VALUE'], 2)) { $arPrices[$key]['DISCOUNT_DIFF'] = 0; $arPrices[$key]['DISCOUNT_DIFF_PERCENT'] = 0; $arPrices[$key]['PRINT_DISCOUNT_DIFF'] = CCurrencyLang::CurrencyFormat(0, $arPrices[$key]['CURRENCY'], true); } else { $arPrices[$key]['DISCOUNT_DIFF'] = $arPrices[$key]['VALUE'] - $arPrices[$key]['DISCOUNT_VALUE']; $arPrices[$key]['DISCOUNT_DIFF_PERCENT'] = roundEx(100*$arPrices[$key]['DISCOUNT_DIFF']/$arPrices[$key]['VALUE'], 0); $arPrices[$key]['PRINT_DISCOUNT_DIFF'] = CCurrencyLang::CurrencyFormat($arPrices[$key]['DISCOUNT_DIFF'], $arPrices[$key]['CURRENCY'], true); } if ($value["CAN_VIEW"]) { if ($boolStartMin) { $dblMinPrice = ($boolConvert || ($arPrices[$key]['CURRENCY'] == $strMinCurrency) ? $arPrices[$key]['DISCOUNT_VALUE'] : CCurrencyRates::ConvertCurrency($arPrices[$key]['DISCOUNT_VALUE'], $arPrices[$key]['CURRENCY'], $strMinCurrency) ); $strMinCode = $key; $boolStartMin = false; } else { $dblComparePrice = ($boolConvert || ($arPrices[$key]['CURRENCY'] == $strMinCurrency) ? $arPrices[$key]['DISCOUNT_VALUE'] : CCurrencyRates::ConvertCurrency($arPrices[$key]['DISCOUNT_VALUE'], $arPrices[$key]['CURRENCY'], $strMinCurrency) ); if ($dblMinPrice > $dblComparePrice) { $dblMinPrice = $dblComparePrice; $strMinCode = $key; } } } } } if ('' != $strMinCode) $arPrices[$strMinCode]['MIN_PRICE'] = 'Y'; CCatalogDiscountSave::Enable(); } else { $strMinCode = ''; $boolStartMin = true; $dblMinPrice = 0; foreach($arCatalogPrices as $key => $value) { if($value["CAN_VIEW"]) { $dblValue = round(doubleval($arItem["PROPERTY_".$value["ID"]."_VALUE"]), 2); if ($boolStartMin) { $dblMinPrice = $dblValue; $strMinCode = $key; $boolStartMin = false; } else { if ($dblMinPrice > $dblValue) { $dblMinPrice = $dblValue; $strMinCode = $key; } } $arPrices[$key] = array( "ID" => $arItem["PROPERTY_".$value["ID"]."_VALUE_ID"], "VALUE" => $dblValue, "PRINT_VALUE" => $dblValue." ".$arItem["PROPERTY_".$value["ID"]."_DESCRIPTION"], "DISCOUNT_VALUE" => $dblValue, "PRINT_DISCOUNT_VALUE" => $dblValue." ".$arItem["PROPERTY_".$value["ID"]."_DESCRIPTION"], "CURRENCY" => $arItem["PROPERTY_".$value["ID"]."_DESCRIPTION"], "CAN_ACCESS" => true, "CAN_BUY" => false, 'DISCOUNT_DIFF_PERCENT' => 0, 'DISCOUNT_DIFF' => 0, 'PRINT_DISCOUNT_DIFF' => '0 '.$arItem["PROPERTY_".$value["ID"]."_DESCRIPTION"], "MIN_PRICE" => "N" ); } } if ('' != $strMinCode) $arPrices[$strMinCode]['MIN_PRICE'] = 'Y'; } return $arPrices; }
public static function GetItemPrices($IBLOCK_ID, $arCatalogPrices, $arItem, $bVATInclude = true, $arCurrencyParams = array(), $USER_ID = 0, $LID = SITE_ID) { static $arCurUserGroups = array(); global $USER; $arPrices = array(); if(CModule::IncludeModule("catalog")) { $USER_ID = intval($USER_ID); $intUserID = $USER_ID; if (0 >= $intUserID) $intUserID = $USER->GetID(); if (!array_key_exists($intUserID, $arCurUserGroups)) { $arCurUserGroups[$intUserID] = (0 < $USER_ID ? CUser::GetUserGroup($USER_ID) : $USER->GetUserGroupArray()); } $arUserGroups = $arCurUserGroups[$intUserID]; $boolConvert = false; $strCurrencyID = ''; if (is_array($arCurrencyParams) && !empty($arCurrencyParams) && !empty($arCurrencyParams['CURRENCY_ID'])) { $boolConvert = true; $strCurrencyID = $arCurrencyParams['CURRENCY_ID']; } foreach($arCatalogPrices as $key => $value) { if($value["CAN_VIEW"] && strlen($arItem["CATALOG_PRICE_".$value["ID"]]) > 0) { // get final price with VAT included. if ($arItem['CATALOG_VAT_INCLUDED'] != 'Y') { $arItem['CATALOG_PRICE_'.$value['ID']] *= (1 + $arItem['CATALOG_VAT'] * 0.01); } CCatalogDiscountSave::Disable(); // so discounts will include VAT $arDiscounts = CCatalogDiscount::GetDiscount( $arItem["ID"], $arItem["IBLOCK_ID"], array($value["ID"]), $arUserGroups, "N", $LID, array() ); CCatalogDiscountSave::Enable(); $discountPrice = CCatalogProduct::CountPriceWithDiscount( $arItem["CATALOG_PRICE_".$value["ID"]], $arItem["CATALOG_CURRENCY_".$value["ID"]], $arDiscounts ); // get clear prices WO VAT $arItem['CATALOG_PRICE_'.$value['ID']] /= (1 + $arItem['CATALOG_VAT'] * 0.01); $discountPrice /= (1 + $arItem['CATALOG_VAT'] * 0.01); $vat_value_discount = $discountPrice * $arItem['CATALOG_VAT'] * 0.01; $vat_discountPrice = $discountPrice + $vat_value_discount; $vat_value = $arItem['CATALOG_PRICE_'.$value['ID']] * $arItem['CATALOG_VAT'] * 0.01; $vat_price = $arItem["CATALOG_PRICE_".$value["ID"]] + $vat_value; if ($boolConvert && $strCurrencyID != $arItem["CATALOG_CURRENCY_".$value["ID"]]) { $strOrigCurrencyID = $arItem["CATALOG_CURRENCY_".$value["ID"]]; $dblOrigNoVat = $arItem["CATALOG_PRICE_".$value["ID"]]; $dblNoVat = CCurrencyRates::ConvertCurrency($dblOrigNoVat, $strOrigCurrencyID, $strCurrencyID); $dblVatPrice = CCurrencyRates::ConvertCurrency($vat_price, $strOrigCurrencyID, $strCurrencyID); $dblVatValue = CCurrencyRates::ConvertCurrency($vat_value, $strOrigCurrencyID, $strCurrencyID); $dblDiscountValueNoVat = CCurrencyRates::ConvertCurrency($discountPrice, $strOrigCurrencyID, $strCurrencyID); $dblVatDiscountPrice = CCurrencyRates::ConvertCurrency($vat_discountPrice, $strOrigCurrencyID, $strCurrencyID); $dblDiscountValueVat = CCurrencyRates::ConvertCurrency($vat_value_discount, $strOrigCurrencyID, $strCurrencyID); $arPrices[$key] = array( 'ORIG_VALUE_NOVAT' => $dblOrigNoVat, "VALUE_NOVAT" => $dblNoVat, "PRINT_VALUE_NOVAT" => FormatCurrency($dblNoVat, $strCurrencyID), 'ORIG_VALUE_VAT' => $vat_price, "VALUE_VAT" => $dblVatPrice, "PRINT_VALUE_VAT" => FormatCurrency($dblVatPrice, $strCurrencyID), 'ORIG_VATRATE_VALUE' => $vat_value, "VATRATE_VALUE" => $dblVatValue, "PRINT_VATRATE_VALUE" => FormatCurrency($dblVatValue, $strCurrencyID), 'ORIG_DISCOUNT_VALUE_NOVAT' => $discountPrice, "DISCOUNT_VALUE_NOVAT" => $dblDiscountValueNoVat, "PRINT_DISCOUNT_VALUE_NOVAT" => FormatCurrency($dblDiscountValueNoVat, $strCurrencyID), "ORIG_DISCOUNT_VALUE_VAT" => $vat_discountPrice, "DISCOUNT_VALUE_VAT" => $dblVatDiscountPrice, "PRINT_DISCOUNT_VALUE_VAT" => FormatCurrency($dblVatDiscountPrice, $strCurrencyID), 'ORIG_DISCOUNT_VATRATE_VALUE' => $vat_value_discount, 'DISCOUNT_VATRATE_VALUE' => $dblDiscountValueVat, 'PRINT_DISCOUNT_VATRATE_VALUE' => FormatCurrency($dblDiscountValueVat, $strCurrencyID), 'ORIG_CURRENCY' => $strOrigCurrencyID, "CURRENCY" => $strCurrencyID, ); } else { $arPrices[$key] = array( "VALUE_NOVAT" => $arItem["CATALOG_PRICE_".$value["ID"]], "PRINT_VALUE_NOVAT" => FormatCurrency($arItem["CATALOG_PRICE_".$value["ID"]],$arItem["CATALOG_CURRENCY_".$value["ID"]]), "VALUE_VAT" => $vat_price, "PRINT_VALUE_VAT" => FormatCurrency($vat_price, $arItem["CATALOG_CURRENCY_".$value["ID"]]), "VATRATE_VALUE" => $vat_value, "PRINT_VATRATE_VALUE" => FormatCurrency($vat_value, $arItem["CATALOG_CURRENCY_".$value["ID"]]), "DISCOUNT_VALUE_NOVAT" => $discountPrice, "PRINT_DISCOUNT_VALUE_NOVAT" => FormatCurrency($discountPrice, $arItem["CATALOG_CURRENCY_".$value["ID"]]), "DISCOUNT_VALUE_VAT" => $vat_discountPrice, "PRINT_DISCOUNT_VALUE_VAT" => FormatCurrency($vat_discountPrice, $arItem["CATALOG_CURRENCY_".$value["ID"]]), 'DISCOUNT_VATRATE_VALUE' => $vat_value_discount, 'PRINT_DISCOUNT_VATRATE_VALUE' => FormatCurrency($vat_value_discount, $arItem["CATALOG_CURRENCY_".$value["ID"]]), "CURRENCY" => $arItem["CATALOG_CURRENCY_".$value["ID"]], ); } $arPrices[$key]["ID"] = $arItem["CATALOG_PRICE_ID_".$value["ID"]]; $arPrices[$key]["CAN_ACCESS"] = $arItem["CATALOG_CAN_ACCESS_".$value["ID"]]; $arPrices[$key]["CAN_BUY"] = $arItem["CATALOG_CAN_BUY_".$value["ID"]]; if ($bVATInclude) { $arPrices[$key]['VALUE'] = $arPrices[$key]['VALUE_VAT']; $arPrices[$key]['PRINT_VALUE'] = $arPrices[$key]['PRINT_VALUE_VAT']; $arPrices[$key]['DISCOUNT_VALUE'] = $arPrices[$key]['DISCOUNT_VALUE_VAT']; $arPrices[$key]['PRINT_DISCOUNT_VALUE'] = $arPrices[$key]['PRINT_DISCOUNT_VALUE_VAT']; } else { $arPrices[$key]['VALUE'] = $arPrices[$key]['VALUE_NOVAT']; $arPrices[$key]['PRINT_VALUE'] = $arPrices[$key]['PRINT_VALUE_NOVAT']; $arPrices[$key]['DISCOUNT_VALUE'] = $arPrices[$key]['DISCOUNT_VALUE_NOVAT']; $arPrices[$key]['PRINT_DISCOUNT_VALUE'] = $arPrices[$key]['PRINT_DISCOUNT_VALUE_NOVAT']; } } } } else { foreach($arCatalogPrices as $key => $value) { if($value["CAN_VIEW"]) { $arPrices[$key] = array( "ID" => $arItem["PROPERTY_".$value["ID"]."_VALUE_ID"], "VALUE" => round(doubleval($arItem["PROPERTY_".$value["ID"]."_VALUE"]),2), "PRINT_VALUE" => round(doubleval($arItem["PROPERTY_".$value["ID"]."_VALUE"]),2)." ".$arItem["PROPERTY_".$value["ID"]."_DESCRIPTION"], "DISCOUNT_VALUE" => round(doubleval($arItem["PROPERTY_".$value["ID"]."_VALUE"]),2), "PRINT_DISCOUNT_VALUE" => round(doubleval($arItem["PROPERTY_".$value["ID"]."_VALUE"]),2)." ".$arItem["PROPERTY_".$value["ID"]."_DESCRIPTION"], "CURRENCY" => $arItem["PROPERTY_".$value["ID"]."_DESCRIPTION"], "CAN_ACCESS" => true, "CAN_BUY" => false, ); } } } return $arPrices; }
/** * <p>Метод выполняет профиль <i>profile_id</i> на агенте.</p> * * * * * @param int $profile_id Код выполняемого профиля. * * * * @return mixed <p>В случае успешного выполнения профиля импорта метод возвращает * строку для следующего вызова агента. В противном случае метод * вернет <i>false</i>.</p><br><br> * * @static * @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogimport/pregenerateimport.php * @author Bitrix */ public static function PreGenerateImport($profile_id) { global $DB; $profile_id = intval($profile_id); if ($profile_id <= 0) return false; $ar_profile = CCatalogImport::GetByID($profile_id); if ((!$ar_profile) || ('Y' == $ar_profile['NEED_EDIT'])) return false; $strFile = CATALOG_PATH2IMPORTS.$ar_profile["FILE_NAME"]."_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"].$strFile)) { $strFile = CATALOG_PATH2IMPORTS_DEF.$ar_profile["FILE_NAME"]."_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"].$strFile)) { CCatalogDiscountSave::Enable(); return false; } } $bFirstLoadStep = true; if (!defined("CATALOG_LOAD_NO_STEP")) // define("CATALOG_LOAD_NO_STEP", true); $strImportErrorMessage = ""; $strImportOKMessage = ""; $bAllDataLoaded = true; $arSetupVars = array(); $intSetupVarsCount = 0; if ('Y' != $ar_profile["DEFAULT_PROFILE"]) { parse_str($ar_profile["SETUP_VARS"], $arSetupVars); if (!empty($arSetupVars) && is_array($arSetupVars)) { $intSetupVarsCount = extract($arSetupVars, EXTR_SKIP); } } CCatalogDiscountSave::Disable(); include($_SERVER["DOCUMENT_ROOT"].$strFile); CCatalogDiscountSave::Enable(); CCatalogImport::Update($profile_id, array( "=LAST_USE" => $DB->GetNowFunction() ) ); return "CCatalogImport::PreGenerateImport(".$profile_id.");"; }
function PreGenerateImport($profile_id) { global $DB; $profile_id = IntVal($profile_id); if ($profile_id <= 0) { return false; } $ar_profile = CCatalogImport::GetByID($profile_id); if (!$ar_profile || 'Y' == $ar_profile['NEED_EDIT']) { return false; } if ($ar_profile["DEFAULT_PROFILE"] != "Y") { parse_str($ar_profile["SETUP_VARS"]); } $bFirstLoadStep = True; if (!defined("CATALOG_LOAD_NO_STEP")) { define("CATALOG_LOAD_NO_STEP", true); } CCatalogDiscountSave::Disable(); $strFile = CATALOG_PATH2IMPORTS . $ar_profile["FILE_NAME"] . "_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $strFile)) { $strFile = CATALOG_PATH2IMPORTS_DEF . $ar_profile["FILE_NAME"] . "_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $strFile)) { CCatalogDiscountSave::Enable(); return false; } } $strImportErrorMessage = ""; $strImportOKMessage = ""; $bAllDataLoaded = True; @(include $_SERVER["DOCUMENT_ROOT"] . $strFile); CCatalogDiscountSave::Enable(); CCatalogImport::Update($profile_id, array("=LAST_USE" => $DB->GetNowFunction())); return "CCatalogImport::PreGenerateImport(" . $profile_id . ");"; }
/** * <p>Метод выполняет профиль <i>profile_id</i> на агенте.</p> * * * * * @param int $profile_id Код выполняемого профиля. * * * * @return mixed <p>В случае успешного выполнения профиля экспорта метод * возвращает строку для следующего вызова агента. В противном * случае метод вернет <i>false</i>.</p><br><br> * * @static * @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogexport/pregenerateexport.php * @author Bitrix */ public static function PreGenerateExport($profile_id) { global $DB; $profile_id = intval($profile_id); if ($profile_id<=0) return false; $ar_profile = CCatalogExport::GetByID($profile_id); if ((!$ar_profile) || ('Y' == $ar_profile['NEED_EDIT'])) return false; $strFile = CATALOG_PATH2EXPORTS.$ar_profile["FILE_NAME"]."_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"].$strFile)) { $strFile = CATALOG_PATH2EXPORTS_DEF.$ar_profile["FILE_NAME"]."_run.php"; if (!file_exists($_SERVER["DOCUMENT_ROOT"].$strFile)) { return false; } } $arSetupVars = array(); $intSetupVarsCount = 0; if ('Y' != $ar_profile["DEFAULT_PROFILE"]) { parse_str($ar_profile["SETUP_VARS"], $arSetupVars); if (!empty($arSetupVars) && is_array($arSetupVars)) { $intSetupVarsCount = extract($arSetupVars, EXTR_SKIP); } } CCatalogDiscountSave::Disable(); include($_SERVER["DOCUMENT_ROOT"].$strFile); CCatalogDiscountSave::Enable(); CCatalogExport::Update($profile_id, array( "=LAST_USE" => $DB->GetNowFunction() ) ); return "CCatalogExport::PreGenerateExport(".$profile_id.");"; }