2], null, '*', null, true); if (!empty($shopList)) { foreach ($shopList as $shop) { $mainId = $shop->mainId ?? 0; $customDefaultClass = ItemClassClass::getByCondition(['mainId' => $mainId, 'isDefault' => 1], true); if (empty($customDefaultClass)) { ShopClass::deleteByCondition(['mainId' => $mainId]); $main = MainClass::getById($mainId, true); if (!empty($main)) { $main->delete(); } } } } } }