WooCommerce args (except 'return' and 'meta_query'). * @param int $limit Maximum number of results to retrieve or -1 for unlimited. * @param int $offset Amount to offset product results. * * @return WC_Product[] Array of WooCommerce product objects */ public function find_synced_products( array $args = [], int $limit = -1, int $offset = 0 ): array { $args['meta_query'] = $this->get_synced_products_meta_query(); return $this->find( $args, $limit, $offset ); } /** * Find and return an array of WooCommerce product IDs already submitted to Google Merchant Center. * * Note: Includes product variations. * * @param array $args Array of WooCommerce args (except 'return' and 'meta_query'). * @param int $limit Maximum number of results to retrieve or -1 for unlimited. * @param int $offset Amount to offset product results. * * @return int[] Array of WooCommerce product IDs */ public function find_synced_product_ids( array $args = [], int $limit = -1, int $offset = 0 ): array { $args['meta_query'] = $this->get_synced_products_meta_query(); return $this->find_ids( $args, $limit, $offset ); } /** * @return array */ protected function get_synced_products_meta_query(): array { return [ [ 'key' => ProductMetaHandler::KEY_GOOGLE_IDS, 'compare' => 'EXISTS', ], ]; } /** * Find and return an array of WooCommerce product objects ready to be submitted to Google Merchant Center. * * @param array $args Array of WooCommerce args (except 'return'), and product metadata. * @param int $limit Maximum number of results to retrieve or -1 for unlimited. * @param int $offset Amount to offset product results. * * @return FilteredProductList List of WooCommerce product objects after filtering. */ public function find_sync_ready_products( array $args = [], int $limit = - 1, int $offset = 0 ): FilteredProductList { $results = $this->find( $this->get_sync_ready_products_query_args( $args ), $limit, $offset ); return $this->product_filter->filter_sync_ready_products( $results ); } /** * Find and return an array of WooCommerce product ID's ready to be deleted from the Google Merchant Center. * * @since 1.12.0 * * @param int[] $ids Array of WooCommerce product IDs * @param int $limit Maximum number of results to retrieve or -1 for unlimited. * @param int $offset Amount to offset product results. * * @return array */ public function find_delete_product_ids( array $ids, int $limit = - 1, int $offset = 0 ): array { // Default status query args in WC_Product_Query plus status trash. $args = [ 'status' => [ 'draft', 'pending', 'private', 'publish', 'trash' ] ]; $results = $this->find_by_ids( $ids, $args, $limit, $offset ); return $this->product_filter->filter_products_for_delete( $results )->get_product_ids(); } /** * @return array */ protected function get_sync_ready_products_meta_query(): array { return [ 'relation' => 'OR', [ 'key' => ProductMetaHandler::KEY_VISIBILITY, 'compare' => 'NOT EXISTS', ], [ 'key' => ProductMetaHandler::KEY_VISIBILITY, 'compare' => '!=', 'value' => ChannelVisibility::DONT_SYNC_AND_SHOW, ], ]; } /** * @param array $args Array of WooCommerce args (except 'return'), and product metadata. * * @return array */ protected function get_sync_ready_products_query_args( array $args = [] ): array { $args['meta_query'] = $this->get_sync_ready_products_meta_query(); // don't include variable products in query $args['type'] = array_diff( ProductSyncer::get_supported_product_types(), [ 'variable' ] ); // only include published products if ( empty( $args['status'] ) ) { $args['status'] = [ 'publish' ]; } return $args; } /** * @return array */ protected function get_valid_products_meta_query(): array { return [ 'relation' => 'OR', [ 'key' => ProductMetaHandler::KEY_ERRORS, 'compare' => 'NOT EXISTS', ], [ 'key' => ProductMetaHandler::KEY_ERRORS, 'compare' => '=', 'value' => '', ], ]; } /** * Find and return an array of WooCommerce product IDs nearly expired and ready to be re-submitted to Google Merchant Center. * * @param int $limit Maximum number of results to retrieve or -1 for unlimited. * @param int $offset Amount to offset product results. * * @return int[] Array of WooCommerce product IDs */ public function find_expiring_product_ids( int $limit = - 1, int $offset = 0 ): array { $args['meta_query'] = [ 'relation' => 'AND', $this->get_sync_ready_products_meta_query(), $this->get_valid_products_meta_query(), [ [ 'key' => ProductMetaHandler::KEY_SYNCED_AT, 'compare' => '<', 'value' => strtotime( '-25 days' ), ], ], ]; return $this->find_ids( $args, $limit, $offset ); } /** * Find all simple and variable product IDs regardless of MC status or visibility. * * @since 2.6.4 * * @param int $limit Maximum number of results to retrieve or -1 for unlimited. * @param int $offset Amount to offset product results. * * @return int[] Array of WooCommerce product IDs */ public function find_all_product_ids( int $limit = -1, int $offset = 0 ): array { $args = [ 'status' => 'publish', 'return' => 'ids', 'type' => 'any', ]; return $this->find_ids( $args, $limit, $offset ); } /** * Returns an array of Google Product IDs associated with all synced WooCommerce products. * Note: excludes variable parent products as only the child variation products are actually synced * to Merchant Center * * @since 1.1.0 * * @return array Google Product IDS */ public function find_all_synced_google_ids(): array { // Don't include variable parent products as they aren't actually synced to Merchant Center. $args['type'] = array_diff( ProductSyncer::get_supported_product_types(), [ 'variable' ] ); $synced_product_ids = $this->find_synced_product_ids( $args ); $google_ids_meta_key = $this->prefix_meta_key( ProductMetaHandler::KEY_GOOGLE_IDS ); $synced_google_ids = []; foreach ( $synced_product_ids as $product_id ) { $meta_google_ids = get_post_meta( $product_id, $google_ids_meta_key, true ); if ( ! is_array( $meta_google_ids ) ) { do_action( 'woocommerce_gla_debug_message', sprintf( 'Invalid Google IDs retrieve for product %d', $product_id ), __METHOD__ ); continue; } $synced_google_ids = array_merge( $synced_google_ids, array_values( $meta_google_ids ) ); } return $synced_google_ids; } /** * Find and return an array of WooCommerce products based on the provided arguments. * * @param array $args Array of WooCommerce args (see below), and product metadata. * @param int $limit Maximum number of results to retrieve or -1 for unlimited. * @param int $offset Amount to offset product results. * * @link https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query * @see ProductMetaHandler::TYPES For the list of meta data that can be used as query arguments. * * @return WC_Product[]|int[] Array of WooCommerce product objects or IDs, depending on the 'return' argument. */ protected function execute_woocommerce_query( array $args = [], int $limit = -1, int $offset = 0 ): array { $args['limit'] = $limit; $args['offset'] = $offset; return wc_get_products( $this->prepare_query_args( $args ) ); } /** * @param array $args Array of WooCommerce args (except 'return'), and product metadata. * * @see execute_woocommerce_query For more information about the arguments. * * @return array */ protected function prepare_query_args( array $args = [] ): array { if ( empty( $args ) ) { return []; } if ( ! empty( $args['meta_query'] ) ) { $args['meta_query'] = $this->meta_handler->prefix_meta_query_keys( $args['meta_query'] ); } // only include supported product types if ( empty( $args['type'] ) ) { $args['type'] = ProductSyncer::get_supported_product_types(); } // It'll fetch all products with the post_type of 'product', excluding variations. if ( $args['type'] === 'any' ) { unset( $args['type'] ); } // use no ordering unless specified in arguments. overrides the default WooCommerce query args if ( empty( $args['orderby'] ) ) { $args['orderby'] = 'none'; } $args = apply_filters( 'woocommerce_gla_product_query_args', $args ); return $args; } }
Warning: class_implements(): Class Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductRepository does not exist and could not be loaded in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 73

Warning: foreach() argument must be of type array|object, bool given in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 73

Fatal error: Uncaught Error: Class "Automattic\WooCommerce\GoogleListingsAndAds\DB\Table" not found in /htdocs/wp-content/plugins/google-listings-and-ads/src/DB/Table/AttributeMappingRulesTable.php:15 Stack trace: #0 /htdocs/wp-content/plugins/jetpack/vendor/jetpack-autoloader/class-php-autoloader.php(90): require() #1 [internal function]: Automattic\Jetpack\Autoloader\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackā“„13_5\al3_0_8\PHP_Autoloader::load_class('Automattic\\WooC...') #2 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/Definition.php(211): class_exists('Automattic\\WooC...') #3 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/DefinitionAggregate.php(106): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolve(false) #4 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(162): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\DefinitionAggregate->resolveTagged('db_table', false) #5 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(178): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->get('db_table', false) #6 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Argument/ArgumentResolverTrait.php(45): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->get('db_table') #7 [internal function]: Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Argument\{closure}('db_table') #8 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Argument/ArgumentResolverTrait.php(19): array_map(Object(Closure), Array) #9 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/Definition.php(253): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolveArguments(Array) #10 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/Definition.php(212): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolveClass('Automattic\\WooC...') #11 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/DefinitionAggregate.php(94): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolve(false) #12 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(157): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\DefinitionAggregate->resolve('Automattic\\WooC...', false) #13 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Argument/ArgumentResolverTrait.php(45): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->get('Automattic\\WooC...') #14 [internal function]: Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Argument\{closure}('Automattic\\WooC...') #15 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Argument/ArgumentResolverTrait.php(19): array_map(Object(Closure), Array) #16 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/Definition.php(253): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolveArguments(Array) #17 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/Definition.php(212): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolveClass('Automattic\\WooC...') #18 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/DefinitionAggregate.php(106): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolve(false) #19 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(162): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\DefinitionAggregate->resolveTagged('Automattic\\WooC...', false) #20 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Argument/ArgumentResolverTrait.php(45): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->get('Automattic\\WooC...') #21 [internal function]: Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Argument\{closure}('Automattic\\WooC...') #22 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Argument/ArgumentResolverTrait.php(19): array_map(Object(Closure), Array) #23 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/Definition.php(237): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolveArguments(Array) #24 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/Definition.php(198): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolveCallable(Object(Closure)) #25 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/DefinitionAggregate.php(106): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition->resolve(false) #26 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(162): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\DefinitionAggregate->resolveTagged('Automattic\\WooC...', false) #27 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(178): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->get('Automattic\\WooC...', false) #28 /htdocs/wp-content/plugins/google-listings-and-ads/src/Container.php(90): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->get('Automattic\\WooC...') #29 /htdocs/wp-content/plugins/google-listings-and-ads/src/Infrastructure/GoogleListingsAndAdsPlugin.php(130): Automattic\WooCommerce\GoogleListingsAndAds\Container->get('Automattic\\WooC...') #30 /htdocs/wp-content/plugins/google-listings-and-ads/src/Infrastructure/GoogleListingsAndAdsPlugin.php(91): Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\GoogleListingsAndAdsPlugin->maybe_register_services() #31 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\GoogleListingsAndAdsPlugin->Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\{closure}('') #32 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #33 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #34 /htdocs/wp-settings.php(559): do_action('plugins_loaded') #35 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #36 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #37 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #38 /htdocs/index.php(17): require('/htdocs/wp-blog...') #39 {main} thrown in /htdocs/wp-content/plugins/google-listings-and-ads/src/DB/Table/AttributeMappingRulesTable.php on line 15