Product Import Export for WooCommerce - Version 2.0.1

Version Description

  • Custom taxonomy support updated.
Download this release

Release Info

Developer webtoffee
Plugin Icon 128x128 Product Import Export for WooCommerce
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0.0 to 2.0.1

admin/modules/export/export.php CHANGED
@@ -126,7 +126,7 @@ class Wt_Import_Export_For_Woo_Basic_Export
126
  $fields['default_export_batch']=array(
127
  'label'=>__("Default Export batch count"),
128
  'type'=>'number',
129
- 'value' =>10,
130
  'field_name'=>'default_export_batch',
131
  'help_text'=>__('Provide the default count for the records to be exported in a batch.'),
132
  'validation_rule'=>array('type'=>'absint'),
@@ -276,7 +276,7 @@ class Wt_Import_Export_For_Woo_Basic_Export
276
  'type'=>'text',
277
  'value'=>$this->default_batch_count,
278
  'field_name'=>'batch_count',
279
- 'help_text'=>sprintf(__('The number of records that the server will process for every iteration within the configured timeout interval. If the export fails due to timeout you can lower this number accordingly and try again. Defaulted to %d records.'), 10),
280
  'validation_rule'=>array('type'=>'absint'),
281
  )
282
  );
126
  $fields['default_export_batch']=array(
127
  'label'=>__("Default Export batch count"),
128
  'type'=>'number',
129
+ 'value' =>100,
130
  'field_name'=>'default_export_batch',
131
  'help_text'=>__('Provide the default count for the records to be exported in a batch.'),
132
  'validation_rule'=>array('type'=>'absint'),
276
  'type'=>'text',
277
  'value'=>$this->default_batch_count,
278
  'field_name'=>'batch_count',
279
+ 'help_text'=>sprintf(__('The number of records that the server will process for every iteration within the configured timeout interval. If the export fails due to timeout you can lower this number accordingly and try again. Defaulted to %d records.'), 100),
280
  'validation_rule'=>array('type'=>'absint'),
281
  )
282
  );
admin/modules/history/history.php CHANGED
@@ -129,6 +129,7 @@ class Wt_Import_Export_For_Woo_Basic_History
129
  $out['history_id']=$history_id;
130
 
131
  $history_item=$this->get_history_entry_by_id($history_id);
 
132
  if($history_item) //history item exists
133
  {
134
  $action_type=$history_item['template_type'];
@@ -137,6 +138,7 @@ class Wt_Import_Export_For_Woo_Basic_History
137
  $action_module_obj=Wt_Import_Export_For_Woo_Basic::load_modules($action_type);
138
  $log_file_name=$action_module_obj->get_log_file_name($history_item['id']);
139
  $log_file_path=$action_module_obj->get_file_path($log_file_name);
 
140
  if(file_exists($log_file_path))
141
  {
142
  include_once WT_P_IEW_PLUGIN_PATH.'admin/classes/class-logreader.php';
@@ -162,7 +164,10 @@ class Wt_Import_Export_For_Woo_Basic_History
162
  include plugin_dir_path(__FILE__).'views/_log_table.php';
163
  $out['html']=ob_get_clean();
164
  }
165
- }
 
 
 
166
  }
167
  }
168
  }else /* raw log viewing */
129
  $out['history_id']=$history_id;
130
 
131
  $history_item=$this->get_history_entry_by_id($history_id);
132
+
133
  if($history_item) //history item exists
134
  {
135
  $action_type=$history_item['template_type'];
138
  $action_module_obj=Wt_Import_Export_For_Woo_Basic::load_modules($action_type);
139
  $log_file_name=$action_module_obj->get_log_file_name($history_item['id']);
140
  $log_file_path=$action_module_obj->get_file_path($log_file_name);
141
+
142
  if(file_exists($log_file_path))
143
  {
144
  include_once WT_P_IEW_PLUGIN_PATH.'admin/classes/class-logreader.php';
164
  include plugin_dir_path(__FILE__).'views/_log_table.php';
165
  $out['html']=ob_get_clean();
166
  }
167
+ }else{
168
+ $out['status']=1;
169
+ $out['html']= sprintf( __( 'Please check the Save import log is enabled under <a target = "_blank" href="%s">settings</a>' ), admin_url('admin.php?page=wt_import_export_for_woo_basic'));
170
+ }
171
  }
