本文整理汇总了PHP中CCatalog::GetByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalog::GetByID方法的具体用法?PHP CCatalog::GetByID怎么用?PHP CCatalog::GetByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalog
的用法示例。
在下文中一共展示了CCatalog::GetByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetMessage
<div class="field"><p><?=$field;?>:</p>
<?
if(in_array($code, array('PREVIEW_TEXT', 'DETAIL_TEXT'))) { ?>
<textarea name="<?=$code;?>"></textarea>
<br>Тип:
<input type="radio" name="<?=$code?>_TYPE" value="text">text
<input type="radio" name="<?=$code?>_TYPE" value="html" checked>html
<? } else { ?>
<input type="text" name="<?=$code;?>">
<? } ?>
</div>
<? } ?>
</td>
<?
if (CModule::IncludeModule('catalog')) {
$conf = CCatalog::GetByID($IBLOCK_ID);
if ($conf) {
?>
<td valign="top">
<p class="name">Базовая цена</p>
x <input type="text" style="width: 50px;" value="1.0" name="base_price_multiplier">
<br>
± <input type="text" style="width: 50px;" value="0" name="base_price_add">
</td>
<? }
}
?></tr></table>
</div>
<?
$props = ob_get_clean();
$arGroupActions["properties"] = GetMessage("IBEL_SET_PROPS");
示例2: CatalogRecurringCallback
function CatalogRecurringCallback($productID, $userID)
{
global $APPLICATION;
global $DB;
$productID = intval($productID);
if ($productID <= 0) {
return false;
}
$userID = intval($userID);
if ($userID <= 0) {
return false;
}
$arProduct = CCatalogProduct::GetByID($productID);
if (!$arProduct) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_PRODUCT")), "NO_PRODUCT");
return false;
}
if ($arProduct["PRICE_TYPE"] == "T") {
$arProduct = CCatalogProduct::GetByID($arProduct["TRIAL_PRICE_ID"]);
if (!$arProduct) {
$APPLICATION->ThrowException(str_replace("#TRIAL_ID#", $productID, str_replace("#ID#", $arProduct["TRIAL_PRICE_ID"], Loc::getMessage("I_NO_TRIAL_PRODUCT"))), "NO_PRODUCT_TRIAL");
return false;
}
}
$productID = intval($arProduct["ID"]);
if ($arProduct["PRICE_TYPE"] != "R") {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_PRODUCT_NOT_SUBSCR")), "NO_IBLOCK_SUBSCR");
return false;
}
$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 (!($arIBlockElement = $dbIBlockElement->GetNext())) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
return false;
}
if ('E' == CIBlock::GetArrayByID($arIBlockElement['IBLOCK_ID'], "RIGHTS_MODE")) {
$arUserRights = CIBlockElementRights::GetUserOperations($productID, $userID);
if (empty($arUserRights)) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
return false;
} elseif (!is_array($arUserRights) || !array_key_exists('element_read', $arUserRights)) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
return false;
}
} else {
if ('R' > CIBlock::GetPermission($arIBlockElement['IBLOCK_ID'], $userID)) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
return false;
}
}
$arCatalog = CCatalog::GetByID($arIBlockElement["IBLOCK_ID"]);
if ($arCatalog["SUBSCRIPTION"] != "Y") {
$APPLICATION->ThrowException(str_replace("#ID#", $arIBlockElement["IBLOCK_ID"], Loc::getMessage("I_CATALOG_NOT_SUBSCR")), "NOT_SUBSCRIPTION");
return false;
}
if ($arProduct["CAN_BUY_ZERO"] != "Y" && ($arProduct["QUANTITY_TRACE"] == "Y" && doubleval($arProduct["QUANTITY"]) <= 0)) {
$APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_PRODUCT_SOLD")), "PRODUCT_END");
return false;
}
$arUserGroups = CUser::GetUserGroup($userID);
$arUserGroups = array_values(array_unique($arUserGroups));
CCatalogDiscountSave::Disable();
$arPrice = CCatalogProduct::GetOptimalPrice($productID, 1, $arUserGroups, "Y");
if (empty($arPrice)) {
if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, 1, $arUserGroups)) {
$quantity = $nearestQuantity;
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $arUserGroups, "Y");
}
}
CCatalogDiscountSave::Enable();
if (empty($arPrice)) {
return false;
}
$currentPrice = $arPrice["PRICE"]["PRICE"];
$currentDiscount = 0.0;
//SIGURD: logic change. see mantiss 5036.
// discount applied to a final price with VAT already included.
if (doubleval($arPrice['PRICE']['VAT_RATE']) > 0) {
$currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
}
$arDiscountList = array();
if (!empty($arPrice["DISCOUNT_LIST"])) {
$dblStartPrice = $currentPrice;
foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount) {
switch ($arOneDiscount['VALUE_TYPE']) {
case CCatalogDiscount::TYPE_FIX:
if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
$currentDiscount = $arOneDiscount['VALUE'];
} else {
$currentDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount["VALUE"], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
$currentPrice = $currentPrice - $currentDiscount;
break;
case CCatalogDiscount::TYPE_PERCENT:
$currentDiscount = $currentPrice * $arOneDiscount["VALUE"] / 100.0;
if (0 < $arOneDiscount['MAX_DISCOUNT']) {
if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
$dblMaxDiscount = $arOneDiscount['MAX_DISCOUNT'];
} else {
$dblMaxDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount['MAX_DISCOUNT'], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
//.........这里部分代码省略.........
示例3: intval
}
$IBLOCK_ID = intval($IBLOCK_ID);
if ($IBLOCK_ID <= 0) {
$strImportErrorMessage .= GetMessage("CATI_NO_IBLOCK") . "<br>";
} else {
$arIBlock = CIBlock::GetArrayByID($IBLOCK_ID);
if (false === $arIBlock) {
$strImportErrorMessage .= GetMessage("CATI_NO_IBLOCK") . "<br>";
}
}
if (strlen($strImportErrorMessage) <= 0) {
$bWorkflow = CModule::IncludeModule("workflow") && $arIBlock["WORKFLOW"] != "N";
}
if (strlen($strImportErrorMessage) <= 0) {
$bIBlockIsCatalog = false;
if (CCatalog::GetByID($IBLOCK_ID)) {
$bIBlockIsCatalog = true;
}
$csvFile = new CCSVData();
$csvFile->LoadFile($_SERVER["DOCUMENT_ROOT"] . $DATA_FILE_NAME);
if ($fields_type != "F" && $fields_type != "R") {
$strImportErrorMessage .= GetMessage("CATI_NO_FILE_FORMAT") . "<br>";
}
}
if (strlen($strImportErrorMessage) <= 0) {
$arDataFileFields = array();
$fields_type = $fields_type == "F" ? "F" : "R";
$csvFile->SetFieldsType($fields_type);
if ($fields_type == "R") {
$first_names_r = $first_names_r == "Y" ? "Y" : "N";
$csvFile->SetFirstHeader($first_names_r == "Y" ? true : false);
示例4: GetByIDExt
function GetByIDExt($ID)
{
$arResult = false;
$ID = intval($ID);
if (0 >= $ID) {
return false;
}
$mxPRResult = CCatalog::GetByID($ID);
if (false != $mxPRResult) {
$arResult = $mxPRResult;
if (0 < $mxPRResult['PRODUCT_IBLOCK_ID']) {
$arResult['CATALOG_TYPE'] = 'O';
$arResult['OFFERS_IBLOCK_ID'] = 0;
$arResult['OFFERS_PROPERTY_ID'] = 0;
} else {
$mxSKU = CCatalogSKU::GetInfoByProductIBlock($ID);
if (false == $mxSKU) {
$arResult['CATALOG_TYPE'] = 'D';
$arResult['OFFERS_IBLOCK_ID'] = 0;
$arResult['OFFERS_PROPERTY_ID'] = 0;
} else {
$arResult['CATALOG_TYPE'] = 'X';
$arResult['OFFERS_IBLOCK_ID'] = $mxSKU['IBLOCK_ID'];
$arResult['OFFERS_PROPERTY_ID'] = $mxSKU['SKU_PROPERTY_ID'];
}
}
$arResult['CATALOG'] = 'Y';
} else {
$mxSKU = CCatalogSKU::GetInfoByProductIBlock($ID);
if (false != $mxSKU) {
$arResult['CATALOG'] = 'N';
$arResult['CATALOG_TYPE'] = 'P';
$arResult['OFFERS_IBLOCK_ID'] = $mxSKU['IBLOCK_ID'];
$arResult['OFFERS_PROPERTY_ID'] = $mxSKU['SKU_PROPERTY_ID'];
}
}
return $arResult;
}
示例5: array
}
if ($obCache->InitCache($arParams["CACHE_TIME"], $cache_id, "/")) {
$vars = $obCache->GetVars();
$pathResizeImage = $vars["PRODUCT_PICTURE_SRC"];
$section = $vars["SECTION"];
} else {
if ($arItem['ITEM_ID'][0] == "S") {
$section = array();
$section_id = intval(substr($arItem['ITEM_ID'], 1));
$arIBlockSection = GetIBlockSection2($section_id);
$image = CFile::GetFileArray($arIBlockSection["PICTURE"]);
$image = $image["SRC"];
if (!$image) {
$section["NOT_IMAGE"] = true;
}
if (CCatalog::GetByID($arItem['PARAM2'])) {
$section["CATALOG"] = true;
}
} else {
$arElement = wfIBSearchElementsByProp(false, array("ID" => $arItem['ITEM_ID']), array("PROPERTY_BRAND_REF", "PROPERTY_MANUFACTURER", "DETAIL_PICTURE"));
$image = $arElement[0]["DETAIL_PICTURE"];
$producer = $arElement[0]["BRAND_REF"];
$brandCountry = $arElement[0]["MANUFACTURER"];
}
$ResizeParams = array('width' => $arParams['WIDTH'], 'height' => $arParams['HEIGHT']);
$ResizeImage = CFile::ResizeImageGet($image, $ResizeParams, BX_RESIZE_IMAGE_PROPORTIONAL, true);
$pathResizeImage = $ResizeImage['src'];
}
if ($obCache->StartDataCache()) {
$obCache->EndDataCache(array("SECTION" => $section, "PRODUCT_PICTURE_SRC" => $pathResizeImage, "PRODUCT_BRAND" => $producer, "PRODUCT_COUNTRY" => $brandCountry));
}
示例6: IncludeModuleLangFile
/** @var string $strWarning */
/** @var int $IBLOCK_ID */
/** @var int $ID */
if ($USER->CanDoOperation('catalog_price')) {
$IBLOCK_ID = (int) $IBLOCK_ID;
$ID = (int) $ID;
$userId = (int) $USER->GetID();
if (0 < $IBLOCK_ID && 0 < $ID) {
$PRODUCT_ID = CIBlockElement::GetRealElement($ID);
$bUseStoreControl = COption::GetOptionString('catalog', 'default_use_store_control', 'N') == "Y";
$bEnableReservation = 'N' != COption::GetOptionString('catalog', 'enable_reservation');
if (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $PRODUCT_ID, "element_edit_price")) {
IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/catalog/templates/product_edit_action.php');
if ('' == $strWarning) {
$bUseExtForm = isset($_POST['price_useextform']) && 'Y' == $_POST['price_useextform'];
$arCatalog = CCatalog::GetByID($IBLOCK_ID);
$arCatalogPrice_tmp = array();
$intBasePriceCount = count($arCatalogBasePrices);
$dbCatGroups = CCatalogGroup::GetList(array(), array("!BASE" => "Y"));
while ($arCatGroups = $dbCatGroups->Fetch()) {
unset($arCatalogPrice_tmp);
$arCatalogPrice_tmp = array();
for ($i = 0; $i < $intBasePriceCount; $i++) {
${"CAT_PRICE_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]} = str_replace(",", ".", ${"CAT_PRICE_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]});
$arCatalogPrice_tmp[$i] = array("ID" => IntVal(${"CAT_ID_" . $arCatGroups["ID"]}[$arCatalogBasePrices[$i]["IND"]]), "EXTRA_ID" => ${"CAT_EXTRA_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]} ? IntVal(${"CAT_EXTRA_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]}) : 0, "PRICE" => ${"CAT_PRICE_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]}, "CURRENCY" => Trim(${"CAT_CURRENCY_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]}), "QUANTITY_FROM" => $arCatalogBasePrices[$i]["QUANTITY_FROM"], "QUANTITY_TO" => $arCatalogBasePrices[$i]["QUANTITY_TO"]);
if (strlen($arCatalogPrice_tmp[$i]["CURRENCY"]) <= 0) {
$arCatalogPrice_tmp[$i]["CURRENCY"] = $arCatalogBasePrices[$i]["CURRENCY"];
}
if ($arCatalogPrice_tmp[$i]["EXTRA_ID"] > 0) {
if (0 < doubleval($arCatalogBasePrices[$i]["PRICE"])) {
$arCatalogPrice_tmp[$i]["CURRENCY"] = $arCatalogBasePrices[$i]["CURRENCY"];
示例7: array
$arIBlockSitesList = array();
$arIBlockFullInfo = array();
$rsIBlocks = CIBlock::GetList(array('IBLOCK_TYPE' => 'ASC', 'NAME' => 'ASC'));
while ($arIBlock = $rsIBlocks->Fetch()) {
if (false == array_key_exists($arIBlock['ID'], $arIBlockSitesList)) {
$arLIDList = array();
$arWithoutLinks = array();
$rsIBlockSites = CIBlock::GetSite($arIBlock['ID']);
while ($arIBlockSite = $rsIBlockSites->Fetch()) {
$arLIDList[] = $arIBlockSite['LID'];
$arWithoutLinks[] = htmlspecialcharsbx($arIBlockSite['LID']);
}
$arIBlockSitesList[$arIBlock['ID']] = array('SITE_ID' => $arLIDList, 'WITHOUT_LINKS' => implode(' ', $arWithoutLinks));
}
$arIBlockItem = array('ID' => $arIBlock['ID'], 'IBLOCK_TYPE_ID' => $arIBlock['IBLOCK_TYPE_ID'], 'SITE_ID' => $arIBlockSitesList[$arIBlock['ID']]['SITE_ID'], 'NAME' => htmlspecialcharsbx($arIBlock['NAME']), 'ACTIVE' => $arIBlock['ACTIVE'], 'FULL_NAME' => '[' . $arIBlock['IBLOCK_TYPE_ID'] . '] ' . htmlspecialcharsbx($arIBlock['NAME']) . ' (' . $arIBlockSitesList[$arIBlock['ID']]['WITHOUT_LINKS'] . ')', 'IS_CATALOG' => 'N', 'SUBSCRIPTION' => 'N', 'YANDEX_EXPORT' => 'N', 'VAT_ID' => 0, 'PRODUCT_IBLOCK_ID' => 0, 'SKU_PROPERTY_ID' => 0, 'OFFERS_IBLOCK_ID' => 0, 'IS_OFFERS' => 'N');
$ar_res1 = CCatalog::GetByID($arIBlock['ID']);
if (is_array($ar_res1)) {
$arIBlockItem['IS_CATALOG'] = 'Y';
$arIBlockItem['SUBSCRIPTION'] = $ar_res1['SUBSCRIPTION'];
$arIBlockItem['YANDEX_EXPORT'] = $ar_res1['YANDEX_EXPORT'];
$arIBlockItem['VAT_ID'] = $ar_res1['VAT_ID'];
$arIBlockItem['PRODUCT_IBLOCK_ID'] = $ar_res1['PRODUCT_IBLOCK_ID'];
$arIBlockItem['SKU_PROPERTY_ID'] = $ar_res1['SKU_PROPERTY_ID'];
$arIBlockItem['OFFERS_IBLOCK_ID'] = 0;
if (0 < $ar_res1['PRODUCT_IBLOCK_ID']) {
$arIBlockItem['IS_OFFERS'] = 'Y';
}
}
$arIBlockFullInfo[$arIBlock['ID']] = $arIBlockItem;
}
foreach ($arIBlockFullInfo as $res) {
示例8: getDataForXml
function getDataForXml()
{
CModule::IncludeModule("iblock");
CModule::IncludeModule('catalog');
$filter["ACTIVE"] = "Y";
$filter["ACTIVE_DATE"] = "Y";
$filter["IBLOCK_ID"] = 2;//goodies
$rsItems = CIBlockElement::GetList(array(), $filter, false, false, array());
$strOfferGoogle = '';
while ($obItem = $rsItems->GetNextElement()) {
$arItem = $obItem->GetFields();
if (CModule::IncludeModule("catalog") && CCatalog::GetByID($arItem['IBLOCK_ID'])) {
$arItem = $obItem->GetFields();
$productId = $arItem['ID'];
$rsPrices = CPrice::GetByID($productId);
$arItem['PROPERTIES'] = $obItem->GetProperties();
$strFile = '';
$arItem["DETAIL_PICTURE"] = (int)$arItem["DETAIL_PICTURE"];
$arItem["PREVIEW_PICTURE"] = (int)$arItem["PREVIEW_PICTURE"];
if ($arItem["DETAIL_PICTURE"] > 0 || $arItem["PREVIEW_PICTURE"] > 0) {
$pictNo = ($arItem["DETAIL_PICTURE"] > 0 ? $arItem["DETAIL_PICTURE"] : $arItem["PREVIEW_PICTURE"]);
if ($ar_file = CFile::GetFileArray($pictNo)) {
if (substr($ar_file["SRC"], 0, 1) == "/")
$strFile = "http://" . $_SERVER['SERVER_NAME'] . CHTTP::urnEncode($ar_file['SRC'], 'utf-8');
else
$strFile = $ar_file["SRC"];
}
}
$arItem['google_PICT'] = $strFile;
if (!empty($arItem["DETAIL_TEXT"]))
$arItem['google_DESCR'] = google_text2xml(strip_tags(stristr($arItem["DETAIL_TEXT"], '.', true)));
else
$arItem['google_DESCR'] = google_text2xml(strip_tags($arItem["NAME"]));
$strOfferGoogle .= "<item>\n";
$strOfferGoogle .= "<title>";
$strOfferGoogle .= $arItem['NAME'];
$strOfferGoogle .= "</title>\n";
$strOfferGoogle .= "<link>";
$strOfferGoogle .= "http://".$_SERVER['SERVER_NAME'].$arItem['DETAIL_PAGE_URL'];
$strOfferGoogle .= "</link>\n";
$strOfferGoogle .= "<description>";
$strOfferGoogle .= $arItem['google_DESCR'];
$strOfferGoogle .= "</description>\n";
$strOfferGoogle .= "<g:image_link>";
$strOfferGoogle .= $strFile;
$strOfferGoogle .= "</g:image_link>\n";
$strOfferGoogle .= "<g:price>";
$strOfferGoogle .= $rsPrices['PRICE'];
$strOfferGoogle .= "</g:price>\n";
$strOfferGoogle .= "<g:condition>";
$strOfferGoogle .= "новый";
$strOfferGoogle .= "</g:condition>\n";
$strOfferGoogle .= "<g:id>";
$strOfferGoogle .= $arItem['CODE'];
$strOfferGoogle .= "</g:id>\n";
$strOfferGoogle .= "</item>\n";
//etc etc
}
else
{
continue;
}
}
writeData($strOfferGoogle);
}
示例9: str_replace
{
$arIBlockInfo['PRODUCT_IBLOCK_ID'] = 0;
$arIBlockInfo['SKU_PROPERTY_ID'] = 0;
$boolCatalogUpdate = true;
}
else
{
$boolFlag = false;
$ex = $APPLICATION->GetException();
$strError = $ex->GetString();
$strWarning .= str_replace(array('#PRODUCT#','#ERROR#'),array($arIBlockInfo['INFO'],$strError),GetMessage('CAT_IBLOCK_OFFERS_ERR_UNLINK_SKU')).'<br />';
}
}
if ($boolFlag)
{
$ar_res1 = CCatalog::GetByID($intIBlockID);
if (($arIBlockInfo['CATALOG']=="Y" || $arIBlockInfo['SUBSCRIPTION']=="Y" || 0 < $arIBlockInfo['PRODUCT_IBLOCK_ID']) && $ar_res1)
{
$boolAttr = $obCatalog->Update($intIBlockID, 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),GetMessage('CAT_IBLOCK_OFFERS_ERR_CAT_UPDATE')).'<br />';
$boolFlag = false;
}
else
{
if (($ar_res1['SUBSCRIPTION'] != $arIBlockInfo['SUBSCRIPTION']) || (intval($ar_res1['PRODUCT_IBLOCK_ID']) != intval($arIBlockInfo['PRODUCT_IBLOCK_ID'])) || ($ar_res1['YANDEX_EXPORT'] != $arIBlockInfo['YANDEX_EXPORT']) || ($ar_res1['VAT_ID'] != $arIBlockInfo['VAT_ID']))
{
示例10: DoIBlockAfterSave
function DoIBlockAfterSave($arg1, $arg2 = false)
{
$ELEMENT_ID = false;
$IBLOCK_ID = false;
$OFFERS_IBLOCK_ID = false;
$OFFERS_PROPERTY_ID = false;
if (CModule::IncludeModule('currency')) {
$strDefaultCurrency = CCurrency::GetBaseCurrency();
}
//Check for catalog event
if (is_array($arg2) && $arg2["PRODUCT_ID"] > 0) {
//Get iblock element
$rsPriceElement = CIBlockElement::GetList(array(), array("ID" => $arg2["PRODUCT_ID"]), false, false, array("ID", "IBLOCK_ID"));
if ($arPriceElement = $rsPriceElement->Fetch()) {
$arCatalog = CCatalog::GetByID($arPriceElement["IBLOCK_ID"]);
if (is_array($arCatalog)) {
//Check if it is offers iblock
if ($arCatalog["OFFERS"] == "Y") {
//Find product element
$rsElement = CIBlockElement::GetProperty($arPriceElement["IBLOCK_ID"], $arPriceElement["ID"], "sort", "asc", array("ID" => $arCatalog["SKU_PROPERTY_ID"]));
$arElement = $rsElement->Fetch();
if ($arElement && $arElement["VALUE"] > 0) {
$ELEMENT_ID = $arElement["VALUE"];
$IBLOCK_ID = $arCatalog["PRODUCT_IBLOCK_ID"];
$OFFERS_IBLOCK_ID = $arCatalog["IBLOCK_ID"];
$OFFERS_PROPERTY_ID = $arCatalog["SKU_PROPERTY_ID"];
}
} elseif ($arCatalog["OFFERS_IBLOCK_ID"] > 0) {
$ELEMENT_ID = $arPriceElement["ID"];
$IBLOCK_ID = $arPriceElement["IBLOCK_ID"];
$OFFERS_IBLOCK_ID = $arCatalog["OFFERS_IBLOCK_ID"];
$OFFERS_PROPERTY_ID = $arCatalog["OFFERS_PROPERTY_ID"];
} else {
$ELEMENT_ID = $arPriceElement["ID"];
$IBLOCK_ID = $arPriceElement["IBLOCK_ID"];
$OFFERS_IBLOCK_ID = false;
$OFFERS_PROPERTY_ID = false;
}
}
}
} elseif (is_array($arg1) && $arg1["ID"] > 0 && $arg1["IBLOCK_ID"] > 0) {
//Check if iblock has offers
$arOffers = CIBlockPriceTools::GetOffersIBlock($arg1["IBLOCK_ID"]);
if (is_array($arOffers)) {
$ELEMENT_ID = $arg1["ID"];
$IBLOCK_ID = $arg1["IBLOCK_ID"];
$OFFERS_IBLOCK_ID = $arOffers["OFFERS_IBLOCK_ID"];
$OFFERS_PROPERTY_ID = $arOffers["OFFERS_PROPERTY_ID"];
}
}
if ($ELEMENT_ID) {
static $arPropCache = array();
if (!array_key_exists($IBLOCK_ID, $arPropCache)) {
//Check for MINIMAL_PRICE property
$rsProperty = CIBlockProperty::GetByID("MINIMUM_PRICE", $IBLOCK_ID);
$arProperty = $rsProperty->Fetch();
if ($arProperty) {
$arPropCache[$IBLOCK_ID] = $arProperty["ID"];
} else {
$arPropCache[$IBLOCK_ID] = false;
}
}
if ($arPropCache[$IBLOCK_ID]) {
//Compose elements filter
if ($OFFERS_IBLOCK_ID) {
$rsOffers = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $OFFERS_IBLOCK_ID, "PROPERTY_" . $OFFERS_PROPERTY_ID => $ELEMENT_ID), false, false, array("ID"));
while ($arOffer = $rsOffers->Fetch()) {
$arProductID[] = $arOffer["ID"];
}
if (!is_array($arProductID)) {
$arProductID = array($ELEMENT_ID);
}
} else {
$arProductID = array($ELEMENT_ID);
}
$minPrice = false;
$maxPrice = false;
//Get prices
$rsPrices = CPrice::GetList(array(), array("PRODUCT_ID" => $arProductID));
while ($arPrice = $rsPrices->Fetch()) {
if (CModule::IncludeModule('currency') && $strDefaultCurrency != $arPrice['CURRENCY']) {
$arPrice["PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["PRICE"], $arPrice["CURRENCY"], $strDefaultCurrency);
}
$PRICE = $arPrice["PRICE"];
if ($minPrice === false || $minPrice > $PRICE) {
$minPrice = $PRICE;
}
if ($maxPrice === false || $maxPrice < $PRICE) {
$maxPrice = $PRICE;
}
}
//Save found minimal price into property
if ($minPrice !== false) {
CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, $IBLOCK_ID, array("MINIMUM_PRICE" => $minPrice, "MAXIMUM_PRICE" => $maxPrice));
}
}
}
}
示例11: CIBlock
}
$IBLOCK_OFFERS_ID = WizardServices::ImportIBlockFromXML($iblockXMLFile, "furniture_offers", $iblockType, WIZARD_SITE_ID, $permissions);
if ($IBLOCK_OFFERS_ID < 1) {
return;
}
//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);
示例12: PrepareIBlock
public function PrepareIBlock($arIBlock = array(), $UseSKU = fasle)
{
$excludeIBlock = array();
if (!is_array($arIBlock)) {
$arIBlock = array();
}
$catalogSKU = array();
if ($UseSKU) {
foreach ($arIBlock as $iblocID) {
if ($iblock = CCatalog::GetByID($iblocID)) {
if (intval($iblock["OFFERS_IBLOCK_ID"]) > 0) {
$catalogSKU[] = $iblock["OFFERS_IBLOCK_ID"];
}
}
}
}
$arIblocks = array_merge($arIBlock, $catalogSKU);
$arIblocks = array_unique($arIblocks);
return $arIblocks;
}
示例13: yandex_GetPrice
public function yandex_GetPrice($Product)
{
$prop = array();
$value = "";
$prc = strlen($this->PRICE) > 0 ? $this->PRICE : 0;
if (!$this->isCat or !CCatalog::GetByID($Product["IBLOCK_ID"])) {
foreach ($this->XML_DATA as $data) {
if (trim($data["UNIT"]) == "g:price") {
$tmp = explode("-", $data["ID"]);
$tmp1 = explode("_", $tmp);
if (in_array("PRICE", $tmp1)) {
$prop = $tmp[1];
} elseif (in_array("SKU", $tmp1)) {
$prop = $tmp1[1];
}
$db_props = CIBlockElement::GetProperty($tmp[0], $Product["ID"], array("sort" => "asc"), array("ID" => $prop));
if ($ar_props = $db_props->Fetch()) {
$value = $ar_props["VALUE"];
} else {
$value = "";
}
break;
} else {
$value = false;
}
}
} elseif ($this->isCat) {
if ($prc > 0) {
$dbProductPrices1 = CPrice::GetList(array(), array("PRODUCT_ID" => $Product["ID"], "CATALOG_GROUP_ID" => $prc));
$price = 0;
while ($arProductPrice = $dbProductPrices1->Fetch()) {
if ($arProductPrice["PRICE"] && ($arProductPrice["PRICE"] < $price || !$price)) {
$price = $arProductPrice["PRICE"];
}
$arDissizeofs = CCatalogDiscount::GetDiscountByProduct($arProductPrice["PRODUCT_ID"], array(), "N", $arProductPrice["CATALOG_GROUP_ID"], $this->LID);
foreach ($arDissizeofs as $arDissizeof) {
if ($arDissizeof["VALUE_TYPE"] == "P") {
$price_buf = $arProductPrice["PRICE"] - $arDissizeof["VALUE"] * $arProductPrice["PRICE"] / 100;
} else {
$price_buf = $arProductPrice["PRICE"] - $arDissizeof["VALUE"];
}
if ($price_buf && ($price_buf < $price || !$price)) {
$price = $price_buf;
}
}
}
$value = $price;
} else {
$value = false;
}
}
return $value;
}
示例14: CatalogBasketCustomCallback
/**
* Функция обратного вызова для корзины
* аналогична функции CatalogBasketCallback за исключением использования одной определенной цены для конкретного города
*
* @param $productID
* @param $quantity
* @param $renewal
*/
function CatalogBasketCustomCallback($productID, $quantity = 0, $renewal = "N")
{
global $USER;
$productID = IntVal($productID);
$quantity = DoubleVal($quantity);
$renewal = (($renewal == "Y") ? "Y" : "N");
$arResult = array();
if ($arCatalogProduct = CCatalogProduct::GetByID($productID))
{
if ($arCatalogProduct["QUANTITY_TRACE"]=="Y" && DoubleVal($arCatalogProduct["QUANTITY"])<=0)
return $arResult;
}
$dbIBlockElement = CIBlockElement::GetList(
array(),
array(
"ID" => $productID,
"ACTIVE_DATE" => "Y",
"ACTIVE" => "Y",
"CHECK_PERMISSIONS" => "Y"
)
);
$arProduct = $dbIBlockElement->GetNext();
$arCatalog = CCatalog::GetByID($arProduct["IBLOCK_ID"]);
if ($arCatalog["SUBSCRIPTION"] == "Y")
{
$quantity = 1;
}
$rs = CPrice::GetList(
array(),
array("CATALOG_GROUP_NAME" => GetCityPrice(), "PRODUCT_ID" => $productID), false, false);
$ar = $rs -> Fetch();
$arPrice = array();
$arPrice[] = array(
"ID" => $ar["ID"],
"PRICE" => $ar["PRICE"],
"CURRENCY" => $ar["CURRENCY"],
"CATALOG_GROUP_ID" => $ar["CATALOG_GROUP_ID"]
);
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $USER -> GetUserGroupArray(), $renewal, $arPrice);
if (!$arPrice || count($arPrice) <= 0)
{
if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, $USER->GetUserGroupArray()))
{
$quantity = $nearestQuantity;
$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $USER->GetUserGroupArray(), $renewal);
}
}
if (!$arPrice || count($arPrice) <= 0)
{
return $arResult;
}
$currentPrice = $arPrice["PRICE"]["PRICE"];
$currentDiscount = 0.0;
//SIGURD: logic change. see mantiss 5036.
// discount applied to a final price with VAT already included.
if ($arPrice['PRICE']['VAT_INCLUDED'] == 'N')
{
if(DoubleVal($arPrice['PRICE']['VAT_RATE']) > 0)
{
$currentPrice *= (1 + $arPrice['PRICE']['VAT_RATE']);
$arPrice['PRICE']['VAT_INCLUDED'] = 'y';
}
}
if (isset($arPrice["DISCOUNT"]) && count($arPrice["DISCOUNT"]) > 0)
{
if ($arPrice["DISCOUNT"]["VALUE_TYPE"]=="F")
{
if ($arPrice["DISCOUNT"]["CURRENCY"] == $arPrice["PRICE"]["CURRENCY"])
$currentDiscount = $arPrice["DISCOUNT"]["VALUE"];
else
$currentDiscount = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT"]["VALUE"], $arPrice["DISCOUNT"]["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
}
else
$currentDiscount = $currentPrice * $arPrice["DISCOUNT"]["VALUE"] / 100.0;
$currentDiscount = roundEx($currentDiscount, SALE_VALUE_PRECISION);
if (DoubleVal($arPrice["DISCOUNT"]["MAX_DISCOUNT"]) > 0)
{
//.........这里部分代码省略.........
示例15: OnBeforePrologHandler
//.........这里部分代码省略.........
$boolCreateSection = false;
if ($bElemPage || $bMixPage) {
$boolCreateElement = CASDIblockRights::IsSectionElementCreate($intDestIBlockID, $intSetSectID);
}
if ($bSectPage || $bMixPage) {
$boolCreateSection = CASDIblockRights::IsSectionSectionCreate($intDestIBlockID, $intSetSectID);
}
if ($boolCreateElement || $boolCreateSection) {
$arPropListCache = array();
$arOldPropListCache = array();
$arNamePropListCache = array();
$arOldNamePropListCache = array();
$boolUFListCache = false;
$arUFListCache = array();
$arOldUFListCache = array();
$arUFEnumCache = array();
$arOldUFEnumCache = array();
$arUFNameEnumCache = array();
$arOldUFNameEnumCache = array();
$arDestIBlock = CIBlock::GetArrayByID($intDestIBlockID);
$arDestIBFields = $arDestIBlock['FIELDS'];
$boolCodeUnique = false;
if ($arDestIBFields['CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') {
$boolCodeUnique = $intSrcIBlockID == $intDestIBlockID;
}
$boolSectCodeUnique = false;
if ($arDestIBFields['SECTION_CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') {
$boolSectCodeUnique = $intSrcIBlockID == $intDestIBlockID;
}
$boolCatalog = CModule::IncludeModule('catalog');
$boolCopyCatalog = false;
$boolNewCatalog = false;
if ($boolCatalog) {
$boolCopyCatalog = is_array(CCatalog::GetByID($intDestIBlockID));
$boolNewCatalog = $boolCopyCatalog;
if ($boolCopyCatalog) {
$boolCopyCatalog = is_array(CCatalog::GetByID($intSrcIBlockID));
}
}
$el = new CIBlockElement();
$sc = new CIBlockSection();
$obEnum = new CUserFieldEnum();
foreach ($_REQUEST['ID'] as $eID) {
$boolCopyElem = false;
$boolCopySect = false;
if ($bMixPage) {
if (substr($eID, 0, 1) != 'E') {
$boolCopySect = true;
} else {
$boolCopyElem = true;
}
$ID = (int) substr($eID, 1);
} else {
$boolCopyElem = $bElemPage;
$boolCopySect = $bSectPage;
$ID = (int) $eID;
}
if ($boolCreateElement && $boolCopyElem) {
if ($obSrc = CIBlockElement::GetByID($ID)->GetNextElement()) {
$arSrc = $obSrc->GetFields();
$arSrcPr = $obSrc->GetProperties(false, array('EMPTY' => 'N'));
$arSrc['PREVIEW_PICTURE'] = (int) $arSrc['PREVIEW_PICTURE'];
if ($arSrc['PREVIEW_PICTURE'] > 0) {
$arSrc['PREVIEW_PICTURE'] = CFile::MakeFileArray($arSrc['PREVIEW_PICTURE']);
if (empty($arSrc['PREVIEW_PICTURE'])) {
$arSrc['PREVIEW_PICTURE'] = false;