13 protected function loadCatalog(array $skuIds): array
15 Main\Type\Collection::normalizeArrayValuesByInt($skuIds,
true);
17 $repositoryFacade = ServiceContainer::getRepositoryFacade();
18 if (!$repositoryFacade)
24 $productSkuIblockMap = [];
25 foreach ($skuIds as $skuId)
27 $sku = $repositoryFacade->loadVariation($skuId);
34 $product = $sku->getParent();
36 $fields = $sku->getFields();
37 $fields[
'PRODUCT_ID'] = $product->getId();
38 $fields[
'SKU_ID'] = $skuId;
39 $fields[
'OFFERS_IBLOCK_ID'] = 0;
40 $fields[
'SKU_TREE'] = [];
41 $fields[
'DETAIL_URL'] = $this->
getElementDetailUrl($product->getIblockId(), $product->getId());
42 $fields[
'TYPE'] = (int)$fields[
'TYPE'];
44 $measure = $this->measures[$sku->getField(
'MEASURE')] ??
null;
50 $fields[
'MEASURE_CODE'] = $measure[
'CODE'];
51 $fields[
'MEASURE_NAME'] = $measure[
'SYMBOL'];
53 if (!$product->isSimple())
55 $fields[
'OFFERS_IBLOCK_ID'] = $fields[
'IBLOCK_ID'];
56 $fields[
'IBLOCK_ID'] = $product->getIblockId();
57 $productSkuIblockMap[$product->getIblockId()] = $productSkuIblockMap[$product->getIblockId()] ?? [];
58 $productSkuIblockMap[$product->getIblockId()][$product->getId()][] = $sku->getId();
61 $productInfo[$skuId] = [
67 if ($productSkuIblockMap)
69 foreach ($productSkuIblockMap as $iblockId => $productMap)
71 $skuTree = ServiceContainer::make(
'sku.tree', [
'iblockId' => $iblockId]);
74 $skuTreeItems = $skuTree->loadJsonOffers($productMap);
75 foreach ($skuTreeItems as $offers)
77 foreach ($offers as $skuId => $skuTreeItem)
79 if (isset($productInfo[$skuId][
'FIELDS']))
81 $productInfo[$skuId][
'FIELDS'][
'SKU_TREE'] = $skuTreeItem;
94 $urlBuilder = BuilderManager::getInstance()->getBuilder($this->arParams[
'BUILDER_CONTEXT']);
100 $urlBuilder->setIblockId($iblockId);
101 return $urlBuilder->getElementDetailUrl($skuId);
106 $measureResult = \CCatalogMeasure::getList(
111 [
'CODE',
'SYMBOL_RUS',
'SYMBOL_INTL',
'IS_DEFAULT',
'ID']
114 $this->measures = [];
115 while ($measureFields = $measureResult->Fetch())
118 'ID' => $measureFields[
'ID'],
119 'CODE' => $measureFields[
'CODE'],
120 'IS_DEFAULT' => $measureFields[
'IS_DEFAULT'],
121 'SYMBOL' => $measureFields[
'SYMBOL_RUS'] ?? $measureFields[
'SYMBOL_INTL'],
124 $this->measures[$measureFields[
'ID']] = $measureItem;
133 return \CCatalogMeasure::getDefaultMeasure(
true);