Code changed in 7.03

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
mfreeze
Commodore (COMO)
Commodore (COMO)
Posts: 421
Joined: Mon Jan 24, 2005 2:07 pm
Location: Washington, NJ
Contact:

Code changed in 7.03

Post by mfreeze » Fri Feb 19, 2010 5:25 pm

I am trying to implement the following code obtained from another forum post in CategoryGridPage4 but the line Int32 variantStockLevel = RFC_ProductHelper.IsProductVariantsInStock(product.ProductId);
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>"));
                        }
Mary E Freeze

Freeze Frame Graphics
Web Hosting and Design, ASP and CFMX Development

http://www.ffgraphics.com

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Code changed in 7.03

Post by mazhar » Mon Feb 22, 2010 12:18 pm

Mary have a look at this thread.
viewtopic.php?f=42&t=10310

User avatar
mfreeze
Commodore (COMO)
Commodore (COMO)
Posts: 421
Joined: Mon Jan 24, 2005 2:07 pm
Location: Washington, NJ
Contact:

Re: Code changed in 7.03

Post by mfreeze » Mon Feb 22, 2010 3:12 pm

I got it to work using the following code. This was in categorygridpage4.ascx.cs. the code I added is after the comment.

Code: Select all

                //OUTPUT RETAIL PRICE IF AVAILABLE
                if (catalogNode.CatalogNodeType == CatalogNodeType.Product)
                {
                    Product product = (Product)catalogNode.ChildObject;
// Mary added the following to show out of stock on category page 					
					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)
                    {
                        int variantStockLevel = 0;
                        foreach (ProductVariant oVariant in product.Variants)
                        {
                            if (oVariant.InStock > variantStockLevel)
                            {
                                variantStockLevel = oVariant.InStock;
                                break;
                            }
                        }
                        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>"));
                        }
                    }
// end out of stock modifications
Mary E Freeze

Freeze Frame Graphics
Web Hosting and Design, ASP and CFMX Development

http://www.ffgraphics.com

Post Reply