Untitled

mail@pastecode.io avatarunknown
plain_text
a month ago
711 B
9
Indexable
Never
-- Update product type to 'simple' for variable products
UPDATE wp_posts
SET post_type = 'product_simple'
WHERE post_type = 'product_variation';

-- Delete variation data from wp_postmeta
DELETE pm
FROM wp_postmeta pm
JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.post_type = 'product_variation';

-- Update product type in wp_postmeta
UPDATE wp_postmeta
SET meta_value = 'simple'
WHERE meta_key = '_product_type'
  AND meta_value = 'variable';

-- Update product type in wp_term_relationships
UPDATE wp_term_relationships
SET term_taxonomy_id = (SELECT term_id FROM wp_terms WHERE name = 'simple')
WHERE object_id IN (
    SELECT ID
    FROM wp_posts
    WHERE post_type = 'product'
);