Custom Data Feed
Custom Data Feed
Hi everyone,
Currently I'm working on implementing a custom data feed for one of our dealers to sell products from our store. It includes inventory counts and special pricing they get. My approach is duplicating the Google Feed and modifying it to include the fields I need and change it to a csv format. I'm also considering adding a product custom field for inclusion into this feed like this post details: viewtopic.php?f=47&t=12056
I have the source code so I can edit the app config and add an additional setting similar to GoogleDataFeedInterval. But because I cant figure out how to integrate the source code really cleanly into my site (Im a Visual Studio novice), I have to compile dll's every time and manually reinsert them. Of course I can do this, but this is why Id rather stay out of the source as long as possible. So I was thinking I could hold my settings as a custom variable like this outlines: http://wiki.ablecommerce.com/index.php/ ... e_anywhere
EDIT - nevermind answered my own question. Please just comment if Im off-track here.
Currently I'm working on implementing a custom data feed for one of our dealers to sell products from our store. It includes inventory counts and special pricing they get. My approach is duplicating the Google Feed and modifying it to include the fields I need and change it to a csv format. I'm also considering adding a product custom field for inclusion into this feed like this post details: viewtopic.php?f=47&t=12056
I have the source code so I can edit the app config and add an additional setting similar to GoogleDataFeedInterval. But because I cant figure out how to integrate the source code really cleanly into my site (Im a Visual Studio novice), I have to compile dll's every time and manually reinsert them. Of course I can do this, but this is why Id rather stay out of the source as long as possible. So I was thinking I could hold my settings as a custom variable like this outlines: http://wiki.ablecommerce.com/index.php/ ... e_anywhere
EDIT - nevermind answered my own question. Please just comment if Im off-track here.
Austin
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Custom Data Feed
I'm not sure what your answer to yourself was
, but you don't need to add to the source code to do this. If you are using either WAP or WSP, you can put your code in the App_Code folder (you can add the folder if it is not there in WAP) of the website and add an automated routine entry in the global.asax file and use it without compiling the site. If you need an admin page and are using WSP, you can add that without recompiling the site. If you are using WAP, you would need to compile the site after you add the file.
If by "source" you are referring to the files for the CommerceBuilder dlls that you purchased separately, I have never had to modify Able's source code. I work in Able every day, 5 days a week and have found ways around doing it. I'm sure there might come a time in the future where a merchant might want me to modify Able's source code, but I don't do it now for a couple of reasons. If I did it, I would need to change the source code every time a merchant upgraded. Also, we have inherited sites where someone else did the programming and changed the source code, but later on, no one had those files so the merchant was faced with having to pay for development from the ground up again. Or there was a bug in the customizations and we couldn't fix it easily because we didn't have those files.

