No aggregation total shown if first result is empty (commerce_price fields)

Created on 21 July 2023, over 1 year ago

Problem/Motivation

Noticed this, while working on a "Table with aggregation options" with commerce_price fields, "Apply column function" SUM and "Column aggregation row applies to" set to "the entire result set".

Steps to reproduce

If the first result (node with a few commerce_price fields in my case) in a view configured like above, has no value set (Field is empty), the aggregated total won't be shown. This is because of this condition in https://git.drupalcode.org/project/views_aggregator/-/blob/2.0.x/src/Plu...

if (isset($field->currency_code)) {
  $field->number = $raw_value;
}
else {
  $field->value = $raw_value;
}

if (isset($field->currency_code)) { will evaluate to FALSE if the field value is empty. So it will set $field->value = $raw_value; on a price field, which won't work since the field excepts the value in $field->number.

Proposed resolution

See MR.

Remaining tasks

This also should respect the "Column aggregation row applies to" setting set to "the entire result set". I noticed that if the view is paged, it will only process the first page in https://git.drupalcode.org/project/views_aggregator/-/blob/2.0.x/src/Plu....

Could use the same as in: https://git.drupalcode.org/project/views_aggregator/-/blob/2.0.x/src/Plu...

User interface changes

API changes

-

Data model changes

-

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany daveiano

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024