• Resolved hommealone

    (@hommealone)


    Can anyone suggest ways to batch alter all of the SKU numbers on all of the products in the WooCommerce database?

    We need to add a suffix to EVERY SKU number (or it it is much easier or the only option, a pre-fix would work too.) Far example, change:

    1111 into 1111-sp
    1112 into 1112-sp
    12345 into 12345-sp
    etc.

    Background if this is helpful:
    We have a distributor’s website with an extensive product catalog of products. We are setting up a new website for a new division of theirs which will contain largely the same catalog of items. We plan to import the products database from the existing website into the new site. We plan to rewrite the product descriptions to help avoid search engine duplicate content penalties. Then we need to modify the SKU numbers.

    Most of the products are “variable” products with the SKU numbers entered into the variations.

    We can do this via phpMyAdmin, or by using a WP search-and-replace plugin like Better Search and Replace.

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • update wp_postmeta set meta_value = CONCAT(meta_value,'-sp') where meta_key = '_sku';

    Please do database backup before it.

    Thread Starter hommealone

    (@hommealone)

    @kursora:
    Thanks, this looks like an elegant and simple solution. I’m afraid however, that you are over-estimating my level of knowledge and perhaps abilities.

    Have you provided a command line MySQL command – which I don’t know how to use? Or is this something else; something I could implement with php perhaps? Where/how would I implement this? Can I implement this using phpMyAdmin – SQL tab – Run SQL query/queries on database? (I think I could handle that.)

    @kursora has given a MySQL command which you can run at:
    phpMyAdmin > find-your-database > find the wp_postmeta table > SQL tab > paste the query and click Go

    You could use php but you would need several lines of code as well, or there is a plugin:
    https://wordpress.org/plugins/admin-bar-queries/
    but using phpMyAdmin if you can is the most straightforward way.

    Thread Starter hommealone

    (@hommealone)

    Thank you both! Glad to have confirmation on how to apply that using phpMyAdmin. I really appreciate the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to batch alter SKU numbers?’ is closed to new replies.