Support » Plugin: WooCommerce » Woocommerce 3.6.1 Breaks wc_get_product_id_by_sku

  • Resolved dpitzer

    (@dpitzer)


    The latest release has broken the call wc_get_product_id_by_sku.

    I have had to go back and use SELECT post_id FROM $wpdb->postmeta WHERE meta_key=’_sku’ AND meta_value=’%s’ LIMIT 1 method.

Viewing 15 replies - 1 through 15 (of 24 total)
  • Soft79

    (@josk79)

    Did the DB upgrade to 3.6 execute succesfully?

    dpitzer

    (@dpitzer)

    Yes. It reported it did. I also took 3.6.1 with no problems.

    Soft79

    (@josk79)

    Can you please paste your WC System Status report?

    dpitzer

    (@dpitzer)

    I would need a secure place to put that. They contain too much information about the system and DB.

    Soft79

    (@josk79)

    Otherwise, what does the ‘Scheduled Actions’ tab say? Did all wc_update_product_lookup_tables_column actions complete?

    dpitzer

    (@dpitzer)

    All completed 721. Only pending is woocommerce_update_marketplace_suggestions

    Soft79

    (@josk79)

    Hmm… strange. Can’t test myself now, I’m on mobile.

    dpitzer

    (@dpitzer)

    Ok no problem. I’m still looking at it. I only upgrade our development server so the our live site is still good. One thing that I am thinking it might be is the dev server runs PHP 7.3

    Plugin Author Mike Jolley

    (@mikejolley)

    wc_get_product_id_by_sku has passing unit tests so I don’t think it’s broken.

    
    SELECT posts.ID
    				FROM {$wpdb->posts} as posts
    				INNER JOIN {$wpdb->wc_product_meta_lookup} AS lookup ON posts.ID = lookup.product_id
    				WHERE
    				posts.post_type IN ( 'product', 'product_variation' )
    				AND posts.post_status != 'trash'
    				AND lookup.sku = %s
    				LIMIT 1
    

    Thats the query it uses. Perhaps the lookup table was not generated successfully. You can build it again from WC > Status > Tools > Regenerate.

    • This reply was modified 4 months ago by  Mike Jolley.
    dpitzer

    (@dpitzer)

    This did correct the issue, thank you Mike!

    dpitzer

    (@dpitzer)

    I was wrong it only correct some items, half of our products fail the look up.

    Plugin Author peterfabian1000

    (@peterfabian1000)

    Hi @dpitzer
    you can check and execute pending/see failed tasks from WooCommerce > Status > Scheduled Actions. Can you please check over there if there is anything still pending/failed?
    Do you see any log messages in the WooCommerce > Status > Logs?

    Hi have same issue,
    WooCommerce > Status > Logs empty
    Status report is ok no problems
    “woocommerce_update_marketplace_suggestions is pending”

    Search not working by sku

    Any suggestions?

    • This reply was modified 3 months, 3 weeks ago by  jura99.
    Dom F

    (@britbikerider)

    @peterfabian1000 After updating to 3.6.1. I have lost my lookup tables as well, regenerating them through WooCommerce > Tools > Regenerate Lookup tables does not work.
    Checking WooCommerce > Scheduled Actions all the table are showing regenerated but wc_product_meta_lookup is coming up as missing. I’m unable to search parts in the admin backend. I tried Rolling back to 3.6 with no luck

    Plugin Author peterfabian1000

    (@peterfabian1000)

    @britbikerider if the wc_product_meta_lookup is missing, can you please try to Deactivate WooCommerce and Activate it again? That should trigger the db delta procedure that creates tables.

    @jura99 Can you please check in your SQL database (e.g. via phpMyAdmin) if table wc_product_meta_lookup is populated?

Viewing 15 replies - 1 through 15 (of 24 total)
  • You must be logged in to reply to this topic.