connection = $connection; $this->mailer = $mailer; } public function notifyCustomers(string $productId, string $productName, string $productUrl, string $shopName): void { $sql = "SELECT email FROM notifyifavail_plugin_notification WHERE product_id = :productId"; $emails = $this->connection->fetchFirstColumn($sql, ['productId' => Uuid::fromHexToBytes($productId)]); foreach ($emails as $email) { $message = (new Email()) ->from('shop@example.com') ->to($email) ->subject('Ihr gewünschter Artikel ist wieder verfügbar!') ->html("

Hallo,

Sie haben sich für eine Benachrichtigung angemeldet, sobald der folgende Artikel wieder verfügbar ist:

{$productName}

Jetzt bestellen

Vielen Dank für Ihr Interesse an unseren Produkten!

Beste Grüße,
{$shopName}-Team

"); $this->mailer->send($message); } // Nach Versand aus der Datenbank löschen $this->connection->executeStatement("DELETE FROM notifyifavail_plugin_notification WHERE product_id = :productId", [ 'productId' => Uuid::fromHexToBytes($productId) ]); } }