If by "source" you are referring to the files for the CommerceBuilder dlls that you purchased separately, I have never had to modify Able's source code. I work in Able every day, 5 days a week and have found ways around doing it. I'm sure there might come a time in the future where a merchant might want me to modify Able's source code, but I don't do it now for a couple of reasons. If I did it, I would need to change the source code every time a merchant upgraded. Also, we have inherited sites where someone else did the programming and changed the source code, but later on, no one had those files so the merchant was faced with having to pay for development from the ground up again. Or there was a bug in the customizations and we couldn't fix it easily because we didn't have those files.
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
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
Re: Custom Data Feed
I noticed that the GoogleFeedInterval variable was declared in the source code in ApplicationSettings.cs. I inferred the custom parameters outlined in that post are stored in the db but the GoogleFeedInterval is stored in application memory. I assumed there was a reason for that variable to be in source instead of outside so I tried to reverse engineer a purpose behind that decision. Probably a rabbit hole that I didn't really need to jump down.
Austin
Re: Custom Data Feed
If you open the \app_data\ablecommerce.config file, you find this code which can be easily modified -
<item key="GoogleFeedInterval" value="360" />
I'm not sure if this information helps, but you shouldn't need to modify the source code...and like Judy indicates, it can really put you in a position of being stuck at one version without being able to upgrade.
<item key="GoogleFeedInterval" value="360" />
I'm not sure if this information helps, but you shouldn't need to modify the source code...and like Judy indicates, it can really put you in a position of being stuck at one version without being able to upgrade.
Thank you for choosing AbleCommerce!
http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support
http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support
Re: Custom Data Feed
Im trying to add another field to the applicationsettings.
I tried adding a <item key="CustomFeedInterval" value="360" /> but that still results in a compilation error referencing that variable like
ApplicationSettings appConfig = ApplicationSettings.Instance;
if(appConfig.CustomFeedInterval > 0) {}
The field is added to the settings in the dll's, is there a way to add a setting to it outside the source? I thought I would have to use a custom parameter like
Store store = AbleContext.Current.Store;
StoreSettingsManager settings = store.Settings;
settings.SetValueByKey("CUSTOM:CustomField", string );
The difference here is that the custom field is stored in the db where as the appconfig setting is in memory correct?
I tried adding a <item key="CustomFeedInterval" value="360" /> but that still results in a compilation error referencing that variable like
ApplicationSettings appConfig = ApplicationSettings.Instance;
if(appConfig.CustomFeedInterval > 0) {}
The field is added to the settings in the dll's, is there a way to add a setting to it outside the source? I thought I would have to use a custom parameter like
Store store = AbleContext.Current.Store;
StoreSettingsManager settings = store.Settings;
settings.SetValueByKey("CUSTOM:CustomField", string );
The difference here is that the custom field is stored in the db where as the appconfig setting is in memory correct?
Austin
Re: Custom Data Feed
That's just a syntax error. There is no member named CustomFeedInterval defined in the ApplicationSettings class (defined in CommerceBuilder.dll). You can add custom values to the config file though (e.g., <item key="CustomFeedInterval" value="120" />), and then access them with:
ApplicationSettings appConfig = ApplicationSettings.Instance;
if (AlwaysConvert.ToInt(appConfig["CustomFeedInterval"]) > 0) { /* do stuff */ }'
The ApplicationSettings class uses an internal Dictionary<string, string> to store the settings that it parses from the config file, and provides an indexer to get at them. You could also write a CustomApplicationSettings class and put it in the Code folder and have it wrap the indexing of the ApplicationSettings class to simplify things (which is what the class members of ApplicationSettings do when you access them):
You should probably implement this as a thread-safe singleton, but I didn't do that here for the sake of brevity. You could do it through inheritance as well I suppose since the ApplicationSettings class isn't sealed (but if they ever do decide to seal it your code would break, so it is safer to decorate it rather than inherit from it).
ApplicationSettings appConfig = ApplicationSettings.Instance;
if (AlwaysConvert.ToInt(appConfig["CustomFeedInterval"]) > 0) { /* do stuff */ }'
The ApplicationSettings class uses an internal Dictionary<string, string> to store the settings that it parses from the config file, and provides an indexer to get at them. You could also write a CustomApplicationSettings class and put it in the Code folder and have it wrap the indexing of the ApplicationSettings class to simplify things (which is what the class members of ApplicationSettings do when you access them):
Code: Select all
public class CustomApplicationSettings
{
//singleton code...
public ApplicationSettings AppSettings { get { return ApplicationSettings.Instance; } }
public int CustomFeedInterval
{
get { return AlwaysConvert.ToInt(AppSettings["CustomFeedInterval"]); }
set { AppSettings["CustomFeedInterval"] = value.ToString(); }
}
public void Save()
{
AppSettings.Save();
}
}
Re: Custom Data Feed
This extension of the application settings is what I thought was possible. Thank you for outlining that for us. Currently I have the data feed implemented and working using a custom setting using this method:
Store store = AbleContext.Current.Store;
StoreSettingsManager settings = store.Settings;
settings.SetValueByKey("CUSTOM:CustomField", string );
Am I right in my thinking that the approach I ended up using causes a query to the db, in contrast to wrapping the application settings in a custom class, which would cause the setting to reside in memory instead of the database?
Store store = AbleContext.Current.Store;
StoreSettingsManager settings = store.Settings;
settings.SetValueByKey("CUSTOM:CustomField", string );
Am I right in my thinking that the approach I ended up using causes a query to the db, in contrast to wrapping the application settings in a custom class, which would cause the setting to reside in memory instead of the database?
Austin
Re: Custom Data Feed
Yes and no, the StoreSettings values are stored in the database (in the ac_StoreSettings table). The ApplicationSettings are parsed from an XML config file in the App_Data folder. When the settings are loaded, or modified and saved, the former causes a trip to the database, and the latter reads/writes to the XML file on disk. Once settings are read from either source, both reside in memory as both classes use an internal Dictionary to hold the parsed settings. It should only hit the database (or the XML file, respectively) when the singleton instance is first accessed and when the settings are modified. That being said, I think using the ApplicationSettings will result in a lot fewer (and faster) read/writes since it has a cache dependency on the XML file with no expiration (triggered when the file is modified), whereas I am not certain of the caching behavior of the StoreSettings.