50 if (!isset($this->variationIds))
53 $variations = \CCatalogSku::getOffersList($productId);
54 if (isset($variations[$productId]))
56 $this->variationIds = array_column($variations[$productId],
'ID');
60 $this->variationIds = [$productId];
110 $offset = $params[
'offset'] ?? 0;
111 $limit = $params[
'limit'] ??
null;
116 '=STORE.ACTIVE' =>
'Y',
119 $filter = array_merge(
121 AccessController::getCurrent()->getEntityFilter(
122 ActionDictionary::ACTION_STORE_VIEW,
123 StoreProductTable::class
128 'select' => [
'SID_DISTINCT'],
135 $storeIds = array_column($storeProductData,
'SID_DISTINCT');
136 $storeIds = array_slice($storeIds, $offset, $limit);
146 '=STORE_ID' => $storeIds,
148 '=STORE.ACTIVE' =>
'Y',
152 $fetchedVariationIds = array_column($storeProductData,
'PRODUCT_ID');
156 foreach ($variationsData as $variationData)
158 $variations[$variationData[
'ID']] = $variationData;
162 foreach ($storeProductData as $storeProduct)
164 $productData = $variations[$storeProduct[
'PRODUCT_ID']];
166 if ((
float)$storeProduct[
'QUANTITY_RESERVED'] === 0.0 && (
float)$storeProduct[
'AMOUNT'] === 0.0)
171 $storeId = (int)$storeProduct[
'STORE_ID'];
172 $amount = (float)$productData[
'PURCHASING_PRICE'] * (
float)$storeProduct[
'AMOUNT'];
175 $currency = $productData[
'PURCHASING_CURRENCY'];
177 if (!isset($stores[$storeId]))
179 $storeIds[] = $storeId;
181 $stores[$storeId] = [
189 if (!isset($stores[$storeId][
'QUANTITY'][$measureId]))
191 $stores[$storeId][
'QUANTITY'][$measureId] = [
192 'QUANTITY_COMMON' => (float)$storeProduct[
'AMOUNT'],
193 'QUANTITY_RESERVED' => (
float)$storeProduct[
'QUANTITY_RESERVED'],
194 'MEASURE_ID' => $measureId,
199 $stores[$storeId][
'QUANTITY'][$measureId][
'QUANTITY_COMMON'] += (float)$storeProduct[
'AMOUNT'];
200 $stores[$storeId][
'QUANTITY'][$measureId][
'QUANTITY_RESERVED'] += (float)$storeProduct[
'QUANTITY_RESERVED'];
204 if (!isset($stores[$storeId][
'AMOUNT'][$currency]))
206 $stores[$storeId][
'AMOUNT'][$currency] = [
208 'CURRENCY' => $currency,
213 $stores[$storeId][
'AMOUNT'][$currency][
'AMOUNT'] += $amount;
219 foreach ($storesInfo as $storeInfo)
221 if (isset($stores[(
int)$storeInfo[
'ID']]))
223 $stores[(int)$storeInfo[
'ID']][
'TITLE'] = $storeInfo[
'TITLE'];
276 $quantityCommon =
'';
277 $quantityReserved =
'';
279 foreach (
$storeTotal[
'QUANTITY'] as $storeQuantity)
281 $measureSymbol = htmlspecialcharsbx($this->
getMeasure($storeQuantity[
'MEASURE_ID']));
284 "<span class='total-info'>
285 <span class='total-info-value'>{$storeQuantity['QUANTITY']}</span>
290 "<span class='total-info'>
291 <span class='total-info-value'>{$storeQuantity['QUANTITY_COMMON']}</span>
295 $measureReservedInfo =
296 "<span class='total-info'>
297 <span class='total-info-value'>{$storeQuantity['QUANTITY_RESERVED']}</span>
301 $quantity .= $measureInfo .
'<br>';
302 $quantityCommon .= $measureCommonInfo .
'<br>';
303 $quantityReserved .= $measureReservedInfo .
'<br>';
310 if (isset($storeAmount[
'CURRENCY']))
313 "<span class='total-info-value'>"
314 . \CCurrencyLang::CurrencyFormat($storeAmount[
'AMOUNT'], $storeAmount[
'CURRENCY'],
false)
318 "<span class='total-info'>"
319 . \CCurrencyLang::getPriceControl(
321 $storeAmount[
'CURRENCY']
325 $amount .= $amountBlock.
'<br>';
331 "QUANTITY" => $quantity,
332 "QUANTITY_COMMON" => $quantityCommon,
333 "QUANTITY_RESERVED" => $quantityReserved,
365 foreach ($variationsTotalData as $variationData)
367 $variationData[
'MEASURE_ID'] = $variationData[
'MEASURE_ID'] ?? (int)$this->
getDefaultMeasure()[
'ID'];
369 if (!isset($storeTotalData[
'QUANTITY'][$variationData[
'MEASURE_ID']]))
371 $storeTotalData[
'QUANTITY'][$variationData[
'MEASURE_ID']] = [
373 'QUANTITY_COMMON' => 0.0,
374 'QUANTITY_RESERVED' => 0.0,
375 'MEASURE_ID' => $variationData[
'MEASURE_ID'],
379 $quantityValue = (float)$variationData[
'QUANTITY_COMMON'] - (
float)$variationData[
'QUANTITY_RESERVED'];
381 $storeTotalData[
'QUANTITY'][$variationData[
'MEASURE_ID']][
'QUANTITY'] += $quantityValue;
382 $storeTotalData[
'QUANTITY'][$variationData[
'MEASURE_ID']][
'QUANTITY_COMMON'] += (float)$variationData[
'QUANTITY_COMMON'];
383 $storeTotalData[
'QUANTITY'][$variationData[
'MEASURE_ID']][
'QUANTITY_RESERVED'] += (float)$variationData[
'QUANTITY_RESERVED'];
385 if (!isset($storeTotalData[
'AMOUNT'][$variationData[
'CURRENCY']]))
387 $storeTotalData[
'AMOUNT'][$variationData[
'CURRENCY']] = [
389 'CURRENCY' => $variationData[
'CURRENCY'],
392 $commonPrice = (float)$variationData[
'QUANTITY_COMMON'] * (
float)$variationData[
'PRICE'];
393 $storeTotalData[
'AMOUNT'][$variationData[
'CURRENCY']][
'AMOUNT'] += $commonPrice;
397 $this->storeTotal = $storeTotalData;
413 '=STORE.ACTIVE' =>
'Y',
416 $filter = array_merge(
418 AccessController::getCurrent()->getEntityFilter(
419 ActionDictionary::ACTION_STORE_VIEW,
420 StoreProductTable::class
427 'MEASURE_ID' =>
'PRODUCT.MEASURE',
428 'PRICE' =>
'PRODUCT.PURCHASING_PRICE',
429 'CURRENCY' =>
'PRODUCT.PURCHASING_CURRENCY',
433 'group' => [
'PRODUCT_ID'],
439 foreach ($commonProductData as $productData)
441 $products[$productData[
'PRODUCT_ID']] = $productData;
451 '=STORE.ACTIVE' =>
'Y',
453 'group' => [
'PRODUCT_ID'],
459 foreach ($productQuantityReservedData as $productData)
461 $products[$productData[
'PRODUCT_ID']][
'QUANTITY_RESERVED'] = $productData[
'RESERVED_AMOUNT'];
475 if ($measureId ===
null)
480 if (!isset($this->measures[$measureId]))
482 $measure = \CCatalogMeasure::getList([], [
'=ID' => $measureId])->Fetch();
486 $this->measures[$measureId] = $measure[
'SYMBOL'];
490 $this->measures[$measureId] =
'';
494 return $this->measures[$measureId];