To test this you need to have another line item type enabled besides "product". Like shipping or coupon or something.

Create a View of line items of all types.
Create a relationship to the referenced product; do not require.
Add the Commerce Product Type field to the View using the Product relationship.
Create a Page display.
Go to the page: you should see this warning:
Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain()

The problem is in commerce_product_handler_field_product_type.inc.

...
function render($values) {
    $type = $this->get_value($values);

    // Return the raw value if specified.
    if (!empty($this->options['use_raw_value'])) {
      return $this->sanitize_value($type);
    }

    $value = commerce_product_type_get_name($type);

    return $this->render_link($this->sanitize_value($value), $values);
  }
...

$type will be null on rows that are not product line items. Thus the commerce_product_type_get_name() returns an array of all product types which then gets passed to check_plain via sanitize_value().

Patch in the comments.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

krlucas’s picture

Status: Active » Needs review
FileSize
1.2 KB

Here's a patch.

rszrama’s picture

Status: Needs review » Fixed

Nice find and perfect patch. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.