-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Product variation assignment fixs #624
base: v2.x
Are you sure you want to change the base?
Conversation
What bug does this fix? |
I have a question about 2 though, would being able to delete an entire vector assignment with one go like it was previously be useful? what do you think? |
I see, I think we should fix this the other way round: The idea for the vectors is that those are exhaustive. With that I mean that when you have 3 variations with 3 values each, the total amount of valid combinations should be 9 and every combination is unique. It should actually not be possible to assign two products to the same proxy with the exact same vector values. And it should only be possible to add an assignment when all vectors are provided. But the way the _id is generated seems error prone anyways to me, as it uses { variant1: 1, variant3: 1, variant2: 2 } and -> We need to sort the vector object by their keys first or add the actual variant keys to the _id like |
@pozylon what do you men by "It should actually not be possible to assign two products to the same proxy with the exact same vector values. And it should only be possible to add an assignment when all vectors are provided." let's say we have we a t-shirt store and color and size vectors but different brands Nike/Adidas etc... so with the above statement we should also create a brand vector to set the register does it look right? what if we create color and size vectors and then assign brand shirts to those vectors? |
I think we need a refactor of this function here:
It should only $push when no product for that vector exists already in proxy.assignments And here we should check if the vector is "complete" and has valid values based on the variations, else it should throw:
That way if I call the mutation twice with the same values, it will not lead to a double assignment and if I call the mutation not providing a value for every variation, it goes error. |
Well, different t-shirts of different brands are usually not in the same proxy because it's not just a variant but another article in general. But yes, it looks right, if we have variations: size: l, m, s It means we can only have a product each for every combination:
|
I can't have 2 products with s-red-round-neck |
What happens If i remove a variation? -> in those cases, the admin UI should warn the user that he needs to re-do the assignments and all assignments should be removed during those mutations If i only add a new variation value -> all good, there is just un-assigned combinations in assignments which is fine |
@Mikearaya Can you please take on this topic? maybe write integration tests first so we can check against the behavior as described. this definitely needs tests. |
No description provided.