Page 1 of 1

Obtaining bread crumb path for a product for use in datafeed

Posted: Mon Nov 10, 2008 6:06 pm
by jmestep
I'm working on re-doing a datafeed I had for an Able 5 store and want to use the bread crumb path to the product as the feed field category. Like Paintball > Paintball Guns > Spyder
I've been working with code I snagged from a bread crumb trail, but I need to have it show only one category path if the product is in more than one. How would I do that in this code, or would there be a better way to construct it?

{ List<CatalogPathNode> path = CatalogDataSource.GetPath(productCategoryId, false);
category = "";
for (int i = path.Count - 1; i >= 0; i--)
{
category = path.Name + " > ";

}
Thanks

Re: Obtaining bread crumb path for a product for use in datafeed

Posted: Tue Nov 11, 2008 11:58 am
by mazhar
What about picking the first category and generating bread crumbs using that

Re: Obtaining bread crumb path for a product for use in datafeed

Posted: Tue Nov 11, 2008 11:58 am
by mazhar
For example

Code: Select all

[code]
Product product = ProductDataSource.Load(167);
        List<CatalogPathNode> pathNodeList = CatalogDataSource.GetPath(product.Categories[0], false);
        StringBuilder breadCrumbs = new StringBuilder();
        foreach (CatalogPathNode cpn in pathNodeList)
            breadCrumbs.Append(cpn.Name+">");
        if(breadCrumbs.Length > 0)
            breadCrumbs.Remove((breadCrumbs.Length - 1), 1);
        Response.Write(breadCrumbs.ToString());
[/code]

Re: Obtaining bread crumb path for a product for use in datafeed

Posted: Tue Nov 11, 2008 3:32 pm
by jmestep
Thank you, that's just what I was trying to do. I just couldn't figure out how to get the first category.

Re: Obtaining bread crumb path for a product for use in datafeed

Posted: Tue Nov 11, 2008 3:35 pm
by bobr2k
I love watching you guys work - even if I don't understand all of it :lol:

Re: Obtaining bread crumb path for a product for use in datafeed

Posted: Fri Jul 17, 2009 11:19 am
by draneb
Hello,

Instead of using the entire breadcrumb path, how could you get it to display just the category or sub category that the item is in?

Thank you for your help!

Re: Obtaining bread crumb path for a product for use in datafeed

Posted: Fri Jul 17, 2009 4:16 pm
by jmestep
Try something like pathNodeList.RemoveRange(0,1);
before the
StringBuilder breadCrumbs = new StringBuilder();

I haven't tested it lately, though.