I am building a site which makes use of variants and shows them all in a nice big table on the shop.
I had set up all the product definitions in Ucommerce and then had to change the ordering of them for the client in the back end to make it easier for them to edit. - nice and easy :)
I checked the front end to the website and it hadn't replicated the new ordering there :(
I have managed to change the headings for the table using the following:
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;
However I use the following for getting the variant data and putting it into a table which now means the column headers don't match the data as it isn't sorted.
var product = SiteContext.Current.CatalogContext.CurrentProduct;
@foreach (var prod in product.Variants)
{
<tr>
@*
Need to add some kind of orderby to the variants below
*@
@foreach (var b in prod.ProductProperties) {
<td>@b.Value</td>
}
</tr>
}
I'm guessing i need to do someting like:
@foreach (var b in prod.ProductProperties.Orderby(x = > "THE SORT ORDER OF THE BACKEND")) {
But no idea as all I can get it do do is show an error page
Sorting variants on the front end
I am building a site which makes use of variants and shows them all in a nice big table on the shop.
I had set up all the product definitions in Ucommerce and then had to change the ordering of them for the client in the back end to make it easier for them to edit. - nice and easy :)
I checked the front end to the website and it hadn't replicated the new ordering there :(
I have managed to change the headings for the table using the following:
However I use the following for getting the variant data and putting it into a table which now means the column headers don't match the data as it isn't sorted.
I'm guessing i need to do someting like:
But no idea as all I can get it do do is show an error page
Has anybody got any ideas?
Hi Rob,
Would something as simple as
not work?
Maybe I am missing something? :-)
Kind regards,
Jesper
Jesper, you're not missing anything that works perfectly!
You are a star - thank you
is working on a reply...