Adding a few more data fields to a products table.

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
bigtires001
Lieutenant (LT)
Lieutenant (LT)
Posts: 55
Joined: Thu Aug 28, 2008 3:40 pm

Adding a few more data fields to a products table.

Post by bigtires001 » Mon Dec 22, 2008 10:09 am

Hello,

I am attempting to add a new field to the products database, then I would like to display this information on the products page.

So far;

#1.) I have modified my ablecommerce database for the ac_product table. I want to add a few custom fields, so at the bottom of the list I added a field called "custom1".

#2.) I also added the field in the EditProduct.aspx
"<asp:TextBox ID="custom1" runat="server" Width="80px" EnableViewState="false"></asp:TextBox>"

The system does save the new data to the database.

Where I'm stuck is editing the "show products" page within the admin. For example if you want the system to display the name you would enter in : $Product.Name

Now I want to show my new custom field and you would think i could just enter "$Product.custom1" into the scriptlet. however it just prints "$Product.custom1" instead of the data itself.

Any ideas or help would be appreciated.

Thanks,
Donnie

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

Re: Adding a few more data fields to a products table.

Post by mazhar » Mon Dec 22, 2008 10:17 am

Modify the database table will not put the support for loading and savding the data into this new column automatically through API. If you want to keep some custom information for the product then better you should use the ac_ProductCustomFields table. Here is a very good example about keeping custom informatoin with products. Also with this solution you will not need to put the code on show product page to show this information. AbleCommerce will automatically show this new information with product.
Please check the following post
viewtopic.php?f=44&t=9088

bigtires001
Lieutenant (LT)
Lieutenant (LT)
Posts: 55
Joined: Thu Aug 28, 2008 3:40 pm

Re: Adding a few more data fields to a products table.

Post by bigtires001 » Tue Dec 23, 2008 3:46 pm

Thanks, I actual figured out to use the Product Template function to create the type of forms i needed. Thanks again,

Donnie

bigtires001
Lieutenant (LT)
Lieutenant (LT)
Posts: 55
Joined: Thu Aug 28, 2008 3:40 pm

Re: Adding a few more data fields to a products table.

Post by bigtires001 » Sat Dec 27, 2008 9:06 am

Well I’ve actually come across another milestone on this project. Well I’ve created a custom product template to capture the additional info. However is there a way to call that data separately?

For example on the Show Product 1 scriptlet to show the product name it has the source: <h1>$Product.Name</h1>

and to show the custom fields as a group its [[ConLib:ProductDescription ShowCustomFields="true"]]

THE QUESTION:
how can I call this data similar to the $Product.Name function. So I can put different custom fields in different areas of the page Show Product 1? Rather than it listing all custom fields in one row.

Thanks for reading!
Last edited by bigtires001 on Sat Dec 27, 2008 9:08 am, edited 1 time in total.

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

Re: Adding a few more data fields to a products table.

Post by jmestep » Sat Dec 27, 2008 12:32 pm

The code on the product page that displays the template fields is:
//BUILD PRODUCT CHOICES
ProductHelper.BuildProductChoices(_Product, phOptions);

That BuildProductChoices is in the App_Code/ProductHelper.cs

public static void BuildProductChoices(Product product, PlaceHolder phChoices)
{
// ADD IN THE PRODUCT TEMPLATE CHOICES
ProductTemplate template = product.ProductTemplate;
if (template != null)
{
foreach (InputField input in template.InputFields)
{
if (!input.IsMerchantField)
{
// ADD THE CONTROL TO THE PLACEHOLDER
phChoices.Controls.Add(new LiteralControl("<tr><td colspan=\"2\">"));
phChoices.Controls.Add(new LiteralControl((input.UserPrompt + "<br />")));
WebControl o = input.GetControl();
if (o != null)
{
phChoices.Controls.Add(o);
}
phChoices.Controls.Add(new LiteralControl("</td></tr>"));
}
}
}
}

You would have to put some conditional code in one of those places based on the criteria you use.
There is a ProductTemplateDataSource.LoadforCriteria(put your where code in here)
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

Post Reply