我需要做这样的事情。我不得不更新 110 种产品的价格。所有产品的尺寸都有变化,所有尺寸的价格都相同。这是我用来获取我需要在后端更改的所有字段的查询。我在网上搜索并搜索了名称中包含价格的所有元键。更新 SQL 后前端的价格没有变化。我发现,如果我对一种产品进行批量编辑(常规价格,因为这不适用于变动价格),那么所有价格都会反映数据库中的变化。奇怪的。也许是一个缓存的东西。
SELECT p.id, IF( p.post_parent =0, p.id, p.post_parent ) AS parent, p.post_type, p.post_title, m.meta_key, m.meta_value
FROM wp_posts p
INNER JOIN wp_postmeta m ON p.id = m.post_id
WHERE
(m.meta_key IN ('_price','_regular_price') AND p.post_type = 'product_variation') OR
(m.meta_key IN ('_max_variation_price','_min_variation_price','_max_variation_regular_price','_min_variation_regular_price') AND p.post_type = 'product')
ORDER BY parent