Quick Question...
Does anyone know of a quick way to recreate the CategoryParents table? I have all my Category, and CatalogNode entries correct, but, don't really want to write code to recreate the parents table...
Any ideas?
Thanks
Scott
CateogryParents
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: CateogryParents
You might be able to make a script that loops through your categories and uses the category.SetParent method to generate the required table entries. But you would have to process them in order of level (top level first, then sub, then sub sub) otherwise the setparent method won't work right.
EDIT: That might be Category.UpdateParent.
EDIT: That might be Category.UpdateParent.
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: CateogryParents
Also there is an explanation of what data goes into that parent table here: http://wiki.ablecommerce.com/index.php/ ... Categories
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Re: CateogryParents
Logan... Thank you SO much for the prompt reply. That Category.UpdateParent was the thing I needed... After that, it's just a simple recursion problem.
Here's the script I came up with, in case it is useful to anyone... It finds the leaf categories first, and then updates backwards, to make sure updates occur in proper sequence.
protected void buildGrid()
{
SetParents(0);
}
protected void SetParents(int ChildID)
{
CategoryCollection c = CategoryDataSource.LoadForParent(ChildID, true);
if (c.Count != 0)
{
foreach (Category cat in c)
{
SetParents(cat.CategoryId);
Category.UpdateParent(cat.CategoryId, cat.ParentId);
}
}
else
{
Category cc = CategoryDataSource.Load(ChildID);
Category.UpdateParent(cc.CategoryId, cc.ParentId);
}
}
Thanks again, Logan.
Scott
Here's the script I came up with, in case it is useful to anyone... It finds the leaf categories first, and then updates backwards, to make sure updates occur in proper sequence.
protected void buildGrid()
{
SetParents(0);
}
protected void SetParents(int ChildID)
{
CategoryCollection c = CategoryDataSource.LoadForParent(ChildID, true);
if (c.Count != 0)
{
foreach (Category cat in c)
{
SetParents(cat.CategoryId);
Category.UpdateParent(cat.CategoryId, cat.ParentId);
}
}
else
{
Category cc = CategoryDataSource.Load(ChildID);
Category.UpdateParent(cc.CategoryId, cc.ParentId);
}
}
Thanks again, Logan.
Scott
Re: CateogryParents
I know this is an old topic, but how would I run the script to upate the CategoryParents table?
Thanks for the help.
Chandler
Thanks for the help.
Chandler