I'm trying to fix a page someone did for the multiple purchase of products with variants. He used ProductOptionCollection productOption = ProductOptionDataSource.LoadForProduct(ProductList[iProductListCount].ProductId); to create a collection to display
and with that, the option sku doesn't get passed to the basket and the availability isn't checked.
Is there something comparable for variants? I've tried ProductVariantCollection productOption = ProductVariantDataSource.LoadAllForProduct(ProductList[iProductListCount].ProductId);
and get the error CS0120: An object reference is required for the nonstatic field, method, or property 'CommerceBuilder.Products.ProductVariantDataSource.LoadAllForProduct(int)'
I've looked at other methods of variants also.
What would be the best way to approach this?
Thanks
Load all variants for product on custom page
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Load all variants for product on custom page
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: Load all variants for product on custom page
You can load the variants as below
If you want to load a single variant depending upon the option choices then it would be
Where in above code I just have a single option with three
choices and I am loading the one of three variants which is for first choice.
Code: Select all
ProductVariantCollection pvc = ProductVariantDataSource.LoadForProduct(productId);
GridView1.DataSource = pvc;
GridView1.DataBind();
Code: Select all
OptionChoiceCollection occ = OptionChoiceDataSource.LoadForOption(optionId);
int[] choiceIds = new int[]{occ[0].OptionChoiceId};
ProductVariant pv = ProductVariantDataSource.LoadForOptionList(productId,choiceIds);
Response.Write(pv.Sku);
choices and I am loading the one of three variants which is for first choice.
Make sure your ProductList variable has some valid reference value.CS0120: An object reference is required for the nonstatic field, method, or property 'CommerceBuilder.Products.ProductVariantDataSource.LoadAllForProduct(int)'