2], 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]); } } } } }