Hi.
We are currently using the demo of ablecommerce to see if we can customize it for our needs.
To get (almost) to the point, most of the actual front end is irrelevant for us and i just want to use products database and load single products into flash using a convenient method such as xml. I have downloaded the API docs but on their own they are a little daunting. Can anyone point me in the direction of a simple example getting a single product from the database using the api? It will be a great help to me!
Thank you very much.
Dave
Any example code for simple data access?
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
Re: Any example code for simple data access?
Following code will load a product for some product id
Following code will load product or products based upon some SQL criteria
You can found more information on this thread.
viewtopic.php?f=42&t=7297
Code: Select all
Product product = ProductDataSource.Load(productid);
Code: Select all
ProductCollection products = ProductDataSource.LoadForCriteria("some sql criteria like Name='abx' ");
viewtopic.php?f=42&t=7297

Visit the links below to Download Plugins for your AC7 Store
http://www.plugables.com
http://blog.plugables.com
Re: Any example code for simple data access?
mazhar: Thanks very much for the post. I was tinkering and had worked out getting a product and i am pleased to say i did it in the same way you have!
I wrote a little test code and thought it may help other people who have just installed ablecommerce (below).
Many thanks
Dave
I wrote a little test code and thought it may help other people who have just installed ablecommerce (below).
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
int ProductId = 1; // Test product id
// Load a product
Product p = CommerceBuilder.Products.ProductDataSource.Load(ProductId);
StringBuilder sb = new StringBuilder();
sb.Append("Product Name: " + p.Name + "<br />");
sb.Append("Price: " + p.Price + "<br />");
sb.Append("Product Image: " + p.ImageUrl + "<br />");
// Display product options (for example color or size).
ProductOptionCollection poCollection = p.ProductOptions;
foreach (ProductOption po in poCollection)
{
// Display each of the option choices (Small, Medium Large).
OptionChoiceCollection ocCollection = po.Option.Choices;
sb.Append("<br />Option: " + po.Option.Name + "<br /><br />");
foreach(OptionChoice oc in ocCollection)
{
sb.Append("Choice: " + oc.Name.ToString() + "<br />");
}
}
Response.Write(sb.ToString());
}
Dave
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
Re: Any example code for simple data access?
Thanks for sharing your experience, these sort of things can help out many people.

Visit the links below to Download Plugins for your AC7 Store
http://www.plugables.com
http://blog.plugables.com