Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The included patch adds support for SKU field variation in its own edit form.
Comment | File | Size | Author |
---|---|---|---|
#19 | 3004550-19-support-single-variation-widget.patch | 7 KB | jwwj |
#18 | 3004550-18-support-single-variation-widget.patch | 6.98 KB | jwwj |
#17 | 3004550-16-support-single-variation-widget.patch | 6.93 KB | jwwj |
#14 | interdiff-6-14.txt | 2.57 KB | megadesk3000 |
#14 | 3004550-14.patch | 6.38 KB | megadesk3000 |
Comments
Comment #2
lukasss CreditAttribution: lukasss commentedComment #3
lukasss CreditAttribution: lukasss commentedSmall UI improvement
Comment #4
lukasss CreditAttribution: lukasss commentedSorry! #3 not working
Here's a working patch #4
Comment #5
lukasss CreditAttribution: lukasss commentedYesterday released a release including this feature.
Any progress here.
Comment #6
flocondetoilePatch #4 works fine with Drupal commerce 2.10 :-)
Attached a slighty udpated patch
- use $form_state->getFormObject()->getEntity() instead of $form_state->getBuildInfo()['callback_object']->getEntity()
- improve the $required parameter in the autoSkuNeeded() method : $required = $this->hasAutoSku() && ($this->entity->getSku() == '%AutoSku%');
Without the second condition, then a SKU is always updated and so if you use token based on the current date, your SKU change everytime someone update a variation.
Improve the title too.
Comment #7
lukasss CreditAttribution: lukasss commented@flocondetoile, this look good!
Comment #8
zenimagine CreditAttribution: zenimagine commentedThank you, I applied the patch. It looks like it works, but I can not get the product ID and variation ID
[commerce_product_variation:product_id]-[commerce_product_variation:variation_id]
Comment #9
eldrupalista CreditAttribution: eldrupalista commentedIt works for me fine. Thanks!
Comment #10
lukasss CreditAttribution: lukasss commentedComment #11
themic8 CreditAttribution: themic8 at Trail 9 commentedPatch #6 does work.
Using commerce 2.11. and pulling the dev version of commerce_autosku
Comment #12
themic8 CreditAttribution: themic8 at Trail 9 commentedTested both options and autosku and tokens work with the patch #6.
My issue was that I was not using the dev version of commerce_autosku.
Note there is also not a way to use the dev version with composer. I had to pull the git repo.
Comment #13
goodDenis CreditAttribution: goodDenis as a volunteer commentedThanks for the patch it works great with checkbox 'Allow each product to have multiple variations.'
But It hides variation for the product with 'single variation', so I cannot set the price or other variations fields.
I use 'drupal/commerce:2.11.0'
Comment #14
megadesk3000 CreditAttribution: megadesk3000 at Unic commented@zenimagine i ran into the same issue.
In my opinion the problem is, that this information (variation_id) is not available in commerce_autosku_commerce_product_variation_presave, since a new variation does not have an id at this point.
Since the variation id seems to be something, that should be definitively supported in an autosku generation process, i would suggest to move the functionality to hook_ENTITY_TYPE_insert and hook_ENTITY_TYPE_update instead of hook_ENTITY_TYPE_presave.
What do others think about that ?
I created a patch for that against the latest version of the module.
Comment #15
goodDenis CreditAttribution: goodDenis as a volunteer commented@megadesk3000
Thanks! You patch works for me.
Comment #16
jwwj CreditAttribution: jwwj as a volunteer commentedThe patch in #14 works if using the form widget "Inline Entity form - simple", but does not work if using the "Single variation (product information)" form widget. My guess is it would only require a similar block of code in commerce_autosku.module as the code below
but I can't figure out what hook to use in order to get it to fire when using the Single variation widget. Any thoughts?
Comment #17
jwwj CreditAttribution: jwwj as a volunteer commentedThe patch in #14 works otherwise, but for me did not work when using products that only allow a single variation and use the Single variation form widget (commerce_product_single_variation). The attached patch should fix that, though I'm not sure it was the best way to fix the issue.
The patch includes the changes from #14, so it should be enough to just apply this patch to get all changes.
Comment #18
jwwj CreditAttribution: jwwj as a volunteer commentedAah snap, sorry! Managed to add a bug, ignore 3004550-16-*.patch. Use 3004550-18-*.patch instead
Comment #19
jwwj CreditAttribution: jwwj as a volunteer commentedAnd one more... very sorry for the multiple patches, my quality control has failed me today :(
But still, only the last patch (#19) should be needed...
Comment #20
hatuhay CreditAttribution: hatuhay commentedI can confirm patch worked for me, commerce 2.12
Comment #21
goodDenis CreditAttribution: goodDenis as a volunteer commentedIt works for me too, commerce 2.12
Thanks!
Comment #22
ohmdesbois CreditAttribution: ohmdesbois commentedIt seems that this is not the case with commerce 2.13
Comment #23
goodDenis CreditAttribution: goodDenis as a volunteer commentedYes, it looks like not working for a product with 'Allow each product to have multiple variations.'
I have a null value in the table commerce_product_variation_field_data 'sku' column after saving the product variation.
Comment #24
goodDenis CreditAttribution: goodDenis as a volunteer commentedThe patch doesn't work for me with "Automatically generate the SKU and hide the label field" option, on the "admin/commerce/config/product-variation-types/PRODUCT-TYPE/auto-sku" (maybe it is my local problem)
but it works with "Automatically generate the SKU if the SKU field is left empty"
tested with commerce 2.13.0
Comment #25
lukasss CreditAttribution: lukasss commentedComment #26
zserno CreditAttribution: zserno as a volunteer commentedPatch from #19 worked for me using Commerce 2.13. I can now use the 'Single Variation (Product information)' widget and leave the SKU field empty to get a generated SKU value.
(A fly in the ointment: on updating an existing product, I ran into this issue: #2974156: TypeError: Argument 1 passed to _editor_get_file_uuids_by_field() must implement interface Drupal\\Core\\Entity\\EntityInterface but patch #9 seems to be working.)
Comment #27
zenimagine CreditAttribution: zenimagine commentedThe last version of the module dates from 2017, now that Commerce is stable think you make an update and fix this problem ?
Comment #29
bojanz CreditAttribution: bojanz at Centarro commentedI have been given commit access, so I've gone ahead and committed #19 (plus a few tweaks), as well as all other patches in the queue. I've also created a -dev release for testing. I won't have time to do work of my own, but I'll commit whatever patch the community provides. Since the module is/was completely non-functional, we can't break it more than it already is.