Variant options : disable option and order options
Hi,
Already finishing one pretty nice uCommerce solution. My second one :)
But have few pretty hard core at least for me questions, redarding variants and variant options.
Have created all options i need (actually two - color and size) and two additional ones (witch i marked not to show on website).
These are disable (checkbox) and SortOrder (number).
I am using standard razor show and all its functionalities.
var uniqueVariants = from v in product.Variants.SelectMany(p => p.ProductProperties) where v.ProductDefinitionField.DisplayOnSite group v by v.ProductDefinitionField into g select g;
@foreach (var prop in uniqueVariants){ var controlName = string.Format("variation-{0}", prop.Key.Name.ToLower()); }
1. Quetion is how i can make it with that Linq/Lambda or etc to sort variant options by field SortOrder if they are filled in
2. How can i not show variant options with disable button checked.
var uniqueVariants = from v in product.Variants.SelectMany(p => p.ProductProperties)
where v.ProductDefinitionField.DisplayOnSite
group v by v.ProductDefinitionField into g
orderby ProductDefinitionField.Get(g.Key.ProductDefinitionFieldId).SortOrder
select g;
Im not sure this is what you are looking for - but give it a go (not testet - im not sure how Nhibernate handle the ProductDefinitionField.Get )
I don't know what i was think with the ProductDefinitionField.Get ^^
var uniqueVariants = from v in product.Variants.SelectMany(p => p.ProductProperties)
where v.ProductDefinitionField.DisplayOnSite
group v by v.ProductDefinitionField into g
orderby g.Key.SortOrder
select g;
This should do the correct sorting (it did i my test ) :)
@foreach (var value in prop.Select(p => p.Value).Distinct()){
<option value="@value">@value</option>
}
</select>
}
Why i am doing this, is that client adds as size (S,L,XL) and then he gets also or remembers that he needs to add M too, so if he whant to get them in nice order he has to delete L and XL add M and then add back L and XL, since variant combinations are not sortable.
And what i want to do is to allow him to set order number so it would be ordered correctly.
And i am not listing product properties i am listing variants by setting select tag on every property and the it has option tag for every variant option. And what i need is to be able to sort these variant options in that select tag :)
p.s. this predefined and code styles do not listen to me :P
Variant options : disable option and order options
Hi,
Already finishing one pretty nice uCommerce solution. My second one :)
But have few pretty hard core at least for me questions, redarding variants and variant options.
Have created all options i need (actually two - color and size) and two additional ones (witch i marked not to show on website).
These are disable (checkbox) and SortOrder (number).
I am using standard razor show and all its functionalities.
1. Quetion is how i can make it with that Linq/Lambda or etc to sort variant options by field SortOrder if they are filled in
2. How can i not show variant options with disable button checked.
Thanks
1.
Im not sure this is what you are looking for - but give it a go (not testet - im not sure how Nhibernate handle the ProductDefinitionField.Get )
Thanks for answer sadly did not worked :(
You example gave me some more ideas witch non of them worked too ... So ... back to squere one :)
And basiclly it is because it tries to sort variants and i want to sort variant options :)
So i assume that at least for 1. some additions need to be done in these lines :
I don't know what i was think with the ProductDefinitionField.Get ^^
This should do the correct sorting (it did i my test ) :)
Hey Nickolaj,
Really thanks for you help :)
Sadly :S did not worked for me :S just to be sure posting a variant structure of mine, and did you understood like that ?
You said it wokrs for you ? :)
Hm ...
Using exactely the same as you :S
Ohh. Mine is sorting by the SortOrder on the ProductDefinitionField so that's why it is not working for you.
Im not quite sure what you are trying to do. You are listing the productProperties, but are trying to order the variants sortOrder property.
What do you want in the dropdown list?
On another node. I would advice using the enum datatype for "Storrelse" and "Farve" to get a better data structure :)
hey Nickolaj,
Sorry fot not full explanation :) and i can see there is a bug in forum showing full code from me :)
Here it is :
Why i am doing this, is that client adds as size (S,L,XL) and then he gets also or remembers that he needs to add M too, so if he whant to get them in nice order he has to delete L and XL add M and then add back L and XL, since variant combinations are not sortable.
And what i want to do is to allow him to set order number so it would be ordered correctly.
And i am not listing product properties i am listing variants by setting select tag on every property and the it has option tag for every variant option. And what i need is to be able to sort these variant options in that select tag :)
p.s. this predefined and code styles do not listen to me :P
Thanks
bump :)
I'm not sure if i understand you right, but to sort the variants by a cusotm property you can just use linq and do something like that:
Not tested but that should do it.
is working on a reply...