_db->select(); $select->from($this->_getPair('Event', 'e'), ['title']) ->join( $this->_getPair('Event2Product', 'e2p'), 'e.id = e2p.eventId AND e2p.productId = ' . (int) $this->getPrimaryKey(), null ); $eventsList = $this->_db->fetchCol($select, 'title'); $message = 'This Product cannot be deleted because it is associated with ' . \Qs_Translate::getPlural(['an Event', 'Events'], count($eventsList)) . ' in the system: ' . implode(', ', $eventsList) . '.'; $this->_foreignKeyLocksMessages[self::EVENT_2_PRODUCTS_FOREIGN_KEY_LOCK] = $message; } return parent::_getForeignKeyLocksMessages($foreignKeyLocks); } }