->all();
$result = [];
-
foreach ($models as $model) {
$productId = $model['product_id'];
$productName = $model['product_name'];
'product_id' => $productId,
'name' => $productName,
'values' => [],
- 'title' => [],
];
}
'id' => $model['plan_id'],
'quantity' => (int)$model['quantity'],
'store_id' => (int)$model['store_id'],
+ // title пока не заполняем
];
}
$guid = $productIdToGuid[$productId] ?? null;
if (!$guid) continue;
- foreach ($productData['values'] as $value) {
+ foreach ($productData['values'] as &$value) {
$storeId = $value['store_id'];
if (!isset($forecast[$storeId][$guid])) continue;
+
$forecastData = $forecast[$storeId][$guid];
+ $value['title'] = [];
foreach ($forecastData as $type => $groups) {
foreach ($groups as $group => $amount) {
- $productData['title'][$type][$group] = $amount;
+ $value['title'][$type][$group] = $amount;
}
}
}