本文整理汇总了PHP中CCatalogProductSet类的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogProductSet类的具体用法?PHP CCatalogProductSet怎么用?PHP CCatalogProductSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCatalogProductSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$arParams['CURRENCY_ID'] = '';
}
else
{
$arParams['CURRENCY_ID'] = $arCurrencyInfo['CURRENCY'];
$arConvertParams['CURRENCY_ID'] = $arCurrencyInfo['CURRENCY'];
}
}
}
$arResult['CONVERT_CURRENCY'] = $arConvertParams;
$countSetDefaultItems = 0;
$arSetItemsID = array($arResult['ELEMENT_ID']);
$arSetItemsDefaultID = array();
$arSetItemsOtherID = array();
$arSetItems = CCatalogProductSet::getAllSetsByProduct($arResult['PRODUCT_ID'], CCatalogProductSet::TYPE_GROUP);
foreach ($arSetItems as $arItems)
{
sortByColumn($arItems["ITEMS"], array('SORT' => SORT_ASC));
foreach ($arItems["ITEMS"] as $arItem)
{
$arSetItemsID[] = $arItem["ITEM_ID"];
if ($countSetDefaultItems < 3)
{
$arSetItemsDefaultID[$arItem["ITEM_ID"]] = $arItem["SORT"];
$countSetDefaultItems++;
}
else
{
$arSetItemsOtherID[$arItem["ITEM_ID"]] = $arItem["SORT"];
示例2: implode
}
foreach($arBarCodes as $productId => $barcode)
{
if (isset($arRows['E'.$productId]))
{
$arRows['E'.$productId]->arRes["CATALOG_BAR_CODE"] = implode(', ', $barcode);
}
}
}
}
if (!empty($arProductGroupIDs))
{
$rsSets = CCatalogProductSet::getList(
array(),
array('OWNER_ID' => array_keys($arProductGroupIDs), 'SET_ID' => 0, 'TYPE' => CCatalogProductSet::TYPE_GROUP),
false,
false,
array('ID', 'OWNER_ID', 'ITEM_ID', 'SET_ID', 'TYPE')
);
while ($arSet = $rsSets->Fetch())
{
$arSet['OWNER_ID'] = (int)$arSet['OWNER_ID'];
$arSet['ITEM_ID'] = (int)$arSet['ITEM_ID'];
if ($arSet['OWNER_ID'] == $arSet['ITEM_ID'] && isset($arProductGroupIDs[$arSet['OWNER_ID']]))
{
$arProductGroupIDs[$arSet['OWNER_ID']] = true;
}
}
}
if (!empty($arProductIDs))
{
示例3: Update
/**
* <p>Функция обновляет параметры товара, относящиеся к товару как к таковому.</p>
*
*
*
*
* @param int $ID Код товара.
*
*
*
* @param array $arFields Ассоциативный массив, ключами которого являются названия
* параметров товара, а значениями - новые значения параметров.
* Допустимые ключи: <br><br> ключи, независящие от типа товаров: <ul> <li>
* <b>QUANTITY</b> - количество товара на складе;</li> <li> <b>QUANTITY_RESERVED</b> -
* зарезервированное количество;</li> <li> <b>QUANTITY_TRACE</b> - флаг (Y/N/D)<b>*</b>
* "включить количественный учет" (до версии 12.5.0 параметр назывался
* "уменьшать ли количество при заказе");</li> </ul> <br> ключи для обычных
* товаров: <ul> <li> <b>CAN_BUY_ZERO</b> - флаг (Y/N/D)<b>*</b> "разрешить покупку при
* отсутствии товара";</li> <li> <b>NEGATIVE_AMOUNT_TRACE</b> - флаг (Y/N/D)<b>*</b>
* "разрешить отрицательное количество товара";</li> <li> <b>SUBSCRIBE</b> - флаг
* (Y/N/D)<b>*</b> "разрешить подписку при отсутствии товара"; <br><br> </li> <li>
* <b>PURCHASING_PRICE</b> - закупочная цена;</li> <li> <b>PURCHASING_CURRENCY</b> - валюта
* закупочной цены;<br><br> </li> <li> <b>WEIGHT</b> - вес единицы товара;<br><br> </li> <li>
* <b>WIDTH</b> - ширина товара (в мм);</li> <li> <b>LENGTH</b> - длина товара (в мм);</li>
* <li> <b>HEIGHT</b> - высота товара (в мм);</li> <li> <b>MEASURE</b> - ID единицы
* измерения;<br><br> </li> <li> <b>BARCODE_MULTI</b> - (Y/N) определяет каждый ли
* экземпляр товара имеет собственный штрихкод;</li> </ul> <br> ключи для
* продажи контента: <ul> <li> <b>PRICE_TYPE</b> - тип цены (S - одноразовый платеж,
* R - регулярные платежи, T - пробная подписка);</li> <li> <b>RECUR_SCHEME_TYPE</b> -
* тип периода подписки ("H" - час, "D" - сутки, "W" - неделя, "M" - месяц, "Q" -
* квартал, "S" - полугодие, "Y" - год);</li> <li> <b>RECUR_SCHEME_LENGTH</b> - длина
* периода подписки;</li> <li> <b>TRIAL_PRICE_ID</b> - код товара, для которого
* данный товар является пробным;</li> <li> <b>WITHOUT_ORDER</b> - флаг "Продление
* подписки без оформления заказа".</li> </ul>
*
*
*
* @return bool <p>Возвращает <i>true</i> в случае успешного обновления параметров и
* <i>false</i> в противном случае.</p>
*
*
* <h4>Example</h4>
* <pre>
* Обновление зарезервированного количества товара
*
*
* Cmodule::IncludeModule('catalog');
* $PRODUCT_ID = 51; // id товара
* $arFields = array('QUANTITY_RESERVED' => 11);// зарезервированное количество
* CCatalogProduct::Update($PRODUCT_ID, $arFields);
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogproduct/ccatalogproduct__update.bc9a623b.php
* @author Bitrix
*/
public static function Update($ID, $arFields)
{
global $DB;
$ID = (int) $ID;
if ($ID <= 0) {
return false;
}
if (array_key_exists('ID', $arFields)) {
unset($arFields["ID"]);
}
foreach (GetModuleEvents("catalog", "OnBeforeProductUpdate", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) {
return false;
}
}
if (!CCatalogProduct::CheckFields("UPDATE", $arFields, $ID)) {
return false;
}
$strUpdate = $DB->PrepareUpdate("b_catalog_product", $arFields);
$boolSubscribe = false;
if (!empty($strUpdate)) {
if (isset($arFields["QUANTITY"]) && $arFields["QUANTITY"] > 0) {
if (!isset($arFields["OLD_QUANTITY"])) {
$strQuery = 'select ID, QUANTITY from b_catalog_product where ID = ' . $ID;
$rsProducts = $DB->Query($strQuery, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arProduct = $rsProducts->Fetch()) {
$arFields["OLD_QUANTITY"] = doubleval($arProduct['QUANTITY']);
}
}
if (isset($arFields["OLD_QUANTITY"])) {
$boolSubscribe = $arFields["OLD_QUANTITY"] <= 0;
}
}
$strSql = "UPDATE b_catalog_product SET " . $strUpdate . " WHERE ID = " . $ID;
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (CBXFeatures::IsFeatureEnabled('CatCompleteSet') && (isset($arFields['QUANTITY']) || isset($arFields['QUANTITY_TRACE']) || isset($arFields['CAN_BUY_ZERO']) || isset($arFields['WEIGHT']))) {
CCatalogProductSet::recalculateSetsByProduct($ID);
}
if (isset(self::$arProductCache[$ID])) {
unset(self::$arProductCache[$ID]);
if (defined('CATALOG_GLOBAL_VARS') && 'Y' == CATALOG_GLOBAL_VARS) {
global $CATALOG_PRODUCT_CACHE;
$CATALOG_PRODUCT_CACHE = self::$arProductCache;
//.........这里部分代码省略.........
示例4: base64_encode
}
}
}
$arResult['OFFERS_PROP'] = $arUsedFields;
$arResult['OFFERS_PROP_CODES'] = (!empty($arUsedFields) ? base64_encode(serialize(array_keys($arUsedFields))) : '');
\Bitrix\Main\Type\Collection::sortByColumn($arResult['OFFERS'], $arSortFields);
if (!empty($arIDS) && CBXFeatures::IsFeatureEnabled('CatCompleteSet'))
{
$rsSets = CCatalogProductSet::getList(
array(),
array(
'@OWNER_ID' => $arIDS,
'=SET_ID' => 0,
'=TYPE' => CCatalogProductSet::TYPE_GROUP
),
false,
false,
array('ID', 'OWNER_ID')
);
while ($arSet = $rsSets->Fetch())
{
$arOfferSet[$arSet['OWNER_ID']] = true;
$arResult['OFFER_GROUP'] = true;
}
}
$arMatrix = array();
$intSelected = -1;
$arResult['MIN_PRICE'] = false;
示例5: makeItemsFromDbResult
/**
* @param \CDBResult $dbResultList
* @return array
*/
protected function makeItemsFromDbResult(\CDBResult $dbResultList)
{
$arItemsResult = $arProductIds = array();
while ($arItem = $dbResultList->Fetch()) {
if ($arItem['TYPE'] != 'S') {
$arProductIds[] = $arItem['ID'];
$arItem['PROPERTIES'] = $this->getItemProperies($arItem['ID']);
}
$arItemsResult[$arItem['ID']] = $arItem;
}
if (!empty($arProductIds)) {
$dbCatalogProduct = \CCatalogProduct::GetList(array(), array("ID" => $arProductIds));
while ($arCatalogProduct = $dbCatalogProduct->fetch()) {
$arItemsResult[$arCatalogProduct["ID"]]['PRODUCT'] = $arCatalogProduct;
}
$offersExistsIds = \CCatalogSKU::getExistOffers($arProductIds, $this->getIblockId());
$noOffersIds = array();
if ($offersExistsIds === false) {
$noOffersIds = $arProductIds;
} else {
$this->loadAllSku(array_keys(array_filter($offersExistsIds)));
foreach ($offersExistsIds as $id => $bExists) {
$arItem =& $arItemsResult[$id];
if ($bExists) {
$arItem['SKU_ITEMS'] = $this->getProductSku($arItem);
} else {
$noOffersIds[] = $id;
}
}
}
if (!empty($noOffersIds)) {
$priceIds = $this->getVisiblePrices();
foreach ($priceIds as $priceId) {
$dbPrice = \CPrice::GetList(array(), array('PRODUCT_ID' => $noOffersIds, 'CATALOG_GROUP_ID' => $priceId), false, false, array('PRODUCT_ID', 'PRICE', 'CURRENCY'));
while ($arPrice = $dbPrice->fetch()) {
$arItemsResult[$arPrice["PRODUCT_ID"]]['PRICES'][$priceId] = array('PRICE' => $arPrice['PRICE'], 'CURRENCY' => $arPrice['CURRENCY']);
}
}
if ($this->getStoreId()) {
$dbStoreProduct = \CCatalogStoreProduct::GetList(array(), array("PRODUCT_ID" => $noOffersIds, "STORE_ID" => $this->getStoreId()));
while ($arStoreProduct = $dbStoreProduct->Fetch()) {
$arItemsResult[$arStoreProduct["PRODUCT_ID"]]['PRODUCT']['STORE_AMOUNT'] = $arStoreProduct["AMOUNT"];
}
}
$groupsIterator = CCatalogProductSet::getList(array(), array('OWNER_ID' => $noOffersIds, 'SET_ID' => 0, 'TYPE' => \CCatalogProductSet::TYPE_GROUP), false, false, array('ID', 'OWNER_ID', 'ITEM_ID', 'SET_ID', 'TYPE'));
while ($group = $groupsIterator->Fetch()) {
if ($group['OWNER_ID'] == $group['ITEM_ID']) {
$arItemsResult[$group['OWNER_ID']]['PRODUCT']['IS_GROUP'] = true;
}
}
}
}
return $arItemsResult;
}
示例6: GetMessage
?></td></tr><?
$tabControl->EndCustomField('PRODUCT_SET', '');
}
if ($arShowTabs['product_group'])
{
$tabControl->BeginNextFormTab();
$tabControl->BeginCustomField('PRODUCT_GROUP', GetMessage('IBLOCK_EL_PRODUCT_GROUP').':', false);
?><tr id="tr_PRODUCT_GROUP"><td colspan="2"><?
$intProductID = (0 < $ID ? CIBlockElement::GetRealElement($ID) : 0);
$arSets = false;
CCatalogAdminProductSetEdit::setProductFormParams(array('TYPE' => CCatalogProductSet::TYPE_GROUP));
if (0 < $intProductID)
{
$arSets = CCatalogProductSet::getAllSetsByProduct($intProductID, CCatalogProductSet::TYPE_GROUP);
if ($bCopy)
CCatalogAdminProductSetEdit::clearOwnerSet($arSets);
}
if (empty($arSets))
$arSets = CCatalogAdminProductSetEdit::getEmptySet($intProductID);
if ($bVarsFromForm)
CCatalogAdminProductSetEdit::getFormValues($arSets);
CCatalogAdminProductSetEdit::addEmptyValues($arSets);
CCatalogAdminProductSetEdit::showEditForm($arSets);
?></td></tr><?
$tabControl->EndCustomField('PRODUCT_SET', '');
}
if($arShowTabs['workflow']):?>
示例7: ExportProductSets
function ExportProductSets()
{
if ($this->bCatalog && $this->bExtended) {
unset($this->next_step["FILTER"][">ID"]);
$rsElements = CIBlockElement::GetList(array(), $this->next_step["FILTER"], false, false, array("ID", "XML_ID"));
fwrite($this->fp, "\t<" . GetMessage("IBLOCK_XML2_PRODUCTS_SETS") . ">\n");
while ($arElement = $rsElements->Fetch()) {
if (CCatalogProductSet::isProductHaveSet($arElement["ID"], CCatalogProductSet::TYPE_GROUP)) {
if (strlen($arElement["XML_ID"]) > 0) {
$xml_id = $arElement["XML_ID"];
} else {
$xml_id = $arElement["ID"];
}
$this->ExportProductSet($arElement["ID"], $xml_id);
}
}
fwrite($this->fp, "\t</" . GetMessage("IBLOCK_XML2_PRODUCTS_SETS") . ">\n");
}
}
示例8: GetSetItems
public static function GetSetItems($productID, $intType, $arProducInfo = array())
{
$arProductId = array();
static $proxyCatalogProductSet = array();
static $proxyCatalogSkuData = array();
static $proxyCatalogProduct = array();
static $proxyIblockProperty = array();
static $proxyProductProperty = array();
$proxyCatalogProductSetKey = $productID . "|" . $intType;
if (!empty($proxyCatalogProductSet[$proxyCatalogProductSetKey]) && is_array($proxyCatalogProductSet[$proxyCatalogProductSetKey])) {
$arSets = $proxyCatalogProductSet[$proxyCatalogProductSetKey];
} else {
$arSets = CCatalogProductSet::getAllSetsByProduct($productID, $intType);
if (!empty($arSets) && is_array($arSets)) {
$proxyCatalogProductSet[$proxyCatalogProductSetKey] = $arSets;
}
}
if (is_array($arSets)) {
foreach ($arSets as $k => $arSet) {
foreach ($arSet["ITEMS"] as $k1 => $item) {
$arItem = self::GetProductData(array("PRODUCT_ID" => $item["ITEM_ID"], "QUANTITY" => $item["QUANTITY"], "CHECK_QUANTITY" => "N", "CHECK_PRICE" => "N"));
if (array_key_exists('QUANTITY_TRACE', $arItem)) {
unset($arItem['QUANTITY_TRACE']);
}
$arItem["PRODUCT_ID"] = $item["ITEM_ID"];
$arItem["MODULE"] = "catalog";
$arItem["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
if ($intType == CCatalogProductSet::TYPE_SET) {
$arItem['SET_DISCOUNT_PERCENT'] = $item['DISCOUNT_PERCENT'] == '' ? false : (double) $item['DISCOUNT_PERCENT'];
}
$arProductId[] = $item["ITEM_ID"];
$arItem["PROPS"] = array();
if (!empty($proxyCatalogSkuData[$item["ITEM_ID"]]) && is_array($proxyCatalogSkuData[$item["ITEM_ID"]])) {
$arParentSku = $proxyCatalogSkuData[$item["ITEM_ID"]];
} else {
if ($arParentSku = CCatalogSku::GetProductInfo($item["ITEM_ID"])) {
$proxyCatalogSkuData[$item["ITEM_ID"]] = $arParentSku;
}
}
if (!empty($arParentSku)) {
$arPropsSku = array();
if (!($arProduct = static::getHitCache('IBLOCK_ELEMENT', $item["ITEM_ID"]))) {
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $item["ITEM_ID"]), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'IBLOCK_SECTION_ID'));
if ($arProduct = $dbProduct->Fetch()) {
static::setHitCache('IBLOCK_ELEMENT', $item["ITEM_ID"], $arProduct);
}
}
if (!($arPropsSku = static::getHitCache('IBLOCK_PROPERTY', $arProduct["IBLOCK_ID"]))) {
$dbOfferProperties = CIBlock::GetProperties($arProduct["IBLOCK_ID"], array(), array("!XML_ID" => "CML2_LINK"));
while ($arOfferProperties = $dbOfferProperties->Fetch()) {
$arPropsSku[] = $arOfferProperties["CODE"];
}
static::setHitCache('IBLOCK_PROPERTY', $arProduct["IBLOCK_ID"], $arPropsSku);
}
$proxyProductPropertyKey = $item["ITEM_ID"] . "_" . $arParentSku["IBLOCK_ID"] . "_" . md5(join('|', $arPropsSku));
if (!($product_properties = static::getHitCache('PRODUCT_PROPERTY', $proxyProductPropertyKey))) {
$product_properties = CIBlockPriceTools::GetOfferProperties($item["ITEM_ID"], $arParentSku["IBLOCK_ID"], $arPropsSku);
static::setHitCache('PRODUCT_PROPERTY', $proxyProductPropertyKey, $product_properties);
}
foreach ($product_properties as $propData) {
$arItem["PROPS"][] = array("NAME" => $propData["NAME"], "CODE" => $propData["CODE"], "VALUE" => $propData["VALUE"], "SORT" => $propData["SORT"]);
}
}
$arSets[$k]["ITEMS"][$k1] = array_merge($item, $arItem);
}
}
if (!($productList = static::getHitCache('IBLOCK_ELEMENT_LIST', $productID))) {
$rsProducts = CIBlockElement::GetList(array(), array('ID' => $arProductId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "IBLOCK_TYPE_ID", "XML_ID"));
while ($arProduct = $rsProducts->GetNext()) {
$productList[] = $arProduct;
}
if (!empty($productList) && is_array($productList)) {
static::setHitCache('IBLOCK_ELEMENT_LIST', $productID, $productList);
}
}
if (!empty($productList) && is_array($productList)) {
foreach ($productList as $arProduct) {
foreach ($arSets as $k => $arSet) {
foreach ($arSet["ITEMS"] as $k1 => $item) {
if ($item["ITEM_ID"] == $arProduct["ID"]) {
$arProps = array();
$strIBlockXmlID = strval(CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'XML_ID'));
if ($strIBlockXmlID != "") {
$arProps[] = array("NAME" => "Catalog XML_ID", "CODE" => "CATALOG.XML_ID", "VALUE" => $strIBlockXmlID);
}
$arProps[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $arProduct["XML_ID"]);
$arSets["{$k}"]["ITEMS"][$k1]["IBLOCK_ID"] = $arProduct["IBLOCK_ID"];
$arSets["{$k}"]["ITEMS"][$k1]["IBLOCK_SECTION_ID"] = $arProduct["IBLOCK_SECTION_ID"];
$arSets["{$k}"]["ITEMS"][$k1]["PREVIEW_PICTURE"] = $arProduct["PREVIEW_PICTURE"];
$arSets["{$k}"]["ITEMS"][$k1]["DETAIL_PICTURE"] = $arProduct["DETAIL_PICTURE"];
$arSets["{$k}"]["ITEMS"][$k1]["PROPS"] = array_merge($arSets["{$k}"]["ITEMS"][$k1]["PROPS"], $arProps);
}
}
}
}
}
}
foreach (GetModuleEvents("sale", "OnGetSetItems", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arSets));
}
//.........这里部分代码省略.........
示例9: getAllCounter
public static function getAllCounter()
{
return (int) CCatalogProductSet::getList(array(), array('TYPE' => CCatalogProductSet::TYPE_SET, 'SET_ID' => 0), array());
}
示例10: checkFieldsToUpdate
protected function checkFieldsToUpdate($intID, &$arFields)
{
global $DB;
global $USER;
$intCurrentUser = 0;
if (CCatalog::IsUserExists()) {
$intCurrentUser = (int) $USER->GetID();
}
if ($intCurrentUser <= 0) {
$intCurrentUser = false;
}
$strTimeFunc = $DB->GetNowFunction();
$arDefItem = self::getEmptyItemFields();
$arProductInSet = array();
$dblDiscountPercent = 0;
$boolItems = false;
$intID = (int) $intID;
if ($intID <= 0) {
self::$arErrors[] = array('id' => 'ID', 'text' => GetMessage('BT_CAT_SET_ERR_ID_IS_BAD'));
}
if (empty(self::$arErrors)) {
$arCurrent = CCatalogProductSet::getSetByID($intID);
if (empty($arCurrent)) {
self::$arErrors[] = array('id' => 'ID', 'text' => GetMessage('BT_CAT_SET_ERR_ID_IS_BAD'));
}
}
if (empty(self::$arErrors)) {
self::clearFieldsForUpdate($arFields, $arCurrent['TYPE']);
if (array_key_exists('ACTIVE', $arFields)) {
$arFields['ACTIVE'] = 'N' != $arFields['ACTIVE'] ? 'Y' : 'N';
}
if (array_key_exists('SORT', $arFields)) {
$arFields['SORT'] = (int) $arFields['SORT'];
if ($arFields['SORT'] <= 0) {
$arFields['SORT'] = 100;
}
}
$arFields['MODIFIED_BY'] = !array_key_exists('MODIFIED_BY', $arFields) ? 0 : (int) $arFields['MODIFIED_BY'];
if ($arFields['MODIFIED_BY'] <= 0) {
$arFields['MODIFIED_BY'] = $intCurrentUser;
}
$arFields['~TIMESTAMP_X'] = $strTimeFunc;
}
if (empty(self::$arErrors)) {
$arProductInSet[$arCurrent['ITEM_ID']] = true;
if (array_key_exists('ITEMS', $arFields)) {
if (empty($arFields['ITEMS']) || !is_array($arFields['ITEMS'])) {
self::$arErrors[] = array('id' => 'ITEMS', 'text' => GetMessage('BT_CAT_SET_ERR_ITEMS_IS_ABSENT'));
} else {
$arValidItems = array();
foreach ($arFields['ITEMS'] as &$arOneItem) {
if (empty($arOneItem) || !is_array($arOneItem)) {
continue;
}
if (array_key_exists('ID', $arOneItem)) {
unset($arOneItem['ID']);
}
if (!array_key_exists('ITEM_ID', $arOneItem)) {
continue;
}
$arOneItem['ITEM_ID'] = (int) $arOneItem['ITEM_ID'];
if ($arOneItem['ITEM_ID'] <= 0) {
continue;
}
if (isset($arProductInSet[$arOneItem['ITEM_ID']])) {
self::$arErrors[] = array('id' => 'ITEM_ID', 'text' => GetMessage('BT_CAT_PRODUCT_SET_ERR_ITEM_ID_DUBLICATE'));
continue;
}
$arProductInSet[$arOneItem['ITEM_ID']] = true;
$intRowID = self::searchItem($arOneItem['ITEM_ID'], $arCurrent['ITEMS']);
if (false === $intRowID) {
$arOneItem = array_merge($arDefItem, $arOneItem);
} else {
$arOneItem['ID'] = $intRowID;
}
if (array_key_exists('SORT', $arOneItem)) {
$arOneItem['SORT'] = (int) $arOneItem['SORT'];
if ($arOneItem['SORT'] <= 0) {
$arOneItem['SORT'] = 100;
}
}
if (array_key_exists('QUANTITY', $arOneItem)) {
$arOneItem['QUANTITY'] = doubleval($arOneItem['QUANTITY']);
if (0 >= $arOneItem['QUANTITY']) {
self::$arErrors[] = array('id' => 'QUANTITY', 'text' => self::TYPE_SET == $arFields['TYPE'] ? GetMessage('BT_CAT_PRODUCT_SET_ERR_QUANTITY_IS_BAD') : GetMessage('BT_CAT_PRODUCT_SET_ERR_QUANTITY_GROUP_IS_BAD'));
continue;
}
}
if (self::TYPE_SET == $arCurrent['TYPE']) {
if (array_key_exists('MEASURE', $arOneItem)) {
$arOneItem['MEASURE'] = (int) $arOneItem['MEASURE'];
if ($arOneItem['MEASURE'] < 0) {
$arOneItem['MEASURE'] = 0;
}
}
if (array_key_exists('DISCOUNT_PERCENT', $arOneItem)) {
if (false !== $arOneItem['DISCOUNT_PERCENT']) {
$arOneItem['DISCOUNT_PERCENT'] = doubleval($arOneItem['DISCOUNT_PERCENT']);
if (0 > $arOneItem['DISCOUNT_PERCENT'] || 100 < $arOneItem['DISCOUNT_PERCENT']) {
self::$arErrors[] = array('id' => 'DISCOUNT_PERCENT', 'text' => GetMessage('BT_CAT_PRODUCT_SET_ERR_DISCOUNT_PERCENT_IS_BAD'));
//.........这里部分代码省略.........
示例11: makeItemsFromDbResult
/**
* @param \CDBResult $dbResultList
* @return array
*/
protected function makeItemsFromDbResult(\CDBResult $dbResultList)
{
$arItemsResult = $arProductIds = array();
while ($arItem = $dbResultList->Fetch()) {
if ($arItem['TYPE'] != 'S') {
$arProductIds[] = $arItem['ID'];
$arItem['PROPERTIES'] = $this->getItemProperies($arItem['ID']);
$arItemsResult[$arItem['ID']] = $arItem;
} else {
$arItemsResult['S' . $arItem['ID']] = $arItem;
}
}
if (!empty($arProductIds)) {
$dbCatalogProduct = \CCatalogProduct::GetList(array(), array('@ID' => $arProductIds));
while ($arCatalogProduct = $dbCatalogProduct->fetch()) {
$arItemsResult[$arCatalogProduct['ID']]['PRODUCT'] = $arCatalogProduct;
}
$offersExistsIds = \CCatalogSKU::getExistOffers($arProductIds, $this->getIblockId());
$noOffersIds = array();
if (empty($offersExistsIds)) {
$noOffersIds = $arProductIds;
} else {
$this->loadAllSku(array_keys(array_filter($offersExistsIds)));
foreach ($offersExistsIds as $id => $bExists) {
$arItem =& $arItemsResult[$id];
if ($bExists) {
$arItem['SKU_ITEMS'] = $this->getProductSku($arItem);
} else {
$noOffersIds[] = $id;
}
}
unset($id, $bExists);
}
if (!empty($noOffersIds)) {
$productRatioList = Catalog\ProductTable::getCurrentRatioWithMeasure($noOffersIds);
if (!empty($productRatioList)) {
foreach ($productRatioList as $productId => $productRatio) {
if (!isset($arItemsResult[$productId]['PRODUCT'])) {
continue;
}
$arItemsResult[$productId]['PRODUCT']['MEASURE_RATIO'] = $productRatio['RATIO'];
$arItemsResult[$productId]['PRODUCT']['MEASURE'] = $productRatio['MEASURE'];
}
unset($productRatio, $productId);
}
unset($productRatioList);
$priceIds = $this->getVisiblePrices();
foreach ($priceIds as $priceId) {
$dbPrice = \CPrice::GetListEx(array(), array('PRODUCT_ID' => $noOffersIds, 'CATALOG_GROUP_ID' => $priceId), false, false, array('PRODUCT_ID', 'PRICE', 'CURRENCY', 'QUANTITY_FROM', 'QUANTITY_TO'));
while ($arPrice = $dbPrice->fetch()) {
$arPrice['QUANTITY_FROM'] = (int) $arPrice['QUANTITY_FROM'];
$arPrice['QUANTITY_TO'] = (int) $arPrice['QUANTITY_TO'];
if (!isset($arItemsResult[$arPrice["PRODUCT_ID"]]['PRICES'][$priceId]) || $arItemsResult[$arPrice["PRODUCT_ID"]]['PRICES'][$priceId]['QUANTITY_FROM'] > $arPrice['QUANTITY_FROM']) {
$arItemsResult[$arPrice["PRODUCT_ID"]]['PRICES'][$priceId] = array('PRICE' => $arPrice['PRICE'], 'CURRENCY' => $arPrice['CURRENCY'], 'QUANTITY_FROM' => $arPrice['QUANTITY_FROM'], 'QUANTITY_TO' => $arPrice['QUANTITY_TO']);
}
}
unset($arPrice, $dbPrice);
}
if ($this->getStoreId()) {
$dbStoreProduct = \CCatalogStoreProduct::GetList(array(), array("PRODUCT_ID" => $noOffersIds, "STORE_ID" => $this->getStoreId()));
while ($arStoreProduct = $dbStoreProduct->Fetch()) {
$arItemsResult[$arStoreProduct["PRODUCT_ID"]]['PRODUCT']['STORE_AMOUNT'] = $arStoreProduct["AMOUNT"];
}
}
$groupsIterator = CCatalogProductSet::getList(array(), array('OWNER_ID' => $noOffersIds, 'SET_ID' => 0, 'TYPE' => \CCatalogProductSet::TYPE_GROUP), false, false, array('ID', 'OWNER_ID', 'ITEM_ID', 'SET_ID', 'TYPE'));
while ($group = $groupsIterator->Fetch()) {
if ($group['OWNER_ID'] == $group['ITEM_ID']) {
$arItemsResult[$group['OWNER_ID']]['PRODUCT']['IS_GROUP'] = true;
}
}
}
}
return $arItemsResult;
}
示例12: GetSetItems
public static function GetSetItems($productID, $intType, $arProducInfo = array())
{
$arProductId = array();
$arSets = CCatalogProductSet::getAllSetsByProduct($productID, $intType);
if (is_array($arSets))
{
foreach ($arSets as $k => $arSet)
{
foreach ($arSet["ITEMS"] as $k1 => $item)
{
$arItem = self::GetProductData(array("PRODUCT_ID" => $item["ITEM_ID"], "QUANTITY" => $item["QUANTITY"], "CHECK_QUANTITY" => "N", "CHECK_PRICE" => "N"));
$arItem["PRODUCT_ID"] = $item["ITEM_ID"];
$arItem["MODULE"] = "catalog";
$arItem["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
if ($intType == CCatalogProductSet::TYPE_SET)
{
$arItem['SET_DISCOUNT_PERCENT'] = ($item['DISCOUNT_PERCENT'] == '' ? false : (float)$item['DISCOUNT_PERCENT']);
}
$arProductId[] = $item["ITEM_ID"];
$arItem["PROPS"] = array();
$arParentSku = CCatalogSku::GetProductInfo($item["ITEM_ID"]);
if (!empty($arParentSku))
{
$arPropsSku = array();
$dbProduct = CIBlockElement::GetList(array(), array("ID" => $item["ITEM_ID"]), false, false, array('IBLOCK_ID', 'IBLOCK_SECTION_ID'));
$arProduct = $dbProduct->Fetch();
$dbOfferProperties = CIBlock::GetProperties($arProduct["IBLOCK_ID"], array(), array("!XML_ID" => "CML2_LINK"));
while($arOfferProperties = $dbOfferProperties->Fetch())
$arPropsSku[] = $arOfferProperties["CODE"];
$product_properties = CIBlockPriceTools::GetOfferProperties(
$item["ITEM_ID"],
$arParentSku["IBLOCK_ID"],
$arPropsSku
);
foreach ($product_properties as $propData)
{
$arItem["PROPS"][] = array(
"NAME" => $propData["NAME"],
"CODE" => $propData["CODE"],
"VALUE" => $propData["VALUE"],
"SORT" => $propData["SORT"]
);
}
}
$arSets[$k]["ITEMS"][$k1] = array_merge($item, $arItem);
}
}
$rsProducts = CIBlockElement::GetList(
array(),
array('ID' => $arProductId),
false,
false,
array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "IBLOCK_TYPE_ID", "XML_ID")
);
while ($arProduct = $rsProducts->GetNext())
{
foreach ($arSets as $k => $arSet)
{
foreach ($arSet["ITEMS"] as $k1 => $item)
{
if ($item["ITEM_ID"] == $arProduct["ID"])
{
$arProps = array();
$strIBlockXmlID = strval(CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'XML_ID'));
if ($strIBlockXmlID != "")
{
$arProps[] = array(
"NAME" => "Catalog XML_ID",
"CODE" => "CATALOG.XML_ID",
"VALUE" => $strIBlockXmlID
);
}
$arProps[] = array(
"NAME" => "Product XML_ID",
"CODE" => "PRODUCT.XML_ID",
"VALUE" => $arProduct["XML_ID"]
);
$arSets["$k"]["ITEMS"][$k1]["IBLOCK_ID"] = $arProduct["IBLOCK_ID"];
$arSets["$k"]["ITEMS"][$k1]["IBLOCK_SECTION_ID"] = $arProduct["IBLOCK_SECTION_ID"];
$arSets["$k"]["ITEMS"][$k1]["PREVIEW_PICTURE"] = $arProduct["PREVIEW_PICTURE"];
$arSets["$k"]["ITEMS"][$k1]["DETAIL_PICTURE"] = $arProduct["DETAIL_PICTURE"];
$arSets["$k"]["ITEMS"][$k1]["PROPS"] = array_merge($arSets["$k"]["ITEMS"][$k1]["PROPS"], $arProps);
}
}
}
}
}
//.........这里部分代码省略.........
示例13: saveFormValues
public static function saveFormValues($arItem)
{
$boolFeatureSet = CBXFeatures::IsFeatureEnabled('CatCompleteSet');
if (!$boolFeatureSet) {
return;
}
if (0 >= $arItem['PRODUCT_ID']) {
return;
}
if (!empty(self::$arCheckValues[self::$strMainPrefix])) {
foreach (self::$arCheckValues[self::$strMainPrefix] as $key => $arSaveSet) {
if (0 >= $arSaveSet['ITEM_ID']) {
$arSaveSet['ITEM_ID'] = $arItem['PRODUCT_ID'];
}
$boolNew = 0 >= (int) $key;
if ($boolNew) {
CCatalogProductSet::add($arSaveSet);
} else {
CCatalogProductSet::update($key, $arSaveSet);
}
}
}
}
示例14: array
$arCurrencyInfo = CCurrency::GetByID($arParams['CURRENCY_ID']);
if (!(is_array($arCurrencyInfo) && !empty($arCurrencyInfo))) {
$arParams['CONVERT_CURRENCY'] = 'N';
$arParams['CURRENCY_ID'] = '';
} else {
$arParams['CURRENCY_ID'] = $arCurrencyInfo['CURRENCY'];
$arConvertParams['CURRENCY_ID'] = $arCurrencyInfo['CURRENCY'];
}
}
}
$arResult['CONVERT_CURRENCY'] = $arConvertParams;
$countSetDefaultItems = 0;
$arSetItemsID = array($elementID);
$arSetItemsDefaultID = array();
$arSetItemsOtherID = array();
$arSetItems = CCatalogProductSet::getAllSetsByProduct($elementID, CCatalogProductSet::TYPE_GROUP);
foreach ($arSetItems as $arItems) {
sortByColumn($arItems["ITEMS"], array('SORT' => SORT_ASC));
foreach ($arItems["ITEMS"] as $arItem) {
$arSetItemsID[] = $arItem["ITEM_ID"];
if ($countSetDefaultItems < 3) {
$arSetItemsDefaultID[$arItem["ITEM_ID"]] = $arItem["SORT"];
$countSetDefaultItems++;
} else {
$arSetItemsOtherID[$arItem["ITEM_ID"]] = $arItem["SORT"];
}
}
}
$arSelect = array("ID", "NAME", "CODE", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PAGE_URL", "PREVIEW_PICTURE", "DETAIL_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE");
$arResult["PRICES"] = CIBlockPriceTools::GetCatalogPrices($arParams["IBLOCK_ID"], $arParams["PRICE_CODE"]);
foreach ($arResult["PRICES"] as $key => $value) {
示例15: array
$arIblockOfferProps[] = array("CODE" => "TITLE", "NAME" => GetMessage("CATALOG_OFFER_NAME"));
}
$arResult["SKU_ELEMENTS"] = $arSku;
$arResult["SKU_PROPERTIES"] = $arIblockOfferProps;
}
if ($arParams['USE_COMPARE']) {
$delimiter = strpos($arParams['COMPARE_URL'], '?') ? '&' : '?';
//$arResult['COMPARE_URL'] = str_replace("#ACTION_CODE#", "ADD_TO_COMPARE_LIST",$arParams['COMPARE_URL']).$delimiter."id=".$arResult['ID'];
$arResult['COMPARE_URL'] = htmlspecialcharsbx($APPLICATION->GetCurPageParam("action=ADD_TO_COMPARE_LIST&id=" . $arResult['ID'], array("action", "id")));
}
if ($arParams["SHOW_KIT_PARTS"] == "Y") {
//const TYPE_SET = 1;
//const TYPE_GROUP = 2;
$arSetItems = array();
$arResult["SET_ITEMS_IDS"] = array();
$arSets = CCatalogProductSet::getAllSetsByProduct($arResult["ID"], 1);
if (is_array($arSets) && $arSets) {
foreach ($arSets as $key => $set) {
foreach ($set["ITEMS"] as $i => $val) {
$arSetItems[] = $val["ITEM_ID"];
$arResult["SET_ITEMS_IDS"][$val["ITEM_ID"]] = $val;
}
}
$arResultPrices = CIBlockPriceTools::GetCatalogPrices($arParams["IBLOCK_ID"], $arParams["PRICE_CODE"]);
$arSelect = array("ID", "IBLOCK_ID", "NAME", "DETAIL_PAGE_URL", "PREVIEW_PICTURE", "DETAIL_PICTURE");
foreach ($arResultPrices as &$value) {
if ($value['CAN_VIEW'] && $value['CAN_BUY']) {
$arSelect[] = $value["SELECT"];
}
}
if (!empty($arSetItems)) {