Is there a limit to the Number of Options for a Dropdown Attribute? Let's say I have 10000 different lists of options in an attribute. How that will affect the Magento, website load time, backend data update, search response time.
3 Answers
Having over 1000 options in a dropdown is never a good idea. Just imagine having to scroll all those options and click the wrong one by mistake and the ordeal to do all the scrolling again.
A better option will be using radio buttons, but it will take a lot of space on your form/page.
The best option with this many options will be to go with searchable select (see demo here - https://harvesthq.github.io/chosen/#selected-and-disabled-support) field which can be implemented using https://harvesthq.github.io/chosen/ or any similar jquery plugin.
Also if you load all the options during page load it may affect the load times, so you should try to load is asynchronously using ajax.
-
I'm thinking adding another table for this attribute purpose and create custom module to populate data where it needed is the final option. Thank you for your insight!– DasunCommented Oct 13, 2021 at 5:00
I don't believe that there is a technical limit to the number of attribute option values other than the size of the primary key on the tables that store the data and the amount of space the database can consume.
How it affects backend performance depends on how the attribute is configured and used.
More options will increase page loads depending on the size of the associated HTML.
Where I would expect real problems is when these options are rendered by the browser as selects, layered navigation checkboxes etc. The result would be unpleasant to interact with and could cause memory issues for the browser. (This also applies to the admin).
If possible, it would be better to re-design the catalog so that there is no need for such an attribute.
-
hopefully, I can remove it from layered navigation bar, yet I'm thinking adding another table for this attribute purpose and create custom module to populate data where it needed is the final option. Thank you for your insight!– DasunCommented Oct 13, 2021 at 4:59
It's a limit of php configuration, because config max_input_vars by default has value 1000, in this case value of max_input_vars should be 10000. After increasing to 100000 it seems to work fine with 2100 options.
-
I don't think this applies, max_input_vars means number of variable for GET,POST or Cookies. Not related to the number of option for a single attribute in Magento 2, Correct me if I'm wrong.– DasunCommented Oct 17, 2021 at 8:23