| @@ -38,13 +38,8 @@ | ||
| 38 | 38 | public function handle_product_save( $post_id, $post ) { |
| 39 | 39 | if ( 'publish' !== $post->post_status ) { |
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | - $ai_data = AIFns::activated_ai_data(); | |
| 43 | - | |
| 44 | - if ( empty( $ai_data['api_key'] ) || empty( $ai_data['client'] ) ) { | |
| 45 | - return; | |
| 46 | - } | |
| 47 | 42 | $title = $post->post_title; |
| 48 | 43 | $content = $post->post_content; |
| 49 | 44 | $service = DataEmbedding::instance(); |
| 50 | 45 | $embedded = $service->generate_and_store( $post_id, $title, $content ); |
| @@ -75,8 +70,9 @@ | ||
| 75 | 70 | update_option( |
| 76 | 71 | 'rtsb_embedding_progress', |
| 77 | 72 | [ |
| 78 | 73 | 'processed' => 0, |
| 74 | + 'total' => AIFns::need_product_embedding(), | |
| 79 | 75 | ] |
| 80 | 76 | ); |
| 81 | 77 | } |
| 82 | 78 | |
| @@ -84,12 +80,8 @@ | ||
| 84 | 80 | /** |
| 85 | 81 | * @return void |
| 86 | 82 | */ |
| 87 | 83 | public function process_batch() { |
| 88 | - $ai_data = AIFns::activated_ai_data(); | |
| 89 | - if ( empty( $ai_data['api_key'] ) ) { | |
| 90 | - return; | |
| 91 | - } | |
| 92 | 84 | $products = get_posts( |
| 93 | 85 | [ |
| 94 | 86 | 'post_type' => 'product', |
| 95 | 87 | 'post_status' => 'publish', |
| @@ -122,8 +114,9 @@ | ||
| 122 | 114 | $progress = get_option( |
| 123 | 115 | 'rtsb_embedding_progress', |
| 124 | 116 | [ |
| 125 | 117 | 'processed' => 0, |
| 118 | + 'total' => 0, | |
| 126 | 119 | ] |
| 127 | 120 | ); |
| 128 | 121 | $progress['processed'] += count( $products ); |
| 129 | 122 | update_option( 'rtsb_embedding_progress', $progress ); |