• Resolved devbynature

    (@devbynature)


    Hey everyone,

    I am trying to modify the query in a strange way. I have the product loop but the client decided that there were too many products being displayed. There is an attribute called “collections” that each product belongs to. They want to group the results by this attribute, while maintaining the dropdown sorting order. I have this working with the exception of one thing. They need the product image and link to be for the first product in that collection alphabetically in those results.

    This is where I am being thrown off. Grouping by collection and ordering alphabetically in the results without messing with the order of the collections themselves.

    Example:

    The results without modifications:

    Belriva Stool
    Leveron Stool
    Leveron Chair
    Zebra A
    Belriva Chair
    Foo Stool
    Foo Chair
    Zebra B

    The results with modifications (should look like):

    Belriva Chair
    Leveron Chair
    Zebra A
    Foo Chair

    Just trying to get the Group By and ordering within that group without modifying the original order (See each appears in order of the first item of that collection)

    https://wordpress.org/plugins/woocommerce/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Group by while maintaining order’ is closed to new replies.