Import Products from any XML or CSV to WooCommerce - Version 1.3.3

Version Description

  • improvement: compatibility with WC 3.x
Download this release

Release Info

Developer soflyy
Plugin Icon 128x128 Import Products from any XML or CSV to WooCommerce
Version 1.3.3
Comparing to
See all releases

Code changes from version 1.3.2 to 1.3.3

models/import/record.php CHANGED
@@ -632,8 +632,8 @@ class PMWI_Import_Record extends PMWI_Model_Record {
632
  // Get types
633
  $product_type = 'simple';
634
 
635
- if ($this->options['update_all_data'] == 'no' and ! $this->options['is_update_product_type'] and ! $is_new_product ){
636
- $product = get_product($pid);
637
  if ( ! empty($product->product_type) ) $product_type = $product->product_type;
638
  }
639
 
@@ -1202,6 +1202,39 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1202
 
1203
  }
1204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1205
  // prepare bulk SQL query
1206
  //$this->executeSQL();
1207
 
@@ -1340,55 +1373,46 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1340
  protected function associate_terms($pid, $assign_taxes, $tx_name, $logger = false){
1341
 
1342
  $terms = wp_get_object_terms( $pid, $tx_name );
1343
- $term_ids = array();
1344
 
1345
- $assign_taxes = (is_array($assign_taxes)) ? array_filter($assign_taxes) : false;
1346
 
1347
- if ( ! empty($terms) ){
1348
- if ( ! is_wp_error( $terms ) ) {
1349
- foreach ($terms as $term_info) {
1350
- $term_ids[] = $term_info->term_taxonomy_id;
1351
- delete_woocommerce_term_meta( $term_info->term_taxonomy_id, 'product_ids' );
1352
- $this->wpdb->query( $this->wpdb->prepare("UPDATE {$this->wpdb->term_taxonomy} SET count = count - 1 WHERE term_taxonomy_id = %d", $term_info->term_taxonomy_id) );
1353
- }
1354
- $in_tt_ids = "'" . implode( "', '", $term_ids ) . "'";
1355
- $this->wpdb->query( $this->wpdb->prepare( "DELETE FROM {$this->wpdb->term_relationships} WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $pid ) );
1356
- delete_transient( 'wc_ln_count_' . md5( sanitize_key( $tx_name ) . sanitize_key( $term_info->term_taxonomy_id ) ) );
1357
- //wp_update_term_count( $term_ids, $tx_name );
1358
- clean_term_cache($term_ids, '', false);
1359
- }
1360
- }
1361
 
1362
- if (empty($assign_taxes)){
1363
- //_wc_term_recount($terms, $tx_name, true, false);
1364
- return;
1365
- }
1366
 
1367
- // foreach ($assign_taxes as $tt) {
1368
- // $this->wpdb->insert( $this->wpdb->term_relationships, array( 'object_id' => $pid, 'term_taxonomy_id' => $tt ) );
1369
- // $this->wpdb->query( "UPDATE {$this->wpdb->term_taxonomy} SET count = count + 1 WHERE term_taxonomy_id = $tt" );
1370
- // delete_transient( 'wc_ln_count_' . md5( sanitize_key( $tx_name ) . sanitize_key( $tt ) ) );
1371
- // }
1372
 
1373
- $values = array();
1374
  $term_order = 0;
1375
- foreach ( $assign_taxes as $tt ){
1376
- $values[] = $this->wpdb->prepare( "(%d, %d, %d)", $pid, $tt, ++$term_order);
1377
- $this->wpdb->query( "UPDATE {$this->wpdb->term_taxonomy} SET count = count + 1 WHERE term_taxonomy_id = $tt" );
1378
- delete_transient( 'wc_ln_count_' . md5( sanitize_key( $tx_name ) . sanitize_key( $tt ) ) );
1379
- delete_woocommerce_term_meta( $tt, 'product_ids' );
1380
- }
1381
-
1382
-
1383
- if ( $values ){
1384
- if ( false === $this->wpdb->query( "INSERT INTO {$this->wpdb->term_relationships} (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" ) ){
1385
- $logger and call_user_func($logger, __('<b>ERROR</b> Could not insert term relationship into the database', 'wpai_woocommerce_addon_plugin') . ': '. $this->wpdb->last_error);
1386
- }
1387
- }
1388
 
1389
- wp_cache_delete( $pid, $tx_name . '_relationships' );
1390
 
1391
- //_wc_term_recount( $assign_taxes, $tx_name );
 
 
 
 
 
 
 
1392
  }
1393
 
1394
  function create_taxonomy($attr_name, $logger){
632
  // Get types
633
  $product_type = 'simple';
634
 
635
+ if ($this->options['update_all_data'] == 'no' and ! $this->options['is_update_product_type'] and ! $is_new_product ){
636
+ $product = WC()->product_factory->get_product($pid);
637
  if ( ! empty($product->product_type) ) $product_type = $product->product_type;
638
  }
639
 
1202
 
1203
  }
1204
 
1205
+ // Update product visibility term WC 3.0.0
1206
+ if ( version_compare(WOOCOMMERCE_VERSION, '3.0') >= 0 ) {
1207
+ if ( pmwi_is_update_taxonomy($articleData, $this->options, 'product_visibility') ){
1208
+ $associate_terms = array();
1209
+ if ($is_featured == "yes"){
1210
+ $featured_term = get_term_by( 'name', 'featured', 'product_visibility' );
1211
+ if (!empty($featured_term) && !is_wp_error($featured_term)){
1212
+ $associate_terms[] = $featured_term->term_taxonomy_id;
1213
+ }
1214
+ }
1215
+ if (in_array($product_visibility[$i], array('hidden', 'catalog'))){
1216
+ $exclude_search_term = get_term_by( 'name', 'exclude-from-search', 'product_visibility' );
1217
+ if (!empty($exclude_search_term) && !is_wp_error($exclude_search_term)){
1218
+ $associate_terms[] = $exclude_search_term->term_taxonomy_id;
1219
+ }
1220
+ }
1221
+ if (in_array($product_visibility[$i], array('hidden', 'search'))){
1222
+ $exclude_catalog_term = get_term_by( 'name', 'exclude-from-catalog', 'product_visibility' );
1223
+ if (!empty($exclude_catalog_term) && !is_wp_error($exclude_catalog_term)){
1224
+ $associate_terms[] = $exclude_catalog_term->term_taxonomy_id;
1225
+ }
1226
+ }
1227
+ $_stock_status = get_post_meta( $pid, '_stock_status', true);
1228
+ if ( $_stock_status == 'outofstock' ){
1229
+ $outofstock_term = get_term_by( 'name', 'outofstock', 'product_visibility' );
1230
+ if (!empty($outofstock_term) && !is_wp_error($outofstock_term)){
1231
+ $associate_terms[] = $outofstock_term->term_taxonomy_id;
1232
+ }
1233
+ }
1234
+ $this->associate_terms( $pid, $associate_terms, 'product_visibility' );
1235
+ }
1236
+ }
1237
+
1238
  // prepare bulk SQL query
1239
  //$this->executeSQL();
1240
 
1373
  protected function associate_terms($pid, $assign_taxes, $tx_name, $logger = false){
1374
 
1375
  $terms = wp_get_object_terms( $pid, $tx_name );
1376
+ $term_ids = array();
1377
 
1378
+ $assign_taxes = (is_array($assign_taxes)) ? array_filter($assign_taxes) : false;
1379
 
1380
+ if ( ! empty($terms) ){
1381
+ if ( ! is_wp_error( $terms ) ) {
1382
+ foreach ($terms as $term_info) {
1383
+ $term_ids[] = $term_info->term_taxonomy_id;
1384
+ $this->wpdb->query( $this->wpdb->prepare("UPDATE {$this->wpdb->term_taxonomy} SET count = count - 1 WHERE term_taxonomy_id = %d", $term_info->term_taxonomy_id) );
1385
+ }
1386
+ $in_tt_ids = "'" . implode( "', '", $term_ids ) . "'";
1387
+ $this->wpdb->query( $this->wpdb->prepare( "DELETE FROM {$this->wpdb->term_relationships} WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $pid ) );
1388
+ }
1389
+ }
 
 
 
 
1390
 
1391
+ if (empty($assign_taxes)) return;
 
 
 
1392
 
1393
+ // foreach ($assign_taxes as $tt) {
1394
+ // $this->wpdb->insert( $this->wpdb->term_relationships, array( 'object_id' => $pid, 'term_taxonomy_id' => $tt ) );
1395
+ // $this->wpdb->query( "UPDATE {$this->wpdb->term_taxonomy} SET count = count + 1 WHERE term_taxonomy_id = $tt" );
1396
+ // }
 
1397
 
1398
+ $values = array();
1399
  $term_order = 0;
1400
+ foreach ( $assign_taxes as $tt )
1401
+ {
1402
+ do_action('wp_all_import_associate_term', $pid, $tt, $tx_name);
1403
+ $values[] = $this->wpdb->prepare( "(%d, %d, %d)", $pid, $tt, ++$term_order);
1404
+ $this->wpdb->query( "UPDATE {$this->wpdb->term_taxonomy} SET count = count + 1 WHERE term_taxonomy_id = $tt" );
1405
+ }
 
 
 
 
 
 
 
1406
 
 
1407
 
1408
+ if ( $values ){
1409
+ if ( false === $this->wpdb->query( "INSERT INTO {$this->wpdb->term_relationships} (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" ) ){
1410
+ $logger and call_user_func($logger, __('<b>ERROR</b> Could not insert term relationship into the database', 'wp_all_import_plugin') . ': '. $this->wpdb->last_error);
1411
+ }
1412
+ }
1413
+
1414
+ wp_cache_delete( $pid, $tx_name . '_relationships' );
1415
+
1416
  }
1417
 
1418
  function create_taxonomy($attr_name, $logger){
plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP All Import - WooCommerce Add-On
4
  Plugin URI: http://www.wpallimport.com/
5
  Description: An extremely easy, drag & drop importer to import WooCommerce simple products. A paid upgrade is available for premium support and support for Variable, Grouped, and External/Affiliate products
6
- Version: 1.3.2
7
  Author: Soflyy
8
  */
9
  /**
@@ -24,7 +24,7 @@ define('PMWI_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
24
  */
25
  define('PMWI_PREFIX', 'pmwi_');
26
 
27
- define('PMWI_FREE_VERSION', '1.3.2');
28
 
29
  define('PMWI_EDITION', 'free');
30
 
3
  Plugin Name: WP All Import - WooCommerce Add-On
4
  Plugin URI: http://www.wpallimport.com/
5
  Description: An extremely easy, drag & drop importer to import WooCommerce simple products. A paid upgrade is available for premium support and support for Variable, Grouped, and External/Affiliate products
6
+ Version: 1.3.3
7
  Author: Soflyy
8
  */
9
  /**
24
  */
25
  define('PMWI_PREFIX', 'pmwi_');
26
 
27
+ define('PMWI_FREE_VERSION', '1.3.3');
28
 
29
  define('PMWI_EDITION', 'free');
30
 
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Import Products from any XML or CSV to WooCommerce ===
2
  Contributors: soflyy, wpallimport
3
  Requires at least: 4.1
4
- Tested up to: 4.7.2
5
- Stable tag: 1.3.2
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  Tags: woocommerce xml import, woocommerce csv import, woocommerce, import, xml, csv, wp all import, csv import, import csv, xml import, import xml, woocommerce csv importer, woocommerce xml importer, csv importer, csv import suite
@@ -83,6 +83,9 @@ The WooCommerce add-on will appear in the Step 4 of WP All Import.
83
 
84
  == Changelog ==
85
 
 
 
 
86
  = 1.3.2 =
87
  * bug fix: updating product gallery
88
  * bug fix: import shipping class
1
  === Import Products from any XML or CSV to WooCommerce ===
2
  Contributors: soflyy, wpallimport
3
  Requires at least: 4.1
4
+ Tested up to: 4.7.3
5
+ Stable tag: 1.3.3
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  Tags: woocommerce xml import, woocommerce csv import, woocommerce, import, xml, csv, wp all import, csv import, import csv, xml import, import xml, woocommerce csv importer, woocommerce xml importer, csv importer, csv import suite
83
 
84
  == Changelog ==
85
 
86
+ = 1.3.3 =
87
+ * improvement: compatibility with WC 3.x
88
+
89
  = 1.3.2 =
90
  * bug fix: updating product gallery
91
  * bug fix: import shipping class
views/admin/import/_tabs/_advanced.php CHANGED
@@ -74,22 +74,32 @@
74
 
75
  <p class="form-field"><?php _e('Catalog visibility','wpai_woocommerce_addon_plugin');?></p>
76
 
77
- <p class="form-field wpallimport-radio-field">
78
- <input type="radio" id="product_visibility_visible" class="switcher" name="is_product_visibility" value="visible" <?php echo 'visible' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
79
- <label for="product_visibility_visible"><?php _e("Catalog/search", "wpai_woocommerce_addon_plugin"); ?></label>
80
- </p>
81
- <p class="form-field wpallimport-radio-field">
82
- <input type="radio" id="product_visibility_catalog" class="switcher" name="is_product_visibility" value="catalog" <?php echo 'catalog' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
83
- <label for="product_visibility_catalog"><?php _e("Catalog", "wpai_woocommerce_addon_plugin"); ?></label>
84
- </p>
85
- <p class="form-field wpallimport-radio-field">
86
- <input type="radio" id="product_visibility_search" class="switcher" name="is_product_visibility" value="search" <?php echo 'search' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
87
- <label for="product_visibility_search"><?php _e("Search", "wpai_woocommerce_addon_plugin"); ?></label>
88
- </p>
89
- <p class="form-field wpallimport-radio-field">
90
- <input type="radio" id="product_visibility_hidden" class="switcher" name="is_product_visibility" value="hidden" <?php echo 'hidden' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
91
- <label for="product_visibility_hidden"><?php _e("Hidden", "wpai_woocommerce_addon_plugin"); ?></label>
92
- </p>
 
 
 
 
 
 
 
 
 
 
93
  <div class="form-field wpallimport-radio-field">
94
  <input type="radio" id="product_visibility_xpath" class="switcher" name="is_product_visibility" value="xpath" <?php echo 'xpath' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
95
  <label for="product_visibility_xpath"><?php _e('Set with XPath', 'wpai_woocommerce_addon_plugin' )?></label>
74
 
75
  <p class="form-field"><?php _e('Catalog visibility','wpai_woocommerce_addon_plugin');?></p>
76
 
77
+ <?php if (function_exists('wc_get_product_visibility_options')): ?>
78
+ <?php $visibility_options = wc_get_product_visibility_options();?>
79
+ <?php foreach ($visibility_options as $visibility_option_key => $visibility_option_name):?>
80
+ <p class="form-field wpallimport-radio-field">
81
+ <input type="radio" id="product_visibility_<?php echo $visibility_option_key;?>" class="switcher" name="is_product_visibility" value="<?php echo $visibility_option_key; ?>" <?php echo $post['is_product_visibility'] == $visibility_option_key ? 'checked="checked"': '' ?>/>
82
+ <label for="product_visibility_<?php echo $visibility_option_key;?>"><?php echo $visibility_option_name; ?></label>
83
+ </p>
84
+ <?php endforeach; ?>
85
+ <?php else: ?>
86
+ <p class="form-field wpallimport-radio-field">
87
+ <input type="radio" id="product_visibility_visible" class="switcher" name="is_product_visibility" value="visible" <?php echo 'visible' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
88
+ <label for="product_visibility_visible"><?php _e("Catalog/search", "wpai_woocommerce_addon_plugin"); ?></label>
89
+ </p>
90
+ <p class="form-field wpallimport-radio-field">
91
+ <input type="radio" id="product_visibility_catalog" class="switcher" name="is_product_visibility" value="catalog" <?php echo 'catalog' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
92
+ <label for="product_visibility_catalog"><?php _e("Catalog", "wpai_woocommerce_addon_plugin"); ?></label>
93
+ </p>
94
+ <p class="form-field wpallimport-radio-field">
95
+ <input type="radio" id="product_visibility_search" class="switcher" name="is_product_visibility" value="search" <?php echo 'search' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
96
+ <label for="product_visibility_search"><?php _e("Search", "wpai_woocommerce_addon_plugin"); ?></label>
97
+ </p>
98
+ <p class="form-field wpallimport-radio-field">
99
+ <input type="radio" id="product_visibility_hidden" class="switcher" name="is_product_visibility" value="hidden" <?php echo 'hidden' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
100
+ <label for="product_visibility_hidden"><?php _e("Hidden", "wpai_woocommerce_addon_plugin"); ?></label>
101
+ </p>
102
+ <?php endif; ?>
103
  <div class="form-field wpallimport-radio-field">
104
  <input type="radio" id="product_visibility_xpath" class="switcher" name="is_product_visibility" value="xpath" <?php echo 'xpath' == $post['is_product_visibility'] ? 'checked="checked"': '' ?>/>
105
  <label for="product_visibility_xpath"><?php _e('Set with XPath', 'wpai_woocommerce_addon_plugin' )?></label>