Reputation: 13
I have a WooCommerce Shop with 850+ products that needs editing. Without having to purchase an Extended/Pro Plugin to mass edit these products... I am trying to do this through phpMyAdmin.
The site is a little bit of "Add to Cart" and "Ask for Quote", so we're using the RFQ Toolkit Plugin, to handle this. The BIG issue is where I need to Edit All 850+ Products by hand... in the Advanced Tab for each Product. :(
WooCommerce stores Product information in both the wp_posts and wp_postmeta tables, where WooCommerce Products have "product" listed for the post_type column. Products sold as "Ask for Quote" (because of the RFQ Tookit) have an entry in the wp_postmeta table of [meta_id, post_id, meta_key, meta_value]... where the meta_key is '_gpls_woo_rfq_rfq_enable', and the meta_value of 'yes'.
So, I'm trying to build an UPDATE query in English like this:
Search the wp_posts table for each Item with post_type 'product' and get the ID's (assuming it's the same as post_id in the wp_postmeta table).
Then, using those ID's, create an associated entry in wp_postmeta of [new meta_id, post_id or ID, _gpls_woo_rfq_rfq_enable, yes].
Does this EVEN make sense? If not, I apologize and will further my question with whatever information you need to reasonable answer this question. :)
Sincerely, Dennis Lambing / Agent CD
Upvotes: 1
Views: 548
Reputation: 13
Much thanks to Fernando M. for your excellent answer! :)
YES, this was exactly what I needed. You are great! :)
INSERT INTO wp_postmeta (
post_id,
meta_key,
meta_value
)
SELECT
ID,
'_gpls_woo_rfq_rfq_enable',
'yes'
FROM wp_posts
WHERE post_type = 'product'
Upvotes: 0
Reputation: 167
I understand that you are looking for inserting a new row on the wp_postmeta table (not updating an existing one) for each product, so maybe this is what you are looking for:
INSERT INTO wp_postmeta (
post_id,
meta_key,
meta_value
)
SELECT
ID,
'_gpls_woo_rfq_rfq_enable',
'yes'
FROM wp_posts
WHERE post_type = 'product'
This makes a new meta for each product with the meta key _gpls_woo_rfq_rfq_enable
and the value yes
Upvotes: 1