Custom Category Fields

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
eJungle
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Wed Aug 12, 2009 11:32 am

Custom Category Fields

Post by eJungle » Wed Aug 12, 2009 11:36 am

Hi,
I would like to know if it is possible to add in some custom fields for the categories. Much like the User object has UserSettings that can be set, I would like to have CategorySettings. I'm not sure if it is already possible or if I have to add a database table and extend classes.

If I do have to add a database table and extend the Categories class, what is the best way to access the database to make the updates?

Thank you for your assistance.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Custom Category Fields

Post by mazhar » Thu Aug 13, 2009 4:06 am

There could be two ways to accomplish this, either through a custom table or making use of custom fields table. Read following thread about custom fields and how to use them
viewtopic.php?f=42&t=8684

Secondly If you want to make use of custom table then data access wouldn't a big problem. Read following thread for auto generating data access code for you.
viewtopic.php?f=47&t=9530

Also read AbleCommerce WIKI for information about custom queries and API
http://wiki.ablecommerce.com/index.php/ ... uilder_API

eJungle
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Wed Aug 12, 2009 11:32 am

Re: Custom Category Fields

Post by eJungle » Fri Aug 14, 2009 8:49 am

I set it up using the custom fields table as you mentioned and it seems to work, the only issue is that when I click "Save" t wont update a FieldName to FK-TableName relationship, it inserts it again. This results in a record for every save and can lead to problems in the future. Am I doing something wrong? or is this a bug that can be fixed?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Custom Category Fields

Post by mazhar » Mon Aug 17, 2009 5:23 am

Most probably you are missing some step in your update script. Update or save process should be as below
1)- Try to load custom field by providing category id and field name to pin point the expected custom field
2)- in case of success you will get a custom field just update its information and then call save method on this loaded object
3)- if load bring nothing then create a new custom field object populate its data and then save it.

eJungle
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Wed Aug 12, 2009 11:32 am

Re: Custom Category Fields

Post by eJungle » Wed Aug 19, 2009 11:24 am

ah, it seems i was setting the custom field in the if (!Page.IsPostBack) ... section so I was always getting null. thanks for the help!

Post Reply