Hi, This is the error I get when I try to add many products to a single product kit. Is there a limit, i may have to add more than a 100..

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'model' at row 1: UPDATE {uc_products} SET model=:db_update_placeholder_0, list_price=:db_update_placeholder_1, cost=:db_update_placeholder_2, sell_price=:db_update_placeholder_3, weight=:db_update_placeholder_4, weight_units=:db_update_placeholder_5, default_qty=:db_update_placeholder_6, ordering=:db_update_placeholder_7, shippable=:db_update_placeholder_8 WHERE ( (vid = :db_condition_placeholder_0) ); Array ( [:db_update_placeholder_0] => FRE-004AR / FRE-004CR / FRE-004GE / FRE-004LA / FRE-004MO / FRE-004SA / FRE-007AR / FRE-007CR / FRE-007GE / FRE-007MO / FRE006-AR / FRE-006CR / FRE-006GE / FRE-006MO / FRE-008AR / FRE-008CR / FRE-008GE / FRE-008MO / FRE-005AR / FRE-005CR / FRE-005GE / FRE-005MO [:db_update_placeholder_1] => 892 [:db_update_placeholder_2] => 0 [:db_update_placeholder_3] => 892 [:db_update_placeholder_4] => 0 [:db_update_placeholder_5] => lb [:db_update_placeholder_6] => 1 [:db_update_placeholder_7] => 0 [:db_update_placeholder_8] => 1 [:db_condition_placeholder_0] => 284 ) in uc_product_kit_update() (line 342 of /home/mercato7/public_html/dev/sites/all/modules/ubercart/uc_product_kit/uc_product_kit.module).

Thanks!
Jaya

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR’s picture

The model (SKU) of the product kit is automatically set to be a concatenation of the individual product models for the products in the kit. In your case, the resulting model exceeds 256 characters (the maximum allowed length of a model), which is why you see an error.

I suppose we should find a better way of automatically generating a product kit model. Just truncating it at 256 isn't sufficient because that might lead to multiple kits with the same model. Changing the size of this database field is the wrong thing to do, that just moves the point where the error occurs, and 256 is already quite large enough to hold single product models. A hash could be used; those typically aren't very "readable", however this may be the best way to go about it. Maybe the kit model should be this string "KIT" with a 32 character hash code appended?

j4’s picture

Maybe I should also point out that while the error appears, the products do get added to the kit. Am afraid am a novice, so wouldnt know about changing kit model to string KIT with a hash. Would you be able to upload a patch and I could test it out?

Thanks for the fast reply!
Jaya

TR’s picture

If you're willing to ignore the error, which should appear only when you create the product kit, then everything from then on should work correctly. The product kit model number gets truncated, which is not ideal, but will work.

longwave’s picture

Title: PDO Exception » Data too long for column 'model' when creating kit with many products
j4’s picture

Status: Active » Fixed

Thank you. That will work for now.

Jaya

TR’s picture

Status: Fixed » Active

Let's leave this open until we have a fix that eliminates the error.

j4’s picture

Hi Just wanted to add that sometimes, I am having to add the products in batches of 3-4, and sometimes, even then go through the process 3-4 times before it accepts it.

Thanks

longwave’s picture

We could just add an SKU field for kits, so the user can specify one. Not sure if or how kits work together with stock tracking, we could perhaps make the SKU field optional if kits don't really need SKUs at all - surely the individual products in the kit should be the stock-keeping units.

j4’s picture

Thank you Longwave and TR for taking the time with this. Actually while I continue to upload I find that I am actually not able to go beyond a number and as usual the error appears but no products get added. So this has become a priority issue with me as my site goes live in about 2 days. Is there anyway I can help with any patch that could make the product kit SKU not mandatory as in my site, we sell only individual products. We only use the product kit to assemble them together.

Thanks again!
Jaya

j4’s picture

chellman’s picture

I have a site that's being affected by this issue as well.

I feel like using a hash for the model makes sense, or maybe making the model optional so kits don't need it, since stock would be tracked on the individual products that make up the kit. Either that, or expose the SKU on node edit forms so we can set one that won't run up against this error.

chellman’s picture

Issue summary: View changes
FileSize
1.83 KB

All right, for my purposes, a simple solution of hard-coding the SKUs to "kit+nid" is good enough. In case that ends up being useful, here's a patch.

chellman’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 12: smaller_kit_skus-2006180-12.patch, failed testing.

hanoii’s picture

Version: 7.x-3.3 » 7.x-3.x-dev
Priority: Normal » Major
Status: Needs work » Needs review
FileSize
2.49 KB

Unbelievable something like this was not fixed since then, it's very likely that product kits is the least used feature in ubercart :), although I used it a bit and this issue has just showed up in one of our clients.

Attached is a patch that does pretty much what @longwave suggested in #8, however, I didn't made SKU optional as that assumption could possible do more harm in how ubercart works internally. Instead I am simply making SKU required as per a normal product. It's really the most sensible fix for something like this, and won't change current product kits models.

Status: Needs review » Needs work

The last submitted patch, 15: ubercart-product_kit_sku-2006180-15.patch, failed testing.

hanoii’s picture

Status: Needs work » Needs review
FileSize
4.15 KB

Fixing tests, I think the taxonomy ones are unrelated to this issue.

Status: Needs review » Needs work

The last submitted patch, 17: ubercart-product_kit_sku-2006180-17.patch, failed testing.

hanoii’s picture

ok, only this taxonomy test failing which is likely a work in progress of some other issue.

TR’s picture

The test failure was due to a disruptive Drupal core commit that broke the test. I fixed the test in #2746103: D7.50 change breaks test.

TR’s picture

Status: Needs work » Needs review
1computerninja’s picture

Ubercart 8.x

CLI postgre db fix: "alter table uc_products alter model type varchar(255);" resolved the issue for me.
I would assume a mysql db would resolve in a similar way.

Is there anyone working on getting the additional field length put into the next Ubercart update?

TR’s picture

@1computerninja: Please read the issue. Increasing the length of the model field is NOT a solution here, and this issue has nothing to do with whether you use PostgreSQL or MySql. In fact, in 7.x-3.x the model length WAS 255, and yet we still had this issue. In 8.x-4.x the length was deliberately reduced to 40 characters, which exacerbates this issue but doesn't affect the possible solution which was suggested by @longwave in #8 with a patch provided by @hanoii in #17. To help, you can test the patch from #17 for 7.x-3.x, or port that patch to 8.x-4.x and post it here for consideration.