Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
y_h CreditAttribution: y_h commentedI 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;
Comment #3
guy_schneerson CreditAttribution: guy_schneerson commentedAnother way of fixing the issue with no code changes is:
Comment #4
guy_schneerson CreditAttribution: guy_schneerson commentedThe 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:
and I can't see the advantage in limiting the list size. Yes it can improve performance but at the cost of data loss.
Comment #5
capellicThe "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.
Comment #6
blasthaus CreditAttribution: blasthaus commentedThis 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.
Comment #7
rszrama CreditAttribution: rszrama at Centarro commentedLet's close this one even though the other one was slightly newer. It has a patch we can review.
Comment #8
capellicI 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.
Comment #9
guy_schneerson CreditAttribution: guy_schneerson commentedThe 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
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
@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.
Comment #10
capellicI 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. :-)
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.
Comment #11
rszrama CreditAttribution: rszrama at Centarro commentedThe 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.
Comment #12
guy_schneerson CreditAttribution: guy_schneerson commentedThanks @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.