Groups

On this page

Overview

Groups is used for categories. For example if you have a page where you sell magic equipment some groups could be "Staffs", "Potions", "Brooms" and "Capes". 

You can choose if you want to show multiple groups or if you just want to show a single group.

 


Groups

Groups are available in all templates through the identifier groups, as long as the site has the webshop module.

Below is a table with all the drops you can use for accessing multiple groups.

Name Description
groups.all Array with all the groups in the webshop
groups.root_items Array with the root groups
groups.tree Array with the root groups but will preload all their descendants
groups.group_url Returns a single GroupDrop
groups['group_url'] Returns a single GroupDrop
groups['group_url'].has_product[product.wm3_id]

Returns boolean



Snippet

If you want to loop through the children of a specific group, you can use the following snippet:

{% for children in groups.wands.children %}
    {{ children.id }}
{% endfor %}

 


Group

In group pages, the current group can be accessed through the identifier group.

Below is a table with all the drops you can use for accessing a single group

Name Description
group.id Group ID
group.name Group name
group.position Group position
group.image_url Group image url
group.tags Returns an array of tag drops
group.url Group URL with full path. Eg. https://hogwarts.wm3.se/catalog/groups/wands
group.default_url Group URL without full path. Eg. wands
group.active? Boolean. True if this group is active
group.has_active_child?  Boolean. True if a descendant of this group is active
group.has_active_ancestor? Boolean. True if an ancestor of this group is active
group.has_active_parent?   Same as `has_active_ancestor?`
group.active_or_ancestor? Boolean. True if is active or is an ancestor of the active group.
Same as group.active? and group.has_active_child?
group.parent Returns the group parent
group.children Returns array with children of the group
group.children_with_products Returns array with the children of the group with products 
Note: Do not use in combination with .children or .tree as this will preload twice
group.tree Same as .children but will preload all descendants
group.descendants Same as .tree
group.products Returns array with products that belongs to the group
group.subtree_products Returns an arraay with products that belong to the current group
and all the groups descendants
group.root Returns the root of this group's tree
group.sub_root Checks the group tree and returns the ancestor on the second level
group.path Breadcrumbs for group. Scopes model on path records of the record
group.excerpt Returns raw text version of the groups published editables
group.saved_editables Get saved editables from group
group.published_editables Get published editables from group
group.groups_with_products_in_common See groups with products in common
group.visible Returns boolean
group.visible? Returns boolean
group.product_property_values Array of PropertyValueDrop for the group's products
group.product_property_unique_values Array of unique property values for the group's products

 

Groups with products in common

Returns groups that have products that are included in the group.

Name Description
group.groups.children_of_wands Returns Array<GroupDrop>.
All groups that are children of group with URL wands
group.groups.descendants_of_wands Returns Array<GroupDrop>.
All groups that are descendants of group with URL wands
group.groups.descendants_of_wands_at_depth_2 Returns Array<GroupDrop>.
All groups that are descendants of group with URL wands
and are at depth 2. (See note below)
group.groups.include_subtree Includes the groups decendants in the results

 

Depth is related to how deep the group is in the tree. Root groups are at depth 0, a root child is at depth 1 and root grandchild is at depth 2 and so on.

Updated: 2022-03-24