22 if (!Loader::includeModule(
'catalog') || !self::checkDocumentReadRights())
24 $this->arResult[
'ERROR_MESSAGES'][] =
Loc::getMessage(
'CATALOG_REPORT_STORE_LIST_NO_READ_RIGHTS_ERROR');
25 $this->includeComponentTemplate();
30 $this->arResult[
'GRID'] = $this->getGridData();
31 $this->arResult[
'GRID_FILTER'] = $this->getGridFilter();
34 $this->includeComponentTemplate();
37 private function getGridData(): array
46 isset($this->arParams[
'RESULT'][
'data'][
'stub'])
47 && is_array($this->arParams[
'RESULT'][
'data'][
'stub'])
50 $result[
'STUB'] = $this->arParams[
'RESULT'][
'data'][
'stub'];
55 $providerData = $this->arParams[
'RESULT'][
'data'][
'items'];
56 $overallData = $this->arParams[
'RESULT'][
'data'][
'overall'];
58 if (!empty($providerData))
60 foreach($providerData as $storeId => $item)
65 'columns' => $this->prepareItemColumn($item),
69 $result[
'ROWS'][] = $this->prepareOverallTotalRow($overallData);
72 $result[
'SHOW_PAGINATION'] =
false;
73 $result[
'SHOW_NAVIGATION_PANEL'] =
false;
74 $result[
'SHOW_PAGESIZE'] =
false;
75 $result[
'SHOW_ROW_CHECKBOXES'] =
false;
76 $result[
'SHOW_CHECK_ALL_CHECKBOXES'] =
false;
77 $result[
'SHOW_ACTION_PANEL'] =
false;
78 $result[
'HANDLE_RESPONSE_ERRORS'] =
true;
79 $result[
'SHOW_GRID_SETTINGS_MENU'] =
false;
80 $result[
'ALLOW_STICKED_COLUMNS'] =
true;
85 private function prepareItemColumn(array $item): array
89 $column[
'TITLE'] = $this->prepareTitleViewForColumn($column);
90 if (isset($column[
'STORE_ID']))
92 $column[
'STORE_ID'] = (int)$column[
'STORE_ID'];
97 $column[$totalField] = $this->prepareTotalField($column[
'TOTALS'], $totalField);
100 unset($column[
'TOTALS']);
105 private function prepareOverallTotalRow(array $overallData): array
107 $overallColumns = [];
108 $overallColumns[
'TITLE'] =
Loc::getMessage(
'CATALOG_REPORT_STORE_LIST_OVERALL_TOTAL');
112 $overallColumns[$totalField] = $this->prepareTotalField($overallData, $totalField);
116 'id' =>
'overallTotal',
117 'data' => $overallData,
118 'columns' => $overallColumns,
122 private function prepareTotalField(array $totals,
string $field): string
130 foreach ($totals as $measureId => $total)
132 $result .= $this->formatNumberWithMeasure($total[$field], (
int)$measureId);
139 private function formatNumberWithMeasure($number,
int $measureId)
142 'CATALOG_REPORT_STORE_LIST_MEASURE_TEMPLATE',
144 '#NUMBER#' => $number,
145 '#MEASURE_SYMBOL#' => $this->getMeasureSymbol($measureId),
150 private function prepareTitleViewForColumn(array $column): string
152 if (!isset($column[
'TITLE'], $column[
'STORE_ID']))
157 if ($column[
'TITLE'])
159 $title = htmlspecialcharsbx($column[
'TITLE']);
169 private function getMeasureSymbol(
int $measureId): string
171 $measure = $this->getMeasures()[$measureId] ??
null;
173 return $measure !==
null ? htmlspecialcharsbx($measure[
'SYMBOL']) :
'';
176 private function getMeasures(): array
178 static $measures = [];
180 if (empty($measures))
182 $measuresResult = \CCatalogMeasure::getList();
183 while ($measure = $measuresResult->Fetch())
185 $measures[$measure[
'ID']] = $measure;
192 private function getGridFilter(): array
194 return $this->arParams[
'RESULT'][
'data'][
'filter'];
201 return getLocalPath(
'components' . $productGridPath .
'/slider.php');
204 private static function checkDocumentReadRights(): bool
206 return AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_READ);
static getMessage($code, $replace=null, $language=null)