find an existing category using api

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
RevereRichard
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Mon Jun 02, 2008 2:20 pm

find an existing category using api

Post by RevereRichard » Tue Jun 10, 2008 2:30 pm

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

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: find an existing category using api

Post by jmestep » Tue Jun 10, 2008 2:46 pm

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();
    }
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

RevereRichard
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Mon Jun 02, 2008 2:20 pm

Re: find an existing category using api

Post by RevereRichard » Tue Jun 10, 2008 3:03 pm

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.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: find an existing category using api

Post by AbleMods » Wed Jun 11, 2008 8:20 am

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.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

RevereRichard
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Mon Jun 02, 2008 2:20 pm

Re: find an existing category using api

Post by RevereRichard » Wed Jun 11, 2008 11:53 am

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.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: find an existing category using api

Post by AbleMods » Wed Jun 11, 2008 11:57 am

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.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

RevereRichard
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Mon Jun 02, 2008 2:20 pm

Re: find an existing category using api

Post by RevereRichard » Wed Jun 11, 2008 1:28 pm

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.

Post Reply