• Resolved markussss

    (@markussss)


    Hi,

    I am dealing with export/import – specifically with WP All Export Import but that should not matter – and I am confused when it comes to the SKU field.

    I learned that custom fields with _underscore should be hidden from the wp-admin.
    As I can see and edit the SKU in WoocCommerce, that would mean the SKU is stored in the sku field.

    However, when I look up the DB, I can’t find an sku fiel but only an _sku field.

    When I run an import, I must match the SKU to the _sku field, otherwise it won’t show in wp-admin.

    So what for is the sku field then?

    Can you please explain the difference?

    Thanks a lot!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @markussss,

    SKU is located in the database table wp_postmeta, where meta_key = '_sku'. Since WP All Import is not supported on this forum it’s best to reach out to the plugin developers for further assistance with this.

    While we’re experts on our own products, third-party plugins are best supported by their own authors/developers.

    If you use the default Product CSV Importer and Exporter tool you will notice that it uses the ID and/or SKU to auto-match and auto-update whatever information you enter on each line getting the source from the database.

    It maps the field SKU of the CSV Column Name in the CSV file. There is more information on the Product CSV Import Schema page:

    https://github.com/woocommerce/woocommerce/wiki/Product-CSV-Import-Schema#csv-columns-and-formatting

    Best regards.

    Thread Starter markussss

    (@markussss)

    Hi Mirko,

    it actually is not about the WP All Import plugin in this case. I just mentioned it for context.

    Isn’t it true that custom fields or meta_key are named with a preceding _ underscore to not show them in wp-admin?

    If SKU is stored in _sku then I wonder why it shows in the wp-admin in WooCommerce?

    Is there a field sku as well in the database or was this my mistake (or a mistake by the 3rd party plugin) and that field does not even exist?

    To me, it looked like there is sku and _sku and I could not tell what is the difference between those two.

    best regards

    Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    Hi @markussss,

    I’m not sure what exactly you’re asking here.

    Is there a field sku as well in the database or was this my mistake (or a mistake by the 3rd party plugin) and that field does not even exist?

    As @rainfallnixfig already mentioned, product SKUs are stored in the wp_postmeta tables where the meta_key = _sku.

    Isn’t it true that custom fields or meta_key are named with a preceding _ underscore to not show them in wp-admin?

    The point of custom fields is NOT to hide something from WP-Admin. Instead, they are used to add additional information to your post or page and a WooCommerce Product is essentially a custom post type.

    You can take a look at this primer about Custom Fields – https://www.wpbeginner.com/wp-tutorials/wordpress-custom-fields-101-tips-tricks-and-hacks/

    If SKU is stored in _sku then I wonder why it shows in the wp-admin in WooCommerce?

    It seems that this question arises for you because your understanding of custom fields is premised on a wrongful assumption.

    To me, it looked like there is sku and _sku and I could not tell what is the difference between those two.

    There’s an sku field in the wp_wc_product_meta_lookup table, but that’s not where you’re importing data to when you import a product. As the name implies, this is a lookup table that indexes order metadata to speed up requests.

    TL;DR

    You’re supposed to match your SKU to the _sku filed when you run an import.

    If you follow @rainfallnixfig’s advice above, you don’t need to do anything extraordinary. If you’re having trouble with a 3rd part plugin like WP All Import, I’d recommend reaching out to the developers of that plugin for assistance.

    Thread Starter markussss

    (@markussss)

    Thanks for further clarifying. I did import data on my second attempt to the _sku field. It worked out just perfectly fine.

    I hope I did not mess up anything as in my first attempt I tried to import to sku instead.

    Hi @markussss

    Good to know it worked perfectly fine this time.

    I’m going to mark this thread as resolved.

    Please feel free to open a new thread if you have any other questions.

    Cheers

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘sku vs. _sku field – which one is it?’ is closed to new replies.