Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
When a product reference field is configured to use the autocomplete text widget, there is currently a 128 character maximum. If you have multiple SKUs you want to add to a given product display, the current maximum can be exceeded quickly.
Ideally, the text box should have no limit.
Comment | File | Size | Author |
---|---|---|---|
#9 | 1115994_product_ref_textfield_maxlength_9.patch | 812 bytes | jeff.maes |
Comments
Comment #1
c600g CreditAttribution: c600g commentedMy proposed solution:
file: commerce_product_reference.module
function: commerce_product_reference_field_widget_form()
add:
'#maxlength' => 0,
to the return $element + array() statement at the end of the function.
Comment #2
c600g CreditAttribution: c600g commentedJust tested maxlength value of 0 in Firefox 4, and it causes problems. Perhaps a suitably large number (like 1,000) would be a better choice.
Comment #3
amateescu CreditAttribution: amateescu commentedI think that
is a better option.
Comment #4
rszrama CreditAttribution: rszrama commentedWhere would you do that in core, though? #maxlength isn't part of the $element yet in the field widget form callback... I wonder what pre-emptively setting it to NULL would do.
Comment #5
c600g CreditAttribution: c600g commentedJust tested a new idea on Chrome, Firefox 4, and IE 9, and it seems to work well:
'#maxlength' => '',
However, this is not valid HTML, and will cause validation issues. A similar issue arises if you try to set it equal to NULL.
Ideally, there would be a method to indicate that a default input attribute not be included in the element at all, as amateescu suggests.
Comment #6
c600g CreditAttribution: c600g commentedI just checked the taxonomy module to see how it defines it's auto-complete text fields, and it sets a #maxlength of 1024.
Comment #7
rszrama CreditAttribution: rszrama commentedWorks for me. Just committed this change.
Comment #9
jeff.maes CreditAttribution: jeff.maes commentedThe default maxlength of a textfield is 128. Because the maxlength parameter has been removed, the problem seems to be back.
I've attached a patch which sets the maxlength to 2048. I guess that will be large enough ;-)
Comment #10
rszrama CreditAttribution: rszrama commentedhah, too funny. Thanks for picking up on that. : )
Comment #11
MickL CreditAttribution: MickL commentedsuddenly when editing the node (image) : Product Reference cannot be longer than 128 characters but is currently 208 characters long.
thanks for the patch. is it in the latest dev release?
Comment #12
rszrama CreditAttribution: rszrama commentedYep.
Comment #13
MickL CreditAttribution: MickL commentedin my opinion this bug is very critical and you should release a 1.1.1
Comment #14
rszrama CreditAttribution: rszrama commentedYeah, it's pretty annoying. The current plan is to deliver 1.2 as a Christmas present, and in the meantime running on 1.x-dev will do no harm to your site.
Comment #15
MickL CreditAttribution: MickL commentedits not about me, its about all the others that a willing to use a nice 1.1 release :)
p.s. that sounds good! i wont tell anybody ;)
Comment #17
quantos CreditAttribution: quantos commentedHi guys. I can't see how this is fixed. On the latest version I'm using (Commerce 1.1) I'm still getting "Product cannot be longer than 128 characters" but more importantly I can imagine lots of scenarios where even 2048 characters could easily be exceeded.
I'm assuming we're all talking about the use of Bulk Product Creator which all on it's own creates super-long SKU's (just one of them). Take this example from an event hire company client of mine who supply custom furniture items, amongst all its full product spectrum, with five variable attributes including colour, width, depth, shape and fabric: that creates a single variable SKU of prod--White-L-shaped-6ft-6ft-Cotton (that's 39 characters). Get the Bulk Product Creator to generate all those babies x six colour variations, five fabric cover types and 3 variations each of width, depth and shape and you end up with a colossal number of characters in the vicinity 31,590 characters for the field (810 SKU's x 39 characters)!
Unfortunately I'm only a front-end designer so wouldn't be able to tell you guys - but surely that's a colossal number of SKUs for the system to juggling irrespective of field length?
I've only just started with Commerce too so I may be barking entirely up the wrong tree with this - and please tell me if so - but there are surely two very awkward non-technical issues directly connected to this scenario:
1. How are we (let alone the end-client) supposed to be able to find any one of these 810 SKU's (loaded into a single field) to edit or delete any one of them?
2. Similarly, navigating View Products to find a single SKU to edit is also nigh-on impossible with just this single product item (with 810 SKU's) loaded in there. I.E. Aside from the pagers on http://localhost/xxx/node#overlay=admin/commerce/products there is no way to quickly navigate, find, filter or search for any of them.
In respect to the last point even a fairly small commerce site with just 500 items, say, but with multiple attributes could easily generate 5,000+ SKUs and well in excess of 10,000 would seem possible.
Please tell me I've got all this wrong - and point me in the right direction if so - otherwise I'm not even sure which of these two items is the biggest problem - or if either of them are viable?
Help!
Comment #18
rszrama CreditAttribution: rszrama commentedNo worries, the 1.2 release that just got packaged up this evening incorporates the actual fix described above.
The product management woes you're experiencing go deeper than this particular issue, though, and are still a key point of focus for us. In short, you're exactly right - an autocomplete textfield is untenable for stores that fit your scenario. Some other system must be developed. My current approach is to embed a table in product display add / edit forms that allows you to create / manage products referenced by the node, but I'd like to see it expanded to incorporate the bulk product creation form so you can create and manage a group of products without having to deal with individual references at all.
This is still a work in progress area for Drupal Commerce, so the best I can do is assure you that we know it's a high priority item to fix... it just got eclipsed toward the end of last year by an equally high priority item (my work on Shipping 2.x / Flat Rate). With the 1.2 release out now, though, I'll be back to focusing on these issues.
Comment #19
quantos CreditAttribution: quantos commentedMany thanks for the reply/points rszrama and good luck with all the work. Commerce still looks like a great improvement on Ubercart, which wasn't so bad, and the Commerce project still looks full of potential. I'll certainly be using and will help if there's anything I can do. Thanks again.
Comment #20
rszrama CreditAttribution: rszrama commentedWill do our best not to let ya down! Keep an eye out for product management usability work and let us know how they work out for you. : )
Comment #21
killua99 CreditAttribution: killua99 commentedAnd what's going on with the SKU Pattern ? idk why but I can put more thant 3 tokens because its 128 max stuff limit .... I did a hook_form_commerce_product_ui_product_type_form_alter() ... '#maxlength' => 99999,