Productsup

Group data across multiple rows with the Group Attributes data service

Group Attributes data service: Group data across multiple products with the Group Attributes data service in Productsup.

The Group Attributes data service lets you create a new attribute in your site to group values from a chosen attribute for all products that have the same value in a grouping attribute. For example, for all products in your site that have the same value in the grouping attribute id, you can create a new attribute ___grouped and populate it in the following ways:

  • Add all values of a chosen attribute. See Concat method.
  • Count values of a chosen attribute and output the result. See Count method.
  • Identify and save the highest or lowest value in a chosen attribute. See Max and Min methods.
  • Produce a sum of all values of a chosen attribute. See Sum method.

The service works based on the SQL function GROUP BY. See SQL Tutorial for more information.

The Group Attributes data service is available for the import and intermediate stages.

Prerequisites

To set up the Group Attributes data service, you need:

  1. A unique item identifier. See Set a unique item identifier for more information.

Add the Group Attributes data service

Go to Data Services from your site's main menu and select Add Service.

Search for Group Attributes, select Add, and rename the data service as desired. UUID-0a06923f-3904-fb5d-bf2c-e5dc5ec70103

Choose the stage containing the attributes you want to group in Service Data Level and select Add. This takes you to the data service setup: UUID-ec7d6652-352c-2151-3020-7c274ba14c15

Select the attribute containing the values you wish to group from the drop-down menu Attribute containing the values.

If you choose Import in Service Data Level in see the relevant section, the drop-down menu Attribute containing the values displays the attributes of your import stage. If you choose Intermediate, the drop-down menu shows your intermediate-stage attributes.

In the drop-down menu Import attribute you want to group by, select the import-stage attribute which should determine your value-grouping range. If multiple products have the same value in this grouping attribute, the data service analyzes the values of these products in the attribute chosen in see the relevant section and groups the values of these products in a newly-created attribute named in see the relevant section by performing the action chosen in see the relevant sectionTo choose several grouping attributes, hold the CTRL (or CMD) key while selecting.In Import attribute you want to group by, you can't choose an attribute that contains only empty values. If you do so and try to save the data service setup, the platform shows an error and prompts you to change your attribute selection: UUID-8ff2eacb-577c-86a4-c872-52d1d4e6687a

Enter the desired name of the new attribute in Result attribute.The system creates a new attribute to store the grouped data without overwriting your existing attributes. The platform prepends the attribute name specified in this field with the prefix you set in see the relevant section.

Select the grouping method from the Method drop-down menu.

For the Concat method only:

In Delimeter, select the delimiter that separates the grouped values in the new attribute.

Activate Concat unique if you don't want to display duplicate values.

Select Save.

For the platform to process a new data service, select Run in the top-right corner of your site's view.

Output examples of different grouping methods

While setting up the data service, you can select from five different data-grouping methods in the Method drop-down menu:

  • Concat
  • Count
  • Max
  • Min
  • Sum

Here is a sample feed we can use to show how each grouping method works:

iditem_group_idstocksizecolordiscount_in_percent
11234Sred10
21232Sblue15
31231Lblue25
4456538black7
5456438blue15
6456738green5
7456240green10

Concat method

Use the Concat method to combine all values from different products in one attribute.

Example:

To concat sizes for products with the same item_group_id, use the following setup:

  • Attribute containing the values: size
  • Import attribute you want to group by: item_group_id
  • Result attribute: concat_sizes
  • Method: Concat
  • Delimiter: ,COMMA
  • Concat unique: off

Using this setup, the system groups all sizes of the products with the same item_group_id in a newly created ___concat_sizes attribute:

iditem_group_idstocksizecolordiscount_in_percent___concat_sizes
11234Sred10S,S,L
21232Sblue15S,S,L
31231Lblue25S,S,L
4456538black738,38,38,40
5456438blue1538,38,38,40
6456738green538,38,38,40
7456240green1038,38,38,40

The system combines the data without any spaces between characters.

Count method

Use the Count method to count the number of product variations.

Example:

To count the number of product variations with the same item_group_id, use the following setup:

  • Attribute containing the values: item_group_id
  • Import attribute you want to group by: item_group_id
  • Result attribute: count_variations
  • Method: Count

Using this setup, the system counts all product variations with the same item_group_id and records the result in a newly created ___count_variations attribute:

iditem_group_idstocksizecolordiscount_in_percent___count_variations
11234Sred103
21232Sblue153
31231Lblue253
4456538black74
5456438blue154
6456738green54
7456240green104

Max and Min methods

Use the Max or Min methods to find and display the highest or lowest value.

Example:

To return the highest discount among all products with the same item_group_id, use the following setup:

  • Attribute containing the values: discount_in_percent
  • Import attribute you want to group by: item_group_id
  • Result attribute: max_discount
  • Method: Max

Using this setup, the system compares discounts of all products with the same item_group_id and records the highest value in a newly created ___max_discount attribute:

iditem_group_idstocksizecolordiscount_in_percent___max_discount
11234Sred1025
21232Sblue1525
31231Lblue2525
4456538black715
5456438blue1515
6456738green515
7456240green1015

Sum method

Use the Sum method to return the numerical sum of products matching the selected conditions.

Example:

To sum the stock for products with the same item_group_id and color, use the following setup:

  • Attribute containing the values: stock
  • Import attribute you want to group by: item_group_id and color
  • Result attribute: stock_sum
  • Method: Sum

Using this setup, the system sums the values of all products with the same item_group_id and color and records the numbers in a newly created ___stock_sum attribute:

iditem_group_idstocksizecolordiscount_in_percent___stock_sum
11234Sred104
21232Sblue153
31231Lblue253
4456538black75
5456438blue154
6456738green59
7456240green109

Edit the Group Attributes data service

Go to Data Services from your site's main menu.

Change the settings of the needed data service:

  1. To deactivate a data service, choose the pause icon next to the desired data service.
  2. Select the cogwheel icon () next to the desired data service to edit other settings and select Save.

Delete the Group Attributes data service

Go to Data Services from your site's main menu.

Tip

To stop a data service from affecting your feed without deleting the data service itself, you can choose the pause icon next to the desired data service.

Select the cogwheel icon UUID-e19d1a4d-9ea0-6607-b841-3cd22c1101e2 next to the desired data service.

In the Danger Area panel, select Remove this service.

Select Yes.

How is this guide?

On this page