Changeset 3435950
- Timestamp:
- 01/09/2026 01:50:10 PM (3 months ago)
- Location:
- storecontrl-wp-connection/trunk
- Files:
-
- 4 edited
-
includes/api/class-storecontrl-web-api-functions.php (modified) (1 diff)
-
includes/cronjob/class-storecontrl-cronjob-functions.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
storecontrl-wp-connection.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
storecontrl-wp-connection/trunk/includes/api/class-storecontrl-web-api-functions.php
r3435393 r3435950 230 230 231 231 return $output; 232 } 233 234 public function storecontrl_update_wc_product_variation($product_variations, $change_api_name = '') 235 { 236 // Find product by SKU 237 $product_id = $this->functions->custom_get_product_id_by_sku($product_variations['product_id']); 238 239 // Check if product exist 240 if ($product_id != 0) { 241 242 // init CRUD 243 $Product = new WC_Product_Variable( $product_id ); 244 245 // SET ALL MASTERDATA 246 $output = $this->set_product_variations_data($product_variations['sku_list']); 247 $product_variations['variations'] = $output['variations']; 248 $product_variations['product_atributes'] = $output['product_atributes']; 249 unset($product_variations['sku_list']); 250 251 $product_attributes = $Product->get_attributes(); 252 if (isset($product_attributes) && !empty($product_attributes)) { 253 254 $product_atributes = array(); 255 foreach( $product_variations['product_atributes'] as $product_atribute ){ 256 $product_atributes[] = 'pa_' . $this->generate_clean_slug($product_atribute); 257 } 258 259 foreach ($product_attributes as $attribute_name => $attribute_data) { 260 $attribute_data = $attribute_data->get_data(); 261 if( $attribute_data['is_variation'] && !in_array($attribute_name, $product_atributes) ){ 262 unset($product_attributes[$attribute_name]); 263 } 264 } 265 } 266 267 $existing_variation_attributes = $Product->get_variation_attributes(); 268 if (isset($existing_variation_attributes) && !empty($existing_variation_attributes)) { 269 270 $new_clean_product_atributes = array(); 271 foreach ($product_variations['product_atributes'] as $variation_attribute_name) { 272 $new_clean_product_atributes[] = 'pa_' . $this->generate_clean_slug($variation_attribute_name); 273 } 274 275 $all_product_attributes = get_post_meta($product_id, '_product_attributes', true); 276 foreach ($existing_variation_attributes as $variation_attribute_name => $variation_attribute_id) { 277 if (!in_array($variation_attribute_name, $new_clean_product_atributes)) { 278 unset($all_product_attributes[$variation_attribute_name]); 279 $this->functions->custom_update_post_meta($product_id, '_product_attributes', $all_product_attributes); 280 } 281 } 282 } 283 284 // Add all attributes to the global size term for filtering ( As in the basic plugin ) 285 $product_variations_attributes = $this->insert_product_attributes('size', $product_variations['variations']); 286 if( isset($product_variations_attributes) && is_array($product_variations_attributes) ){ 287 $product_attributes = array_merge($product_attributes, $this->insert_product_attributes('size', $product_variations['variations'])); 288 $product_attributes = array_merge($product_attributes, $this->insert_product_attributes($product_variations['product_atributes'], $product_variations['variations'])); 289 $this->insert_product_variations($product_id, $product_variations); 290 } 291 292 $Product->set_attributes($product_attributes); 293 $Product->save(); 294 295 do_action('after_sc_variations_process', $product_id, $product_variations); 296 297 return 'true'; 298 } else { 299 return 'false'; 300 } 232 301 } 233 302 -
storecontrl-wp-connection/trunk/includes/cronjob/class-storecontrl-cronjob-functions.php
r3435393 r3435950 531 531 break; 532 532 533 // SK uAdded batch processing533 // SKU Added batch processing 534 534 case (strpos($file, 'sku_added') !== false): 535 535 … … 539 539 // Iterate products batch 540 540 foreach ( $results as $key => $product_variations) { 541 541 542 $product_variations = (array)$product_variations; 542 543 … … 546 547 } 547 548 548 $all_variations[$key]->processed = 'true'; 549 file_put_contents( $directory . '/' . $file, json_encode($all_variations) ); 550 551 // Update time after every succefull processed product 552 $processing_batch_time = time(); 553 update_option( 'processing_batch_time', $processing_batch_time ); 549 $response = $api_functions->storecontrl_update_wc_product_variation( $product_variations, 'GetSkuAdded'); 550 551 // Check if product is processed or 10 times try to process 552 if( $response == 'true' || isset($product_variations['retry']) && $product_variations['retry'] == 12 ) { 553 $all_variations[$key]->processed = 'true'; 554 file_put_contents( $directory . '/' . $file, json_encode($all_variations) ); 555 556 // Update time after every succefull processed product 557 $processing_batch_time = time(); 558 update_option( 'processing_batch_time', $processing_batch_time ); 559 } 560 else{ 561 $retry = 0; 562 if( isset($product_variations['retry']) ) { 563 $retry = $product_variations['retry']; 564 } 565 $retry++; 566 $all_variations[$key]->retry = $retry; 567 file_put_contents( $directory . '/' . $file, json_encode($all_variations) ); 568 569 $file_finished = false; 570 } 554 571 555 572 } 556 573 break; 557 574 558 // SK uChanged batch processing575 // SKU Changed batch processing 559 576 case (strpos($file, 'sku_changed') !== false): 577 560 578 $all_variations = $results; 561 579 $results = (array) $results; … … 571 589 } 572 590 573 $all_variations[$key]->processed = 'true'; 574 file_put_contents( $directory . '/' . $file, json_encode($all_variations) ); 575 576 // Update time after every succefull processed product 577 $processing_batch_time = time(); 578 update_option( 'processing_batch_time', $processing_batch_time ); 591 $response = $api_functions->storecontrl_update_wc_product_variation($product_variations, 'GetSkuChanged'); 592 593 // Check if product is processed 594 if( $response == 'true' ) { 595 $all_variations[$key]->processed = 'true'; 596 file_put_contents( $directory . '/' . $file, json_encode($all_variations) ); 597 598 // Update time after every succefull processed product 599 $processing_batch_time = time(); 600 update_option( 'processing_batch_time', $processing_batch_time ); 601 } 602 else{ 603 $this->logging->log_file_write( 'Cronjob | SKU changed | Product ID not found: ' . $product_variations['product_id'] ); 604 } 579 605 } 580 606 break; -
storecontrl-wp-connection/trunk/readme.txt
r3435393 r3435950 5 5 Requires at least: 6.6.0 6 6 Tested up to: 6.8.3 7 Stable tag: 4.2. 47 Stable tag: 4.2.5 8 8 Requires PHP: 8.0 9 9 License: GPLv2 or later … … 93 93 == Changelog == 94 94 95 = 4.2.5 = 96 * Bugfix with new added products and variations processing 97 95 98 = 4.2.3 = 96 99 * Optimalisatie in product update flow -
storecontrl-wp-connection/trunk/storecontrl-wp-connection.php
r3435714 r3435950 4 4 Plugin URI: http://www.arture.nl/storecontrl 5 5 Description: The Wordpress plugin for connecting Woocommerce with StoreContrl Cloud. With the synchronizing cronjobs your products will be automatically processed, images added, and the categories set. Every 5 minutes all stock changes are processed. We provide a up-to-date plugin, easy setup and always the best support. 6 Version: 4.2. 46 Version: 4.2.5 7 7 Requires Plugins: woocommerce 8 8 Author: Arture
Note: See TracChangeset
for help on using the changeset viewer.