Page 1 of 1
find an existing category using api
Posted: Tue Jun 10, 2008 2:30 pm
by RevereRichard
Hello,
I am trying to determine if a Category exists before add to it using the API. It's unclear from the documentation on how to accomplish this. The only variables I have available for the search are Category.Name and Category.ParentID (StoreID is a given). If I have to do it via SQL, is there an AC API that I can call that would provide the data layer or do I have to provide my own (if so, could I lift the connection string from somewhere)?
Thanks for the hand holding.
Richard
Re: find an existing category using api
Posted: Tue Jun 10, 2008 2:46 pm
by jmestep
Here are a couple of examples from Conlib/CategoryGrid3.ascx:
Code: Select all
public int CategoryId
{
get
{
if (ViewState["CategoryId"] == null)
ViewState["CategoryId"] = PageHelper.GetCategoryId();
return (int)ViewState["CategoryId"];
}
set
{
ViewState["CategoryId"] = value;
}
}
private void BindPage()
{
//BIND THE DISPLAY ELEMENTS
if (_Category != null)
{
Page.Title = _Category.Name;
CategoryBreadCrumbs1.CategoryId = this.CategoryId;
Caption.Text = _Category.Name;
BindSubCategories();
}
else
{
CategoryHeaderPanel.Visible = false;
}
BindSearchResultsPanel();
}
Re: find an existing category using api
Posted: Tue Jun 10, 2008 3:03 pm
by RevereRichard
Thanks, but I forgot to mention that this is for a webservice that will be populating categories from a third party source.
Any other ideas?
-Richard.
Re: find an existing category using api
Posted: Wed Jun 11, 2008 8:20 am
by AbleMods
RevereRichard wrote:I am trying to determine if a Category exists before add to it using the API.
Just query AC_Categories for the .Name and .ParentID.
RevereRichard wrote:If I have to do it via SQL, is there an AC API that I can call that would provide the data layer or do I have to provide my own (if so, could I lift the connection string from somewhere)?
There is no data layer provided via SQL. You can use the AC API (known as CommerceBuilder) via .Net code to accomplish the same task, however your import program design will obviously have to be altered.
Adding categories and linking products to them is a bit intricate as there are three tables involved. It's often easier to do it via .Net code and use the CommerceBuilder data classes as Able has simplified alot by writing a lot of functionality into them.
Re: find an existing category using api
Posted: Wed Jun 11, 2008 11:53 am
by RevereRichard
Thanks for the response.
Can I piggy back off the data application block in use by AC for my database stuff? If so, can I access the encrypted connection string?
Question on adding categories;
Let's assume I have a hiearchy similar to the Wiki example; Books>Fiction>Mystery and all three categories are new and have been added. It's unclear what should be entered into the ac_CatalogNodes table. Using the samples from the Wiki example, can you tell me how many rows go into the ac_CatalogNodes table?
Thanks.
Re: find an existing category using api
Posted: Wed Jun 11, 2008 11:57 am
by AbleMods
Can't help you much there - I do everything through the Able data classes these days and gave up on loading the tables directly.
I do recall there are some other posts though that did a pretty good job of explaining it, you might try doing a forum search.
Re: find an existing category using api
Posted: Wed Jun 11, 2008 1:28 pm
by RevereRichard
Perhaps I am misunderstanding your previous post. I prefer doing this all in .net. Can you query AC_Categories using the Able data classes? If so, is there any info on this object? The API reference I have doesn't seem to indicate there is one.
Edit. found one of your previous posts referring to MoveCatalogObject.aspx. Lots of good stuff there. thx.