select('l.id, l.data, l.cron_assignment') ->from('labels', 'l') ->andWhere(Operator::equals(['id' => $this->getID()])) ->execute() ->fetchAssociative(); $data = json_decode($label['data'] ?? '{}', true); if ($label['cron_assignment'] == 'Y' || $data['active_type'] == 'Y') { $result = $this->productLabelUtil->updateProductLabelRelationsByAutoAssignment($this->getID(), $data); return new ActionResult(true, "Dokončeno. Smazáno: {$result['deleted']}, Přiřazeno: {$result['inserted']}"); } else { $result = $this->productLabelUtil->removeProductLabelRelationsByAutoAssignment($this->getID()); return new ActionResult(false, "Štítek nemá platné nastavení. Počet odebraných přiřazení: {$result}"); } } }