I have a class provided by Microsoft.solutions.framework which is
derived from CollectionBase. I have inherited from this class as I
wished to modify the constructor sightly.
The problem that I have is that I seem to be adding the product
objects into the base as when I check the list the count is being
incremented. however when I try to retrieve any of the objects via
enumeration there is no data being retrieved.
There is probably something easy missing but just can't see what.
any help would be greatly appreciated.
Cheers.
-------------------------------------------------
using System;
using System.Data;
using System.Collections;
using Microsoft.CommerceServer.Runtime;
using Microsoft.CommerceServer.Runtime.Catalog;
using Microsoft.Solutions.Framework;
namespace Microsoft.Solutions.Applications.Components
{
/// <summary>
/// Summary description for CatalogueHelper.
/// </summary>
public class RelatedProductCollection : ProductCollection
{
private string _catalogueName;
private string _productId;
private int _recordCount;
public int RecordCount
{
get{return _recordCount;}
}
public string CatalogueName
{
get{return _catalogueName;}
}
public string ProductId
{
get{return _productId;}
}
public int BaseCount
{
get{return base.List.Count;}
}
public RelatedProductCollection(string catalogueName, string
productId)
{
_productId = productId;
_catalogueName = catalogueName;
CatalogContext _catalogueContext =
CommerceContext.Current.CatalogSystem;
ProductCatalog _productCatalog =
_catalogueContext.GetCatalog(catalogueName);
if(_productCatalog != null)
{
Product _product = _productCatalog.GetProduct(productId);
if(_product != null)
{
DataSet relatedProducts = _product.GetRelatedProducts();
_recordCount = relatedProducts.Tables[0].Rows.Count;
foreach(DataRow _relatedProduct in
relatedProducts.Tables[0].Rows)
{
base.List.Add(_productCatalog.GetProduct(_relatedP roduct["productId"].ToString()));
}
}
}
}
new protected IList List
{
get{return base.List;}
}
public override Product this[int index]
{
get
{
return (Product) base.List[index];
}
set
{
base.List[index] = value;
}
}
}
}