Low stock products bug on 4.3

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hello it seems that you have re-written the GetLowStockProductCombinations, but you forgot to put some (). In terms of .net code the stuff is ok, but since it;s translated to sql it's bad.
Put some () for the || conditions or it will return all products :)
In sql it's translated to this
(([pac].[StockQuantity] < [pac].[NotifyAdminForQuantityBelow] AND [p].[ManageInventoryMethodId] = 2 AND 1 <> [p].[Deleted] AND [p].[ProductTypeId] <> 10 OR [p].[VendorId] = @vendorId) OR [p].[Published] IS NULL)

Corrected below:

var combinations = from pac in _productAttributeCombinationRepository.Table
                join p in _productRepository.Table on pac.ProductId equals p.Id
                where
                    //filter by combinations with stock quantity less than the minimum
                    pac.StockQuantity < pac.NotifyAdminForQuantityBelow &&
                    //filter by products with tracking inventory by attributes
                    p.ManageInventoryMethodId == (int)ManageInventoryMethod.ManageStockByAttributes &&
                    //ignore deleted products
                    !p.Deleted &&
                    //ignore grouped products
                    p.ProductTypeId != (int)ProductType.GroupedProduct &&
                    //filter by vendor
                    ((vendorId ?? 0) == 0 || p.VendorId == vendorId) &&
                    //whether to load published products only
                    (loadPublishedOnly == null || p.Published == loadPublishedOnly)
                orderby pac.ProductId, pac.Id
                select pac;
3 years ago
Thanks. We'll check it.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.