0], null, '*', null, true); if (!empty($list)) { foreach ($list as $order) { $shopId = $order->shopId ?? 0; $shop = ShopClass::getById($shopId, true); $mainId = $shop->mainId ?? 0; if (!empty($mainId)) { $order->mainId = $mainId; $order->save(); } } } } }