I'm about out of hair to pull out trying to get my custom feed provider working. I've tried following the instructions at http://wiki.ablecommerce.com/index.php/ ... d_Provider but am not having any luck.
I'm extremely new to asp.net, but know enough to figure out most things.
What I've been trying to do is make a copy of the GoogleBase feed and modify it for my own custom format.
I'm using the source code example snippet included on the Wiki page, but it isn't complete. I have a local development installation setup and working just fine. I have used Visual Studio 2008 to open the web site and get it imported into my environment.
Things I'm stuck on:
1) I don't how to create the DLL file to put into the Bin folder. At this point I've added my CustomFeed.cs file in the App_Code folder and am going from there.
2) Apparently the code snippet from the Wiki is missing the GetHeaderRow() required method from the FeedProviderBase. I tried to create one myself, but I'm not sure what it is supposed to contain since I can't find any documentation referencing it.
I have no problem taking the code in the Admin/Marketing/Feeds/ section and customizing that.
Is there a complete CustomFeedProvider source available? Can anyone walk me through what I need to do in Visual Studio 2008 to create the DLL file? Do I even need the DLL file, or can I just place the .cs code in the App_Data folder?
I've spent 2 days now trying to do this on my own so now I'm asking for some help.
Custom Feed Provider problems
Re: Custom Feed Provider problems
BTW, this is with AC 7.0.3
Okay, so I figured out how to create the C# compiled DLL file and I now have it in my /bin directory. That part is resolved...I think.
I have made a copy of the Admin/Feeds/Data/GoogleBase.aspx and GoogleBase.aspx.cs pages doing a search replace for "GoogleBase" and replaced with "Where2GetIt".
I can pull up the Where2GetIt.aspx page, enter my parameters and select Create Feed.
I get the processing...screen, then an error. The error log is showing:
10/5/2009 8:35:23 PM Warn Error Feed Creator Thread : Object reference not set to an instance of an object. Object reference not set to an instance of an object.
10/5/2009 8:35:23 PM Error An error has occured at http://localhost/mystore/Admin/Marketin ... GetIt.aspx Exception of type 'System.Web.HttpUnhandledException' was thrown.; Object reference not set to an instance of an object.
Here is the stack trace from the Application events log:
at Admin_Marketing_Feeds_Where2GetIt.Create() in c:\ac7\Admin\Marketing\Feeds\Where2GetIt.aspx.cs:line 251
at Admin_Marketing_Feeds_Where2GetIt.FeedActionButton_Click(Object sender, ImageClickEventArgs e) in c:\ac7\Admin\Marketing\Feeds\Where2GetIt.aspx.cs:line 456
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Here is my Where2GetIt.dll source:
I'm at my limits of knowledge here. I've used the Wiki, but the Wiki doesn't seem to be updated. Even the API Help file listed seems to be outdated.
Does anyone have any suggestions for me?
Okay, so I figured out how to create the C# compiled DLL file and I now have it in my /bin directory. That part is resolved...I think.
I have made a copy of the Admin/Feeds/Data/GoogleBase.aspx and GoogleBase.aspx.cs pages doing a search replace for "GoogleBase" and replaced with "Where2GetIt".
I can pull up the Where2GetIt.aspx page, enter my parameters and select Create Feed.
I get the processing...screen, then an error. The error log is showing:
10/5/2009 8:35:23 PM Warn Error Feed Creator Thread : Object reference not set to an instance of an object. Object reference not set to an instance of an object.
10/5/2009 8:35:23 PM Error An error has occured at http://localhost/mystore/Admin/Marketin ... GetIt.aspx Exception of type 'System.Web.HttpUnhandledException' was thrown.; Object reference not set to an instance of an object.
Here is the stack trace from the Application events log:
at Admin_Marketing_Feeds_Where2GetIt.Create() in c:\ac7\Admin\Marketing\Feeds\Where2GetIt.aspx.cs:line 251
at Admin_Marketing_Feeds_Where2GetIt.FeedActionButton_Click(Object sender, ImageClickEventArgs e) in c:\ac7\Admin\Marketing\Feeds\Where2GetIt.aspx.cs:line 456
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Here is my Where2GetIt.dll source:
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommerceBuilder.DataFeeds;
using CommerceBuilder.Common;
using CommerceBuilder.Products;
using CommerceBuilder.Utility;
using System.IO;
namespace CommerceBuilder.DataFeeds
{
public class Where2GetIt : FeedProviderBase
{
private static Where2GetIt _Instance = null;
public Where2GetIt() { }
//Singleton Instance of the Where2GetIt feed provider implementation
public static Where2GetIt Instance
{
get
{
if (_Instance == null) _Instance = new Where2GetIt();
return _Instance;
}
}
protected override string GetFeedData(ProductCollection products)
{
StringWriter feedWriter = new StringWriter();
//Order of parameters for Where2GetIt
//Columns are tab delimited.
//MPN,SKU,UPC,StyleNumber,Manufacturer,ProductName,Description,InStock,Price,ImageLink,ProductPageURL,StoreName,ShippingCost,Currency
//Required
// description, id, link, price, title
StringBuilder feedLine = new StringBuilder();
feedLine.Append("MPN\tSKU\tUPC\tStyleNumber\tManufacturer\tProductName\tDescription\tInStock\tPrice\tImageLink\tProductPageURL\t");
feedLine.Append("StoreName\tShippingCost\tCurrency");
//write header row
feedWriter.WriteLine(feedLine.ToString());
string storeUrl = Token.Instance.Store.StoreUrl;
storeUrl = storeUrl + (storeUrl.EndsWith("/") ? "" : "/");
string url, name, desc, price, imgurl, id, brand, upc, mpn, style, quantity;
foreach (Product product in products)
{
url = product.NavigateUrl;
if (url.StartsWith("~/"))
{
url = url.Substring(2);
}
url = storeUrl + url;
name = StringHelper.CleanupSpecialChars(product.Name);
desc = StringHelper.CleanupSpecialChars(product.Summary);
price = string.Format("{0:F2}", product.Price);
imgurl = product.ImageUrl;
if (!string.IsNullOrEmpty(imgurl) && !IsAbsoluteURL(imgurl))
{
if (imgurl.StartsWith("~/"))
{
imgurl = imgurl.Substring(2);
}
imgurl = storeUrl + imgurl;
}
//MPN,SKU,UPC,StyleNumber,Manufacturer,ProductName,Description,InStock,Price,ImageLink,ProductPageURL,StoreName,ShippingCost,Currency
id = product.ProductId.ToString();
brand = product.Manufacturer != null ? product.Manufacturer.Name : "";
quantity = "1";
style = "";
mpn = string.IsNullOrEmpty(product.ModelNumber) ? product.ModelNumber : product.Sku;
upc = string.IsNullOrEmpty(product.Sku) ? product.ProductId.ToString() : product.Sku;
feedLine = new StringBuilder();
feedLine.Append(mpn + "\t" + upc + "\t" + style + "\t" + brand + "\t" + name + "\t");
feedLine.Append(desc + "\t" + quantity + "\t" + price + "\t" + imgurl + "\t" + url);
feedWriter.WriteLine(feedLine.ToString());
}
string returnData = feedWriter.ToString();
feedWriter.Close();
return returnData;
}
protected override string GetHeaderRow()
{
StringWriter feedWriter = new StringWriter();
StringBuilder feedLine = new StringBuilder();
feedLine.Append("MPN\tSKU\tUPC\tStyleNumber\tManufacturer\tProductName\tDescription\tInStock\tPrice\tImageLink\tProductPageURL\t");
feedLine.Append("StoreName\tShippingCost\tCurrency");
//write header row
feedWriter.WriteLine(feedLine.ToString());
string returnData = feedWriter.ToString();
feedWriter.Close();
return returnData;
}
}
public class Where2GetItOptionKeys : IFeedOptionKeys
{
public string FeedFileName { get { return "Where2GetIt_FeedFileName"; } }
public string OverwriteFeedFile { get { return "Where2GetIt_OverwriteFeedFile"; } }
public string IncludeAllProducts { get { return "Where2GetIt_IncludeAllProducts"; } }
public string CompressedFeedFileName { get { return "Where2GetIt_CompressedFeedFileName"; } }
public string OverwriteCompressedFile { get { return "Where2GetIt_OverwriteCompressedFile"; } }
public string FtpHost { get { return "Where2GetIt_FtpHost"; } }
public string FtpUser { get { return "Where2GetIt_FtpUser"; } }
public string FtpPassword { get { return "Where2GetIt_FtpPassword"; } }
public string FeedDataPath { get { return "Where2GetIt_FeedDataPath"; } }
public string RemoteFileName { get { return "Where2GetIt_RemoteFileName"; } }
}
}
Does anyone have any suggestions for me?
Re: Custom Feed Provider problems
In you feed code file locate following code
and change it as below
save change recompile the dll and try again.
Code: Select all
public Where2GetIt() { }
Code: Select all
public Where2GetIt()
{
this.FeedOperationStatus = new FeedOperationStatus();
}
Re: Custom Feed Provider problems
WIKI post is also updated for this change.
Re: Custom Feed Provider problems
That fixed it!
Additional changes you need to do to the Wiki on this entry:
You have private GoogleBase() instead of public GoogleBase() for the constructor.
Also, you need to update the GoogleBase class to include the required GetHeaderRow() method and update the GetFeedData() method to remove the hard-coded output of the feed header.
Additional changes you need to do to the Wiki on this entry:
You have private GoogleBase() instead of public GoogleBase() for the constructor.
Also, you need to update the GoogleBase class to include the required GetHeaderRow() method and update the GetFeedData() method to remove the hard-coded output of the feed header.