diff --git a/src/Synolia/Bundle/StockAlertBundle/EventListener/InventoryLevelNotificationEventListener.php b/src/Synolia/Bundle/StockAlertBundle/EventListener/InventoryLevelNotificationEventListener.php index 7dbc59d..98e61e9 100644 --- a/src/Synolia/Bundle/StockAlertBundle/EventListener/InventoryLevelNotificationEventListener.php +++ b/src/Synolia/Bundle/StockAlertBundle/EventListener/InventoryLevelNotificationEventListener.php @@ -63,8 +63,12 @@ public function postUpdate(): void protected function inventoryHasNewStock(PreUpdateEventArgs $args): bool { - $oldQuantity = floatval($args->getOldValue('quantity')); - $newQuantity = floatval($args->getNewValue('quantity')); + if (!$args->hasChangedField('quantity')) { + return false; + } + + $oldQuantity = (float) $args->getOldValue('quantity'); + $newQuantity = (float) $args->getNewValue('quantity'); return $oldQuantity <= 0 && $newQuantity > 0; }