Adding custom fields and tables to the DB

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
rpb3
Lieutenant (LT)
Lieutenant (LT)
Posts: 60
Joined: Fri Jan 23, 2009 11:20 am

Adding custom fields and tables to the DB

Post by rpb3 » Wed Apr 15, 2009 3:25 pm

I need to add a handful of custom fields to the database for the products. I see where I can add fields to the product template and then enter values for those fields in the Product Template section of the EditProduct Screen.

I am not sure that is really what I need to do. The store is going to be a book store. They need some simple "custom fields" like number of pages. I could do that with a template field I suppose, but there are also fields that need to come from a list, like classification and author.

Yes, I also need a custom author table that will store the author's personal information and be bound by a one-to-many relationship to the products. It would be nice if the classifications were managed in a separate table as well.

I know you can add a "Drop Down List" style template field and enter the optional values, but that is not sufficient for the authors. I need an entire table to store name, bio, url, etc.... for each author.

So, do I just add extra fields to the ac_Products table for authorId and classificationId? I am sure the answer to that is no.

Do I use the product template fields and add those fields as "Text Box" input and then manually edit the EditProduct page to instead show a drop down list of authors from the authors table.

Or, do I need to use ac_CustomFields table? I really don't understand that table at all.

Is there any documentation that can point me in the right direction here or is there a thread I can look at?

Thanks for any help.

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

Re: Adding custom fields and tables to the DB

Post by mazhar » Thu Apr 16, 2009 4:42 am

One possible solution to accomplish this with custom table would be to first crate your authors table. Once you are done with this new table you can generate data access code for this newly crated table. In order to find how to generate code read following topic
viewtopic.php?f=47&t=9530

Now next job would be make product accommodate this new information. For this you can make use of ac_ProductCustomFields table. Read following topic about how to use product custom fields with a complete example.
viewtopic.php?f=44&t=9088

rpb3
Lieutenant (LT)
Lieutenant (LT)
Posts: 60
Joined: Fri Jan 23, 2009 11:20 am

Re: Adding custom fields and tables to the DB

Post by rpb3 » Fri Apr 17, 2009 2:00 pm

Thanks mazhar. I have read both threads and although they seem very informative, I am not quite grasping what they will do for me. I'm fairly new to Able Commerce so can you fill in some blanks for me?

I have the MyGeneration program installed with the templates and I created the code. I browsed it and see where it generated the code related to my authors table. But where do I put that code and how will I use it?

Also, what are your thoughts about tying the ac_products table to my new author table? I created an authorId field in the author table. Should that be an input field on a product template for book products? Or should I use the custom fields table? I really don't understand how that custom fields table is supposed to work.

I did read the second thread you posted but I didn't see how it would help me with this situation.

Thanks again for your help.

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

Re: Adding custom fields and tables to the DB

Post by mazhar » Wed Apr 29, 2009 9:14 am

I have the MyGeneration program installed with the templates and I created the code. I browsed it and see where it generated the code related to my authors table. But where do I put that code and how will I use it?
After generating code create class files and code in respective files. You can create class fiels either in a separate class library project, compile it then placing generated dll into website bin folder. The other solution could be to just place class files under App_Code folder of website and they will work for you.
Also, what are your thoughts about tying the ac_products table to my new author table? I created an authorId field in the author table. Should that be an input field on a product template for book products? Or should I use the custom fields table? I really don't understand how that custom fields table is supposed to work.
Product custom fields can be used to extend product attributes. For example in you case you want to associate an author with book products. So you update edit product page to have a dropdown showing authors from your custom table. When some users selects any author and save product you can put author id into custom fields. Finally you can update the product details page so that when some product having author id custom field is shown you can load author from your custom table using saved author id and render it.

Post Reply