Version Description
- Woocommerce 3.0 Compatibility.
Download this release
Release Info
Developer | hikeforce |
Plugin | Product Import Export for WooCommerce |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.4 to 1.3.0
includes/importer/class-wf-csv-parser.php
CHANGED
@@ -188,12 +188,13 @@ class WF_CSV_Parser {
|
|
188 |
|
189 |
$product['merging'] = true;
|
190 |
|
191 |
-
|
192 |
-
|
|
|
193 |
// Required fields
|
194 |
if ( ! $post_id && empty( $item['sku'] ) ) {
|
195 |
|
196 |
-
$WF_CSV_Product_Import->
|
197 |
|
198 |
$merging = false;
|
199 |
} else {
|
@@ -211,14 +212,14 @@ class WF_CSV_Parser {
|
|
211 |
", $item['sku']);
|
212 |
$found_product_id = $wpdb->get_var($db_query);
|
213 |
if ( ! $found_product_id ) {
|
214 |
-
$WF_CSV_Product_Import->
|
215 |
$merging = false;
|
216 |
|
217 |
} else {
|
218 |
|
219 |
$post_id = $found_product_id;
|
220 |
|
221 |
-
$WF_CSV_Product_Import->
|
222 |
|
223 |
}
|
224 |
}
|
@@ -229,15 +230,15 @@ class WF_CSV_Parser {
|
|
229 |
if ( ! $merging ) {
|
230 |
|
231 |
$product['merging'] = false;
|
232 |
-
$WF_CSV_Product_Import->
|
233 |
|
234 |
// Required fields
|
235 |
if ( $item['post_parent']=== '' && $item['post_title']=== '') {
|
236 |
-
$WF_CSV_Product_Import->
|
237 |
return new WP_Error( 'parse-error', __( 'No post_title set for new product.', 'wf_csv_import_export' ) );
|
238 |
}
|
239 |
if ( $item['post_parent']!== '' && $item['post_parent']!== null && $item['parent_sku'] === '' ) {
|
240 |
-
$WF_CSV_Product_Import->
|
241 |
//return new WP_Error( 'parse-error', __( 'No post_title set for new product.', 'wf_csv_import_export' ) );
|
242 |
return new WP_Error( 'parse-error', __( 'No parent set for new variation product.', 'wf_csv_import_export' ) );
|
243 |
}
|
@@ -430,7 +431,7 @@ class WF_CSV_Parser {
|
|
430 |
|
431 |
// Exists?
|
432 |
if ( ! taxonomy_exists( $taxonomy ) ) {
|
433 |
-
$WF_CSV_Product_Import->
|
434 |
continue;
|
435 |
}
|
436 |
|
@@ -439,7 +440,7 @@ class WF_CSV_Parser {
|
|
439 |
$term = strtolower( $value );
|
440 |
|
441 |
if ( ! array_key_exists( $term, $this->allowed_product_types ) ) {
|
442 |
-
$WF_CSV_Product_Import->
|
443 |
$term_id = $this->allowed_product_types['simple'];
|
444 |
} else {
|
445 |
$term_id = $this->allowed_product_types[ $term ];
|
@@ -466,6 +467,8 @@ class WF_CSV_Parser {
|
|
466 |
|
467 |
$raw_term = explode( '>', $raw_term );
|
468 |
$raw_term = array_map( 'trim', $raw_term );
|
|
|
|
|
469 |
$raw_term = array_map( 'wp_specialchars', $raw_term );
|
470 |
$raw_term = array_filter( $raw_term );
|
471 |
|
@@ -485,7 +488,7 @@ class WF_CSV_Parser {
|
|
485 |
*/
|
486 |
$term_may_exist = term_exists( $term, $taxonomy, absint( $parent ) );
|
487 |
|
488 |
-
$WF_CSV_Product_Import->
|
489 |
|
490 |
if ( is_array( $term_may_exist ) ) {
|
491 |
$possible_term = get_term( $term_may_exist['term_id'], 'product_cat' );
|
@@ -510,7 +513,7 @@ class WF_CSV_Parser {
|
|
510 |
if ( ! is_wp_error( $t ) ) {
|
511 |
$term_id = $t['term_id'];
|
512 |
} else {
|
513 |
-
$WF_CSV_Product_Import->
|
514 |
break;
|
515 |
}
|
516 |
}
|
@@ -532,7 +535,7 @@ class WF_CSV_Parser {
|
|
532 |
} else {
|
533 |
|
534 |
$term_id = '';
|
535 |
-
$raw_term = wp_specialchars( $raw_term );
|
536 |
|
537 |
if ( isset( $this->inserted_terms[$taxonomy][0][$raw_term] ) ) {
|
538 |
|
@@ -550,7 +553,7 @@ class WF_CSV_Parser {
|
|
550 |
if ( ! is_wp_error( $t ) ) {
|
551 |
$term_id = $t['term_id'];
|
552 |
} else {
|
553 |
-
$WF_CSV_Product_Import->
|
554 |
break;
|
555 |
}
|
556 |
}
|
@@ -599,7 +602,7 @@ class WF_CSV_Parser {
|
|
599 |
|
600 |
$nicename = strtolower( sanitize_title( str_replace( 'pa_', '', $taxonomy ) ) );
|
601 |
|
602 |
-
$WF_CSV_Product_Import->
|
603 |
|
604 |
$exists_in_db = $wpdb->get_var( "SELECT attribute_id FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name = '" . $nicename . "';" );
|
605 |
|
@@ -607,7 +610,7 @@ class WF_CSV_Parser {
|
|
607 |
// Create the taxonomy
|
608 |
$wpdb->insert( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_name' => $nicename, 'attribute_label' => $nicename, 'attribute_type' => 'select', 'attribute_orderby' => 'menu_order' ) );
|
609 |
} else {
|
610 |
-
$WF_CSV_Product_Import->
|
611 |
}
|
612 |
|
613 |
// Register the taxonomy now so that the import works!
|
@@ -646,13 +649,13 @@ class WF_CSV_Parser {
|
|
646 |
if ( ! is_wp_error( $t ) ) {
|
647 |
$term_id = $t['term_id'];
|
648 |
|
649 |
-
$WF_CSV_Product_Import->
|
650 |
} else {
|
651 |
-
$WF_CSV_Product_Import->
|
652 |
break;
|
653 |
}
|
654 |
} else {
|
655 |
-
$WF_CSV_Product_Import->
|
656 |
}
|
657 |
|
658 |
if ( $term_id ) {
|
188 |
|
189 |
$product['merging'] = true;
|
190 |
|
191 |
+
|
192 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> Row %s - preparing for merge.', 'wf_csv_import_export'), $this->row ) );
|
193 |
+
|
194 |
// Required fields
|
195 |
if ( ! $post_id && empty( $item['sku'] ) ) {
|
196 |
|
197 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', __( '> > Cannot merge without id or sku. Importing instead.', 'wf_csv_import_export') );
|
198 |
|
199 |
$merging = false;
|
200 |
} else {
|
212 |
", $item['sku']);
|
213 |
$found_product_id = $wpdb->get_var($db_query);
|
214 |
if ( ! $found_product_id ) {
|
215 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf(__( '> > Skipped. Cannot find product with sku %s. Importing instead.', 'wf_csv_import_export'), $item['sku']) );
|
216 |
$merging = false;
|
217 |
|
218 |
} else {
|
219 |
|
220 |
$post_id = $found_product_id;
|
221 |
|
222 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf(__( '> > Found product with ID %s.', 'wf_csv_import_export'), $post_id) );
|
223 |
|
224 |
}
|
225 |
}
|
230 |
if ( ! $merging ) {
|
231 |
|
232 |
$product['merging'] = false;
|
233 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> Row %s - preparing for import.', 'wf_csv_import_export'), $this->row ) );
|
234 |
|
235 |
// Required fields
|
236 |
if ( $item['post_parent']=== '' && $item['post_title']=== '') {
|
237 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', __( '> > Skipped. No post_title set for new product.', 'wf_csv_import_export') );
|
238 |
return new WP_Error( 'parse-error', __( 'No post_title set for new product.', 'wf_csv_import_export' ) );
|
239 |
}
|
240 |
if ( $item['post_parent']!== '' && $item['post_parent']!== null && $item['parent_sku'] === '' ) {
|
241 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', __( '> > Skipped. No parent set for new variation product.', 'wf_csv_import_export') );
|
242 |
//return new WP_Error( 'parse-error', __( 'No post_title set for new product.', 'wf_csv_import_export' ) );
|
243 |
return new WP_Error( 'parse-error', __( 'No parent set for new variation product.', 'wf_csv_import_export' ) );
|
244 |
}
|
431 |
|
432 |
// Exists?
|
433 |
if ( ! taxonomy_exists( $taxonomy ) ) {
|
434 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > Skipping taxonomy "%s" - it does not exist.', 'wf_csv_import_export'), $taxonomy ) );
|
435 |
continue;
|
436 |
}
|
437 |
|
440 |
$term = strtolower( $value );
|
441 |
|
442 |
if ( ! array_key_exists( $term, $this->allowed_product_types ) ) {
|
443 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > > Product type "%s" not allowed - using simple.', 'wf_csv_import_export'), $term ) );
|
444 |
$term_id = $this->allowed_product_types['simple'];
|
445 |
} else {
|
446 |
$term_id = $this->allowed_product_types[ $term ];
|
467 |
|
468 |
$raw_term = explode( '>', $raw_term );
|
469 |
$raw_term = array_map( 'trim', $raw_term );
|
470 |
+
|
471 |
+
|
472 |
$raw_term = array_map( 'wp_specialchars', $raw_term );
|
473 |
$raw_term = array_filter( $raw_term );
|
474 |
|
488 |
*/
|
489 |
$term_may_exist = term_exists( $term, $taxonomy, absint( $parent ) );
|
490 |
|
491 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'CSV-Import', sprintf( __( '> > (' . __LINE__ . ') Term %s (%s) exists? %s', 'wf_csv_import_export' ), sanitize_text_field( $term ), esc_html( $taxonomy ), $term_may_exist ? print_r( $term_may_exist, true ) : '-' ) );
|
492 |
|
493 |
if ( is_array( $term_may_exist ) ) {
|
494 |
$possible_term = get_term( $term_may_exist['term_id'], 'product_cat' );
|
513 |
if ( ! is_wp_error( $t ) ) {
|
514 |
$term_id = $t['term_id'];
|
515 |
} else {
|
516 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'CSV-Import', sprintf( __( '> > (' . __LINE__ . ') Failed to import term %s, parent %s - %s', 'wf_csv_import_export' ), sanitize_text_field( $term ), sanitize_text_field( $parent ), sanitize_text_field( $taxonomy ) ) );
|
517 |
break;
|
518 |
}
|
519 |
}
|
535 |
} else {
|
536 |
|
537 |
$term_id = '';
|
538 |
+
$raw_term = (WC()->version < '2.7.0') ? wp_specialchars( $raw_term ) : esc_html( $raw_term );
|
539 |
|
540 |
if ( isset( $this->inserted_terms[$taxonomy][0][$raw_term] ) ) {
|
541 |
|
553 |
if ( ! is_wp_error( $t ) ) {
|
554 |
$term_id = $t['term_id'];
|
555 |
} else {
|
556 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Failed to import term %s %s', 'wf_csv_import_export' ), esc_html($raw_term), esc_html($taxonomy) ) );
|
557 |
break;
|
558 |
}
|
559 |
}
|
602 |
|
603 |
$nicename = strtolower( sanitize_title( str_replace( 'pa_', '', $taxonomy ) ) );
|
604 |
|
605 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > Attribute taxonomy "%s" does not exist. Adding it. Nicename: %s', 'wf_csv_import_export'), $taxonomy, $nicename ) );
|
606 |
|
607 |
$exists_in_db = $wpdb->get_var( "SELECT attribute_id FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name = '" . $nicename . "';" );
|
608 |
|
610 |
// Create the taxonomy
|
611 |
$wpdb->insert( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_name' => $nicename, 'attribute_label' => $nicename, 'attribute_type' => 'select', 'attribute_orderby' => 'menu_order' ) );
|
612 |
} else {
|
613 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > Attribute taxonomy %s already exists in DB.', 'wf_csv_import_export'), $taxonomy ) );
|
614 |
}
|
615 |
|
616 |
// Register the taxonomy now so that the import works!
|
649 |
if ( ! is_wp_error( $t ) ) {
|
650 |
$term_id = $t['term_id'];
|
651 |
|
652 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Inserted Raw Term %s ID = %s', 'wf_csv_import_export' ), esc_html( $raw_term ), $term_id ) );
|
653 |
} else {
|
654 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Failed to import term %s %s', 'wf_csv_import_export' ), esc_html($raw_term), esc_html($taxonomy) ) );
|
655 |
break;
|
656 |
}
|
657 |
} else {
|
658 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Raw Term %s ID = %s', 'wf_csv_import_export' ), esc_html( $raw_term ), $term_id ) );
|
659 |
}
|
660 |
|
661 |
if ( $term_id ) {
|
includes/importer/class-wf-prodimpexpcsv-product-import.php
CHANGED
@@ -31,7 +31,15 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
31 |
*/
|
32 |
public function __construct() {
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
$this->import_page = 'woocommerce_csv';
|
36 |
$this->file_url_import_enabled = apply_filters( 'woocommerce_csv_product_file_url_import_enabled', true );
|
37 |
}
|
@@ -542,8 +550,8 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
542 |
|
543 |
wp_suspend_cache_invalidation( true );
|
544 |
|
545 |
-
$this->
|
546 |
-
$this->
|
547 |
foreach ( $this->parsed_data as $key => &$item ) {
|
548 |
|
549 |
$product = $this->parser->parse_product( $item, $this->merge_empty_cells );
|
@@ -555,7 +563,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
555 |
unset( $item, $product );
|
556 |
$i++;
|
557 |
}
|
558 |
-
$this->
|
559 |
wp_suspend_cache_invalidation( false );
|
560 |
}
|
561 |
|
@@ -564,19 +572,37 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
564 |
*
|
565 |
* @param string $file Path to the CSV file for importing
|
566 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
public function import_start( $file, $mapping, $start_pos, $end_pos, $eval_field ) {
|
568 |
|
|
|
569 |
$memory = size_format( woocommerce_let_to_num( ini_get( 'memory_limit' ) ) );
|
570 |
$wp_memory = size_format( woocommerce_let_to_num( WP_MEMORY_LIMIT ) );
|
571 |
-
|
572 |
-
|
573 |
-
$
|
|
|
|
|
|
|
|
|
|
|
574 |
|
575 |
$this->parser = new WF_CSV_Parser( 'product' );
|
576 |
|
577 |
list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data( $file, $this->delimiter, $mapping, $start_pos, $end_pos, $eval_field );
|
578 |
|
579 |
-
$this->
|
580 |
|
581 |
unset( $import_data );
|
582 |
|
@@ -726,14 +752,14 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
726 |
|
727 |
if ( ! empty( $processing_product_id ) && isset( $this->processed_posts[ $processing_product_id ] ) ) {
|
728 |
$this->add_import_result( 'skipped', __( 'Product already processed', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
729 |
-
$this->
|
730 |
unset( $post );
|
731 |
return;
|
732 |
}
|
733 |
|
734 |
if ( ! empty ( $post['post_status'] ) && $post['post_status'] == 'auto-draft' ) {
|
735 |
$this->add_import_result( 'skipped', __( 'Skipping auto-draft', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
736 |
-
$this->
|
737 |
unset( $post );
|
738 |
return;
|
739 |
}
|
@@ -747,14 +773,14 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
747 |
$usr_msg = 'Product already exists.';
|
748 |
}
|
749 |
$this->add_import_result( 'skipped', __( $usr_msg, 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
750 |
-
$this->
|
751 |
unset( $post );
|
752 |
return;
|
753 |
}
|
754 |
|
755 |
if ( $processing_product_id && is_string( get_post_status( $processing_product_id ) ) ) {
|
756 |
$this->add_import_result( 'skipped', __( 'Importing post ID conflicts with an existing post ID', 'wf_csv_import_export' ), $processing_product_id, get_the_title( $processing_product_id ), '' );
|
757 |
-
$this->
|
758 |
unset( $post );
|
759 |
return;
|
760 |
}
|
@@ -763,7 +789,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
763 |
$is_post_exist_in_db = get_post_type( $processing_product_id );
|
764 |
if ( $merging && $processing_product_id && !empty($is_post_exist_in_db) && (get_post_type( $processing_product_id ) !== $post['post_type'] )) {
|
765 |
$this->add_import_result( 'skipped', __( 'Post is not a product', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
766 |
-
$this->
|
767 |
unset( $post );
|
768 |
return;
|
769 |
}
|
@@ -773,7 +799,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
773 |
// Only merge fields which are set
|
774 |
$post_id = $processing_product_id;
|
775 |
|
776 |
-
$this->
|
777 |
|
778 |
$postdata = array(
|
779 |
'ID' => $post_id
|
@@ -837,11 +863,11 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
837 |
|
838 |
if ( ! $result ) {
|
839 |
$this->add_import_result( 'failed', __( 'Failed to update product', 'wf_csv_import_export' ), $post_id, $processing_product_title, $processing_product_sku );
|
840 |
-
$this->
|
841 |
unset( $post );
|
842 |
return;
|
843 |
} else {
|
844 |
-
$this->
|
845 |
}
|
846 |
}
|
847 |
|
@@ -870,7 +896,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
870 |
}
|
871 |
|
872 |
// Insert product
|
873 |
-
$this->
|
874 |
|
875 |
$postdata = array(
|
876 |
'import_id' => $processing_product_id,
|
@@ -893,13 +919,13 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
893 |
if ( is_wp_error( $post_id ) ) {
|
894 |
|
895 |
$this->add_import_result( 'failed', __( 'Failed to import product', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
896 |
-
$this->
|
897 |
unset( $post );
|
898 |
return;
|
899 |
|
900 |
} else {
|
901 |
|
902 |
-
$this->
|
903 |
|
904 |
}
|
905 |
}
|
@@ -997,7 +1023,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
997 |
if ( $image == $attachment_url || basename( $image ) == $attachment_basename ) {
|
998 |
unset( $post['images'][ $key ] );
|
999 |
|
1000 |
-
$this->
|
1001 |
|
1002 |
if ( $key == 0 ) {
|
1003 |
update_post_meta( $post_id, '_thumbnail_id', $attachment );
|
@@ -1027,7 +1053,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
1027 |
|
1028 |
if ( $post['images'] ) foreach ( $post['images'] as $image_key => $image ) {
|
1029 |
|
1030 |
-
$this->
|
1031 |
|
1032 |
$filename = basename( $image );
|
1033 |
|
@@ -1042,7 +1068,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
1042 |
|
1043 |
if ( ! is_wp_error( $attachment_id ) && $attachment_id ) {
|
1044 |
|
1045 |
-
$this->
|
1046 |
|
1047 |
// Set alt
|
1048 |
update_post_meta( $attachment_id, '_wp_attachment_image_alt', $processing_product_title );
|
@@ -1057,14 +1083,14 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
1057 |
|
1058 |
$featured = false;
|
1059 |
} else {
|
1060 |
-
$this->
|
1061 |
-
$this->
|
1062 |
}
|
1063 |
|
1064 |
unset( $attachment, $attachment_id );
|
1065 |
}
|
1066 |
|
1067 |
-
$this->
|
1068 |
|
1069 |
ksort( $gallery_ids );
|
1070 |
|
@@ -1117,10 +1143,10 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
1117 |
|
1118 |
if ( $merging ) {
|
1119 |
$this->add_import_result( 'merged', 'Merge successful', $post_id, $processing_product_title, $processing_product_sku );
|
1120 |
-
$this->
|
1121 |
} else {
|
1122 |
$this->add_import_result( 'imported', 'Import successful', $post_id, $processing_product_title, $processing_product_sku );
|
1123 |
-
$this->
|
1124 |
}
|
1125 |
|
1126 |
unset( $post );
|
@@ -1223,7 +1249,7 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
1223 |
}
|
1224 |
|
1225 |
if ( ! is_wp_error( $attachment_id ) && $attachment_id > 0 ) {
|
1226 |
-
$this->
|
1227 |
|
1228 |
$this->attachments[] = $attachment_id;
|
1229 |
}
|
31 |
*/
|
32 |
public function __construct() {
|
33 |
|
34 |
+
if(WC()->version < '2.7.0'){
|
35 |
+
$this->log = new WC_Logger();
|
36 |
+
|
37 |
+
}else
|
38 |
+
{
|
39 |
+
$this->log = wc_get_logger();
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
$this->import_page = 'woocommerce_csv';
|
44 |
$this->file_url_import_enabled = apply_filters( 'woocommerce_csv_product_file_url_import_enabled', true );
|
45 |
}
|
550 |
|
551 |
wp_suspend_cache_invalidation( true );
|
552 |
|
553 |
+
$this->hf_log_data_change( 'csv-import', '---' );
|
554 |
+
$this->hf_log_data_change( 'csv-import', __( 'Processing products.', 'wf_csv_import_export' ) );
|
555 |
foreach ( $this->parsed_data as $key => &$item ) {
|
556 |
|
557 |
$product = $this->parser->parse_product( $item, $this->merge_empty_cells );
|
563 |
unset( $item, $product );
|
564 |
$i++;
|
565 |
}
|
566 |
+
$this->hf_log_data_change( 'csv-import', __( 'Finished processing products.', 'wf_csv_import_export' ) );
|
567 |
wp_suspend_cache_invalidation( false );
|
568 |
}
|
569 |
|
572 |
*
|
573 |
* @param string $file Path to the CSV file for importing
|
574 |
*/
|
575 |
+
|
576 |
+
public function hf_log_data_change ($content = 'csv-import',$data='')
|
577 |
+
{
|
578 |
+
if (WC()->version < '2.7.0')
|
579 |
+
{
|
580 |
+
$this->log->add($content,$data);
|
581 |
+
}else
|
582 |
+
{
|
583 |
+
$context = array( 'source' => $content );
|
584 |
+
$this->log->log("debug", $data ,$context);
|
585 |
+
}
|
586 |
+
}
|
587 |
public function import_start( $file, $mapping, $start_pos, $end_pos, $eval_field ) {
|
588 |
|
589 |
+
if(WC()->version < '2.7.0'){
|
590 |
$memory = size_format( woocommerce_let_to_num( ini_get( 'memory_limit' ) ) );
|
591 |
$wp_memory = size_format( woocommerce_let_to_num( WP_MEMORY_LIMIT ) );
|
592 |
+
}else
|
593 |
+
{
|
594 |
+
$memory = size_format( wc_let_to_num( ini_get( 'memory_limit' ) ) );
|
595 |
+
$wp_memory = size_format( wc_let_to_num( WP_MEMORY_LIMIT ) );
|
596 |
+
|
597 |
+
}
|
598 |
+
$this->hf_log_data_change( 'csv-import', '---[ New Import ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory );
|
599 |
+
$this->hf_log_data_change( 'csv-import', __( 'Parsing products CSV.', 'wf_csv_import_export' ) );
|
600 |
|
601 |
$this->parser = new WF_CSV_Parser( 'product' );
|
602 |
|
603 |
list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data( $file, $this->delimiter, $mapping, $start_pos, $end_pos, $eval_field );
|
604 |
|
605 |
+
$this->hf_log_data_change( 'csv-import', __( 'Finished parsing products CSV.', 'wf_csv_import_export' ) );
|
606 |
|
607 |
unset( $import_data );
|
608 |
|
752 |
|
753 |
if ( ! empty( $processing_product_id ) && isset( $this->processed_posts[ $processing_product_id ] ) ) {
|
754 |
$this->add_import_result( 'skipped', __( 'Product already processed', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
755 |
+
$this->hf_log_data_change( 'csv-import', __('> Post ID already processed. Skipping.', 'wf_csv_import_export'), true );
|
756 |
unset( $post );
|
757 |
return;
|
758 |
}
|
759 |
|
760 |
if ( ! empty ( $post['post_status'] ) && $post['post_status'] == 'auto-draft' ) {
|
761 |
$this->add_import_result( 'skipped', __( 'Skipping auto-draft', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
762 |
+
$this->hf_log_data_change( 'csv-import', __('> Skipping auto-draft.', 'wf_csv_import_export'), true );
|
763 |
unset( $post );
|
764 |
return;
|
765 |
}
|
773 |
$usr_msg = 'Product already exists.';
|
774 |
}
|
775 |
$this->add_import_result( 'skipped', __( $usr_msg, 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
776 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s”'.$usr_msg, 'wf_csv_import_export'), esc_html($processing_product_title) ), true );
|
777 |
unset( $post );
|
778 |
return;
|
779 |
}
|
780 |
|
781 |
if ( $processing_product_id && is_string( get_post_status( $processing_product_id ) ) ) {
|
782 |
$this->add_import_result( 'skipped', __( 'Importing post ID conflicts with an existing post ID', 'wf_csv_import_export' ), $processing_product_id, get_the_title( $processing_product_id ), '' );
|
783 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” ID already exists.', 'wf_csv_import_export'), esc_html( $processing_product_id ) ), true );
|
784 |
unset( $post );
|
785 |
return;
|
786 |
}
|
789 |
$is_post_exist_in_db = get_post_type( $processing_product_id );
|
790 |
if ( $merging && $processing_product_id && !empty($is_post_exist_in_db) && (get_post_type( $processing_product_id ) !== $post['post_type'] )) {
|
791 |
$this->add_import_result( 'skipped', __( 'Post is not a product', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
792 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” is not a product.', 'wf_csv_import_export'), esc_html($processing_product_id) ), true );
|
793 |
unset( $post );
|
794 |
return;
|
795 |
}
|
799 |
// Only merge fields which are set
|
800 |
$post_id = $processing_product_id;
|
801 |
|
802 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Merging post ID %s.', 'wf_csv_import_export'), $post_id ), true );
|
803 |
|
804 |
$postdata = array(
|
805 |
'ID' => $post_id
|
863 |
|
864 |
if ( ! $result ) {
|
865 |
$this->add_import_result( 'failed', __( 'Failed to update product', 'wf_csv_import_export' ), $post_id, $processing_product_title, $processing_product_sku );
|
866 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Failed to update product %s', 'wf_csv_import_export'), $post_id ), true );
|
867 |
unset( $post );
|
868 |
return;
|
869 |
} else {
|
870 |
+
$this->hf_log_data_change( 'csv-import', __( '> Merged post data: ', 'wf_csv_import_export' ) . print_r( $postdata, true ) );
|
871 |
}
|
872 |
}
|
873 |
|
896 |
}
|
897 |
|
898 |
// Insert product
|
899 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Inserting %s', 'wf_csv_import_export'), esc_html( $processing_product_title ) ), true );
|
900 |
|
901 |
$postdata = array(
|
902 |
'import_id' => $processing_product_id,
|
919 |
if ( is_wp_error( $post_id ) ) {
|
920 |
|
921 |
$this->add_import_result( 'failed', __( 'Failed to import product', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
922 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( 'Failed to import product “%s”', 'wf_csv_import_export' ), esc_html($processing_product_title) ) );
|
923 |
unset( $post );
|
924 |
return;
|
925 |
|
926 |
} else {
|
927 |
|
928 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Inserted - post ID is %s.', 'wf_csv_import_export'), $post_id ) );
|
929 |
|
930 |
}
|
931 |
}
|
1023 |
if ( $image == $attachment_url || basename( $image ) == $attachment_basename ) {
|
1024 |
unset( $post['images'][ $key ] );
|
1025 |
|
1026 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Image exists - skipping %s', 'wf_csv_import_export' ), basename( $image ) ) );
|
1027 |
|
1028 |
if ( $key == 0 ) {
|
1029 |
update_post_meta( $post_id, '_thumbnail_id', $attachment );
|
1053 |
|
1054 |
if ( $post['images'] ) foreach ( $post['images'] as $image_key => $image ) {
|
1055 |
|
1056 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Importing image "%s"', 'wf_csv_import_export' ), $image ) );
|
1057 |
|
1058 |
$filename = basename( $image );
|
1059 |
|
1068 |
|
1069 |
if ( ! is_wp_error( $attachment_id ) && $attachment_id ) {
|
1070 |
|
1071 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Imported image "%s"', 'wf_csv_import_export' ), $image ) );
|
1072 |
|
1073 |
// Set alt
|
1074 |
update_post_meta( $attachment_id, '_wp_attachment_image_alt', $processing_product_title );
|
1083 |
|
1084 |
$featured = false;
|
1085 |
} else {
|
1086 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Error importing image "%s"', 'wf_csv_import_export' ), $image ) );
|
1087 |
+
$this->hf_log_data_change( 'csv-import', '> > ' . $attachment_id->get_error_message() );
|
1088 |
}
|
1089 |
|
1090 |
unset( $attachment, $attachment_id );
|
1091 |
}
|
1092 |
|
1093 |
+
$this->hf_log_data_change( 'csv-import', __( '> > Images set', 'wf_csv_import_export' ) );
|
1094 |
|
1095 |
ksort( $gallery_ids );
|
1096 |
|
1143 |
|
1144 |
if ( $merging ) {
|
1145 |
$this->add_import_result( 'merged', 'Merge successful', $post_id, $processing_product_title, $processing_product_sku );
|
1146 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Finished merging post ID %s.', 'wf_csv_import_export'), $post_id ) );
|
1147 |
} else {
|
1148 |
$this->add_import_result( 'imported', 'Import successful', $post_id, $processing_product_title, $processing_product_sku );
|
1149 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Finished importing post ID %s.', 'wf_csv_import_export'), $post_id ) );
|
1150 |
}
|
1151 |
|
1152 |
unset( $post );
|
1249 |
}
|
1250 |
|
1251 |
if ( ! is_wp_error( $attachment_id ) && $attachment_id > 0 ) {
|
1252 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Inserted image attachment "%s"', 'wf_csv_import_export' ), $url ) );
|
1253 |
|
1254 |
$this->attachments[] = $attachment_id;
|
1255 |
}
|
product-csv-import-export.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.xadapter.com/product/product-import-export-plugin-for-woo
|
|
5 |
Description: Import and Export Products From and To your WooCommerce Store.
|
6 |
Author: HikeForce
|
7 |
Author URI: http://www.xadapter.com/vendor/hikeforce/
|
8 |
-
Version: 1.
|
9 |
Text Domain: wf_csv_import_export
|
10 |
*/
|
11 |
|
5 |
Description: Import and Export Products From and To your WooCommerce Store.
|
6 |
Author: HikeForce
|
7 |
Author URI: http://www.xadapter.com/vendor/hikeforce/
|
8 |
+
Version: 1.3.0
|
9 |
Text Domain: wf_csv_import_export
|
10 |
*/
|
11 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link:
|
|
4 |
Tags: woocommerce import products, woocommerce export products, woocommerce export import products, export woocommerce products with images, woocommerce csv import variable products, woocommerce import products with attributes
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 4.7
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -81,6 +81,8 @@ Yes. You can import or export product images along with other details
|
|
81 |
3. Premium Export Settings Screen
|
82 |
|
83 |
== Changelog ==
|
|
|
|
|
84 |
= 1.2.4 =
|
85 |
* Marketing Content Changed.
|
86 |
= 1.2.3 =
|
@@ -137,6 +139,8 @@ Yes. You can import or export product images along with other details
|
|
137 |
* Import /Export Woocommerce Products.
|
138 |
|
139 |
== Upgrade Notice ==
|
|
|
|
|
140 |
= 1.2.4 =
|
141 |
* Marketing Content Changed.
|
142 |
= 1.2.3 =
|
4 |
Tags: woocommerce import products, woocommerce export products, woocommerce export import products, export woocommerce products with images, woocommerce csv import variable products, woocommerce import products with attributes
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 4.7
|
7 |
+
Stable tag: 1.3.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
81 |
3. Premium Export Settings Screen
|
82 |
|
83 |
== Changelog ==
|
84 |
+
= 1.3.0 =
|
85 |
+
* Woocommerce 3.0 Compatibility.
|
86 |
= 1.2.4 =
|
87 |
* Marketing Content Changed.
|
88 |
= 1.2.3 =
|
139 |
* Import /Export Woocommerce Products.
|
140 |
|
141 |
== Upgrade Notice ==
|
142 |
+
= 1.3.0 =
|
143 |
+
* Woocommerce 3.0 Compatibility.
|
144 |
= 1.2.4 =
|
145 |
* Marketing Content Changed.
|
146 |
= 1.2.3 =
|