0

I'm creating a webshop with Drupal Commerce.

I have a product variation called T-shirt. It has three product attributes, color, size and print.

My problem

Let's say I need a T-shirt with 5 different colors, 5 different sizes and 5 different prints. Then I need to enter 125 product variations manually in the Admin UI.

What I need

I need to be able to automatically generate those product variations, since it takes extremely long time to create them manually.

It should be possible to enter the default price for all the variations.


Am I the only one who has had the need to do this? I feel like this should be possible, but I can't find any help on how to do it.

I found this thread, but it says that the functionality has been made in the Commerce Bulk module. I tried to install that module, but I can't find the option to bulk generate the product variations.

Have any of you tried this before, or know how to do it?

2
  • advice, make a module, hook_install make the product variations see stackoverflow.com/questions/39874672/… save your time – taggartJ Jan 2 '20 at 22:43
  • Thanks @TaggartJensen, but this should be a feature that I can use for future products too. It want to be able to generate the variations for all products, including new ones. – user72672 Jan 3 '20 at 11:12
1

Well, I did have a look around I could not get Commerce Bulk module to install. Then I saw https://www.drupal.org/project/commerce/issues/2755529, which will be a sweet feature when it has been merged. I could not get the patch to apply so I ended up creating a sandbox module based on this and here we go: https://www.drupal.org/sandbox/taggartj/3104497

Judging by your rank you will know how to get the code.

https://git.drupalcode.org/sandbox/taggartj-3104497/commit/7997ee4

This module will give you a route (no link yet):

You need to create at least one Product variation manually, then go to:

"/product/PRODUCTID/variations/VARIATIONID/bulk-generate"

or example /product/331/variations/1/bulk-generate, for it to allow you to bulk generate your variations.

enter image description here

6
  • Thanks for the module! I tried to install it, but have one question? Where do I get the variation ID for the route? It doesn't seem to work with the machine name. I think it would make sense to pass the machine name eg. default to generate all variations based on the default variation. – user72672 Jan 6 '20 at 11:07
  • I would also like to contribute to this module. My username is J_Drupal if you want to add me as a contributor! – user72672 Jan 6 '20 at 11:08
  • done added you. – taggartJ Jan 6 '20 at 22:26
  • Thanks, I’ll take a look at it tomorrow. – user72672 Jan 6 '20 at 22:26
  • Right now it seems like the module generates based on a variation Id and not a variation type is. Is that correct? – user72672 Jan 6 '20 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy