public static function getOfferObject(array $offerParams) { if (!isset($offerParams["IBLOCK_ID"]) || intval($offerParams["IBLOCK_ID"]) <= 0) { throw new SystemException("Incorrect iBlock ID (" . __CLASS__ . "::" . __METHOD__ . ")"); } $arCatalog = \CCatalog::GetByIDExt($offerParams["IBLOCK_ID"]); if (empty($arCatalog)) { throw new SystemException("IBlock is not catalog. (" . __CLASS__ . "::" . __METHOD__ . ")"); } $catalogType = $arCatalog["CATALOG_TYPE"]; $catalogTypes = \CCatalogSKU::GetCatalogTypes(); if (!in_array($catalogType, $catalogTypes)) { throw new SystemException("Unknown type of catalog (" . __CLASS__ . "::" . __METHOD__ . ")"); } $result = array(); switch ($catalogType) { case \CCatalogSKU::TYPE_CATALOG: case \CCatalogSKU::TYPE_OFFERS: $result = new ExportOffer($catalogType, $offerParams); break; case \CCatalogSKU::TYPE_PRODUCT: case \CCatalogSKU::TYPE_FULL: $result = new ExportOfferSKU($catalogType, $offerParams); break; } return $result; }
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; }
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__); }
public function checkByShipment(\Bitrix\Sale\Shipment $shipment, array $restrictionParams, $deliveryId = 0) { if (!\Bitrix\Main\Loader::includeModule('iblock')) { return array(); } if (!\Bitrix\Main\Loader::includeModule('catalog')) { return array(); } $productIds = array(); /** @var \Bitrix\Sale\ShipmentItem $shipmentItem */ foreach ($shipment->getShipmentItemCollection() as $shipmentItem) { /** @var \Bitrix\Sale\BasketItem $basketItem */ $basketItem = $shipmentItem->getBasketItem(); if ($basketItem->getField('MODULE') != 'catalog') { continue; } $productId = intval($basketItem->getField('PRODUCT_ID')); $iblockId = (int) \CIBlockElement::getIBlockByID($productId); $info = \CCatalogSKU::getProductInfo($productId, $iblockId); if (!empty($info['ID'])) { $candidate = $info['ID']; } else { $candidate = $productId; } if (!in_array($candidate, $productIds)) { $productIds[] = $candidate; } } $categoriesIds = self::getGroupsIds($productIds); return $this->check($categoriesIds, $restrictionParams, $deliveryId); }
public function GetProductInfo($intOfferID, $intIBlockID = 0) { $intOfferID = intval($intOfferID); if (0 >= $intOfferID) { return false; } $intIBlockID = intval($intIBlockID); if (0 >= $intIBlockID) { $rsItems = CIBlockElement::GetList(array(), array("ID" => $intOfferID, "SHOW_HISTORY" => "Y"), false, false, array('ID', 'IBLOCK_ID')); if ($arItem = $rsItems->Fetch()) { $intIBlockID = intval($arItem['IBLOCK_ID']); } } if (0 >= $intIBlockID) { return false; } $arSkuInfo = CCatalogSKU::GetInfoByOfferIBlock($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'] = intval($arItem['VALUE']); if (0 < $arItem['VALUE']) { return array('ID' => $arItem['VALUE'], 'IBLOCK_ID' => $arSkuInfo['PRODUCT_IBLOCK_ID']); } } return false; }
function getOffers() { if (!class_exists('\\CCatalogSKU')) { \CModule::IncludeModule('catalog'); } $retval = array(); $arInfo = \CCatalogSKU::GetInfoByProductIBlock($this->iblock_id); if (is_array($arInfo)) { $retval = \Cpeople\Classes\Block\Getter::instance()->setFilter(array('IBLOCK_ID' => $arInfo['IBLOCK_ID'], 'PROPERTY_' . $arInfo['SKU_PROPERTY_ID'] => $this->id))->setClassName('\\Cpeople\\Classes\\Catalog\\Offer')->get(); } return empty_array($retval) ? false : $retval; }
/** * Common function, used to update/insert any product. * * @param int $productId Id of product. * @param int $fuserId User basket id. * @param string $siteId Site id. * @param int $elementId Parent id. * @param string $recommendationId Bigdata recommendation id. * * @return int Id of row. */ public static function refresh($productId, $fuserId, $siteId = SITE_ID, $elementId = 0, $recommendationId = '') { $connection = Application::getConnection(); $productId = (int) $productId; if ($productId <= 0) { return -1; } $fuserId = (int) $fuserId; if ($fuserId <= 0) { return -1; } if (!is_string($siteId) || strlen($siteId) <= 0) { return -1; } $filter = array("FUSER_ID" => $fuserId, "SITE_ID" => $siteId); if ($elementId > 0) { $filter["ELEMENT_ID"] = $elementId; // Delete parent product id (for capability) if ($elementId != $productId) { $connection->query("DELETE FROM\n\t\t\t\t\t\t\t\t\t\tb_catalog_viewed_product\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\tPRODUCT_ID = " . intval($elementId) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tFUSER_ID = " . intval($fuserId) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tSITE_ID = '" . $connection->getSqlHelper()->forSql($siteId) . "'"); } } else { $iblockId = (int) \CIBlockElement::getIBlockByID($productId); if ($iblockId <= 0) { return -1; } $productInfo = \CCatalogSKU::getProductInfo($productId, $iblockId); // Concrete SKU ID if (!empty($productInfo)) { $filter['PRODUCT_ID'] = array(); $siblings = array(); // Delete parent product id (for capability) $connection->query("DELETE FROM\n\t\t\t\t\t\t\t\t\t\tb_catalog_viewed_product\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\tPRODUCT_ID = " . intval($productInfo['ID']) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tFUSER_ID = " . intval($fuserId) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tSITE_ID = '" . $connection->getSqlHelper()->forSql($siteId) . "'"); $skuInfo = \CCatalogSKU::getInfoByOfferIBlock($iblockId); $skus = \CIBlockElement::getList(array(), array('IBLOCK_ID' => $iblockId, 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID'] => $productInfo['ID']), false, false, array('ID', 'IBLOCK_ID')); while ($oneSku = $skus->fetch()) { $siblings[] = $oneSku['ID']; } $filter["PRODUCT_ID"] = $siblings; } else { $filter["PRODUCT_ID"] = $productId; } } $iterator = static::getList(array("filter" => $filter, "select" => array("ID", "FUSER_ID", "DATE_VISIT", "PRODUCT_ID", "SITE_ID", "VIEW_COUNT"))); if ($row = $iterator->fetch()) { static::update($row["ID"], array("PRODUCT_ID" => $productId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), 'VIEW_COUNT' => $row['VIEW_COUNT'] + 1, "ELEMENT_ID" => $elementId, "RECOMMENDATION" => $recommendationId)); return $row['ID']; } else { $result = static::add(array("FUSER_ID" => $fuserId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), "PRODUCT_ID" => $productId, "ELEMENT_ID" => $elementId, "SITE_ID" => $siteId, "VIEW_COUNT" => 1, "RECOMMENDATION" => $recommendationId)); return $result->getId(); } }
/** * If elementId is an offer, then it's product identifier returned * Otherwise $elementId returned. * * @param integer $iblockId Information block identifier. * @param integer $elementId Element identifier. * * @return integer */ public static function resolveElement($iblockId, $elementId) { if (self::$catalog === null) { self::$catalog = \Bitrix\Main\Loader::includeModule("catalog"); } if (self::$catalog) { $catalog = \CCatalogSKU::getProductInfo($elementId, $iblockId); if (!empty($catalog) && is_array($catalog)) { return $catalog["ID"]; } } return $elementId; }
private function checkOffers($product_id) { if (CCatalogSKU::IsExistOffers($product_id, $this->iblock_id)) { $arSelect = array("IBLOCK_ID", "ID", "CATALOG_GROUP_1"); $arFilter = array("PROPERTY_CML2_LINK" => $product_id, "ACTIVE" => "Y"); $res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect); if ($ob = $res->GetNextElement()) { $arFields = $ob->GetFields(); return $arFields['CATALOG_PRICE_1']; } } else { return false; } }
protected function getOffers() { $arPropertyMap = array(); $arSelectedPropTypes = array('S', 'N', 'L', 'E', 'G'); $this->arSelectOfferProps = array(); $arOffers = \CCatalogSKU::GetInfoByProductIBlock($this->iBlockId); if (empty($arOffers['IBLOCK_ID'])) { return array(); } $this->intOfferIBlockID = $arOffers['IBLOCK_ID']; $rsOfferIBlocks = \CIBlock::GetByID($this->intOfferIBlockID); if (!($this->arOfferIBlock = $rsOfferIBlocks->Fetch())) { throw new SystemException("Bad offers iBlock ID (" . __CLASS__ . "::" . __METHOD__ . ")"); } $rsProps = \CIBlockProperty::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('IBLOCK_ID' => $this->intOfferIBlockID, 'ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N')); while ($arProp = $rsProps->Fetch()) { $arProp['ID'] = (int) $arProp['ID']; if ($arOffers['SKU_PROPERTY_ID'] != $arProp['ID']) { $arProp['USER_TYPE'] = (string) $arProp['USER_TYPE']; $arProp['CODE'] = (string) $arProp['CODE']; $this->arIblock['OFFERS_PROPERTY'][$arProp['ID']] = $arProp; $this->arProperties[$arProp['ID']] = $arProp; if (in_array($arProp['PROPERTY_TYPE'], $arSelectedPropTypes)) { $this->arSelectOfferProps[] = $arProp['ID']; } if ($arProp['CODE'] !== '') { foreach ($this->arIblock['PROPERTY'] as &$arMainProp) { if ($arMainProp['CODE'] == $arProp['CODE']) { $arPropertyMap[$arProp['ID']] = $arMainProp['CODE']; break; } } if (isset($arMainProp)) { unset($arMainProp); } } } } $this->arOfferIBlock['LID'] = $this->arIblock['LID']; $this->arOfferIBlock['PROPERTY'] = array(); $rsProps = \CIBlockProperty::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('IBLOCK_ID' => $this->intOfferIBlockID, 'ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N')); while ($arProp = $rsProps->Fetch()) { $arProp['ID'] = (int) $arProp['ID']; $arProp['USER_TYPE'] = (string) $arProp['USER_TYPE']; $arProp['CODE'] = (string) $arProp['CODE']; $this->arOfferIBlock['PROPERTY'][$arProp['ID']] = $arProp; } return $arOffers; }
/** * Initializes internal object state. Must be called before usage. * * @throws \Bitrix\Main\LoaderException * @return void */ public function init() { $this->dictionary = new Dictionary($this->iblockId); $this->storage = new Storage($this->iblockId); if (self::$catalog === null) { self::$catalog = \Bitrix\Main\Loader::includeModule("catalog"); } if (self::$catalog) { $catalog = \CCatalogSKU::getInfoByProductIBlock($this->iblockId); if (!empty($catalog) && is_array($catalog)) { $this->skuIblockId = $catalog["IBLOCK_ID"]; $this->skuPropertyId = $catalog["SKU_PROPERTY_ID"]; } } }
/** * @param integer $iblockId Information block identifier. */ public function __construct($iblockId) { $this->iblockId = intval($iblockId); $this->valid = \CIBlock::getArrayByID($this->iblockId, "PROPERTY_INDEX") === "Y"; if (Loader::includeModule("catalog")) { $catalogInfo = \CCatalogSKU::getInfoByProductIBlock($this->iblockId); if (!empty($catalogInfo) && is_array($catalogInfo)) { $this->skuIblockId = $catalogInfo["IBLOCK_ID"]; $this->skuPropertyId = $catalogInfo["SKU_PROPERTY_ID"]; $this->valid = $this->valid && \CIBlock::getArrayByID($this->skuIblockId, "PROPERTY_INDEX") === "Y"; } } $this->dictionary = new \Bitrix\Iblock\PropertyIndex\Dictionary($this->iblockId); $this->storage = new \Bitrix\Iblock\PropertyIndex\Storage($this->iblockId); }
/** * @param integer $iblockId Information block identifier. * @param integer $elementId Element identifier. * * @throws \Bitrix\Main\LoaderException */ public function __construct($iblockId, $elementId) { $this->iblockId = intval($iblockId); $this->elementId = intval($elementId); if (self::$catalog === null) { self::$catalog = \Bitrix\Main\Loader::includeModule("catalog"); } if (self::$catalog) { $catalog = \CCatalogSKU::getInfoByProductIBlock($this->iblockId); if (!empty($catalog) && is_array($catalog)) { $this->skuIblockId = $catalog["IBLOCK_ID"]; $this->skuPropertyId = $catalog["SKU_PROPERTY_ID"]; } } }
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]; }
/** * Common function, used to update/insert any product. * * @param int $productId Id of product. * @param int $fuserId User basket id. * @param string $siteId Site id. * * @return int Id of row. */ public static function refresh($productId, $fuserId, $siteId = SITE_ID) { $connection = Application::getConnection(); $productId = (int) $productId; if ($productId <= 0) { return -1; } $iblockID = (int) \CIBlockElement::getIBlockByID($productId); if ($iblockID <= 0) { return -1; } $productInfo = \CCatalogSKU::getProductInfo($productId, $iblockID); $fuserId = (int) $fuserId; if ($fuserId <= 0) { return -1; } if (!is_string($siteId) || strlen($siteId) <= 0) { return -1; } $filter = array("FUSER_ID" => $fuserId, "SITE_ID" => $siteId); // Concrete SKU ID if (!empty($productInfo)) { $filter['PRODUCT_ID'] = array(); $siblings = array(); // Delete parent product id (for capability) $connection->query("DELETE FROM b_catalog_viewed_product WHERE PRODUCT_ID = {$productInfo['ID']} AND FUSER_ID = {$fuserId} AND SITE_ID = '{$siteId}'"); $skuInfo = \CCatalogSKU::getInfoByOfferIBlock($iblockID); $skus = \CIBlockElement::getList(array(), array('IBLOCK_ID' => $iblockID, 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID'] => $productInfo['ID']), false, false, array('ID', 'IBLOCK_ID')); while ($oneSku = $skus->fetch()) { $siblings[] = $oneSku['ID']; } $filter["PRODUCT_ID"] = $siblings; } else { $filter["PRODUCT_ID"] = $productId; } $iterator = static::getList(array("filter" => $filter, "select" => array("ID", "FUSER_ID", "DATE_VISIT", "PRODUCT_ID", "SITE_ID", "VIEW_COUNT"))); if ($row = $iterator->fetch()) { static::update($row["ID"], array("PRODUCT_ID" => $productId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), 'VIEW_COUNT' => $row['VIEW_COUNT'] + 1)); return $row['ID']; } else { $result = static::add(array("FUSER_ID" => $fuserId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), "PRODUCT_ID" => $productId, "SITE_ID" => $siteId, "VIEW_COUNT" => 1)); return $result->getId(); } }
/** * @param integer $iblockId Information block identifier. */ public function __construct($iblockId) { $this->iblockId = intval($iblockId); $this->valid = \CIBlock::getArrayByID($this->iblockId, "PROPERTY_INDEX") === "Y"; if (self::$catalog === null) { self::$catalog = \Bitrix\Main\Loader::includeModule("catalog"); } if (self::$catalog) { $catalogInfo = \CCatalogSKU::getInfoByProductIBlock($this->iblockId); if (!empty($catalogInfo) && is_array($catalogInfo)) { $this->skuIblockId = $catalogInfo["IBLOCK_ID"]; $this->skuPropertyId = $catalogInfo["SKU_PROPERTY_ID"]; $this->valid = $this->valid && \CIBlock::getArrayByID($this->skuIblockId, "PROPERTY_INDEX") === "Y"; } } $this->dictionary = new Dictionary($this->iblockId); $this->storage = new Storage($this->iblockId); $this->valid = $this->valid && $this->dictionary->isExists(); }
public function loadFromDatabase() { if (!isset($this->fields)) { $this->fields = array(); $select = array_values($this->fieldMap); $elementList = \Freetrix\Iblock\ElementTable::getList(array("select" => $select, "filter" => array("=ID" => $this->id))); $this->elementFields = $elementList->fetch(); if ($this->elementFields) { $arCatalog = \CCatalogSKU::getInfoByProductIBlock($this->elementFields["IBLOCK_ID"]); if (is_array($arCatalog)) { $this->skuIblockId = $arCatalog["IBLOCK_ID"]; $skuList = \CIBlockElement::getList(array(), array("IBLOCK_ID" => $arCatalog["IBLOCK_ID"], "=PROPERTY_" . $arCatalog["SKU_PROPERTY_ID"] => $this->id), false, false, $select); while ($sku = $skuList->fetch()) { $this->skuList[] = $sku; foreach ($sku as $fieldName => $fieldValue) { $this->fields[$fieldName][] = $fieldValue; } } } } } return is_array($this->fields); }
$arResult["IS_SKU"] = true; $lang = \Bitrix\Main\Application::getInstance()->getContext()->getLanguage(); if ($arParams["ELEMENT_ID"] <= 0) { ShowError(GetMessage("PRODUCT_NOT_EXIST")); return; } if ($this->StartResultCache()) { $arResult['STORES'] = array(); $isProductExistSKU = CCatalogSKU::IsExistOffers($arParams['ELEMENT_ID'], $iblockId); if ($isProductExistSKU) { $res = CIBlockElement::GetList(array(), array('ID' => $arParams['ELEMENT_ID']), false, false, array('ID', 'IBLOCK_ID')); if ($productInfo = $res->Fetch()) { $productId = $productInfo['ID']; $iblockId = $productInfo['IBLOCK_ID']; } $skuInfo = CCatalogSKU::GetInfoByProductIBlock($iblockId); $skuIterator = CIBlockElement::GetList(array('ID' => 'DESC'), array('IBLOCK_ID' => $skuInfo['IBLOCK_ID'], 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID'] => $productId), false, false, array('ID')); $productSku = array(); while ($sku = $skuIterator->Fetch()) { $amount = array(); $sum = 0; $filter = array('PRODUCT_ID' => $sku['ID']); if (!empty($arParams['STORES'])) { $filter['STORE_ID'] = $arParams['STORES']; } $storeIterator = CCatalogStoreProduct::GetList(array(), $filter, false, false, array('ID', 'STORE_ID', 'AMOUNT')); while ($store = $storeIterator->Fetch()) { if ($arParams["SHOW_GENERAL_STORE_INFORMATION"] == "Y") { $sum += $store['AMOUNT']; } else { $amount[$store['STORE_ID']] = 0;
$rsPath->SetUrlTemplates("", $arParams["SECTION_URL"]); while ($arPath = $rsPath->GetNext()) { $ipropValues = new \Bitrix\Iblock\InheritedProperty\SectionValues($arParams["IBLOCK_ID"], $arPath["ID"]); $arPath["IPROPERTY_VALUES"] = $ipropValues->getValues(); $arResult["PATH"][] = $arPath; } } $bIBlockCatalog = false; $bOffersIBlockExist = false; $arCatalog = false; $boolNeedCatalogCache = false; $bCatalog = Loader::includeModule('catalog'); if ($bCatalog) { $arResultModules['catalog'] = true; $arResultModules['currency'] = true; $arCatalog = CCatalogSKU::GetInfoByIBlock($arParams["IBLOCK_ID"]); if (!empty($arCatalog) && is_array($arCatalog)) { $bIBlockCatalog = $arCatalog['CATALOG_TYPE'] != CCatalogSKU::TYPE_PRODUCT; $bOffersIBlockExist = $arCatalog['CATALOG_TYPE'] == CCatalogSKU::TYPE_PRODUCT || $arCatalog['CATALOG_TYPE'] == CCatalogSKU::TYPE_FULL; $boolNeedCatalogCache = true; } } $arResult['CATALOG'] = $arCatalog; //This function returns array with prices description and access rights //in case catalog module n/a prices get values from element properties $arResult["PRICES"] = CIBlockPriceTools::GetCatalogPrices($arParams["IBLOCK_ID"], $arParams["PRICE_CODE"]); $arResult['PRICES_ALLOW'] = CIBlockPriceTools::GetAllowCatalogPrices($arResult["PRICES"]); if ($bCatalog && $boolNeedCatalogCache && !empty($arResult['PRICES_ALLOW'])) { $boolNeedCatalogCache = CIBlockPriceTools::SetCatalogDiscountCache($arResult['PRICES_ALLOW'], $USER->GetUserGroupArray()); } $arResult['CONVERT_CURRENCY'] = $arConvertParams;
<?php define("NO_KEEP_STATISTIC", true); // Не собираем стату по действиям AJAX require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (CModule::IncludeModule("iblock") && CModule::IncludeModule("catalog")) { if (isset($_POST['id']) && isset($_POST['ib']) && isset($_POST['fl'])) { $ids = $_POST['id']; $IBLOCK_ID = $_POST['ib']; $f = fopen($_POST['fl'], "a"); $arInfo = CCatalogSKU::GetInfoByProductIBlock($IBLOCK_ID); foreach ($ids as $id) { $rsOffers = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $arInfo['IBLOCK_ID'], 'PROPERTY_' . $arInfo['SKU_PROPERTY_ID'] => $id)); while ($arOffer = $rsOffers->GetNextElement()) { $el = $arOffer->GetFields(); $el["PROPERTIES"] = $arOffer->GetProperties(); $NewCnt = $id . '|' . $el['ID'] . '|' . $el['ACTIVE'] . '|' . $el['NAME'] . '|' . $el['XML_ID'] . '|' . $el['DETAIL_PAGE_URL'] . '|'; //$NewCnt.=$el['PROPERTIES']['CML2_2']['VALUE'].'|'.$el['PROPERTIES']['COLOR']['VALUE'].'|'.$el['PROPERTIES']['CML2_1']['VALUE'].'|'; $NewCnt .= chr(13); $NewCnt = iconv('UTF-8', "windows-1251", $NewCnt); fwrite($f, $NewCnt); } } fclose($f); //print_r($ids); echo true; } else { echo md5('GET OUT!!!');
$intSectionID = $APPLICATION->IncludeComponent("bitrix:catalog.section", "", array("IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arParams["IBLOCK_ID"], "ELEMENT_SORT_FIELD" => $arParams["ELEMENT_SORT_FIELD"], "ELEMENT_SORT_ORDER" => $arParams["ELEMENT_SORT_ORDER"], "ELEMENT_SORT_FIELD2" => $arParams["ELEMENT_SORT_FIELD2"], "ELEMENT_SORT_ORDER2" => $arParams["ELEMENT_SORT_ORDER2"], "PROPERTY_CODE" => $arParams["LIST_PROPERTY_CODE"], "META_KEYWORDS" => $arParams["LIST_META_KEYWORDS"], "META_DESCRIPTION" => $arParams["LIST_META_DESCRIPTION"], "BROWSER_TITLE" => $arParams["LIST_BROWSER_TITLE"], "SET_LAST_MODIFIED" => $arParams["SET_LAST_MODIFIED"], "INCLUDE_SUBSECTIONS" => $arParams["INCLUDE_SUBSECTIONS"], "BASKET_URL" => $arParams["BASKET_URL"], "ACTION_VARIABLE" => $arParams["ACTION_VARIABLE"], "PRODUCT_ID_VARIABLE" => $arParams["PRODUCT_ID_VARIABLE"], "SECTION_ID_VARIABLE" => $arParams["SECTION_ID_VARIABLE"], "PRODUCT_QUANTITY_VARIABLE" => $arParams["PRODUCT_QUANTITY_VARIABLE"], "PRODUCT_PROPS_VARIABLE" => $arParams["PRODUCT_PROPS_VARIABLE"], "FILTER_NAME" => $arParams["FILTER_NAME"], "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "CACHE_FILTER" => $arParams["CACHE_FILTER"], "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], "SET_TITLE" => $arParams["SET_TITLE"], "MESSAGE_404" => $arParams["MESSAGE_404"], "SET_STATUS_404" => $arParams["SET_STATUS_404"], "SHOW_404" => $arParams["SHOW_404"], "FILE_404" => $arParams["FILE_404"], "DISPLAY_COMPARE" => $arParams["USE_COMPARE"], "PAGE_ELEMENT_COUNT" => $arParams["PAGE_ELEMENT_COUNT"], "LINE_ELEMENT_COUNT" => $arParams["LINE_ELEMENT_COUNT"], "PRICE_CODE" => $arParams["PRICE_CODE"], "USE_PRICE_COUNT" => $arParams["USE_PRICE_COUNT"], "SHOW_PRICE_COUNT" => $arParams["SHOW_PRICE_COUNT"], "PRICE_VAT_INCLUDE" => $arParams["PRICE_VAT_INCLUDE"], "USE_PRODUCT_QUANTITY" => $arParams['USE_PRODUCT_QUANTITY'], "ADD_PROPERTIES_TO_BASKET" => isset($arParams["ADD_PROPERTIES_TO_BASKET"]) ? $arParams["ADD_PROPERTIES_TO_BASKET"] : '', "PARTIAL_PRODUCT_PROPERTIES" => isset($arParams["PARTIAL_PRODUCT_PROPERTIES"]) ? $arParams["PARTIAL_PRODUCT_PROPERTIES"] : '', "PRODUCT_PROPERTIES" => $arParams["PRODUCT_PROPERTIES"], "DISPLAY_TOP_PAGER" => $arParams["DISPLAY_TOP_PAGER"], "DISPLAY_BOTTOM_PAGER" => $arParams["DISPLAY_BOTTOM_PAGER"], "PAGER_TITLE" => $arParams["PAGER_TITLE"], "PAGER_SHOW_ALWAYS" => $arParams["PAGER_SHOW_ALWAYS"], "PAGER_TEMPLATE" => $arParams["PAGER_TEMPLATE"], "PAGER_DESC_NUMBERING" => $arParams["PAGER_DESC_NUMBERING"], "PAGER_DESC_NUMBERING_CACHE_TIME" => $arParams["PAGER_DESC_NUMBERING_CACHE_TIME"], "PAGER_SHOW_ALL" => $arParams["PAGER_SHOW_ALL"], "PAGER_BASE_LINK_ENABLE" => $arParams["PAGER_BASE_LINK_ENABLE"], "PAGER_BASE_LINK" => $arParams["PAGER_BASE_LINK"], "PAGER_PARAMS_NAME" => $arParams["PAGER_PARAMS_NAME"], "OFFERS_CART_PROPERTIES" => $arParams["OFFERS_CART_PROPERTIES"], "OFFERS_FIELD_CODE" => $arParams["LIST_OFFERS_FIELD_CODE"], "OFFERS_PROPERTY_CODE" => $arParams["LIST_OFFERS_PROPERTY_CODE"], "OFFERS_SORT_FIELD" => $arParams["OFFERS_SORT_FIELD"], "OFFERS_SORT_ORDER" => $arParams["OFFERS_SORT_ORDER"], "OFFERS_SORT_FIELD2" => $arParams["OFFERS_SORT_FIELD2"], "OFFERS_SORT_ORDER2" => $arParams["OFFERS_SORT_ORDER2"], "OFFERS_LIMIT" => $arParams["LIST_OFFERS_LIMIT"], "SECTION_ID" => $arResult["VARIABLES"]["SECTION_ID"], "SECTION_CODE" => $arResult["VARIABLES"]["SECTION_CODE"], "SECTION_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["section"], "DETAIL_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["element"], "USE_MAIN_ELEMENT_SECTION" => $arParams["USE_MAIN_ELEMENT_SECTION"], 'CONVERT_CURRENCY' => $arParams['CONVERT_CURRENCY'], 'CURRENCY_ID' => $arParams['CURRENCY_ID'], 'HIDE_NOT_AVAILABLE' => $arParams["HIDE_NOT_AVAILABLE"], 'LABEL_PROP' => $arParams['LABEL_PROP'], 'ADD_PICT_PROP' => $arParams['ADD_PICT_PROP'], 'PRODUCT_DISPLAY_MODE' => $arParams['PRODUCT_DISPLAY_MODE'], 'OFFER_ADD_PICT_PROP' => $arParams['OFFER_ADD_PICT_PROP'], 'OFFER_TREE_PROPS' => $arParams['OFFER_TREE_PROPS'], 'PRODUCT_SUBSCRIPTION' => $arParams['PRODUCT_SUBSCRIPTION'], 'SHOW_DISCOUNT_PERCENT' => $arParams['SHOW_DISCOUNT_PERCENT'], 'SHOW_OLD_PRICE' => $arParams['SHOW_OLD_PRICE'], 'MESS_BTN_BUY' => $arParams['MESS_BTN_BUY'], 'MESS_BTN_ADD_TO_BASKET' => $arParams['MESS_BTN_ADD_TO_BASKET'], 'MESS_BTN_SUBSCRIBE' => $arParams['MESS_BTN_SUBSCRIBE'], 'MESS_BTN_DETAIL' => $arParams['MESS_BTN_DETAIL'], 'MESS_NOT_AVAILABLE' => $arParams['MESS_NOT_AVAILABLE'], 'TEMPLATE_THEME' => isset($arParams['TEMPLATE_THEME']) ? $arParams['TEMPLATE_THEME'] : '', "ADD_SECTIONS_CHAIN" => "N", 'ADD_TO_BASKET_ACTION' => $basketAction, 'SHOW_CLOSE_POPUP' => isset($arParams['COMMON_SHOW_CLOSE_POPUP']) ? $arParams['COMMON_SHOW_CLOSE_POPUP'] : '', 'COMPARE_PATH' => $arResult['FOLDER'] . $arResult['URL_TEMPLATES']['compare']), $component); $GLOBALS['CATALOG_CURRENT_SECTION_ID'] = $intSectionID; unset($basketAction); if ($verticalGrid) { ?> </div> <div style="clear: both;"></div> </div><?php } if (ModuleManager::isModuleInstalled("sale")) { $arRecomData = array(); $recomCacheID = array('IBLOCK_ID' => $arParams['IBLOCK_ID']); $obCache = new CPHPCache(); if ($obCache->InitCache(36000, serialize($recomCacheID), "/sale/bestsellers")) { $arRecomData = $obCache->GetVars(); } elseif ($obCache->StartDataCache()) { if (Loader::includeModule("catalog")) { $arSKU = CCatalogSKU::GetInfoByProductIBlock($arParams['IBLOCK_ID']); $arRecomData['OFFER_IBLOCK_ID'] = !empty($arSKU) ? $arSKU['IBLOCK_ID'] : 0; } $obCache->EndDataCache($arRecomData); } if (!empty($arRecomData)) { if (!isset($arParams['USE_SALE_BESTSELLERS']) || $arParams['USE_SALE_BESTSELLERS'] != 'N') { $APPLICATION->IncludeComponent("bitrix:sale.bestsellers", "", array("HIDE_NOT_AVAILABLE" => $arParams["HIDE_NOT_AVAILABLE"], "PAGE_ELEMENT_COUNT" => "5", "SHOW_DISCOUNT_PERCENT" => $arParams['SHOW_DISCOUNT_PERCENT'], "PRODUCT_SUBSCRIPTION" => $arParams['PRODUCT_SUBSCRIPTION'], "SHOW_NAME" => "Y", "SHOW_IMAGE" => "Y", "MESS_BTN_BUY" => $arParams['MESS_BTN_BUY'], "MESS_BTN_DETAIL" => $arParams['MESS_BTN_DETAIL'], "MESS_NOT_AVAILABLE" => $arParams['MESS_NOT_AVAILABLE'], "MESS_BTN_SUBSCRIBE" => $arParams['MESS_BTN_SUBSCRIBE'], "LINE_ELEMENT_COUNT" => 5, "TEMPLATE_THEME" => isset($arParams['TEMPLATE_THEME']) ? $arParams['TEMPLATE_THEME'] : '', "DETAIL_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["element"], "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], "BY" => array(0 => "AMOUNT"), "PERIOD" => array(0 => "15"), "FILTER" => array(0 => "CANCELED", 1 => "ALLOW_DELIVERY", 2 => "PAYED", 3 => "DEDUCTED", 4 => "N", 5 => "P", 6 => "F"), "FILTER_NAME" => $arParams["FILTER_NAME"], "ORDER_FILTER_NAME" => "arOrderFilter", "DISPLAY_COMPARE" => $arParams["USE_COMPARE"], "SHOW_OLD_PRICE" => $arParams['SHOW_OLD_PRICE'], "PRICE_CODE" => $arParams["PRICE_CODE"], "SHOW_PRICE_COUNT" => $arParams["SHOW_PRICE_COUNT"], "PRICE_VAT_INCLUDE" => $arParams["PRICE_VAT_INCLUDE"], "CONVERT_CURRENCY" => $arParams["CONVERT_CURRENCY"], "CURRENCY_ID" => $arParams["CURRENCY_ID"], "BASKET_URL" => $arParams["BASKET_URL"], "ACTION_VARIABLE" => (!empty($arParams["ACTION_VARIABLE"]) ? $arParams["ACTION_VARIABLE"] : "action") . "_slb", "PRODUCT_ID_VARIABLE" => $arParams["PRODUCT_ID_VARIABLE"], "PRODUCT_QUANTITY_VARIABLE" => $arParams["PRODUCT_QUANTITY_VARIABLE"], "ADD_PROPERTIES_TO_BASKET" => isset($arParams["ADD_PROPERTIES_TO_BASKET"]) ? $arParams["ADD_PROPERTIES_TO_BASKET"] : '', "PRODUCT_PROPS_VARIABLE" => $arParams["PRODUCT_PROPS_VARIABLE"], "PARTIAL_PRODUCT_PROPERTIES" => isset($arParams["PARTIAL_PRODUCT_PROPERTIES"]) ? $arParams["PARTIAL_PRODUCT_PROPERTIES"] : '', "USE_PRODUCT_QUANTITY" => $arParams['USE_PRODUCT_QUANTITY'], "SHOW_PRODUCTS_" . $arParams["IBLOCK_ID"] => "Y", "OFFER_TREE_PROPS_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams["OFFER_TREE_PROPS"], "ADDITIONAL_PICT_PROP_" . $arParams['IBLOCK_ID'] => $arParams['ADD_PICT_PROP'], "ADDITIONAL_PICT_PROP_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams['OFFER_ADD_PICT_PROP']), $component, array("HIDE_ICONS" => "Y")); } if (!isset($arParams['USE_BIG_DATA']) || $arParams['USE_BIG_DATA'] != 'N') { $APPLICATION->IncludeComponent("bitrix:catalog.bigdata.products", "", array("LINE_ELEMENT_COUNT" => 5, "TEMPLATE_THEME" => isset($arParams['TEMPLATE_THEME']) ? $arParams['TEMPLATE_THEME'] : '', "DETAIL_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["element"], "BASKET_URL" => $arParams["BASKET_URL"], "ACTION_VARIABLE" => (!empty($arParams["ACTION_VARIABLE"]) ? $arParams["ACTION_VARIABLE"] : "action") . "_cbdp", "PRODUCT_ID_VARIABLE" => $arParams["PRODUCT_ID_VARIABLE"], "PRODUCT_QUANTITY_VARIABLE" => $arParams["PRODUCT_QUANTITY_VARIABLE"], "ADD_PROPERTIES_TO_BASKET" => isset($arParams["ADD_PROPERTIES_TO_BASKET"]) ? $arParams["ADD_PROPERTIES_TO_BASKET"] : '', "PRODUCT_PROPS_VARIABLE" => $arParams["PRODUCT_PROPS_VARIABLE"], "PARTIAL_PRODUCT_PROPERTIES" => isset($arParams["PARTIAL_PRODUCT_PROPERTIES"]) ? $arParams["PARTIAL_PRODUCT_PROPERTIES"] : '', "SHOW_OLD_PRICE" => $arParams['SHOW_OLD_PRICE'], "SHOW_DISCOUNT_PERCENT" => $arParams['SHOW_DISCOUNT_PERCENT'], "PRICE_CODE" => $arParams["PRICE_CODE"], "SHOW_PRICE_COUNT" => $arParams["SHOW_PRICE_COUNT"], "PRODUCT_SUBSCRIPTION" => $arParams['PRODUCT_SUBSCRIPTION'], "PRICE_VAT_INCLUDE" => $arParams["PRICE_VAT_INCLUDE"], "USE_PRODUCT_QUANTITY" => $arParams['USE_PRODUCT_QUANTITY'], "SHOW_NAME" => "Y", "SHOW_IMAGE" => "Y", "MESS_BTN_BUY" => $arParams['MESS_BTN_BUY'], "MESS_BTN_DETAIL" => $arParams['MESS_BTN_DETAIL'], "MESS_BTN_SUBSCRIBE" => $arParams['MESS_BTN_SUBSCRIBE'], "MESS_NOT_AVAILABLE" => $arParams['MESS_NOT_AVAILABLE'], "PAGE_ELEMENT_COUNT" => 5, "SHOW_FROM_SECTION" => "Y", "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arParams["IBLOCK_ID"], "DEPTH" => "2", "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], "SHOW_PRODUCTS_" . $arParams["IBLOCK_ID"] => "Y", "HIDE_NOT_AVAILABLE" => $arParams["HIDE_NOT_AVAILABLE"], "CONVERT_CURRENCY" => $arParams["CONVERT_CURRENCY"], "CURRENCY_ID" => $arParams["CURRENCY_ID"], "SECTION_ID" => $intSectionID, "SECTION_CODE" => "", "SECTION_ELEMENT_ID" => "", "SECTION_ELEMENT_CODE" => "", "LABEL_PROP_" . $arParams["IBLOCK_ID"] => $arParams['LABEL_PROP'], "PROPERTY_CODE_" . $arParams["IBLOCK_ID"] => $arParams["LIST_PROPERTY_CODE"], "PROPERTY_CODE_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams["LIST_OFFERS_PROPERTY_CODE"], "CART_PROPERTIES_" . $arParams["IBLOCK_ID"] => $arParams["PRODUCT_PROPERTIES"], "CART_PROPERTIES_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams["OFFERS_CART_PROPERTIES"], "ADDITIONAL_PICT_PROP_" . $arParams["IBLOCK_ID"] => $arParams['ADD_PICT_PROP'], "ADDITIONAL_PICT_PROP_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams['OFFER_ADD_PICT_PROP'], "OFFER_TREE_PROPS_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams["OFFER_TREE_PROPS"], "RCM_TYPE" => isset($arParams['BIG_DATA_RCM_TYPE']) ? $arParams['BIG_DATA_RCM_TYPE'] : ''), $component, array("HIDE_ICONS" => "Y")); } } }
public function obtainBasketPropsSKU(&$arBasketItems, $arSkuProps, $arParents) { $arRes = array(); $arSkuIblockID = array(); if (self::isNonemptyArray($arBasketItems) && self::isNonemptyArray($arParents)) { foreach ($arBasketItems as &$arItem) { // catalog-specific logic farther if (!$this->cameFromCatalog($arItem)) { continue; } if (array_key_exists($arItem["PRODUCT_ID"], $arParents)) { $arSKU = CCatalogSKU::GetInfoByProductIBlock($arParents[$arItem["PRODUCT_ID"]]["IBLOCK_ID"]); if (!array_key_exists($arSKU["IBLOCK_ID"], $arSkuIblockID)) { $arSkuIblockID[$arSKU["IBLOCK_ID"]] = $arSKU; } $arItem["IBLOCK_ID"] = $arSKU["IBLOCK_ID"]; $arItem["SKU_PROPERTY_ID"] = $arSKU["SKU_PROPERTY_ID"]; } } unset($arItem); if ($this->useIBlock) { if (!self::isNonemptyArray($arSkuProps)) { $arSkuProps = array(); } foreach ($arSkuIblockID as $skuIblockID => $arSKU) { // possible props values $rsProps = CIBlockProperty::GetList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $skuIblockID, 'ACTIVE' => 'Y')); while ($arProp = $rsProps->Fetch()) { if ($arProp['PROPERTY_TYPE'] == 'L' || $arProp['PROPERTY_TYPE'] == 'E' || $arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') { if ($arProp['XML_ID'] == 'CML2_LINK') { continue; } if (!in_array($arProp['CODE'], $arSkuProps)) { continue; } $arRes[$skuIblockID][$arProp['ID']] = array('ID' => $arProp['ID'], 'CODE' => $arProp['CODE'], 'NAME' => $arProp['NAME'], 'TYPE' => $arProp['PROPERTY_TYPE'], 'VALUES' => array()); if ($arProp['PROPERTY_TYPE'] == 'L') { $arValues = array(); $rsPropEnums = CIBlockProperty::GetPropertyEnum($arProp['ID']); while ($arEnum = $rsPropEnums->Fetch()) { $arValues[$arEnum['ID']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['VALUE'], 'PICT' => false); } $arRes[$skuIblockID][$arProp['ID']]['VALUES'] = $arValues; } elseif ($arProp['PROPERTY_TYPE'] == 'E') { $arValues = array(); $rsPropEnums = CIBlockElement::GetList(array('SORT' => 'ASC'), array('IBLOCK_ID' => $arProp['LINK_IBLOCK_ID'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'PREVIEW_PICTURE')); while ($arEnum = $rsPropEnums->Fetch()) { $arEnum['PREVIEW_PICTURE'] = CFile::GetFileArray($arEnum['PREVIEW_PICTURE']); if (!is_array($arEnum['PREVIEW_PICTURE'])) { continue; } $productImg = CFile::ResizeImageGet($arEnum['PREVIEW_PICTURE'], array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false); $arEnum['PREVIEW_PICTURE']['SRC'] = $productImg['src']; $arValues[$arEnum['ID']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['NAME'], 'SORT' => $arEnum['SORT'], 'PICT' => $arEnum['PREVIEW_PICTURE']); } $arRes[$skuIblockID][$arProp['ID']]['VALUES'] = $arValues; } elseif ($arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') { $arValues = array(); if ($this->useHL) { $hlblock = HL\HighloadBlockTable::getList(array("filter" => array("TABLE_NAME" => $arProp["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch(); if ($hlblock) { $entity = HL\HighloadBlockTable::compileEntity($hlblock); $entity_data_class = $entity->getDataClass(); $rsData = $entity_data_class::getList(); while ($arData = $rsData->fetch()) { $arValues[$arData['ID']] = array('ID' => $arData['ID'], 'NAME' => $arData['UF_NAME'], 'SORT' => $arData['UF_SORT'], 'FILE' => $arData['UF_FILE'], 'PICT' => '', 'XML_ID' => $arData['UF_XML_ID']); } $arRes[$skuIblockID][$arProp['ID']]['VALUES'] = $arValues; } } } } } } foreach ($arBasketItems as &$arItem) { // catalog-specific logic farther: iblocks, catalogs and other friends if (!$this->cameFromCatalog($arItem)) { continue; } $arSelectSkuProps = array(); foreach ($arSkuProps as $prop) { $arSelectSkuProps[] = "PROPERTY_" . $prop; } if (isset($arItem["IBLOCK_ID"]) && intval($arItem["IBLOCK_ID"]) > 0 && array_key_exists($arItem["IBLOCK_ID"], $arRes)) { $arItem["SKU_DATA"] = $arRes[$arItem["IBLOCK_ID"]]; $arUsedValues = array(); $arTmpRes = array(); $arOfFilter = array("IBLOCK_ID" => $arItem["IBLOCK_ID"], "PROPERTY_" . $arSkuIblockID[$arItem["IBLOCK_ID"]]["SKU_PROPERTY_ID"] => $arParents[$arItem["PRODUCT_ID"]]["PRODUCT_ID"]); $rsOffers = CIBlockElement::GetList(array(), $arOfFilter, false, false, array_merge(array("ID"), $arSelectSkuProps)); while ($arOffer = $rsOffers->GetNext()) { foreach ($arSkuProps as $prop) { if (!empty($arOffer["PROPERTY_" . $prop . "_VALUE"]) && (!is_array($arUsedValues[$arItem["PRODUCT_ID"]][$prop]) || !in_array($arOffer["PROPERTY_" . $prop . "_VALUE"], $arUsedValues[$arItem["PRODUCT_ID"]][$prop]))) { $arUsedValues[$arItem["PRODUCT_ID"]][$prop][] = $arOffer["PROPERTY_" . $prop . "_VALUE"]; } } } if (!empty($arUsedValues)) { // add only used values to the item SKU_DATA foreach ($arRes[$arItem["IBLOCK_ID"]] as $propId => $arProp) { if (!array_key_exists($arProp["CODE"], $arUsedValues[$arItem["PRODUCT_ID"]])) { continue; } $propValues = array(); $skuType = ''; foreach ($arProp["VALUES"] as $valId => $arValue) { // properties of various type have different values in the used values data if ($arProp["TYPE"] == "L" && in_array($arValue["NAME"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]]) || $arProp["TYPE"] == "E" && in_array($arValue["ID"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]]) || $arProp["TYPE"] == "S" && in_array($arValue["XML_ID"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]])) { if ($arProp["TYPE"] == "S") { $arTmpFile = CFile::GetFileArray($arValue["FILE"]); $tmpImg = CFile::ResizeImageGet($arTmpFile, array('width' => 30, 'height' => 30), BX_RESIZE_IMAGE_PROPORTIONAL, true); $arValue['PICT'] = array_change_key_case($tmpImg, CASE_UPPER); $skuType = 'image'; } else { $skuType = 'link'; } $propValues[$valId] = $arValue; } } $arTmpRes['n' . $propId] = array('CODE' => $arProp["CODE"], 'NAME' => $arProp["NAME"], 'SKU_TYPE' => $skuType, 'VALUES' => $propValues); } } $arItem["SKU_DATA"] = $arTmpRes; } if (self::isNonemptyArray($arItem['PROPS'])) { foreach ($arItem['PROPS'] as $v => $prop) { // search for sku property that matches current one // establishing match based on codes even if the code may not set $code = $prop['CODE']; if (self::isNonemptyArray($arItem['SKU_DATA'])) { foreach ($arItem['SKU_DATA'] as $spIndex => $skuProp) { if ($skuProp['CODE'] == $code) { $arItem['PROPS'][$v]['SKU_PROP'] = $spIndex; $arItem['PROPS'][$v]['SKU_TYPE'] = $skuProp['SKU_TYPE']; if (self::isNonemptyArray($skuProp['VALUES'])) { foreach ($skuProp['VALUES'] as $spValue) { if ($skuProp['SKU_TYPE'] == 'image') { $match = $prop["VALUE"] == $spValue["NAME"] || $prop["VALUE"] == $spValue["XML_ID"]; } else { $match = $prop["VALUE"] == $spValue["NAME"]; } // otherwise - the other if ($match) { $arItem['PROPS'][$v]['SKU_VALUE'] = $spValue; break; } } } } } } } } } } } }
if ($pid === "") unset($arParams["OFFERS_CART_PROPERTIES"][$i]); if($this->StartResultCache(false, array($elementID, ($arParams["CACHE_GROUPS"]==="N"? false: $USER->GetGroups())))) { if(!CModule::IncludeModule("catalog")) { ShowError(GetMessage("CATALOG_MODULE_NOT_INSTALLED")); $this->AbortResultCache(); return; } $isProductHaveSet = CCatalogProductSet::isProductHaveSet($elementID, CCatalogProductSet::TYPE_GROUP); $product = false; if (!$isProductHaveSet) { $product = CCatalogSKU::GetProductInfo($elementID, $arParams['IBLOCK_ID']); if (!empty($product)) { $isProductHaveSet = true; } } if (!$isProductHaveSet) { $this->AbortResultCache(); return; } if (!empty($product)) { $arResult['PRODUCT_ID'] = $product['ID']; $arResult['PRODUCT_IBLOCK_ID'] = $product['IBLOCK_ID'];
while ($arSet = $rsSets->Fetch()) { $arSet['OWNER_ID'] = (int)$arSet['OWNER_ID']; $arSet['ITEM_ID'] = (int)$arSet['ITEM_ID']; if ($arSet['OWNER_ID'] == $arSet['ITEM_ID'] && isset($arProductGroupIDs[$arSet['OWNER_ID']])) { $arProductGroupIDs[$arSet['OWNER_ID']] = true; } } } if (!empty($arProductIDs)) { $arProductKeys = array_keys($arProductIDs); foreach ($arProductKeys as &$intProductID) { $arProductIDs[$intProductID] = CCatalogSKU::IsExistOffers($intProductID, $IBLOCK_ID); if ($arProductIDs[$intProductID]) { $arRows['E'.$intProductID]->arRes['CATALOG_TYPE'] = CCatalogProduct::TYPE_SKU; if (!$showCatalogWithOffers) { $arRows['E'.$intProductID]->AddViewField('CATALOG_QUANTITY', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_QUANTITY_TRACE', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_WEIGHT', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_VAT_INCLUDED', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_PURCHASING_PRICE', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_MEASURE_RATIO', ' '); $arRows['E'.$intProductID]->AddViewField('CATALOG_MEASURE', ' '); if (isset($arRows['E'.$intProductID]->aFields['CATALOG_QUANTITY']['edit'])) unset($arRows['E'.$intProductID]->aFields['CATALOG_QUANTITY']['edit']); if (isset($arRows['E'.$intProductID]->aFields['CATALOG_QUANTITY_TRACE']['edit']))
protected function getFilter() { $arFilter = array("IBLOCK_ID" => $this->getIblockId(), 'SECTION_ID' => $this->getSectionId() > 0 ? $this->getSectionId() : 0, 'ACTIVE' => empty($_REQUEST['filter_active']) ? 'Y' : $_REQUEST['filter_active'], "WF_PARENT_ELEMENT_ID" => false, "SHOW_NEW" => "Y"); if ($arProps = $this->getProps()) { $filtered = null; foreach ($arProps as $arProp) { $value = $_REQUEST['filter_el_property_' . $arProp["ID"]]; if (array_key_exists("AddFilterFields", $arProp["PROPERTY_USER_TYPE"])) { call_user_func_array($arProp["PROPERTY_USER_TYPE"]["AddFilterFields"], array($arProp, array("VALUE" => "filter_el_property_" . $arProp["ID"]), &$arFilter, &$filtered)); } elseif (is_array($value) || strlen($value)) { if ($value === "NOT_REF") { $value = false; } $arFilter["?PROPERTY_" . $arProp["ID"]] = $value; } } } $arSubQuery = array(); if ($arSKUProps = $this->getSkuProps()) { $arCatalog = $this->getOffersCatalog(); $arSubQuery = array("IBLOCK_ID" => $arCatalog['IBLOCK_ID']); $filtered = null; for ($i = 0, $intPropCount = count($arSKUProps); $i < $intPropCount; $i++) { if ('Y' == $arSKUProps[$i]["FILTRABLE"] && 'F' != $arSKUProps[$i]["PROPERTY_TYPE"] && $arCatalog['SKU_PROPERTY_ID'] != $arSKUProps[$i]["ID"]) { if (array_key_exists("AddFilterFields", $arSKUProps[$i]["PROPERTY_USER_TYPE"])) { call_user_func_array($arSKUProps[$i]["PROPERTY_USER_TYPE"]["AddFilterFields"], array($arSKUProps[$i], array("VALUE" => "filter_sub_el_property_" . $arSKUProps[$i]["ID"]), &$arSubQuery, &$filtered)); } else { $value = $_REQUEST['filter_sub_el_property_' . $arSKUProps[$i]["ID"]]; if (is_array($value) || strlen($value)) { if ($value === "NOT_REF") { $value = false; } $arSubQuery["?PROPERTY_" . $arSKUProps[$i]["ID"]] = $value; } } } } } if (!empty($_REQUEST["filter_timestamp_from"])) { $arFilter["DATE_MODIFY_FROM"] = $_REQUEST["filter_timestamp_from"]; } if (!empty($_REQUEST["filter_timestamp_to"])) { $arFilter["DATE_MODIFY_TO"] = $_REQUEST["filter_timestamp_to"]; } if (!empty($_REQUEST["filter_code"])) { $arFilter["CODE"] = $_REQUEST["filter_code"]; } $arSearchedIds = $arSearchedSectionIds = null; if (!empty($_REQUEST['QUERY'])) { $arFilter['QUERY'] = $_REQUEST['QUERY']; $arSearchedIds = $arSearchedSectionIds = array(0); if (preg_match('#^[0-9\\s]+$#', $_REQUEST['QUERY'])) { $barcode = preg_replace('#[^0-9]#', '', $_REQUEST['QUERY']); if (strlen($barcode) > 0) { $rsBarCode = \CCatalogStoreBarCode::getList(array(), array("BARCODE" => $barcode), false, false, array('PRODUCT_ID')); while ($res = $rsBarCode->Fetch()) { $res2 = \CCatalogSKU::GetProductInfo($res["PRODUCT_ID"]); $arSearchedIds[] = $res2 ? $res2['ID'] : $res['PRODUCT_ID']; } } } elseif ($this->isAdvancedSearchAvailable()) { $arFilter['PARAM2'] = $this->getIblockId(); if (!empty($arFilter['SECTION_ID'])) { $arFilter['PARAMS'] = array('iblock_section' => $arFilter['SECTION_ID']); } $obSearch = new \CSearch(); $obSearch->Search($arFilter); $cnt = 0; $activeSectionId = $this->getSectionId(); while ($ar = $obSearch->Fetch()) { if (strpos($ar['ITEM_ID'], 'S') === 0) { $sectionId = preg_replace('#[^0-9]+#', '', $ar['ITEM_ID']); if ($sectionId != $activeSectionId) { $arSearchedSectionIds[] = $sectionId; } } else { $arSearchedIds[] = $ar['ITEM_ID']; } if (++$cnt >= 100) { break; } } } else { $arSearchedIds = $arSearchedSectionIds = null; $arFilter['NAME'] = $_REQUEST['QUERY']; } } if (sizeof($arSubQuery) > 1) { $arFilteredIds = array(0); $db = \CIBlockElement::GetList(array(), $arSubQuery, false, false, array('PROPERTY_' . $arCatalog['SKU_PROPERTY_ID'])); while ($res = $db->Fetch()) { $arFilteredIds[] = $res['PROPERTY_' . $arCatalog['SKU_PROPERTY_ID'] . '_VALUE']; } $arFilter['ID'] = is_array($arSearchedIds) ? array_intersect($arFilteredIds, $arSearchedIds) : $arFilteredIds; } elseif ($arSearchedIds) { $arFilter['ID'] = $arSearchedIds; } if ($arSearchedSectionIds) { $arFilter['S_ID'] = $arSearchedSectionIds; } unset($arFilter['PARAM1'], $arFilter['PARAM2'], $arFilter['PARAMS']); if ($this->isFiltering() || !empty($_REQUEST['QUERY'])) { $arFilter['INCLUDE_SUBSECTIONS'] = 'Y'; if (isset($arFilter['SECTION_ID']) && $arFilter['SECTION_ID'] == 0) { unset($arFilter["SECTION_ID"]); } } return $arFilter; }
/** * @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"]; } if ($arImgSku[$arOffer['ID']]["DETAIL_PICTURE"] != "") { $arSkuTmp["DETAIL_PICTURE"] = $arImgSku[$arOffer['ID']]["DETAIL_PICTURE"]; } } } foreach ($arIblockOfferProps as $arCode) { if (is_array($arCode) && isset($arOffer["PROPERTIES"][$arCode["CODE"]])) { if (isset($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]])) { $mxValues = ''; if ('E' == $arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['PROPERTY_TYPE']) { if (!empty($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['LINK_ELEMENT_VALUE'])) { $mxValues = array(); foreach ($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['LINK_ELEMENT_VALUE'] as $arTempo) { $mxValues[] = $arTempo['NAME'] . ' [' . $arTempo['ID'] . ']'; } } } elseif ('G' == $arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['PROPERTY_TYPE']) { if (!empty($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['LINK_SECTION_VALUE'])) { $mxValues = array(); foreach ($arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]['LINK_SECTION_VALUE'] as $arTempo) { $mxValues[] = $arTempo['NAME'] . ' [' . $arTempo['ID'] . ']'; } } } if (empty($mxValues)) { $mxValues = $arOffer["DISPLAY_PROPERTIES"][$arCode["CODE"]]["DISPLAY_VALUE"]; } $arSkuTmp[] = strip_tags(is_array($mxValues) ? implode("/ ", $mxValues) : $mxValues); } else { $arSkuTmp[] = ''; } } } if (!empty($arCatalogProduct)) { $arSkuTmp["BALANCE"] = $arCatalogProduct["QUANTITY"]; $arSkuTmp["WEIGHT"] = $arCatalogProduct["WEIGHT"]; $arSkuTmp["BARCODE_MULTI"] = $arCatalogProduct["BARCODE_MULTI"]; } else { $arSkuTmp["BALANCE"] = 0; $arSkuTmp["WEIGHT"] = 0; $arSkuTmp["BARCODE_MULTI"] = 'N'; } $arSkuTmp["USER_ID"] = $userId; $arSkuTmp["ID"] = $arOffer["ID"]; $arSkuTmp["TYPE"] = $arOffer["CATALOG_TYPE"]; $arSkuTmp["NAME"] = CUtil::JSEscape($arOffer["NAME"]); $arSkuTmp["PRODUCT_NAME"] = CUtil::JSEscape(htmlspecialcharsbx($productName)); $arSkuTmp["PRODUCT_ID"] = $productId; $arSkuTmp["LID"] = CUtil::JSEscape($lid); $arSkuTmp["CAN_BUY"] = $arOffer["CAN_BUY"]; $arSkuTmp["ACTIVE"] = $active; $arSkuTmp["EXTERNAL_ID"] = $arOffer['EXTERNAL_ID']; $arSku[] = $arSkuTmp; } if ((!is_array($arIblockOfferProps) || empty($arIblockOfferProps)) && is_array($arSku) && !empty($arSku)) { $arIblockOfferProps[0] = array("CODE" => "TITLE", "NAME" => GetMessage("SKU_TITLE")); foreach ($arSku as $key => $val) { $arSku[$key][0] = $val["NAME"]; } } $arResult["SKU_ELEMENTS"] = $arSku; $arResult["SKU_PROPERTIES"] = $arIblockOfferProps; $arResult["OFFERS_IBLOCK_ID"] = $arOffersIblock[$arProduct["IBLOCK_ID"]]; } return $arResult; }
function ExportProperties(&$PROPERTY_MAP) { $PROPERTY_MAP = array(); fwrite($this->fp, "\t\t<" . GetMessage("IBLOCK_XML2_PROPERTIES") . ">\n"); if ($this->bExtended) { $arElementFields = array("CML2_ACTIVE" => GetMessage("IBLOCK_XML2_BX_ACTIVE"), "CML2_CODE" => GetMessage("IBLOCK_XML2_SYMBOL_CODE"), "CML2_SORT" => GetMessage("IBLOCK_XML2_SORT"), "CML2_ACTIVE_FROM" => GetMessage("IBLOCK_XML2_START_TIME"), "CML2_ACTIVE_TO" => GetMessage("IBLOCK_XML2_END_TIME"), "CML2_PREVIEW_TEXT" => GetMessage("IBLOCK_XML2_ANONS"), "CML2_DETAIL_TEXT" => GetMessage("IBLOCK_XML2_DETAIL"), "CML2_PREVIEW_PICTURE" => GetMessage("IBLOCK_XML2_PREVIEW_PICTURE")); foreach ($arElementFields as $key => $value) { fwrite($this->fp, $this->formatXMLNode(3, GetMessage("IBLOCK_XML2_PROPERTY"), array(GetMessage("IBLOCK_XML2_ID") => $key, GetMessage("IBLOCK_XML2_NAME") => $value, GetMessage("IBLOCK_XML2_MULTIPLE") => "false"))); } } $arFilter = array("IBLOCK_ID" => $this->arIBlock["ID"], "ACTIVE" => "Y"); $arSort = array("sort" => "asc"); $obProp = new CIBlockProperty(); $rsProp = $obProp->GetList($arSort, $arFilter); while ($arProp = $rsProp->Fetch()) { fwrite($this->fp, "\t\t\t<" . GetMessage("IBLOCK_XML2_PROPERTY") . ">\n"); $xml_id = $this->GetPropertyXML_ID($this->arIBlock["ID"], $arProp["NAME"], $arProp["ID"], $arProp["XML_ID"]); $PROPERTY_MAP[$arProp["ID"]] = $xml_id; $PROPERTY_MAP["~" . $arProp["ID"]] = $arProp["NAME"]; fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_ID"), $xml_id)); fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_NAME"), $arProp["NAME"])); fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_MULTIPLE"), $arProp["MULTIPLE"] == "Y" ? "true" : "false")); if ($arProp["PROPERTY_TYPE"] == "L") { fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_CHOICE_VALUES") . ">\n"); $rsEnum = CIBlockProperty::GetPropertyEnum($arProp["ID"]); while ($arEnum = $rsEnum->Fetch()) { fwrite($this->fp, $this->formatXMLNode(5, GetMessage("IBLOCK_XML2_VALUE"), $arEnum["VALUE"])); if ($this->bExtended) { fwrite($this->fp, "\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_CHOICE") . ">\n" . $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_ID"), $arEnum["XML_ID"]) . $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_VALUE"), $arEnum["VALUE"]) . $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_BY_DEFAULT"), $arEnum["DEF"] == "Y" ? "true" : "false") . $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_SORT"), intval($arEnum["SORT"])) . "\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_CHOICE") . ">\n"); } } fwrite($this->fp, "\t\t\t\t</" . GetMessage("IBLOCK_XML2_CHOICE_VALUES") . ">\n"); } if ($this->bExtended) { $strUserSettings = ''; if ('' != $arProp["USER_TYPE"]) { if (!empty($arProp['USER_TYPE_SETTINGS']) && is_array($arProp['USER_TYPE_SETTINGS'])) { $strUserSettings = $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_USER_TYPE_SETTINGS"), serialize($arProp['USER_TYPE_SETTINGS'])); } } fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_SORT"), intval($arProp["SORT"])) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_CODE"), $arProp["CODE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_PROPERTY_TYPE"), $arProp["PROPERTY_TYPE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_ROWS"), $arProp["ROW_COUNT"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_COLUMNS"), $arProp["COL_COUNT"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_LIST_TYPE"), $arProp["LIST_TYPE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_FILE_EXT"), $arProp["FILE_TYPE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_FIELDS_COUNT"), $arProp["MULTIPLE_CNT"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_LINKED_IBLOCK"), $this->GetIBlockXML_ID($arProp["LINK_IBLOCK_ID"])) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_WITH_DESCRIPTION"), $arProp["WITH_DESCRIPTION"] == "Y" ? "true" : "false") . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_SEARCH"), $arProp["SEARCHABLE"] == "Y" ? "true" : "false") . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_FILTER"), $arProp["FILTRABLE"] == "Y" ? "true" : "false") . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_USER_TYPE"), $arProp["USER_TYPE"]) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_IS_REQUIRED"), $arProp["IS_REQUIRED"] == "Y" ? "true" : "false") . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_BX_DEFAULT_VALUE"), serialize($arProp["DEFAULT_VALUE"])) . $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_SERIALIZED"), 1) . $strUserSettings); } fwrite($this->fp, "\t\t\t</" . GetMessage("IBLOCK_XML2_PROPERTY") . ">\n"); } fwrite($this->fp, "\t\t</" . GetMessage("IBLOCK_XML2_PROPERTIES") . ">\n"); if ($this->bExtended) { $catalog = false; if (CModule::IncludeModule("catalog")) { $catalog = CCatalogSKU::getInfoByOfferIBlock($this->arIBlock["ID"]); } if (!empty($catalog) && is_array($catalog)) { $this->ExportSmartFilter(2, $this->arIBlock["ID"], false, $PROPERTY_MAP, $catalog["PRODUCT_IBLOCK_ID"]); } else { $this->ExportSmartFilter(2, $this->arIBlock["ID"], 0, $PROPERTY_MAP); } } }
$arThemesList = array('blue' => GetMessage('CP_BCT_TPL_THEME_BLUE'), 'green' => GetMessage('CP_BCT_TPL_THEME_GREEN'), 'red' => GetMessage('CP_BCT_TPL_THEME_RED'), 'wood' => GetMessage('CP_BCT_TPL_THEME_WOOD'), 'yellow' => GetMessage('CP_BCT_TPL_THEME_YELLOW'), 'black' => GetMessage('CP_BCT_TPL_THEME_BLACK')); $dir = trim(preg_replace("'[\\\\/]+'", "/", dirname(__FILE__) . '/' . $arCurrentValues['VIEW_MODE'] . '/themes/')); if (is_dir($dir)) { foreach ($arThemesList as $themeID => $themeName) { if (!is_file($dir . $themeID . '/style.css')) { continue; } $arThemes[$themeID] = $themeName; } } $arTemplateParameters['TEMPLATE_THEME'] = array('PARENT' => 'VISUAL', 'NAME' => GetMessage("CP_BCT_TPL_TEMPLATE_THEME"), 'TYPE' => 'LIST', 'VALUES' => $arThemes, 'DEFAULT' => 'blue', 'ADDITIONAL_VALUES' => 'Y'); } $arSKU = false; $boolSKU = false; if ($boolCatalog && (isset($arCurrentValues['IBLOCK_ID']) && 0 < intval($arCurrentValues['IBLOCK_ID']))) { $arSKU = CCatalogSKU::GetInfoByProductIBlock($arCurrentValues['IBLOCK_ID']); $boolSKU = !empty($arSKU) && is_array($arSKU); } if ($boolSKU) { $arDisplayModeList = array('N' => GetMessage('CP_BCT_TPL_DML_SIMPLE'), 'Y' => GetMessage('CP_BCT_TPL_DML_EXT')); $arTemplateParameters['PRODUCT_DISPLAY_MODE'] = array('PARENT' => 'VISUAL', 'NAME' => GetMessage('CP_BCT_TPL_PRODUCT_DISPLAY_MODE'), 'TYPE' => 'LIST', 'MULTIPLE' => 'N', 'ADDITIONAL_VALUES' => 'N', 'REFRESH' => 'Y', 'DEFAULT' => 'N', 'VALUES' => $arDisplayModeList); } if (isset($arCurrentValues['IBLOCK_ID']) && 0 < intval($arCurrentValues['IBLOCK_ID'])) { $arAllPropList = array(); $arFilePropList = array('-' => GetMessage('CP_BCT_TPL_PROP_EMPTY')); $arListPropList = array('-' => GetMessage('CP_BCT_TPL_PROP_EMPTY')); $rsProps = CIBlockProperty::GetList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $arCurrentValues['IBLOCK_ID'], 'ACTIVE' => 'Y')); while ($arProp = $rsProps->Fetch()) { $strPropName = '[' . $arProp['ID'] . ']' . ('' != $arProp['CODE'] ? '[' . $arProp['CODE'] . ']' : '') . ' ' . $arProp['NAME']; if ('' == $arProp['CODE']) { $arProp['CODE'] = $arProp['ID'];
public function getSkuPropsData($arBasketItems, $arParents, $arSkuProps = array()) { $arRes = array(); $arSkuIblockID = array(); if (is_array($arParents)) { foreach ($arBasketItems as &$arItem) { if (array_key_exists($arItem["PRODUCT_ID"], $arParents)) { $arSKU = CCatalogSKU::GetInfoByProductIBlock($arParents[$arItem["PRODUCT_ID"]]["IBLOCK_ID"]); if (!array_key_exists($arSKU["IBLOCK_ID"], $arSkuIblockID)) { $arSkuIblockID[$arSKU["IBLOCK_ID"]] = $arSKU; } $arItem["IBLOCK_ID"] = $arSKU["IBLOCK_ID"]; $arItem["SKU_PROPERTY_ID"] = $arSKU["SKU_PROPERTY_ID"]; } } unset($arItem); foreach ($arSkuIblockID as $skuIblockID => $arSKU) { // possible props values $rsProps = CIBlockProperty::GetList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $skuIblockID, 'ACTIVE' => 'Y')); while ($arProp = $rsProps->Fetch()) { if ($arProp['PROPERTY_TYPE'] == 'L' || $arProp['PROPERTY_TYPE'] == 'E' || $arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') { if ($arProp['XML_ID'] == 'CML2_LINK') { continue; } if (!in_array($arProp['CODE'], $arSkuProps)) { continue; } $arValues = array(); if ($arProp['PROPERTY_TYPE'] == 'L') { $arValues = array(); $rsPropEnums = CIBlockProperty::GetPropertyEnum($arProp['ID']); while ($arEnum = $rsPropEnums->Fetch()) { $arValues['n' . $arEnum['ID']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['VALUE'], 'PICT' => false); } } elseif ($arProp['PROPERTY_TYPE'] == 'E') { $rsPropEnums = CIBlockElement::GetList(array('SORT' => 'ASC'), array('IBLOCK_ID' => $arProp['LINK_IBLOCK_ID'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'PREVIEW_PICTURE')); while ($arEnum = $rsPropEnums->Fetch()) { $arEnum['PREVIEW_PICTURE'] = CFile::GetFileArray($arEnum['PREVIEW_PICTURE']); if (!is_array($arEnum['PREVIEW_PICTURE'])) { $arEnum['PREVIEW_PICTURE'] = false; } if ($arEnum['PREVIEW_PICTURE'] !== false) { $productImg = CFile::ResizeImageGet($arEnum['PREVIEW_PICTURE'], array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false); $arEnum['PREVIEW_PICTURE']['SRC'] = $productImg['src']; } $arValues['n' . $arEnum['ID']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['NAME'], 'SORT' => $arEnum['SORT'], 'PICT' => $arEnum['PREVIEW_PICTURE']); } } elseif ($arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') { if (self::$highLoadInclude === null) { self::$highLoadInclude = Loader::includeModule('highloadblock'); } if (self::$highLoadInclude) { $hlblock = HL\HighloadBlockTable::getList(array("filter" => array("=TABLE_NAME" => $arProp["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch(); if ($hlblock) { $entity = HL\HighloadBlockTable::compileEntity($hlblock); $entity_data_class = $entity->getDataClass(); $rsData = $entity_data_class::getList(); while ($arData = $rsData->fetch()) { $arValues['n' . $arData['ID']] = array('ID' => $arData['ID'], 'NAME' => $arData['UF_NAME'], 'SORT' => $arData['UF_SORT'], 'FILE' => $arData['UF_FILE'], 'PICT' => false, 'XML_ID' => $arData['UF_XML_ID']); } } } } if (!empty($arValues) && is_array($arValues)) { $arRes[$skuIblockID][$arProp['ID']] = array('ID' => $arProp['ID'], 'CODE' => $arProp['CODE'], 'NAME' => $arProp['NAME'], 'TYPE' => $arProp['PROPERTY_TYPE'], 'USER_TYPE' => $arProp['USER_TYPE'], 'VALUES' => $arValues); } } } } foreach ($arBasketItems as &$arItem) { if (isset($arItem["IBLOCK_ID"]) && (int) $arItem["IBLOCK_ID"] > 0 && isset($arRes[$arItem["IBLOCK_ID"]])) { $arItem["SKU_DATA"] = $arRes[$arItem["IBLOCK_ID"]]; $arUsedValues = array(); $arTmpRes = array(); $arOfFilter = array("IBLOCK_ID" => $arItem["IBLOCK_ID"], "PROPERTY_" . $arSkuIblockID[$arItem["IBLOCK_ID"]]["SKU_PROPERTY_ID"] => $arParents[$arItem["PRODUCT_ID"]]["PRODUCT_ID"]); $rsOffers = CIBlockElement::GetList(array(), $arOfFilter, false, false, array("ID", "IBLOCK_ID")); while ($obOffer = $rsOffers->GetNextElement()) { $arProps = $obOffer->GetProperties(); foreach ($arProps as $propName => $propValue) { if (in_array($propName, $arSkuProps)) { if (array_key_exists('VALUE', $propValue)) { if (strlen($propValue['VALUE']) > 0 && (!is_array($arUsedValues[$arItem["PRODUCT_ID"]][$propName]) || !in_array($propValue['VALUE'], $arUsedValues[$arItem["PRODUCT_ID"]][$propName]))) { $arUsedValues[$arItem["PRODUCT_ID"]][$propName][] = $propValue['VALUE']; } } } } } if (!empty($arUsedValues)) { // add only used values to the item SKU_DATA foreach ($arRes[$arItem["IBLOCK_ID"]] as $propId => $arProp) { if (!array_key_exists($arProp["CODE"], $arUsedValues[$arItem["PRODUCT_ID"]])) { continue; } $arTmpRes['n' . $propId] = array(); foreach ($arProp["VALUES"] as $valId => $arValue) { // properties of various type have different values in the used values data if ($arProp["TYPE"] == "L" && in_array($arValue["NAME"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]]) || $arProp["TYPE"] == "E" && in_array($arValue["ID"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]]) || $arProp["TYPE"] == "S" && in_array($arValue["XML_ID"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]])) { if ($arProp["TYPE"] == "S") { if (!empty($arValue["FILE"])) { $arTmpFile = CFile::GetFileArray($arValue["FILE"]); if (!empty($arTmpFile)) { $tmpImg = CFile::ResizeImageGet($arTmpFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false); $arValue['PICT']['SRC'] = $tmpImg['src']; } } } $arTmpRes['n' . $propId]["CODE"] = $arProp["CODE"]; $arTmpRes['n' . $propId]["NAME"] = $arProp["NAME"]; $arTmpRes['n' . $propId]["VALUES"][$valId] = $arValue; } } } } $arItem["SKU_DATA"] = $arTmpRes; } } unset($arItem); } return $arBasketItems; }
die; } } else { require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; echo ShowError(str_replace('#ID#', $intIBlockID, GetMessage("YANDEX_ERR_NO_IBLOCK_FOUND_EXT"))); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"; die; } $boolOffers = false; $arOffers = false; $arOfferIBlock = false; $intOfferIBlockID = 0; $arSelectOfferProps = array(); $arSelectedPropTypes = array('S', 'N', 'L', 'E', 'G'); $arOffersSelectKeys = array(YANDEX_SKU_EXPORT_ALL, YANDEX_SKU_EXPORT_MIN_PRICE, YANDEX_SKU_EXPORT_PROP); $arOffers = CCatalogSKU::GetInfoByProductIBlock($intIBlockID); if (!empty($arOffers['IBLOCK_ID'])) { $intOfferIBlockID = $arOffers['IBLOCK_ID']; $strPerm = 'D'; $rsOfferIBlocks = CIBlock::GetByID($intOfferIBlockID); if ($arOfferIBlock = $rsOfferIBlocks->Fetch()) { $bBadBlock = !CIBlockRights::UserHasRightTo($intOfferIBlockID, $intOfferIBlockID, "iblock_admin_display"); if ($bBadBlock) { require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; echo ShowError(GetMessage('YANDEX_ERR_NO_ACCESS_IBLOCK_SKU')); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"; die; } } else { require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; echo ShowError(str_replace('#ID#', $intIBlockID, GetMessage("YANDEX_ERR_NO_IBLOCK_SKU_FOUND")));