Automattic\WooCommerce\Blocks\AIContent
UpdateProducts::fetch_product_ids()
Return all existing products that have the _headstart_post meta assigned to them.
Method of the class: UpdateProducts{}
No Hooks.
Return
Array|null
.
Usage
$UpdateProducts = new UpdateProducts(); $UpdateProducts->fetch_product_ids( $type );
- $type(string)
- The type of products to fetch.
Default: 'user_created'
UpdateProducts::fetch_product_ids() UpdateProducts::fetch product ids code WC 9.8.1
public function fetch_product_ids( string $type = 'user_created' ) { global $wpdb; if ( 'user_created' === $type ) { return $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE ID NOT IN ( SELECT p.ID FROM {$wpdb->posts} p JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id WHERE pm.meta_key = %s AND p.post_type = 'product' AND p.post_status = 'publish' ) AND post_type = 'product' AND post_status = 'publish' LIMIT 6", '_headstart_post' ) ); } return $wpdb->get_results( $wpdb->prepare( "SELECT p.ID FROM {$wpdb->posts} p JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id WHERE pm.meta_key = %s AND p.post_type = 'product' AND p.post_status = 'publish'", '_headstart_post' ) ); }