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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

c600g’s picture

My 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.

c600g’s picture

Just 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.

amateescu’s picture

I think that

unset($element['#maxlength']);

is a better option.

rszrama’s picture

Where 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.

c600g’s picture

Just 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.

c600g’s picture

I just checked the taxonomy module to see how it defines it's auto-complete text fields, and it sets a #maxlength of 1024.

rszrama’s picture

Status: Active » Fixed

Works for me. Just committed this change.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jeff.maes’s picture

Category: feature » bug
Status: Closed (fixed) » Needs review
FileSize
812 bytes

The 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 ;-)

rszrama’s picture

Category: bug » feature
Status: Needs review » Fixed

hah, too funny. Thanks for picking up on that. : )

MickL’s picture

suddenly 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?

rszrama’s picture

Yep.

MickL’s picture

in my opinion this bug is very critical and you should release a 1.1.1

rszrama’s picture

Yeah, 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.

MickL’s picture

its 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 ;)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

quantos’s picture

Version: 7.x-1.x-dev » 7.x-1.1
Category: feature » bug
Priority: Normal » Major
Status: Closed (fixed) » Needs review

Hi 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!

rszrama’s picture

Status: Needs review » Closed (fixed)

No 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.

quantos’s picture

Many 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.

rszrama’s picture

Will 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. : )

killua99’s picture

And 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,