172
  }
173
  }else /* raw log viewing */
admin/modules/product/import/import.php CHANGED
@@ -425,6 +425,10 @@ class Wt_Import_Export_For_Woo_Basic_Product_Import {
425
  $this->wt_parse_meta_field($value, $column);
426
  continue;
427
  }
 
 
 
 
428
 
429
  }
430
 
@@ -702,6 +706,53 @@ class Wt_Import_Export_For_Woo_Basic_Product_Import {
702
  $this->item_data['meta_data'][] = array('key'=>$meta_key,'value'=>$value);
703
  }
704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
705
  public function wt_parse_taxonomy_field($value) {
706
  return $value;
707
  }
@@ -865,7 +916,7 @@ class Wt_Import_Export_For_Woo_Basic_Product_Import {
865
  }
866
 
867
  $postdata = array( // if not specifiying id (id is empty) or if not found by given id or Product
868
- 'post_title' => ($this->item_data['type'] == 'variation' ? 'product variation' : $this->item_data['name'] ),
869
  'post_status' => 'importing',
870
  'post_type' => $this->post_type,
871
  );
@@ -1341,6 +1392,7 @@ class Wt_Import_Export_For_Woo_Basic_Product_Import {
1341
  $this->set_image_data($object, $data);
1342
 
1343
  $this->set_meta_data($object, $data);
 
1344
 
1345
  $object = apply_filters('wt_woocommerce_product_import_pre_insert_product_object', $object, $data);
1346
 
@@ -1434,7 +1486,7 @@ class Wt_Import_Export_For_Woo_Basic_Product_Import {
1434
  return new WP_Error('woocommerce_product_importer_parent_set_as_variation', 'Variation cannot be imported: Parent product cannot be a product variation', array('status' => 401));
1435
  }
1436
 
1437
- if (isset($data['raw_attributes'])) {
1438
  $attributes = array();
1439
  $parent_attributes = $this->get_variation_parent_attributes($data['raw_attributes'], $parent);
1440
 
@@ -1573,7 +1625,7 @@ class Wt_Import_Export_For_Woo_Basic_Product_Import {
1573
  }
1574
 
1575
  function set_product_data(&$product, $data) {
1576
- if (isset($data['raw_attributes'])) {
1577
  $attributes = array();
1578
  $default_attributes = array();
1579
  $existing_attributes = $product->get_attributes();
@@ -1798,5 +1850,43 @@ class Wt_Import_Export_For_Woo_Basic_Product_Import {
1798
  }
1799
  }
1800
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1801
  }
1802
  }
425
  $this->wt_parse_meta_field($value, $column);
426
  continue;
427
  }
428
+ if (strstr($column, 'tax:')) {
429
+ $this->wt_parse_other_taxomomy_field($value, $column);
430
+ continue;
431
+ }
432
 
433
  }
434
 
706
  $this->item_data['meta_data'][] = array('key'=>$meta_key,'value'=>$value);
707
  }
708
 
