We had the same problem...
The problem is in Libraries\Nop.Services\Catalog\ProductService.cs lines 152-173
protected virtual async Task ApplyLowStockActivityAsync(Product product, int totalStock)
{
var stockDec = product.MinStockQuantity >= totalStock;
var stockInc = _catalogSettings.PublishBackProductWhenCancellingOrders && product.MinStockQuantity < totalStock;
switch (product.LowStockActivity)
{
case LowStockActivity.DisableBuyButton:
product.DisableBuyButton = stockDec && !stockInc;
product.DisableWishlistButton = stockDec && !stockInc;
await UpdateProductAsync(product);
break;
case LowStockActivity.Unpublish:
product.Published = !stockDec && stockInc;
await UpdateProductAsync(product);
break;
default:
break;
}
}
If the setting "catalogsettings.publishbackproductwhencancellingorders" is set to True, then the LowStockActivity products don't get unpublished, otherwise the line
product.Published = !stockDec && stockInc;
always gets evaluated to False, thus unpublishing the product.
I think the formula should include the previous value of Published anyways with an or operator...
....
case LowStockActivity.Unpublish:
product.Published = product.Published || (!stockDec && stockInc);
await UpdateProductAsync(product);
....
So the quick and dirty solution is to set
catalogsettings.publishbackproductwhencancellingorders to True (and ignoring the actual function of the setting) or the right way to change the code, update & recompile the website.
edit: it's not so simple... just tried some other input values and it doesn't work if the product is already published... will update the post soon with the correct way