Data Access Layer - From Wiki

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
sweeperq
Commodore (COMO)
Commodore (COMO)
Posts: 497
Joined: Tue Jan 03, 2006 2:45 pm

Data Access Layer - From Wiki

Post by sweeperq » Thu Nov 07, 2013 1:41 pm

Able Gold has examples for the data access layer (Affiliates) in the wiki: http://wiki.ablecommerce.com/index.php/ ... _-_AC_Gold

I can't find these Affiliate files anywhere in the project, so I'm assuming they are in the core CommerceBuilder libraries.

Where are we supposed to put our classes and NHibernate mapping files for custom tables?

If we need/want to add a custom field to an existing table, how do we go about doing that?

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

Re: Data Access Layer - From Wiki

Post by mazhar » Fri Nov 08, 2013 12:35 am

You need to put your custom classes and mappings in Class Library Project. If you want to extend an existing table and expose the field in existing AbleCommerce object then you will need to make change to class and HBM file within CommerceBuilder. Have a look at this thread viewtopic.php?f=65&t=17586 where new database tables and nhibernate is discussed.

sweeperq
Commodore (COMO)
Commodore (COMO)
Posts: 497
Joined: Tue Jan 03, 2006 2:45 pm

Re: Data Access Layer - From Wiki

Post by sweeperq » Fri Nov 08, 2013 1:05 pm

If you want to extend an existing table and expose the field in existing AbleCommerce object then you will need to make change to class and HBM file within CommerceBuilder
I presume I need to purchase the CommerceBuilder source code then?

Is there anything that isn't included/customize-able in the source code package?

If you buy the source code package, do you release updates for the source at the same time as the store/website so we can keep things up to date?

User avatar
Shopping Cart Admin
AbleCommerce Admin
AbleCommerce Admin
Posts: 3055
Joined: Mon Dec 01, 2003 8:41 pm
Location: Vancouver, WA
Contact:

Re: Data Access Layer - From Wiki

Post by Shopping Cart Admin » Fri Nov 08, 2013 2:47 pm

I presume I need to purchase the CommerceBuilder source code then?
I do believe so, but Mazhar can confirm.
Is there anything that isn't included/customize-able in the source code package?
No
If you buy the source code package, do you release updates for the source at the same time as the store/website so we can keep things up to date?
Yes, it's typically released the same day as a normal release. The builds are automated.
Thanks for your support

Shopping Cart Guru
AbleCommerce.com
Follow us on Facebook

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

Re: Data Access Layer - From Wiki

Post by jmestep » Sat Nov 09, 2013 6:41 am

I didn't have to modify Able's source code when I did what I explained in the link mazhar posted. I did that code using a custom table. If you want to add properties to one of Able's objects you would need the source code, but there are ways around that so you don't need the source code. You can do like Able does with the subcategory listing on a couple of the category page- make a new kind of object right on the page. They do something similar on the conlibs they use to display product items within a category page- they turn a product into something called Item.
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

sweeperq
Commodore (COMO)
Commodore (COMO)
Posts: 497
Joined: Tue Jan 03, 2006 2:45 pm

Re: Data Access Layer - From Wiki

Post by sweeperq » Mon Nov 11, 2013 12:21 pm

Thanks, will look into it.

sweeperq
Commodore (COMO)
Commodore (COMO)
Posts: 497
Joined: Tue Jan 03, 2006 2:45 pm

Re: Data Access Layer - From Wiki

Post by sweeperq » Thu Jan 09, 2014 3:47 pm

Judy, I just took a look at the CategoryGridPage and to see if I could find what you were talking about. I found SubCategoryData, but that is kind of different because SubCategoryData isn't persisting anything to the database; it is basically being used as a View Model for the SubCategoryRepeater.

Be cool if there was a Settings or CustomFields property on all the entities that could be populated when the main object loaded (as opposed to lazy load and firing a query on demand). Hardly anybody would need access to the source then.

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

Re: Data Access Layer - From Wiki

Post by AbleMods » Fri Jan 10, 2014 8:36 am

sweeperq wrote:Be cool if there was a Settings or CustomFields property on all the entities that could be populated when the main object loaded (as opposed to lazy load and firing a query on demand). Hardly anybody would need access to the source then.
This is easy to accomplish (indirectly) using the CustomField class. However you wouldn't want child objects queried on every load of the parent object - that would slam the SQL server unnecessarily and potentially slow the whole site down.

Let's say you have a category with ID 288 and want to store a custom field with it called 'Explosive'.

To persist a custom field, do this:

Code: Select all

            CustomField newField = new CustomField();
            newField.FieldName = "Explosive";
            newField.FieldValue = "Yes";
            newField.ForeignKeyId = 288;
            newField.TableName = "ac_Categories";
            AbleContext.Current.Database.BeginTransaction();
            newField.Save();
            AbleContext.Current.Database.CommitTransaction();
Now when you want to read the custom field back in within a category page user control:

Code: Select all

            IList<CustomField> customFields = NHibernateHelper.CreateCriteria<CustomField>()
                .Add(Restrictions.Eq("TableName", "ac_Categories"))
                .Add(Restrictions.Eq("FieldName", "Explosive"))
                .Add(Restrictions.Eq("ForeignKeyId", categoryId))
                .List<CustomField>();

            if (customFields.Count > 0)
            {
                string fieldValue = customFields[0].FieldValue;
            }
Note how I'm passing the variable categoryId as the parameter in the nHibernate query. This is presumed to be populated already by the user control driving your category display page.

Gets much easier once you build a helper class to handle the heaving lifting above.
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

Post Reply