Jump to grandparent category page.

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
deverill
Lieutenant (LT)
Lieutenant (LT)
Posts: 64
Joined: Tue Jan 06, 2009 11:58 am
Location: Key West, FL
Contact:

Jump to grandparent category page.

Post by deverill » Thu May 24, 2012 3:57 pm

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
Jim Sewell - Web Programmer
Trusted Tours & Attractions

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Jump to grandparent category page.

Post by david-ebt » Thu May 24, 2012 6:48 pm

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.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

User avatar
deverill
Lieutenant (LT)
Lieutenant (LT)
Posts: 64
Joined: Tue Jan 06, 2009 11:58 am
Location: Key West, FL
Contact:

Re: Jump to grandparent category page.

Post by deverill » Fri May 25, 2012 11:30 am

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!
Jim Sewell - Web Programmer
Trusted Tours & Attractions

Post Reply