• Resolved gamethrall

    (@gamethrall)


    Is there a way to set the default product Condition rather than having to go into each and every product to set it?

    We only sell New products and it’s a lot of work to go into 2800+ products one by one to set the Conditions of each one.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Christian

    (@christian1983)

    Hey @gamethrall

    Hope you are doing well!

    right now there is no way to do bulk edit for those fields. But you can add that idea here so it gains popularity: https://ideas.woocommerce.com/forums/133476-woocommerce?category_id=412041

    Best,
    Christian

    Thread Starter gamethrall

    (@gamethrall)

    I have done that.

    Could you tell me what table the Condition is in?

    Plugin Support Christian

    (@christian1983)

    Hey @gamethrall

    Hope you are doing well!

    The meta_key is on the wp_postmeta table for each product. when you install the plugin this meta still not added. so you need to add them not update them.

    for condition the meta_key on wp_postmeta is “_wc_pinterest_condition”
    for google category is “_wc_pinterest_google_product_category”.

    Let me know.

    Best,
    Christian

    Thread Starter gamethrall

    (@gamethrall)

    Great, that’ll do in interim! Thanks!

    I solved it with the following query:

    For products:
    INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT id, "_wc_pinterest_condition", "new" FROM wp_posts WHERE post_type="product" AND post_status="publish" AND NOT EXISTS (SELECT 1 FROM wp_postmeta WHERE meta_key="_wc_pinterest_condition" AND wp_posts.ID = wp_postmeta.post_id);

    For variations:
    INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT id, "_wc_pinterest_condition", "new" FROM wp_posts WHERE post_type="product_variation" AND post_status="publish" AND NOT EXISTS (SELECT 1 FROM wp_postmeta WHERE meta_key="_wc_pinterest_condition" AND wp_posts.ID = wp_postmeta.post_id);

    Explaination:

    • INSERT INTO wp_postmeta (post_id, meta_key, meta_value) Insert values into wp_postmeta table with the following fields: post_id, meta_key, meta_value
    • SELECT id, "_wc_pinterest_condition", "new" FROM wp_posts Use the id from the wp_posts table, as well as two constants (“_wc_pinterest_condition” for meta_key and “new” for meta_value)
    • WHERE post_type="product" AND post_status="publish" only for products (not the variations in this example) and the ones, that are published (not trashed, draft, etc)
    • AND NOT EXISTS (SELECT 1 FROM wp_postmeta WHERE meta_key="_wc_pinterest_condition" AND wp_posts.ID = wp_postmeta.post_id); and where there is not already a condition set for this product (would result in a double key)

    Probably there are “better” ways like replace or on duplicate, but this also works ??

    Hope that helps.

    FYI I did something similar with Google Product categories:

    1. Exported wp_posts for published products and variations (id, post_title)
    2. Filled out in Excel Spreadsheet all the Google Categories
    3. Removed post_title column (was just for easy editing), Exported that into a text file
    4. Regex Replace to create statements “INSERT INTO …”
    5. Exectuted those thousands of queries
    Plugin Support Christian

    (@christian1983)

    Hey @ataub2qf ,

    Thanks for you help!

    I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Best,
    Christian

    Thread Starter gamethrall

    (@gamethrall)

    Thank you, @ataub2qf! That saved me a BUNCH of time, especially on variations.

    I’ll have to do the same thing for Google Products sometime soon myself. *sigh*

    Great solution @ataub2qf ??

    Another way to do it, which a client of mine uses quite a bit for other mass metadata, is doing a products export CSV with product and variation IDs then adding the meta column “_wc_pinterest_condition” to the spreadsheet file with value “new”, saving as CSV and uploading it under Products > Import checking “Update existing products” option. That seems a bit less risky but will take longer to run. CSV files with variations can be tricky to follow. I recommend more narrow files with just one or two columns of data being updated at a time.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Way to set default product Condition?’ is closed to new replies.