709
+
710
+ /**
711
+ * handle extra/other (custom taxonomy by other plugin) taxonomies.
712
+ */
713
+ public function wt_parse_other_taxomomy_field($value, $column) {
714
+ // Get taxonomy
715
+ $taxonomy = trim(str_replace('tax:', '', $column));
716
+
717
+ // Exists?
718
+ if (!taxonomy_exists($taxonomy)) {
719
+ return;
720
+ }
721
+
722
+ if (empty($value)) {
723
+ return array();
724
+ }
725
+
726
+ $names = $this->wt_explode_values($value, '|');
727
+ $taxs = array();
728
+
729
+ foreach ($names as $name) {
730
+ $parent = null;
731
+ $other_terms = array_map( 'trim', explode( '>', $name ) );
732
+ $total = count( $other_terms );
733
+
734
+ foreach ( $other_terms as $index => $_term ) {
735
+ $term = term_exists( $_term, $taxonomy, $parent );
736
+ if ( is_array( $term ) ) {
737
+ $term_id = $term['term_id'];
738
+ }else {
739
+ $term = wp_insert_term( $_term, $taxonomy, array( 'parent' => intval( $parent ) ) );
740
+ if ( is_wp_error( $term ) ) {
741
+ break;
742
+ }
743
+ $term_id = $term['term_id'];
744
+ }
745
+ if ( ( 1 + $index ) === $total ) {
746
+ $taxs[] = $term_id;
747
+ } else {
748
+ $parent = $term_id;
749
+ }
750
+ }
751
+ }
752
+ $this->item_data['other_taxomomy_data'][] = array('taxonomy' => $taxonomy, 'terms' => $taxs);
753
+ }
754
+
755
+
756
  public function wt_parse_taxonomy_field($value) {
757
  return $value;
758
  }
916
  }
917
 
918
  $postdata = array( // if not specifiying id (id is empty) or if not found by given id or Product
919
+ 'post_title' => (($this->item_data['type'] == 'variation') ? 'product variation' : $this->item_data['name'] ),
920
  'post_status' => 'importing',
921
  'post_type' => $this->post_type,
922
  );
1392
  $this->set_image_data($object, $data);
1393
 
1394
  $this->set_meta_data($object, $data);
1395
+ $this->set_other_taxonomy_data($object, $data);
1396
 
1397
  $object = apply_filters('wt_woocommerce_product_import_pre_insert_product_object', $object, $data);
1398
 
1486
  return new WP_Error('woocommerce_product_importer_parent_set_as_variation', 'Variation cannot be imported: Parent product cannot be a product variation', array('status' => 401));
1487
  }
1488
 
1489
+ if (isset($data['raw_attributes']) && !empty($data['raw_attributes'])) {
1490
  $attributes = array();
1491
  $parent_attributes = $this->get_variation_parent_attributes($data['raw_attributes'], $parent);
1492
 
1625
  }
1626
 
1627
  function set_product_data(&$product, $data) {
1628
+ if (isset($data['raw_attributes']) && !empty($data['raw_attributes'])) {
1629
  $attributes = array();
1630
  $default_attributes = array();
1631
  $existing_attributes = $product->get_attributes();
1850
  }
1851
  }
1852
  }
1853
+
1854
+ /* Set third-party taxonomy data ( eg:- brand ) */
1855
+ public function set_other_taxonomy_data(&$product, $data) {
1856
+
1857
+ if (isset($data['other_taxomomy_data']) && !empty($data['other_taxomomy_data'])) {
1858
+ $terms_to_set = array();
1859
+
1860
+ foreach ($data['other_taxomomy_data'] as $term_group) {
1861
+
1862
+ $taxonomy = $term_group['taxonomy'];
1863
+ $terms = $term_group['terms'];
1864
+
1865
+ if (!$taxonomy || !taxonomy_exists($taxonomy)) {
1866
+ continue;
1867
+ }
1868
+
1869
+ if (!is_array($terms)) {
1870
+ $terms = array($terms);
1871
+ }
1872
+
1873
+ $terms_to_set[$taxonomy] = array();
1874
+
1875
+ foreach ($terms as $term_id) {
1876
+
1877
+ $terms_to_set[$taxonomy][] = intval($term_id);
1878
+ }
1879
+ }
1880
+ foreach ($terms_to_set as $tax => $ids) {
1881
+ if(isset($data['id'])&& !empty($data['id'])){
1882
+ wp_set_post_terms($data['id'], $ids, $tax, false);
1883
+ }
1884
+ }
1885
+
1886
+ unset($data['other_taxomomy_data'], $terms_to_set);
1887
+
1888
+ }
1889
+ }
1890
+
1891
  }
1892
  }
