Page 1 of 1

Jump to grandparent category page.

Posted: Thu May 24, 2012 3:57 pm
by deverill
Hi gang.

We are using AC 7.0.6 here and I have something that's probably not hard but I just don't know the right way to ask the AC libraries for it.

On some of our tours we have a calendar. After the customer picks the quantity, date, time, etc. I have a button in the BuyTourProductDialog ConLib that I want to take them from the current page (product) to the category page for their city (grandparent category).

An example is that Deverill's Awesome Tour is in a category of Land Tours and that is a subcategory to the category of Key West. I want to go back to the Key West page (grandparent) when they are done reserving my Awesome Tour.

Currently I have a button that goes to the Land Tour category (parent) using

Code: Select all

CategoryID = PageHelper.GetCategoryId();
Response.Redirect("~/categorylistsubs-tta.aspx?CategoryID=" + CategoryID);
There are two problems: It only goes to the parent, not grandparent, and it is a hardcoded display page name.

I am confident there is a more robust and flexible way of doing this but as I said, I just don't know the AbleCommerce functions to use to do it.

Thanks

Re: Jump to grandparent category page.

Posted: Thu May 24, 2012 6:48 pm
by david-ebt
Try something like this:

Code: Select all

List<CatalogPathNode> cPaths = CatalogDataSource.GetPath(CategoryId, false);
string grandParentName = cPaths[cPaths.Count - 2].Name;
string grandParentUrl = cPaths[cPaths.Count - 2].NavigateUrl;
You'll probably want to do some checking to make sure the index doesn't return an invalid number, but this should return the grandparent category for the current category.

Re: Jump to grandparent category page.

Posted: Fri May 25, 2012 11:30 am
by deverill
Perfect! Thanks David. I had to add

Code: Select all

using CommerceBuilder.Catalog;
(for anyone seeing this with the same problem later) but after that it worked exactly like I wanted.

I'll add that checking you mentioned and it's a done task.

Thanks!