$quantity = $value['quantity'];
$value['title'] = [];
- if (!isset($forecast[$storeId])) {
+ if (!isset($forecast[$storeId]) || !isset($forecast[$storeId][$productId])) {
continue;
}
foreach (['offline', 'marketplace', 'online'] as $channel) {
- if (isset($forecast[$storeId][$channel]['share']) && is_numeric($forecast[$storeId][$channel]['share'])) {
- $coef = $forecast[$storeId][$channel]['share'];
- $value['title'][$channel] = round($quantity * $coef, 2);
+ if (isset($forecast[$storeId][$productId][$channel]) && is_array($forecast[$storeId][$productId][$channel])) {
+ // Суммируем все коэффициенты по группам для данного канала
+ $coefSum = 0;
+ foreach ($forecast[$storeId][$productId][$channel] as $coef) {
+ if (is_numeric($coef)) {
+ $coefSum += $coef;
+ }
+ }
+ if ($coefSum > 0) {
+ $value['title'][$channel] = round($quantity * $coefSum, 2);
+ }
}
}
}