本文整理汇总了PHP中CIBlockElement::GetIBlockByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElement::GetIBlockByID方法的具体用法?PHP CIBlockElement::GetIBlockByID怎么用?PHP CIBlockElement::GetIBlockByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockElement
的用法示例。
在下文中一共展示了CIBlockElement::GetIBlockByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetProductList
public static function GetProductList($ID, $minCNT, $limit, $getParentOnly = false)
{
global $DB;
$ID = (int) $ID;
if ($ID <= 0) {
return false;
}
$limit = (int) $limit;
if ($limit < 0) {
$limit = 0;
}
$minCNT = (int) $minCNT;
if ($minCNT < 0) {
$minCNT = 0;
}
$getParentOnly = $getParentOnly === true;
$elementInclude = array($ID);
$elementExclude = array();
if (Loader::includeModule('catalog')) {
$intIBlockID = (int) CIBlockElement::GetIBlockByID($ID);
if ($intIBlockID == 0) {
return false;
}
$skuInfo = CCatalogSKU::GetInfoByProductIBlock($intIBlockID);
if (!empty($skuInfo)) {
$itemsIterator = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $skuInfo['IBLOCK_ID'], 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID'] => $ID), false, false, array('ID', 'IBLOCK_ID', 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID']));
while ($item = $itemsIterator->Fetch()) {
$item['ID'] = (int) $item['ID'];
$elementInclude[] = $item['ID'];
$elementExclude[] = $item['ID'];
}
}
}
if ($getParentOnly) {
$strSql = "select PARENT_PRODUCT_ID from b_sale_product2product where PRODUCT_ID IN (" . implode(',', $elementInclude) . ")";
if (!empty($elementExclude)) {
$strSql .= " and PARENT_PRODUCT_ID not in (" . implode(',', $elementExclude) . ")";
}
if ($minCNT > 0) {
$strSql .= " and CNT >= " . $minCNT;
}
$strSql .= ' group by PARENT_PRODUCT_ID';
if ($limit > 0) {
$strSql .= " limit " . $limit;
}
} else {
$strSql = "select * from b_sale_product2product where PRODUCT_ID in (" . implode(',', $elementInclude) . ")";
if (!empty($elementExclude)) {
$strSql .= " and PARENT_PRODUCT_ID not in (" . implode(',', $elementExclude) . ")";
}
if ($minCNT > 0) {
$strSql .= " and CNT >= " . $minCNT;
}
$strSql .= " order by CNT desc, PRODUCT_ID asc";
if ($limit > 0) {
$strSql .= " limit " . $limit;
}
}
return $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
示例2: GetProductInfo
public static function GetProductInfo($intOfferID, $intIBlockID = 0)
{
$intOfferID = (int) $intOfferID;
if ($intOfferID <= 0) {
return false;
}
$intIBlockID = (int) $intIBlockID;
if ($intIBlockID <= 0) {
$intIBlockID = (int) CIBlockElement::GetIBlockByID($intOfferID);
}
if ($intIBlockID <= 0) {
return false;
}
if (!isset(self::$arOfferCache[$intIBlockID])) {
$arSkuInfo = CCatalogSKU::GetInfoByOfferIBlock($intIBlockID);
} else {
$arSkuInfo = self::$arOfferCache[$intIBlockID];
}
if (empty($arSkuInfo) || empty($arSkuInfo['SKU_PROPERTY_ID'])) {
return false;
}
$rsItems = CIBlockElement::GetProperty($intIBlockID, $intOfferID, array(), array('ID' => $arSkuInfo['SKU_PROPERTY_ID']));
if ($arItem = $rsItems->Fetch()) {
$arItem['VALUE'] = (int) $arItem['VALUE'];
if ($arItem['VALUE'] > 0) {
return array('ID' => $arItem['VALUE'], 'IBLOCK_ID' => $arSkuInfo['PRODUCT_IBLOCK_ID'], 'OFFER_IBLOCK_ID' => $intIBlockID, 'SKU_PROPERTY_ID' => $arSkuInfo['SKU_PROPERTY_ID']);
}
}
return false;
}
示例3: GetProductInfo
public static function GetProductInfo($intOfferID, $intIBlockID = 0)
{
$intOfferID = (int) $intOfferID;
if ($intOfferID <= 0) {
return false;
}
if (!isset(self::$parentCache[$intOfferID])) {
self::$parentCache[$intOfferID] = false;
$intIBlockID = (int) $intIBlockID;
if ($intIBlockID <= 0) {
$intIBlockID = (int) CIBlockElement::GetIBlockByID($intOfferID);
}
if ($intIBlockID <= 0) {
return self::$parentCache[$intOfferID];
}
if (!isset(self::$arOfferCache[$intIBlockID])) {
$skuInfo = CCatalogSKU::GetInfoByOfferIBlock($intIBlockID);
} else {
$skuInfo = self::$arOfferCache[$intIBlockID];
}
if (empty($skuInfo) || empty($skuInfo['SKU_PROPERTY_ID'])) {
return self::$parentCache[$intOfferID];
}
$conn = Application::getConnection();
$helper = $conn->getSqlHelper();
if ($skuInfo['VERSION'] == 2) {
$productField = $helper->quote('PROPERTY_' . $skuInfo['SKU_PROPERTY_ID']);
$sqlQuery = 'select ' . $productField . ' as ID from ' . $helper->quote('b_iblock_element_prop_s' . $skuInfo['IBLOCK_ID']) . ' where ' . $helper->quote('IBLOCK_ELEMENT_ID') . ' = ' . $intOfferID;
} else {
$productField = $helper->quote('VALUE_NUM');
$sqlQuery = 'select ' . $productField . ' as ID from ' . $helper->quote('b_iblock_element_property') . ' where ' . $helper->quote('IBLOCK_PROPERTY_ID') . ' = ' . $skuInfo['SKU_PROPERTY_ID'] . ' and ' . $helper->quote('IBLOCK_ELEMENT_ID') . ' = ' . $intOfferID;
}
unset($productField);
$parentIterator = $conn->query($sqlQuery);
if ($parent = $parentIterator->fetch()) {
$parent['ID'] = (int) $parent['ID'];
if ($parent['ID'] > 0) {
self::$parentCache[$intOfferID] = array('ID' => $parent['ID'], 'IBLOCK_ID' => $skuInfo['PRODUCT_IBLOCK_ID'], 'OFFER_IBLOCK_ID' => $intIBlockID, 'SKU_PROPERTY_ID' => $skuInfo['SKU_PROPERTY_ID']);
}
}
unset($parent, $parentIterator, $sqlQuery, $helper, $conn, $skuInfo);
}
return self::$parentCache[$intOfferID];
}
示例4: GetDiscountByProduct
/**
* <p>Метод вычисляет скидку на товар с кодом productID для пользователя, принадлежащего группам пользователей arUserGroups.</p>
*
*
*
*
* @param int $productID = 0[ Код товара
*
*
*
* @param array $arUserGroups = array()[
*
*
*
* @param string $renewal = "N"[ Массив групп, которым принадлежит пользователь. Для текущего
* пользователя он возвращается методом $USER->GetUserGroupArray()
*
*
*
* @param array $arCatalogGroups = array()[ Флаг "Продление подписки"
*
*
*
* @param string $siteID = false]]] Массив типов цен, для которых искать скидку.
*
*
*
* @return bool <p>Метод возвращает массив ассоциативных массивов скидок или
* <i>false</i> в случае ошибки. В массиве содержится ассоциативный
* массив параметров максимальной процентной скидки (если есть) и
* ассоциативный массив параметров максимальной фиксированной
* скидки (если есть).</p><a name="examples"></a>
*
*
* <h4>Example</h4>
* <pre>
* <?
* $arDiscounts = CCatalogDiscount::GetDiscountByProduct(
* 150,
* $USER->GetUserGroupArray(),
* "N",
* 2,
* SITE_ID
* );
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogdiscount/ccatalogdiscount.getdiscountbyproduct.php
* @author Bitrix
*/
static public function GetDiscountByProduct($productID = 0, $arUserGroups = array(), $renewal = "N", $arCatalogGroups = array(), $siteID = false, $arDiscountCoupons = false)
{
global $DB;
global $APPLICATION;
foreach (GetModuleEvents("catalog", "OnGetDiscountByProduct", true) as $arEvent)
{
$mxResult = ExecuteModuleEventEx($arEvent, array($productID, $arUserGroups, $renewal, $arCatalogGroups, $siteID, $arDiscountCoupons));
if (true !== $mxResult)
return $mxResult;
}
$productID = intval($productID);
if (0 >= $productID)
{
$APPLICATION->ThrowException(str_replace("#ID#", $productID, GetMessage("BT_MOD_CATALOG_DISC_ERR_ELEMENT_ID_NOT_FOUND")), "NO_ELEMENT");
return false;
}
$intIBlockID = intval(CIBlockElement::GetIBlockByID($productID));
if (0 >= $intIBlockID)
{
$APPLICATION->ThrowException(str_replace("#ID#", $productID, GetMessage("BT_MOD_CATALOG_DISC_ERR_ELEMENT_ID_NOT_FOUND")), "NO_ELEMENT");
return false;
}
return CCatalogDiscount::GetDiscount($productID, $intIBlockID, $arCatalogGroups, $arUserGroups, $renewal, $siteID, $arDiscountCoupons);
}
示例5: GetOptimalPrice
//.........这里部分代码省略.........
$arUserGroups = array(intval($arUserGroups));
if (!is_array($arUserGroups))
$arUserGroups = array();
if (!in_array(2, $arUserGroups))
$arUserGroups[] = 2;
$rsVAT = CCatalogProduct::GetVATInfo($intProductID);
if ($arVAT = $rsVAT->Fetch())
{
$arVAT['RATE'] = doubleval($arVAT['RATE'] * 0.01);
}
else
{
$arVAT = array('RATE' => 0.0, 'VAT_INCLUDED' => 'N');
}
$renewal = (($renewal == "N") ? "N" : "Y");
if (false === $siteID)
$siteID = SITE_ID;
if (false === $arDiscountCoupons)
$arDiscountCoupons = CCatalogDiscountCoupon::GetCoupons();
$strBaseCurrency = CCurrency::GetBaseCurrency();
if (empty($strBaseCurrency))
{
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_PROD_ERR_NO_BASE_CURRENCY"), "NO_BASE_CURRENCY");
return false;
}
$intIBlockID = intval(CIBlockElement::GetIBlockByID($intProductID));
if (0 >= $intIBlockID)
{
$APPLICATION->ThrowException(str_replace("#ID#", $intProductID, GetMessage('BT_MOD_CATALOG_PROD_ERR_ELEMENT_ID_NOT_FOUND')), "NO_ELEMENT");
return false;
}
if (!isset($arPrices) || !is_array($arPrices))
$arPrices = array();
if (empty($arPrices))
{
$arPrices = array();
$dbPriceList = CPrice::GetListEx(
array(),
array(
"PRODUCT_ID" => $intProductID,
"GROUP_GROUP_ID" => $arUserGroups,
"GROUP_BUY" => "Y",
"+<=QUANTITY_FROM" => $quantity,
"+>=QUANTITY_TO" => $quantity
),
false,
false,
array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY")
);
while ($arPriceList = $dbPriceList->Fetch())
{
$arPriceList['ELEMENT_IBLOCK_ID'] = $intIBlockID;
$arPrices[] = $arPriceList;
}
}
else
示例6: getProductDataToFillBasket
function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
{
if (!\Bitrix\Main\Loader::includeModule("catalog"))
return array();
$arParams = array();
$productId = (int)$productId;
if ($productId <= 0)
{
return $arParams;
}
$iblockId = (int)CIBlockElement::GetIBlockByID($productId);
if ($iblockId <= 0)
{
return $arParams;
}
$arSku2Parent = array();
$arElementId = array();
$arElementId[] = $productId;
$arParent = CCatalogSku::GetProductInfo($productId, $iblockId);
if ($arParent)
{
$arElementId[] = $arParent["ID"];
$arSku2Parent[$productId] = $arParent["ID"];
}
$arPropertyInfo = array();
$userColumns = (string)$userColumns;
$arUserColumns = ($userColumns != '') ? explode(",", $userColumns) : array();
foreach ($arUserColumns as $key => $column)
{
if (strncmp($column, 'PROPERTY_', 9) != 0)
{
unset($arUserColumns[$key]);
}
else
{
$propertyCode = substr($column, 9);
if ($propertyCode == '')
{
unset($arUserColumns[$key]);
continue;
}
$dbres = CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
if ($arPropData = $dbres->GetNext())
$arPropertyInfo[$column] = $arPropData;
}
}
$arSelect = array_merge(
array("ID", "NAME", "LID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL", "XML_ID", "IBLOCK_XML_ID"),
$arUserColumns
);
$arProductData = getProductProps($arElementId, $arSelect);
$defaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
if (!empty($arProductData))
{
$arElementInfo = array();
foreach ($arProductData as $elemId => &$arElement)
{
foreach ($arElement as $key => $value)
{
if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE")
{
$columnCode = str_replace("_VALUE", "", $key);
$arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
}
}
}
unset($arElement);
if (isset($arProductData[$productId]))
$arElementInfo = $arProductData[$productId];
if (isset( $arSku2Parent[$productId]))
$arParent = $arProductData[$arSku2Parent[$productId]];
if (!empty($arSku2Parent)) // if sku element doesn't have value of some property - we'll show parent element value instead
{
foreach ($arUserColumns as $field)
{
$fieldVal = $field."_VALUE";
$parentId = $arSku2Parent[$productId];
if ((!isset($arElementInfo[$fieldVal]) || (isset($arElementInfo[$fieldVal]) && strlen($arElementInfo[$fieldVal]) == 0))
&& (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) // can be array or string
{
$arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
}
}
if (strpos($arElementInfo["~XML_ID"], '#') === false)
{
$arElementInfo["~XML_ID"] = $arParent['~XML_ID'].'#'.$arElementInfo["~XML_ID"];
}
//.........这里部分代码省略.........
示例7: GetProductSku
/**
* @param $userId
* @param $lid
* @param $productId
* @param string $productName
* @param string $currency
* @param array $arProduct
* @return array|bool
*/
function GetProductSku($userId, $lid, $productId, $productName = '', $currency = '', $arProduct = array())
{
$userId = intval($userId);
$productId = intval($productId);
if ($productId <= 0) {
return false;
}
$lid = trim($lid);
if (strlen($lid) <= 0) {
return false;
}
$productName = trim($productName);
$arResult = array();
static $arCacheGroups = array();
if (!isset($arCacheGroups[$userId])) {
$arCacheGroups[$userId] = CUser::GetUserGroup($userId);
}
$arGroups = $arCacheGroups[$userId];
if (!isset($arProduct["IBLOCK_ID"]) || 0 >= intval($arProduct["IBLOCK_ID"])) {
$arProduct["IBLOCK_ID"] = CIBlockElement::GetIBlockByID($arProduct["IBLOCK_ID"]);
}
static $arOffersIblock = array();
if (!isset($arOffersIblock[$arProduct["IBLOCK_ID"]])) {
$mxResult = CCatalogSKU::GetInfoByProductIBlock($arProduct["IBLOCK_ID"]);
if (is_array($mxResult)) {
$arOffersIblock[$arProduct["IBLOCK_ID"]] = $mxResult["IBLOCK_ID"];
}
}
if ($arOffersIblock[$arProduct["IBLOCK_ID"]] > 0) {
static $arCacheOfferProperties = array();
if (!is_set($arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]])) {
$dbOfferProperties = CIBlockProperty::GetList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $arOffersIblock[$arProduct["IBLOCK_ID"]], 'ACTIVE' => 'Y', "!XML_ID" => "CML2_LINK"));
while ($arOfferProperties = $dbOfferProperties->Fetch()) {
if ('F' == $arOfferProperties['PROPERTY_TYPE']) {
continue;
}
$arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]][] = $arOfferProperties;
}
}
$arOfferProperties = $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]];
$arIblockOfferProps = array();
$arIblockOfferPropsFilter = array();
if (is_array($arOfferProperties)) {
foreach ($arOfferProperties as $val) {
$arIblockOfferProps[] = array("CODE" => $val["CODE"], "NAME" => $val["NAME"]);
$arIblockOfferPropsFilter[] = $val["CODE"];
}
}
$arOffers = CIBlockPriceTools::GetOffersArray($arProduct["IBLOCK_ID"], $productId, array("ID" => "DESC"), array("NAME", "EXTERNAL_ID"), $arIblockOfferPropsFilter, 0, array(), 1, array(), $userId, $lid);
$arSku = array();
$arSkuId = array();
$arImgSku = array();
foreach ($arOffers as $arOffer) {
$arSkuId[] = $arOffer['ID'];
}
if (!empty($arSkuId)) {
$res = CIBlockElement::GetList(array(), array("ID" => $arSkuId), false, false, array("ID", "IBLOCK_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PICTURE", "DETAIL_PAGE_URL", "ACTIVE"));
while ($arOfferImg = $res->GetNext()) {
$arImgSku[$arOfferImg["ID"]] = $arOfferImg;
}
}
$arOffersId = array();
foreach ($arOffers as $arOffer) {
$arOffersId[] = $arOffer['ID'];
}
$dbCatalogProduct = CCatalogProduct::GetList(array(), array("ID" => $arOffersId));
while ($arCatalogProduct = $dbCatalogProduct->fetch()) {
$arCatalogProductResult[$arCatalogProduct["ID"]] = $arCatalogProduct;
}
foreach ($arOffers as $arOffer) {
$arSkuTmp = array();
$active = '';
$arOffer["CAN_BUY"] = "N";
$arCatalogProduct = $arCatalogProductResult[$arOffer["ID"]];
if (!empty($arCatalogProduct)) {
if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) <= 0)) {
$arOffer["CAN_BUY"] = "N";
} else {
$arOffer["CAN_BUY"] = "Y";
}
}
$arSkuTmp["ImageUrl"] = '';
if ($arOffer["CAN_BUY"] == "Y") {
if (isset($arImgSku[$arOffer['ID']]) && !empty($arImgSku[$arOffer['ID']])) {
if ('' == $productName) {
$productName = $arImgSku[$arOffer['ID']]["~NAME"];
}
$active = $arImgSku[$arOffer['ID']]["ACTIVE"];
if ($arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"] != "") {
$arSkuTmp["PREVIEW_PICTURE"] = $arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"];
}
//.........这里部分代码省略.........
示例8: 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')
);
while($arAllSkuElements = $dbAllSkuElements->fetch())
{
$arSkuElements[] = $arAllSkuElements;
}
示例9: CatalogGetPriceTableEx
function CatalogGetPriceTableEx($ID, $filterQauntity = 0, $arFilterType = array(), $VAT_INCLUDE = 'Y', $arCurrencyParams = array())
{
global $USER;
static $arPriceTypes = array();
$ID = (int) $ID;
if ($ID <= 0) {
return false;
}
$filterQauntity = (int) $filterQauntity;
if (!is_array($arFilterType)) {
$arFilterType = array($arFilterType);
}
$boolConvert = false;
$strCurrencyID = '';
$arCurrencyList = array();
if (!empty($arCurrencyParams) && is_array($arCurrencyParams) && !empty($arCurrencyParams['CURRENCY_ID'])) {
$boolConvert = true;
$strCurrencyID = $arCurrencyParams['CURRENCY_ID'];
}
$arResult = array();
$arResult["ROWS"] = array();
$arResult["COLS"] = array();
$arResult["MATRIX"] = array();
$arResult["CAN_BUY"] = array();
$arResult["AVAILABLE"] = "N";
$cacheTime = CATALOG_CACHE_DEFAULT_TIME;
if (defined("CATALOG_CACHE_TIME")) {
$cacheTime = intval(CATALOG_CACHE_TIME);
}
$arUserGroups = $USER->GetUserGroupArray();
CatalogClearArray($arUserGroups, true);
$strCacheID = 'UG_' . implode('_', $arUserGroups);
if (isset($arPriceTypes[$strCacheID])) {
$arPriceGroups = $arPriceTypes[$strCacheID];
} else {
$arPriceGroups = CCatalogGroup::GetGroupsPerms($arUserGroups, array());
$arPriceTypes[$strCacheID] = $arPriceGroups;
}
if (empty($arPriceGroups["view"])) {
return $arResult;
}
$currentQuantity = -1;
$rowsCnt = -1;
$arFilter = array("PRODUCT_ID" => $ID);
if ($filterQauntity > 0) {
$arFilter["+<=QUANTITY_FROM"] = $filterQauntity;
$arFilter["+>=QUANTITY_TO"] = $filterQauntity;
}
if (!empty($arFilterType)) {
$arTmp = array();
foreach ($arPriceGroups["view"] as &$intOneGroup) {
if (in_array($intOneGroup, $arFilterType)) {
$arTmp[] = $intOneGroup;
}
}
if (isset($intOneGroup)) {
unset($intOneGroup);
}
if (empty($arTmp)) {
return $arResult;
}
$arFilter["CATALOG_GROUP_ID"] = $arTmp;
} else {
$arFilter["CATALOG_GROUP_ID"] = $arPriceGroups["view"];
}
$productQuantity = 0;
$productQuantityTrace = "N";
$dbRes = CCatalogProduct::GetVATInfo($ID);
if ($arVatInfo = $dbRes->Fetch()) {
$fVatRate = floatval($arVatInfo['RATE'] * 0.01);
$bVatIncluded = $arVatInfo['VAT_INCLUDED'] == 'Y';
} else {
$fVatRate = 0.0;
$bVatIncluded = false;
}
$rsProducts = CCatalogProduct::GetList(array(), array('ID' => $ID), false, false, array('ID', 'CAN_BUY_ZERO', 'QUANTITY_TRACE', 'QUANTITY'));
if ($arProduct = $rsProducts->Fetch()) {
$intIBlockID = CIBlockElement::GetIBlockByID($arProduct['ID']);
if (!$intIBlockID) {
return false;
}
$arProduct['IBLOCK_ID'] = $intIBlockID;
} else {
return false;
}
$dbPrice = CPrice::GetListEx(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC"), $arFilter, false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "QUANTITY_FROM", "QUANTITY_TO"));
while ($arPrice = $dbPrice->Fetch()) {
if ($VAT_INCLUDE == 'N') {
if ($bVatIncluded) {
$arPrice['PRICE'] /= 1 + $fVatRate;
}
} else {
if (!$bVatIncluded) {
$arPrice['PRICE'] *= 1 + $fVatRate;
}
}
$arPrice['VAT_RATE'] = $fVatRate;
CCatalogDiscountSave::Disable();
$arDiscounts = CCatalogDiscount::GetDiscount($ID, $arProduct["IBLOCK_ID"], $arPrice["CATALOG_GROUP_ID"], $arUserGroups, "N", SITE_ID, array());
CCatalogDiscountSave::Enable();
//.........这里部分代码省略.........
示例10: intval
} else {
$result["err_code"] = -3;
//wID doesn't exists, can't delete 0;
}
break;
case 'ADD':
$param1 = $_REQUEST["PARAM1"];
$param2 = intval($_REQUEST["PARAM2"]) ?: false;
$param3 = intval($_REQUEST["PARAM3"]);
if ($param3 <= 0) {
$result["err_code"] = -4;
/*unknow element*/
break;
}
if (!$param2) {
$param2 = CIBlockElement::GetIBlockByID($param3);
if (!$param2) {
$result["err_code"] = -5;
/*unknown iblock_id*/
break;
}
}
$dbWishlistElement = CBrWishlist::GetList(array(), array("WL_USER_ID" => $WL_USER_ID, "PARAM1" => $param1, "PARAM2" => $param2, "PARAM3" => $param3), array("ID"));
if ($arWishlistElement = $dbWishlistElement->GetNext()) {
//element already exists
$result["WID"] = $arWishlistElement["ID"];
} else {
//add element to wishlist
$result["WID"] = CBrWishlist::Add(array("WL_USER_ID" => $WL_USER_ID, "PARAM1" => $param1, "PARAM2" => $param2, "PARAM3" => $param3));
}
$result["result"] = true;
示例11: GetOptimalPrice
//.........这里部分代码省略.........
}
}
$intProductID = (int) $intProductID;
if ($intProductID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage("BT_MOD_CATALOG_PROD_ERR_PRODUCT_ID_ABSENT"), "NO_PRODUCT_ID");
return false;
}
$quantity = (double) $quantity;
if ($quantity <= 0) {
$APPLICATION->ThrowException(Loc::getMessage("BT_MOD_CATALOG_PROD_ERR_QUANTITY_ABSENT"), "NO_QUANTITY");
return false;
}
if (!is_array($arUserGroups) && (int) $arUserGroups . '|' == (string) $arUserGroups . '|') {
$arUserGroups = array((int) $arUserGroups);
}
if (!is_array($arUserGroups)) {
$arUserGroups = array();
}
if (!in_array(2, $arUserGroups)) {
$arUserGroups[] = 2;
}
$renewal = $renewal == 'Y' ? 'Y' : 'N';
if ($siteID === false) {
$siteID = SITE_ID;
}
$resultCurrency = CCurrency::GetBaseCurrency();
if (empty($resultCurrency)) {
$APPLICATION->ThrowException(Loc::getMessage("BT_MOD_CATALOG_PROD_ERR_NO_BASE_CURRENCY"), "NO_BASE_CURRENCY");
return false;
}
if (self::$usedCurrency !== null) {
$resultCurrency = self::$usedCurrency;
}
$intIBlockID = (int) CIBlockElement::GetIBlockByID($intProductID);
if ($intIBlockID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_CATALOG_PROD_ERR_ELEMENT_ID_NOT_FOUND', array('#ID#' => $intProductID)), 'NO_ELEMENT');
return false;
}
if (!isset($arPrices) || !is_array($arPrices)) {
$arPrices = array();
}
if (empty($arPrices)) {
$arPrices = array();
$dbPriceList = CPrice::GetListEx(array(), array("PRODUCT_ID" => $intProductID, "GROUP_GROUP_ID" => $arUserGroups, "GROUP_BUY" => "Y", "+<=QUANTITY_FROM" => $quantity, "+>=QUANTITY_TO" => $quantity), false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY"));
while ($arPriceList = $dbPriceList->Fetch()) {
$arPriceList['ELEMENT_IBLOCK_ID'] = $intIBlockID;
$arPrices[] = $arPriceList;
}
unset($arPriceList, $dbPriceList);
} else {
foreach ($arPrices as &$arOnePrice) {
$arOnePrice['ELEMENT_IBLOCK_ID'] = $intIBlockID;
}
unset($arOnePrice);
}
if (empty($arPrices)) {
return false;
}
$rsVAT = CCatalogProduct::GetVATInfo($intProductID);
if ($arVAT = $rsVAT->Fetch()) {
$arVAT['RATE'] = (double) $arVAT['RATE'] * 0.01;
} else {
$arVAT = array('RATE' => 0.0, 'VAT_INCLUDED' => 'N');
}
unset($rsVAT);
if (self::getUseDiscount()) {
示例12: intval
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die;
}
if (isset($arParams["COMPONENT_ENABLE"]) && $arParams["COMPONENT_ENABLE"] === false) {
return;
}
if (!CModule::IncludeModule("brsoft.wishlist")) {
return;
}
//Обработка $arParams
$arParams["PARAM1"] = "iblock";
///TODO: for all modules
$arParams["PARAM2"] = intval($arParams["PARAM2"]) ?: false;
$arParams["PARAM3"] = intval($arParams["PARAM3"]);
if (!$arParams["PARAM2"]) {
$arParams["PARAM2"] = CIBlockElement::GetIBlockByID($arParams["PARAM3"]);
if (!$arParams["PARAM2"]) {
return;
}
}
if (empty($arParams["PARAM3"])) {
return;
}
//не показывать компонент если не указаны к чему он подкреплен (ИД ИБ, ИД елемента ИБ)
//Выбор данных для $arResult
$arResult = array();
$arResult["WL_USER_ID"] = intval(CBrWishlist::GetWLUserID());
$arResult["USER_ID"] = CBrWishlistUser::GetBXUserID($arResult["WL_USER_ID"]);
if ($arResult["WL_USER_ID"] <= 0) {
return;
}
示例13: clearPublicCache
protected static function clearPublicCache($productID, $productInfo = array())
{
$productID = (int)$productID;
if ($productID <= 0)
return;
$iblockID = (int)(isset($productInfo['IBLOCK_ID']) ? $productInfo['IBLOCK_ID'] : CIBlockElement::GetIBlockByID($productID));
if ($iblockID <= 0)
return;
if (defined('BX_COMP_MANAGED_CACHE') && !isset(self::$clearAutoCache[$iblockID]))
{
$taggedCache = \Bitrix\Main\Application::getInstance()->getTaggedCache();
$taggedCache->clearByTag('iblock_id_'.$iblockID);
self::$clearAutoCache[$iblockID] = true;
}
$productInfo['ID'] = $productID;
$productInfo['ELEMENT_IBLOCK_ID'] = $iblockID;
$productInfo['IBLOCK_ID'] = $iblockID;
foreach (GetModuleEvents('catalog', 'OnProductQuantityTrace', true) as $arEvent)
ExecuteModuleEventEx($arEvent, array($productID, $productInfo));
}
示例14: getIBlockCodeByElement
function getIBlockCodeByElement($elementId)
{
$arIblock = \CIBlock::GetArrayByID(\CIBlockElement::GetIBlockByID($elementId));
if (!empty($arIblock)) {
return $arIblock['CODE'];
}
return false;
}
示例15: GetDiscountByProduct
public function GetDiscountByProduct($productID = 0, $arUserGroups = array(), $renewal = "N", $arCatalogGroups = array(), $siteID = false, $arDiscountCoupons = false)
{
global $APPLICATION;
foreach (GetModuleEvents("catalog", "OnGetDiscountByProduct", true) as $arEvent) {
$mxResult = ExecuteModuleEventEx($arEvent, array($productID, $arUserGroups, $renewal, $arCatalogGroups, $siteID, $arDiscountCoupons));
if (true !== $mxResult) {
return $mxResult;
}
}
$productID = (int) $productID;
if ($productID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_CATALOG_DISC_ERR_ELEMENT_ID_NOT_FOUND', array('#ID' => $productID)), 'NO_ELEMENT');
return false;
}
$intIBlockID = CIBlockElement::GetIBlockByID($productID);
if ($intIBlockID === false) {
$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_CATALOG_DISC_ERR_ELEMENT_ID_NOT_FOUND', array('#ID#' => $productID)), 'NO_ELEMENT');
return false;
}
return CCatalogDiscount::GetDiscount($productID, $intIBlockID, $arCatalogGroups, $arUserGroups, $renewal, $siteID, $arDiscountCoupons);
}