Automattic\WooCommerce\Blocks\AIContent
UpdateProducts::generate_content()
Generate AI content and assign AI-managed images to Products.
Метод класса: UpdateProducts{}
Хуков нет.
Возвращает
Массив|WP_Error
. The generated content for the products. An error if the content could not be generated.
Использование
$UpdateProducts = new UpdateProducts(); $UpdateProducts->generate_content( $ai_connection, $token, $images, $business_description );
- $ai_connection(Connection) (обязательный)
- The AI connection.
- $token(строка|WP_Error) (обязательный)
- The JWT token.
- $images(массив|WP_Error) (обязательный)
- The array of images.
- $business_description(строка) (обязательный)
- The business description.
Код UpdateProducts::generate_content() UpdateProducts::generate content WC 9.8.5
public function generate_content( $ai_connection, $token, $images, $business_description ) { if ( is_wp_error( $token ) ) { return $token; } $images = ContentProcessor::verify_images( $images, $ai_connection, $token, $business_description ); if ( is_wp_error( $images ) ) { return $images; } if ( empty( $business_description ) ) { return new \WP_Error( 'missing_business_description', __( 'No business description provided for generating AI content.', 'woocommerce' ) ); } $dummy_products_to_update = $this->fetch_dummy_products_to_update(); if ( is_wp_error( $dummy_products_to_update ) ) { return $dummy_products_to_update; } if ( empty( $dummy_products_to_update ) ) { return array( 'product_content' => array(), ); } $products_information_list = $this->assign_ai_selected_images_to_dummy_products( $dummy_products_to_update, $images['images'] ); return $this->assign_ai_generated_content_to_dummy_products( $ai_connection, $token, $products_information_list, $business_description, $images['search_term'] ); }