In the Stone Edge interface script below, they are cycling through the products in AbleCommerce and then attempting to cycle through each variant. (Note: I have removed all but the relevant parts from this code sample.)
Code: Select all
01 Dim colProducts As CommerceBuilder.Products.ProductCollection
02 Dim objProduct As CommerceBuilder.Products.Product
03 Dim colVariants As CommerceBuilder.Products.ProductVariantCollection
04 colProducts = CommerceBuilder.Products.ProductDataSource.LoadForStore()
05 For Each objProduct In colProducts
06 colVariants = objProduct.Variants
07 For Each objVariant In colVariants // *** This is the problem right here ***
08 //Do Some Processing
09 Next
10 Next
For all intents and purposes, if a variant does not have a quantity on hand, Stone Edge does not realize it exists.
I am currently on AbleCommerce Verision 7.0.5.14053. According to Stone Edge support, this issue does not exist in version 7.0.4. I have no way of testing this older version, but if that is true, something was changed in the AbleCommerce ProductVariantCollection method that Stone Edge uses.
My questions are these. Did this indeed work correctly in 7.0.4? If so, what changed in the ProductVariantCollection method and was it an intentional design change or an over site? How does the ProductVariantCollection method work in 7.0.6? Does it return all variants or only the ones with a positive quantity on hand?
Incidentally, this is a way to way to return all variants (regardless of quantity) using ProductVariantManager, but it would require Stone Edge to do some major rewrites to their script. If including a code snippet with this "fix" below. (It's in C# because that's what I know.)
Code: Select all
ProductVariantManager _VariantManager = new ProductVariantManager(ProductId);
for (int i = 0; i < _VariantManager.Count; i++)
{
ProductVariant variant = _VariantManager.GetVariantByIndex(i);
//Do Some Processing
}