Yes, this is proving to be quite difficult. I still haven't found a way to do it.
Is there a class/method to use in the BVSoftware.Bvc5.Core that will get me a list of choice options for a color that has inventory?
As I'm thinking through the possible scenarios, I'm running into issues such as what if there are no sizes for a particular color? The customer wants the color to be removed from the drop down.
So, in my Product view, I have Color first and then Size below it. So in the BVModules/ProductChoices/Drop Down List/View.ascx.vb in the Display() method is where the list of choices is bound to the drop down list.
However, the choice.ChoiceOptions returns a list of all possible choices for the "color" choice the first time this control is added to the VariantsPlaceHolder control. The second time the ProductChoices/Drop Down List/View.ascx.vb is called is when the choice is set to "size" and the choice.ChoiceOptions list is bound to the drop down list and added to the VariantsPlaceHolder control after the first drop down list.
So, the lists are really independent of each other when they are added to the page.
So far, what I'm thinking is somehow I have to determine when View.ascx.vb is called with "color" choices the first time, I have to go through each color choice and then find all the sizes in that color and see if they have any inventory. If all sizes for that color have no inventory, then I should remove that color from the list (I'm not sure if I should do this before databinding or after and remove the list items themselves from the control). Of course, it may end up that all colors are empty and then I'd have an empty drop down list. That's another problem...
However, the sizes is even more difficult because I have to show only sizes that have inventory for the currently selected color (assuming there is a color left over from step 1 above).
Yet another problem is that the "default" color choice may be removed by step 1 if there was no inventory for all sizes of that color. Then I'd have to make sure something is selected.
Then there's the issue of handling the SelectedIndexChanged event when the user changes the color in the top drop-down list, this needs to re-populate the sizes drop-down with only the sizes with inventory for that particular color.
I'm trying to find useful methods in the Bvc5.core that might make this easier, but the ChoiceOptions list has Catalog.ProductChoiceOption objects and the bvin property there doesn't let me find the inventory with something like:
Dim inventory As Catalog.ProductInventory = Catalog.ProductInventory.FindByBvin(productChoiceOption.Bvin)
It could be our bvc_ProductChoiceCombinations table is giving us problems because the ChoiceOptionId column is populated by an external application that pushes products into the database via the web service calls. Our table looks like this:
bvin ChoiceId ChoiceOptionId ProductId ParentProductId Available LastUpdated
10db1293-ab41-4b7e-b945-0e9d5398ceec 1385-11-Color 1385-11-Color-BLACK 8ad963b0-f170-4c50-a338-d9fc37e646c4 1385-11 False 2010-02-10 14:05:48.570
2339be27-734c-43e2-91e0-12673d0c2774 1385-11-Color 1385-11-Color-BLACK 03fc0c91-e5ad-4e2a-af7c-45d6fd7ee125 1385-11 True 2010-02-10 14:05:48.503
3774f3b9-31c9-41de-9526-291a421a4eff 1385-11-Color 1385-11-Color-BLACK 07ff551b-0551-4751-a9f6-1495779b745b 1385-11 False 2010-02-10 14:05:48.537
But I noticed if I manually create a new ChoiceOption for color like "red" , then the ProductChoiceCombinations table is populated with GUIDs in the ChoiceOptionId field.
Could this be causing me retrieval problems with the inventory? Or should I be using a different method?
Is Marcus available to help out?
Thank you!
amarion attached the following image(s):
bvc_ProductChoiceCombinations table.JPG
(109kb) downloaded 42 time(s).You cannot view/download attachments. Try to login or register.