Hi,
Since 7.x-1.13, in a product reference field, the number of choices is limited to 10 (with the widget select list).
Thank!

Comments

Projet Oeb created an issue. See original summary.

y_h’s picture

I noticed this as well

Inside the commerce_product_reference.module inside the function commerce_product_reference_options_list at line 1048 you can fix this by changing
$limit = 10;
to
$limit = NULL;

guy_schneerson’s picture

Another way of fixing the issue with no code changes is:

  1. Edit the "product reference" field
  2. Set "Options list limit" to 99999 (or any number that's bigger then current and future product number)
  3. click "Save Settings"
guy_schneerson’s picture

The code in #2 works and is a sensible change especially as UI for the "Options list limit" states "Limits the number of products available in field widgets with options lists; leave blank for no limit."
As the blank value correlates to the empty "if" condition:

<?php
  // Look for an options list limit in the field settings.
  if (!empty($field['settings']['options_list_limit'])) {
    $limit = (int) $field['settings']['options_list_limit'];
  }
  else {
    $limit = 10;
  } 
?>

and I can't see the advantage in limiting the list size. Yes it can improve performance but at the cost of data loss.

capellic’s picture

The "Options list limit" field on the product reference field has the following helper text: "Limits the number of products available in field widgets with options lists; leave blank for no limit." My field is blank yet it imposes a limit of 10? This is most certainly a bug.

blasthaus’s picture

This issue has a duplicate All product reference fields are empty
with a patch that fixes the bug for us. One of these should be closed as dupe.

rszrama’s picture

Status: Active » Closed (duplicate)

Let's close this one even though the other one was slightly newer. It has a patch we can review.

capellic’s picture

Status: Closed (duplicate) » Active

I don't know that this is a duplicate. This is an issue with only showing 10. The other case is an issue of not showing any. Our issue here is the arbitrary limit of 10 items in the list and the patch at #2704507-4: All product reference fields are empty doesn't address this.

guy_schneerson’s picture

The two issues are definitely linked and the patch does fix this issue for me and I suspect most if not all cases
@capellic - did you test the patch?

should work as

<?php
empty($field['settings']['options_list_limit']
?>

does return true as is set to an empty string and as a result $limit is set NULL.

However I do not understand the need for the

<?php
   else {
     $limit = 10;
   }
?>

@rszrama I can not find an explanation In both issues for this:
1) what are the circumstances in which the options_list_limit don't exist ?
2) Why are we limiting to 10 in such cases?
I would assume NULL should be the value for the else but I may have missed related conversations.

capellic’s picture

The two issues are definitely linked and the patch does fix this issue for me and I suspect most if not all cases
@capellic - did you test the patch?

I tested. It worked on one site but not another and that boggled my mind so much it hurt! So I'm sticking with 99999 in the Options list limit" field for now. :-)

I would assume NULL should be the value for the else but I may have missed related conversations.

Bingo! Hard coding an arbitrary limit in the code doesn't make sense to me. If people are having problems with performance and want to arbitrarily limit what products appear in this field, then they can do that with the new "Options list limit" field.

rszrama’s picture

The limit wasn't actually related to the field, unfortunately. The real issue is that the same code was governing options lists and other uses of autocomplete / SKU matching if I recall - places where we don't have a UI for limiting the number of options included.

guy_schneerson’s picture

Status: Active » Closed (duplicate)

Thanks @rszrama for the explanation.
@capellic - I am marking this as duplicate of #2697017: Revert the EntityFieldQuery based product matcher and arbitrary options list limit as even if this is not the same issue, they are both a result of the same code and it will not serve us posting on two separate issues. hope you don't mind.