I'm trying to run SQL to update every product that is published in a particular category so that the status is 'draft' on a scheduled basis
the SQL commands between the BEGIN and END work on their own, but not as part of the event
DELIMITER $$
CREATE EVENT uncat_draft_60sec
ON SCHEDULE
EVERY 60 seconds
DO
BEGIN
UPDATE wp_posts p
JOIN wp_term_relationships r on p.id=r.object_id
SET p.post_status='draft'
WHERE r.term_taxonomy_id in (18);
END;
$$;
EVENTS are on,
What I'm trying to achieve is to fix an issue with Lightspeed x-series and Woo commerce integration where Lightspeed publishes everything you push, and as categories aren't synced between the two they end up uncategorised. This is a nightmare if you are adding products at volume, only half the data you want to publish comes through from Lightspeed, the rest needs to be added and categorised later prior to publishing. I'm open to other solutions if anyone has ideas.