Page 1 of 1

CatalogNode Parent Category ID

Posted: Tue Feb 10, 2009 7:51 am
by jmestep
I've had to take some objects like webpages and add them to an array list after turning them into catalog nodes. How can I get the category id of the parent category? I've seen it in other places like product.
Thanks

Re: CatalogNode Parent Category ID

Posted: Tue Feb 10, 2009 8:00 am
by mazhar
Try

Code: Select all

catalogNode.CategoryId

Re: CatalogNode Parent Category ID

Posted: Tue Feb 10, 2009 9:28 am
by jmestep
That wasn't coming up in intellisense so I hadn'tused and now it breaks the page.
I'm creating the node from an object that has an id and a type so that I can get a link to it.
CatalogNode node = new CatalogNode(0, objectId2, (byte)objectType2);
The above line is what I have to go on. I can't add the CategoryId in place of the 0 because the custom object doesn't know the category Id.
So I added the following, but it still shows 0 for the category Id
int CID = node.CategoryId;

newNode = new CatalogNode(CID, objectId2, (byte)objectType2);

If I hard-code a number in for the CID, then it picks up that number.
I'm still not able to get the category id. I need something like Lookup the object that has a CatalogNodeId of xx and a type of yy and find the category id for one instance of that node.
Maybe I need to approach this a different way, but I don't know how.
I am just trying to get a category id into the link so that there won't be duplicate content in search engines-- the link works fine with a 0 for the category id.
Thanks

Re: CatalogNode Parent Category ID

Posted: Tue Feb 10, 2009 9:46 am
by mazhar
I think for this you need to query the ac_CatalogNodes table to find out the parent category id. For example

Code: Select all

SELECT CategoryId FROM ac_CatalogNodes WHERE CatalogNodeId = nodeId AND CatalogNodeType = nodeType
You can create another property which returns the parent category ids and when you call that property first it query the ac_CatalogNodes table using above query with the current node id and type of your object.

Re: CatalogNode Parent Category ID

Posted: Thu Feb 19, 2009 8:30 am
by jmestep
I ended up cloning the GetCategoryId(int nodeId, CatalogNodeType nodeType) from the Able source code and it works well.