Developer forum

Forum » Dynamicweb 10 » Back in stock notification

Back in stock notification

Jason
Reply

I am customizing the back to stock notification. I want to do something when stock is back instead of sending email using DW standard. May I know how we identify the stock is back via notification?

 

Regards

Jason


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

We do it like this:

internal virtual IEnumerable<ProductBackInStockNotification> GetNotificationsToSent(int areaId)
    {
        var commandBuilder = CommandBuilder.Create(
            """
            SELECT n.* FROM [EcomNotification] n
           
                INNER JOIN [EcomProducts] p
                    ON p.ProductID = n.NotificationProductID
                    AND p.ProductVariantID = n.NotificationProductVariantID
                    AND p.ProductActive = 1
                    AND p.ProductLanguageID = n.NotificationProductLanguageID
           
                WHERE [NotificationContextAreaID] = {0}
                AND [NotificationSentTime] IS NULL
                AND ((n.NotificationProductUnitID = '' AND p.ProductStock > 0)
                    OR (p.ProductDefaultUnitID > ''
                        AND EXISTS (
                            SELECT 1 FROM [EcomStockUnit]
                               WHERE p.ProductID = [StockUnitProductID]
                               AND p.ProductVariantID = [StockUnitVariantID]
                               AND [StockUnitQuantity] > 0
                               AND (n.NotificationProductUnitID = '' OR [StockUnitID] = n.NotificationProductUnitID)
                        )
                    )
                )
 
            ORDER BY n.NotificationUserID, n.NotificationEmail
            """,
            areaId);
 
        var result = new List<ProductBackInStockNotification>();
        using var dataReader = Database.CreateDataReader(commandBuilder);
        while (dataReader.Read())
        {
            result.Add(ExtractProductBackInStockNotification(dataReader));
        }
 
        return result;
    }
Votes for this answer: 1
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

GetNotificationsToSent on the ProductStockNotificationService

 

You must be logged in to post in the forum