Custom Header Issues in Product and Category Pages

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
euroluxantiques
Commander (CMDR)
Commander (CMDR)
Posts: 118
Joined: Sat Dec 20, 2008 11:27 pm

Custom Header Issues in Product and Category Pages

Post by euroluxantiques » Sun Feb 17, 2013 7:45 pm

I wanted to show our categories in the top nav bar, so I adjusted SimpleCategoryList and made a new custom control to do this. Works great here:

http://dev.euroluxantiques.com/Default.aspx

However, on the product page and category page, the categories do not show up in the nav bar. Only the blog link shows up because it is hard coded in my custom SimpleCategoryList. Because I see the blog link there on these pages, I know I am referencing the custom control. Here are the 2 problem children:

http://dev.euroluxantiques.com/Furniture-C214.aspx

http://dev.euroluxantiques.com/New-Righ ... 24239.aspx

Is there something about these 2 pages that are not calling the categories in PageLoad, as it does on all other pages? Is there a workaround? The new layout editor really has my aggravated, and now this. Please help! Thanks!

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

Re: Custom Header Issues in Product and Category Pages

Post by mazhar » Mon Feb 18, 2013 3:55 am

You need to understand the intended functionality of SimpleCategoryList control. The control was coded to list child categories of any given category or categories from root. For example on home page, contact or any other custom page it will list root categories since there is no category available in that context. On categories page it will list child categories of the category you are viewing. I think in case of product page it tries to find out the category in context which leads it to category product belongs too. The chances are product category doesn't have any sub category hence you endup with empty list.

There can be two ways to fix it. First if you always want to list only the root categories or specific categories then hard code the categoryid to load from. This can be done by locating following code lines

Code: Select all

if (_CategoryId < 0) _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
IList<Category> subCategories = GetSubcategories(_CategoryId);
and then by updating it like

Code: Select all

IList<Category> subCategories = GetSubcategories(1); 
Where 1 is the category id which contains the sub categories to list.

Secondly if you want to keep the behaviour same means list categories child of the category in context in then you need to update the code like this

Code: Select all

if (_CategoryId < 0) _CategoryId = AlwaysConvert.ToInt(request.QueryString["CategoryId"]);
IList<Category> subCategories = GetSubcategories(_CategoryId);
Hopefully this will help

euroluxantiques
Commander (CMDR)
Commander (CMDR)
Posts: 118
Joined: Sat Dec 20, 2008 11:27 pm

Re: Custom Header Issues in Product and Category Pages

Post by euroluxantiques » Mon Feb 18, 2013 2:06 pm

Thanks Mazhar. I changed it to IList<Category> subCategories = GetSubcategories(0); and it loads my root categories perfectly on those 2 pages. Excellent!

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: Custom Header Issues in Product and Category Pages

Post by sfeher » Sun Jul 26, 2015 4:31 pm

Mazhar,

is there an update to this code for R6? These changes do not work correctly in R6.

Looking to be sure that the SimpleCategoryList ConLib would show only those products which are contained in the currently-active Category.
I think that if this thread is updated to reflect R6, that this would work.

Can you please advise?

Thanks!

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

Re: Custom Header Issues in Product and Category Pages

Post by mazhar » Tue Jul 28, 2015 4:52 am

In order to list product you would need to update the following code

Code: Select all

IList<Category> subCategories = GetSubcategories(_CategoryId);
            CategoryList.DataSource = subCategories;
            CategoryList.DataBind();
            if (subCategories.Count == 0)
            {
                CategoryList.Visible = false;
                NoSubcategoryMessage.Visible = true;
            }
to look like

Code: Select all

if (_CategoryId < 0) _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
            IList<CommerceBuilder.Products.Product> products = CommerceBuilder.Products.ProductDataSource.LoadForCategory(_CategoryId, false);
            CategoryList.DataSource = products;
            CategoryList.DataBind();
            if (products.Count == 0)
            {
                CategoryList.Visible = false;
                NoSubcategoryMessage.Visible = true;
            }
That should now start listing all products under active category.

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: Custom Header Issues in Product and Category Pages

Post by sfeher » Tue Jul 28, 2015 10:11 am

THANK YOU, Mazhar....
Much appreciated!

Post Reply