I have a variation creation form with a size taxonomy. And instead of having a fixed selection list for terms, I allow the administrator to add new terms as the comes in. For this I am using the Autocomplete term widget and the user just write a new term name. This has a small bug. That the line items is not displayed correctly if added to cart. But if variation is deleted and recreated with same term it works.
Steps for reproduce:
- Install Commerce Kickstart 1.6
- Install Inline Entity Form 7.x-1.x-dev (2012-Apr-25)
- Add vocabulary Size.
- Add termreference to Size for Product. (Product type)
- Use widget Autocomplete term widget
- Use Size vocabulary
- Enable this field to function as an attribute field on Add to Cart forms
- Attribute selection widget: Select list
- Change widget type for Product-field for the Product Display
- To "Inline entity form"
- Edit "Product One"
- Add variation
- Set Size to "Large"
- Set SKU to "LargeTshirt"
- Set Price to "10" USD
- Skip image
- Save "Product One"
- Add Large variation to cart
In Shopping cart block the title is now "Product One ()". Should be "Product One(Large)".
- Now edit "Product One"
- Delete the Large variation.
- Recreate Variation
- Set Size to the already existing size "Large"
- Set SKU to "LargeTshirt2"
- Set Pric to "10" USD"
- Skip image
- Save "Product One"
- Add Large variation to cart
Now the shopping cart block has the correct line item displayed with "Product One (Large)".
So there is a bug when creating new taxonomy term for product. But reusing existing terms works.
Comment | File | Size | Author |
---|---|---|---|
#17 | inline_entity_form-1559968-17.patch | 1.26 KB | yingtho |
#14 | term_attribute_product_title-1559968-14.patch | 1.19 KB | vasike |
#10 | inline_entity_form-1559968-10.patch | 1.29 KB | akalata |
#7 | inline_entity_form-1559968-7.patch | 1.23 KB | star-szr |
#7 | interdiff.txt | 1.32 KB | star-szr |
Comments
Comment #1
wesleydv CreditAttribution: wesleydv commentedI have found myself in the same situation and can confirm that this is indeed a bug.
I attached a patch solving this issue but I'm not sure if it is most efficient/secure way to do it.
It also adds support for empty attributes (eg. not required attributes).
Comment #2
rupertj CreditAttribution: rupertj commentedwesleydv's patch fixes the Issues I've been having with non-required fields, and products showing up with titles like Product (Small, , ).
Here's a re-roll against current -dev.
Comment #3
kristofferwiklund CreditAttribution: kristofferwiklund commentedIt works nice.
Thanks
Comment #4
bojanz CreditAttribution: bojanz commentedNeeds to be rerolled against latest -dev, no longer applies.
Comment #5
christosku CreditAttribution: christosku commentedA reroll against current -dev.
Comment #6
star-szrThanks for the reroll, @christosku!
I don't think this patch will get committed with
'und'
, and probably not withLANGUAGE_NONE
, either. Is it possible to refactor this to use the Entity API metadata wrapper instead, ala$wrapper->{$field_name}->value()
?Minor: the closing bracket for the if statement needs to be indented by one space.
Comment #7
star-szrThe filtering for empty attributes can cause errors if all attributes are empty:
If we check (!empty($attribute_values)) that should do the trick, and then we don't end up with Product ().
Here's a new patch which fixes the indentation, replaces
'und'
withLANGUAGE_NONE
, and doesn't run aforeach()
for each taxonomy field. I'm not sure if we need to check for tid anymore, especially if we know the field belongs to the taxonomy module.I did try to get the taxonomy term information via the Entity API, but came up empty, perhaps because the term hasn't been saved yet.
One remaining issue is that if multiple taxonomy terms are added to one taxonomy field, only the first term will be displayed.
Comment #8
UrmasZ CreditAttribution: UrmasZ commentedFor me last patch(#7) is working. Thanks. :)
Comment #9
akalata CreditAttribution: akalata commentedWith #7, I still get the '()' even when there should be one out of two attributes listed. I'm going to play with it today, but in case I get distracted I'm also getting this error message after saving the product:
Notice: Undefined index: name in CommerceProductInlineEntityFormController->save() (line 383 of ... inline_entity_form/includes/commerce_product.inline_entity_form.inc).
Comment #10
akalata CreditAttribution: akalata commentedMy taxonomy field was only saving the tid, so I had to use taxonomy_term_load to get the name.
Comment #11
akalata CreditAttribution: akalata commentedI also created a separate issue for updating existing products whose titles have already been saved: #1811390: Batch update existing product titles autogenerated by Inline_Entity_Form.
Comment #12
GuyPaddock CreditAttribution: GuyPaddock commentedAfter applying #10, I'm still not getting taxonomy-driven attributes in the titles.
I have 1 required taxonomy attribute, and 3 optional. Perhaps this is the issue?
Comment #13
kristofferwiklund CreditAttribution: kristofferwiklund commentedPatch is not applying. And manual apply changes is not working either.
Comment #14
vasikeso the issue here was about the new product attribute terms using autocomplete widget for taxonomy term fields.
it seems the previous patches provided or a solution only for this case (new term) or for the existing term (already working).
here is patch that should help to add the new and old terms attributes to product title.
i'm not sure about the language key (LANGUAGE_NONE) used for this.
it seems this autocomplete widget for taxonomy term reference fields brings some issues in IEF.
there's another one : #1723864: Term multiplication for new Term values added for Term fields with autocomplete widget on multiple references fields.
Comment #15
kingfisher64 CreditAttribution: kingfisher64 commentedI'm getting these output when I try to add a product. What can be done to get rid of these notices? Many thanks
Comment #16
kingfisher64 CreditAttribution: kingfisher64 commentedUpdate - setting sku to non auto generated appears to output these messages. However changing the setting back to auto sku doesn't fix it. Only a db restore did in this case?
Comment #17
yingtho CreditAttribution: yingtho as a volunteer commentedHere is a patch for the undefined index sku/status.
Comment #19
oncreative CreditAttribution: oncreative commentedAny progress on this? I'm having this issue and have done a DB restore but has not fixed this.