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:
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"; } }
}
}
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?