Here is the result of a category: stdClass Object ( [CategoryID] => 150009 [CategoryLevel] => 4 [CategoryName] => 1800-1934 [CategoryParentID] => 713 [CategoryNamePath] => Collectibles:Cultures & Ethnicities:Native American: US:1800-1934 [CategoryIDPath] => 1:3913:713:150009 [LeafCategory] => ) I would like to parse out the CategoryNamePath. Only problem is that some categories have ":" in the name.. like above! Is there a simpler way to do it (and using less calls) without resorting to using the CategoryIDPath and getting the CategoryName for each ID one by one and then rebuilding the name path?
It would be nice to have this reliable and have Path and ID added to Finding API. It's a very easy way to build breadcrumbs. Same info is returned by Shopping. You could scan all categories offline and flag the ones that have mismatches in the colon counts and put in exception code in your production system to correct these before processing. Otherwise, you have to walk the path. Start from the end and back up until you find a category with a colon in the name.
The hack I use is to do a simple full string replace on the path and replace ": " (colon+space) with something else, like hyphen+space, or just a space. AFAIK, when colons are used in the category name, a space always follows. So I can search/replace based on that.
Thanks helios.. I should have thought of that! I did the long way of walking the CategoryIDPath to get the CategoryName (only for categories with : in the name). Then I cached these calls... But this sounds a lot easier and faster!