79114885

Date: 2024-10-22 15:49:50
Score: 1
Natty:
Report link

My problem was briefly the same -hundreds of products, which numbers are continuously increasing- and didn't find any feasable code based solution, also Woocommerce documentation looks intentionally outdated.

Long story short: Use built-in WooCommerce Product CSV Importer and Exporter tool to achieve this goal. Makes things way simpler and faster in the long run. Although Woocommerce states the following:

In the long term, this extension will be phased out... source

Would be logical to just refer to variation id, when it comes to selecting the default one for each product, right? For some reason it was implemented differently...

I'll guide you through an example, which already includes some variable products and their variations. Here's an example

  1. Export your products or create a CSV UTF-8 sheet based on parameters available in Woocommerce documentation. Here

  2. Add the following columns with their respective number as:

Attribute 1 default Attribute 2 default
  1. Choose the desired attribute value and insert it under the corresponding column. Eg.: Attribute 1 value has: S, M, L and you'd like to have the default variation size as M, then put M here.

Attribute related header titles in order in this example:

Type SKU Name Visibility in catalogue Tax class In stock? Stock Regular price Parent Attribute 1 name Attribute 1 value(s) Attribute 1 visible Attribute 1 global Attribute 1 default Attribute 2 name Attribute 2 value(s) Attribute 2 visible Attribute 2 global Attribute 2 default

Since it's a plain text database, you can let your excel skills push the limit of this method, and save load of time by using formulas, just like me or even better: scripting the whole process.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: David Beszeda