no longer works.
I see that the inventory count for variants is no longer in producthelper. Looking at the class files, I believe it moved to commercebuilder.products.productvariant but I have not yet been successful at setting it correctly. Does anybody know what I should use to replace the producthelper reference in order to retrieve the variant stock level for the product?
The sole purpose of this code is to check the stock level of the product variants to determine whether to show the 'out of stock message'. If anybody knows a better way I would appreciate any help you could give.
Code: Select all
int _ProductId = 0;
_ProductId = catalogNode.CatalogNodeId;
if (AlwaysConvert.ToInt(product.InventoryModeId) == 1)
{
if (product.InStock > 0)
{
string inStockformat = Token.Instance.Store.Settings.InventoryInStockMessage;
string inStockMessage = string.Format(inStockformat, product.InStock);
inStockMessage = "IN STOCK";
itemTemplate1.Controls.Add(new LiteralControl("<p>" + inStockMessage + "</p>"));
}
else
{
string outOfStockformat = Token.Instance.Store.Settings.InventoryOutOfStockMessage;
string outOfStockMessage = string.Format(outOfStockformat, product.InStock);
itemTemplate1.Controls.Add(new LiteralControl("<p>" + outOfStockMessage + "</p>"));
}
}
else if (AlwaysConvert.ToInt(product.InventoryModeId) == 2)
{
Int32 variantStockLevel = RFC_ProductHelper.IsProductVariantsInStock(product.ProductId);
if (variantStockLevel > 0)
{
string inStockformat = Token.Instance.Store.Settings.InventoryInStockMessage;
string inStockMessage = string.Format(inStockformat, product.InStock);
inStockMessage = "IN STOCK";
itemTemplate1.Controls.Add(new LiteralControl("<p>" + inStockMessage + "</p>"));
}
else
{
string outOfStockformat = Token.Instance.Store.Settings.InventoryOutOfStockMessage;
string outOfStockMessage = string.Format(outOfStockformat, product.InStock);
itemTemplate1.Controls.Add(new LiteralControl("<p>" + outOfStockMessage + "</p>"));
}