Close

Grouping specification attributes

ifmobler
7 years ago
#12935 Quote
Avatar
  • 4
I updated the TabSpecifications to allow grouping. In our website it's very useful.
File: views\product\_ProductSpecifications.cshtml

Before:
Color: NameofColor
Color: NameofColor
Color: NameofColor ....

After:
Color: NameofColor, NameofColor, NameofColor...

If I want to group for example color into a single line I changed these lines below.


   @{
                    var groupedList = Model.GroupBy(u => u.SpecificationAttributeName).Select(grp => grp.ToList()).ToList();
                    int a = -1;

                    foreach (var i in groupedList)
                    {  
                        a++;
                        var item = i.First();
                        <tr @(a % 2 == 0 ? Html.Raw(" class=\"odd\"") : Html.Raw(" class=\"even\""))>
                          
                            <td class="spec-name">
                                @item.SpecificationAttributeName
                            </td>
                            <td class="spec-value">

                                @if (String.IsNullOrEmpty(item.ColorSquaresRgb))
                                {
                                    if (i.Count() > 1)
                                    {
                                        foreach (var attr in i)
                                        {
                                            <div style="margin-right: 10px;">@Html.Raw(attr.ValueRaw)</div>
                                        }
                                    }
                                    else
                                    {
                                        @Html.Raw(item.ValueRaw)
                                    }
                                }
                                else
                                {
                                    foreach (var color in i)
                                    {
                                            <div class="color-squares">
                                                <span class="color-container" title="@Html.Raw(color.ValueRaw)" style="float:left;margin-right: 10px;border: 1px solid #d5d5d5">
                                                    <span class="color" style="background-color: @(color.ColorSquaresRgb);">&nbsp;</span>
                                                </span>
                                            </div>
                                        }
                                }
                            </td>
                        </tr>
                        }
                    }
hristian.dimov
7 years ago
#12947 Quote
Avatar
  • Moderator
  • 386
ifmobler wrote:
I updated the TabSpecifications to allow grouping. In our website it's very useful.
File: views\product\_ProductSpecifications.cshtml
...


Hi,

Thank you for the suggestion, but nopCommerce does not group the specifications and we need to consistent with this. This is why we cannot implement this in the Quick Tabs plugin.

However, someone might like what have you done and use your solution in their sites.
Regards,
Hristian Dimov
Nop-Templates.com