includes/class-wt-import-export-for-woo.php CHANGED
@@ -80,7 +80,7 @@ class Wt_Import_Export_For_Woo_Basic {
80
  if ( defined( 'WT_P_IEW_VERSION' ) ) {
81
  $this->version = WT_P_IEW_VERSION;
82
  } else {
83
- $this->version = '2.0.0';
84
  }
85
  $this->plugin_name = 'wt-import-export-for-woo-basic';
86
 
80
  if ( defined( 'WT_P_IEW_VERSION' ) ) {
81
  $this->version = WT_P_IEW_VERSION;
82
  } else {
83
+ $this->version = '2.0.1';
84
  }
85
  $this->plugin_name = 'wt-import-export-for-woo-basic';
86
 
product-import-export-for-woo.php CHANGED
@@ -5,7 +5,7 @@
5
  Description: Import and Export Products From and To your WooCommerce Store.
6
  Author: WebToffee
7
  Author URI: https://www.webtoffee.com/product/product-import-export-woocommerce/
8
- Version: 2.0.0
9
  WC tested up to: 5.3.0
10
  License: GPLv3
11
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -43,7 +43,7 @@ if ( !defined( 'WT_IEW_DEBUG_BASIC_TROUBLESHOOT' ) ) {
43
  * Start at version 1.0.0 and use SemVer - https://semver.org
44
  * Rename this for your plugin and update it as you release new versions.
45
  */
46
- define( 'WT_P_IEW_VERSION', '2.0.0' );
47
 
48
  /**
49
  * The code that runs during plugin activation.
5
  Description: Import and Export Products From and To your WooCommerce Store.
6
  Author: WebToffee
7
  Author URI: https://www.webtoffee.com/product/product-import-export-woocommerce/
8
+ Version: 2.0.1
9
  WC tested up to: 5.3.0
10
  License: GPLv3
11
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
43
  * Start at version 1.0.0 and use SemVer - https://semver.org
44
  * Rename this for your plugin and update it as you release new versions.
45
  */
46
+ define( 'WT_P_IEW_VERSION', '2.0.1' );
47
 
48
  /**
49
  * The code that runs during plugin activation.
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce product import, woocommerce import products, woocommerce expor
5
  Requires at least: 3.0.1
6
  Tested up to: 5.7
7
  Requires PHP: 5.6
8
- Stable tag: 2.0.0
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -198,6 +198,9 @@ LibreOffice.
198
 
199
  == Changelog ==
200
 
 
 
 
201
  = 2.0.0 =
202
  * Heads up! This version has been revamped majorly. The new version update will not automatically adopt the existing settings.
203
  * Please make sure you record/note the existing plugin settings and redo them in the new version after an update.
@@ -485,14 +488,5 @@ LibreOffice.
485
 
486
  == Upgrade Notice ==
487
 
488
- = 2.0.0 =
489
- * Heads up! This version has been revamped majorly. The new version update will not automatically adopt the existing settings.
490
- * Please make sure you record/note the existing plugin settings and redo them in the new version after an update.
491
- * Improved UI for better user experience
492
- * Export/Import options: via a pre-saved template or a quick(standard columns) export/import
493
- * Option to export/import selective columns
494
- * Option to reorder columns during export
495
- * Import: Support for different types of delimiters
496
- * Export/Import options: Batch option with configurable batch count
497
- * History of all the Import/Export process
498
- * Dedicated logs for debugging failures
5
  Requires at least: 3.0.1
6
  Tested up to: 5.7
7
  Requires PHP: 5.6
8
+ Stable tag: 2.0.1
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
198
 
199
  == Changelog ==
200
 
201
+ = 2.0.1 =
202
+ * Custom taxonomy support updated.
203
+
204
  = 2.0.0 =
205
  * Heads up! This version has been revamped majorly. The new version update will not automatically adopt the existing settings.
206
  * Please make sure you record/note the existing plugin settings and redo them in the new version after an update.
488
 
489
  == Upgrade Notice ==
490
 
491
+ = 2.0.1 =
492
+ * Custom taxonomy support updated.