query = $query; } // getOrderProductsFormOrderShopsGroupByStorageOrder public function getByOrderShopsGroupByStorageOrder(array $orderShops): array { $orderProductsByStorageOrder = []; foreach ($orderShops as $orderShop) { foreach ($orderShop->getOrderProducts() as $orderProduct) { if ($orderProduct->getProduct() && $orderProduct->getProduct()->getProductFamily()) { $storageOrder = 0; if ($orderProduct->getProduct()->getProductFamily()->getStorageOrder()) $storageOrder = $productFamily->getStorageOrder(); if (!isset($orderProductsByStorageOrder[$storageOrder])) { $orderProductsByStorageOrder[$productFamily->getId()] = [ 'order_products' => [], 'total_quantity_weight' => 0, ]; } $orderProductsByStorageOrder[$storageOrder]['order_products'][] = $orderProduct; $orderProductsByStorageOrder[$storageOrder]['total_quantity_weight'] += ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient()) * $orderProduct->getQuantityOrder(); } } } return $orderProductsByStorageOrder; } }