Including ghosted (hidden) items in API calls
Posted: Thu May 06, 2010 2:28 pm
I've looked all over for a thread that covers this, but haven't found one.
Basically, I've got 1 database that covers 2 sites. The first one is the primary site, and it has a number of cobrand sites.
The second site is has a specialized product list that includes everything from the first site, but adds a number of items only available on the second site. I inherited maintenance of this site, so I'm not the one who made these choices.
In order to accommodate this, they used hidden items for all of the 2nd site specific items. I'm not sure why, but it's what I'm stuck with.
The problem I have is that on an admin screen orders set for review are displayed, and a dropdown list is used to show products of the same category and their variants so that an admin can correct an erroneous order. (The site has all in-house customers, not public facing). The problem is that when one of the hidden items is the one that's ordered, the LINQ query that gets the category siblings and variants to populate the list is not returning the hidden item. Thus, when the control databinds and tries to select the item that was actually ordered, it's not on the list. I trap the error, but then it appears to the customer that the order is changing.
Is there a way to force hidden items to be returned, or will I have to write a custom search?
Here's the LINQ statement:
protected IEnumerable<ProductOptionContainer> GetSiblings(OrderItem orderItem)
{
return orderItem.Product.Categories
.Select(catId => CategoryDataSource.Load(catId))
.SelectMany(cat => cat.CatalogNodes.Cast<CatalogNode>())
.Where(node => node.CatalogNodeType == CatalogNodeType.Product)
.Select(node => node.ChildObject as Product)
.Distinct()
.SelectMany(product => product.ProductOptions.Cast<ProductOption>())
.Select(po => po.Option)
.SelectMany(option => option.Choices.Cast<OptionChoice>())
.Select(choice => new ProductOptionContainer(choice));
}
Is there a better way I can do this to get the hidden items? (SQL Query, or an API method?)
Thanks,
Jon Upchurch
LyntonWeb
Basically, I've got 1 database that covers 2 sites. The first one is the primary site, and it has a number of cobrand sites.
The second site is has a specialized product list that includes everything from the first site, but adds a number of items only available on the second site. I inherited maintenance of this site, so I'm not the one who made these choices.
In order to accommodate this, they used hidden items for all of the 2nd site specific items. I'm not sure why, but it's what I'm stuck with.
The problem I have is that on an admin screen orders set for review are displayed, and a dropdown list is used to show products of the same category and their variants so that an admin can correct an erroneous order. (The site has all in-house customers, not public facing). The problem is that when one of the hidden items is the one that's ordered, the LINQ query that gets the category siblings and variants to populate the list is not returning the hidden item. Thus, when the control databinds and tries to select the item that was actually ordered, it's not on the list. I trap the error, but then it appears to the customer that the order is changing.
Is there a way to force hidden items to be returned, or will I have to write a custom search?
Here's the LINQ statement:
protected IEnumerable<ProductOptionContainer> GetSiblings(OrderItem orderItem)
{
return orderItem.Product.Categories
.Select(catId => CategoryDataSource.Load(catId))
.SelectMany(cat => cat.CatalogNodes.Cast<CatalogNode>())
.Where(node => node.CatalogNodeType == CatalogNodeType.Product)
.Select(node => node.ChildObject as Product)
.Distinct()
.SelectMany(product => product.ProductOptions.Cast<ProductOption>())
.Select(po => po.Option)
.SelectMany(option => option.Choices.Cast<OptionChoice>())
.Select(choice => new ProductOptionContainer(choice));
}
Is there a better way I can do this to get the hidden items? (SQL Query, or an API method?)
Thanks,
Jon Upchurch
LyntonWeb