Sorry I'm reposting this as I posted a response to a closed issue: http://drupal.org/node/1200172. I didn't know how to retract the post.

I have a multiattribute product display with two problems.

1) the multiattribute select list is empty. The label and dropdown controls are there but there are no values. The values are entered in the respective product listing field.

2) I have a second, unwanted, select list in the product display of the product titles for products referenced in product reference. This field is not checked for this capability in the product listing--the field is uneditable. How do I remove this?

CommentFileSizeAuthor
product_fields.jpg42.38 KBdbkern
power_field.jpg268.73 KBdbkern
display.jpg22.35 KBdbkern

Comments

damien tournoud’s picture

Category: support » bug

This looks like a bug report for now. Your two issues are one the consequence of the other: because the power field is not picked up properly, the add to cart for renders the other available products (listed by their titles) in an additional drop-down.

dbkern’s picture

Thanks--I feel a bit less stupid--but I guess I'll still have to hold tight until someone much better at this than me resolves the issue. What can I do to help someone fix this?

damien tournoud’s picture

Title: Multiattribute Select List Empty » List (float) relies on comparisons between float values
Project: Commerce Core » Drupal core
Version: 7.x-1.0-beta4 » 8.x-dev
Component: Product reference » field system

Ok, it is actually a core bug. In a nutshell: List (float) relies on comparing float values for equality and as a consequence is *utterly broken*.

If you input 0.0 as an allowed value, it will be stored as:

  • (int) 0 as the key of the allowed values,
  • Something close to 0 in the database

If you input 1.5 as an allowed value, it will be stored as:

  • (string) '1.5' as the key of the allowed values because PHP only supports integers and strings as keys to associative arrays
  • Something close to 1.5 in the database

As a consequence, all the comparisons between the value stored in the database and the allowed value list just fail (including the one that generates the selected value in the widget form...).

Short term, you can workaround the issue by not using a List (float) type but instead a List (text) or List (integer).

dbkern’s picture

Damien,

Many thanks! I switched the keys in the multiattribute field to all integers and the select list in the display is now populated and the unwanted dropdown is gone.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

Issue summary: View changes
Status: Active » Closed (cannot reproduce)

We've fixed this in Drupal - we store floats in config as real floats like

  allowed_values:
    -
      value: !!float 0
      label: '0'
    -
      value: !!float 1
      label: '1.0'

If you enter both 0 and 0.0 in the initial default value list the system is clever enough to work out these are the same value and you only end up with one allowed value.