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

Version Description

  • fixed updating stock qty with disabled manage_stock import
Download this release

Release Info

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

Code changes from version 1.2.7 to 1.2.8

actions/pmxi_after_xml_import.php CHANGED
@@ -6,7 +6,7 @@ function pmwi_pmxi_after_xml_import($import_id)
6
 
7
  $import->getById($import_id);
8
 
9
- if ( ! $import->isEmpty() and in_array($import->options['custom_type'], array('product', 'product_variation')) )
10
  {
11
  $product_cats = get_terms( 'product_cat', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
12
 
6
 
7
  $import->getById($import_id);
8
 
9
+ if ( ! $import->isEmpty() and in_array($import->options['custom_type'], array('product', 'product_variation')) and $import->options['is_keep_former_posts'] == 'no' and ( $import->options['update_all_data'] == 'yes' or $import->options['is_update_categories']))
10
  {
11
  $product_cats = get_terms( 'product_cat', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
12
 
actions/pmxi_extend_options_main.php CHANGED
@@ -4,7 +4,7 @@ function pmwi_pmxi_extend_options_main($entry, $post = array()){
4
  if ($entry != 'product' and empty($post['is_override_post_type'])) return;
5
 
6
  $woo_controller = new PMWI_Admin_Import();
7
- $woo_controller->index();
8
 
9
  }
10
  ?>
4
  if ($entry != 'product' and empty($post['is_override_post_type'])) return;
5
 
6
  $woo_controller = new PMWI_Admin_Import();
7
+ $woo_controller->index($post);
8
 
9
  }
10
  ?>
controllers/admin/import.php CHANGED
@@ -1,53 +1,16 @@
1
  <?php
2
- /**
3
- * Import configuration wizard
4
  *
5
  * @author Pavel Kulbakin <p.kulbakin@gmail.com>
6
  */
7
 
8
- class PMWI_Admin_Import extends PMWI_Controller_Admin {
9
-
10
- /**
11
- * Step #1: Choose File
12
- */
13
- public function index() {
14
-
15
- $default = PMWI_Plugin::get_default_import_options();
16
-
17
- $this->data['id'] = $id = $this->input->get('id');
18
-
19
- $this->data['import'] = $import = new PMXI_Import_Record();
20
- if ( ! $id or $import->getById($id)->isEmpty()) { // specified import is not found
21
- $DefaultOptions = ((!empty(PMXI_Plugin::$session->options)) ? PMXI_Plugin::$session->options : array()) + $default;
22
- $post = $this->input->post( apply_filters( 'pmxi_options_options', $DefaultOptions, true) );
23
- }
24
- else
25
- $post = $this->input->post(
26
- $this->data['import']->options
27
- + $default
28
- );
29
-
30
- $this->data['is_loaded_template'] = (!empty(PMXI_Plugin::$session->is_loaded_template)) ? PMXI_Plugin::$session->is_loaded_template : false;
31
-
32
- $load_options = $this->input->post('load_template');
33
-
34
- if ($load_options) { // init form with template selected
35
-
36
- $template = new PMXI_Template_Record();
37
- if ( ! $template->getById($this->data['is_loaded_template'])->isEmpty()) {
38
- $post = (!empty($template->options) ? $template->options : array()) + $default;
39
- }
40
-
41
- } elseif ($load_options == -1){
42
-
43
- $post = $default;
44
-
45
- }
46
 
47
  $this->data['post'] =& $post;
48
 
49
  $this->render();
50
 
51
- }
52
-
53
  }
1
  <?php
2
+ /**
 
3
  *
4
  * @author Pavel Kulbakin <p.kulbakin@gmail.com>
5
  */
6
 
7
+ class PMWI_Admin_Import extends PMWI_Controller_Admin
8
+ {
9
+ public function index($post) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  $this->data['post'] =& $post;
12
 
13
  $this->render();
14
 
15
+ }
 
16
  }
filters/pmxi_custom_types.php CHANGED
@@ -1,9 +1,42 @@
1
  <?php
2
- function pmwi_pmxi_custom_types($custom_types){
3
- if ( ! empty($custom_types['product']) and class_exists('WooCommerce') ) $custom_types['product']->labels->name = __('WooCommerce Products','wpai_woocommerce_addon_plugin');
4
- if ( ! empty($custom_types['product_variation'])) unset($custom_types['product_variation']);
5
- if ( ! empty($custom_types['shop_order']) and class_exists('WooCommerce') ) $custom_types['shop_order']->labels->name = __('WooCommerce Orders','wpai_woocommerce_addon_plugin');
 
 
 
 
 
 
6
 
7
- return $custom_types;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
9
- ?>
 
 
1
  <?php
2
+
3
+ function pmwi_pmxi_custom_types($custom_types)
4
+ {
5
+ if (class_exists('WooCommerce'))
6
+ {
7
+ if ( ! empty($custom_types['product']) ) $custom_types['product']->labels->name = __('WooCommerce Products','wpai_woocommerce_addon_plugin');
8
+ if ( ! empty($custom_types['shop_order']) ) $custom_types['shop_order']->labels->name = __('WooCommerce Orders','wpai_woocommerce_addon_plugin');
9
+ if ( ! empty($custom_types['shop_coupon'])) unset($custom_types['shop_coupon']);
10
+ if ( ! empty($custom_types['product_variation'])) unset($custom_types['product_variation']);
11
+ if ( ! empty($custom_types['shop_order_refund'])) unset($custom_types['shop_order_refund']);
12
 
13
+ $order = array('shop_order', 'product');
14
+
15
+ $ordered_custom_types = array();
16
+
17
+ foreach ($order as $type)
18
+ {
19
+ if (isset($ordered_custom_types[$type])) continue;
20
+
21
+ foreach ($custom_types as $key => $custom_type)
22
+ {
23
+ if (isset($ordered_custom_types[$key])) continue;
24
+
25
+ if (in_array($key, $order))
26
+ {
27
+ if ($key == $type)
28
+ {
29
+ $ordered_custom_types[$key] = $custom_type;
30
+ }
31
+ }
32
+ else
33
+ {
34
+ $ordered_custom_types[$key] = $custom_type;
35
+ }
36
+ }
37
+ }
38
+ return $ordered_custom_types;
39
  }
40
+
41
+ return $custom_types;
42
+ }
models/import/record.php CHANGED
@@ -1147,7 +1147,9 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1147
  $this->pushmeta( $pid, '_stock_status', $stock_status );
1148
  }
1149
 
1150
- if ( $product_manage_stock[$i] == 'yes' ) {
 
 
1151
  $this->pushmeta( $pid, '_stock', wc_stock_amount( $product_stock_qty[$i] ) );
1152
  } else {
1153
  $this->pushmeta($pid, '_stock', '');
@@ -1198,7 +1200,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1198
  if ( isset( $product_download_type[$i] ) )
1199
  $this->pushmeta($pid, '_download_type', esc_attr( $product_download_type[$i] ));
1200
 
1201
- }
1202
 
1203
  // prepare bulk SQL query
1204
  //$this->executeSQL();
@@ -1210,7 +1212,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1210
  public function saved_post( $importData )
1211
  {
1212
 
1213
- if ( ! in_array($importData['import']->options['custom_type'], array('product', 'product_variation'))) return;
1214
 
1215
  $table = $this->wpdb->posts;
1216
 
@@ -1218,47 +1220,68 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1218
 
1219
  if ($p)
1220
  {
1221
- $post_to_update_id = $importData['pid'];
1222
 
1223
- update_post_meta( $post_to_update_id, '_product_version', WC_VERSION );
 
 
 
1224
 
1225
- // [associate linked products]
1226
- $wp_all_import_not_linked_products = get_option('wp_all_import_not_linked_products_' . $importData['import']->id );
1227
 
1228
- if ( ! empty($wp_all_import_not_linked_products) )
1229
- {
1230
- $post_to_update_sku = get_post_meta($post_to_update_id, '_sku', true);
1231
-
1232
- foreach ($wp_all_import_not_linked_products as $product)
1233
- {
1234
- if ( $product['pid'] != $post_to_update_id && ! empty($product['not_linked_products']) )
1235
- {
1236
- if ( in_array($post_to_update_sku, $product['not_linked_products'])
1237
- or in_array( (string) $post_to_update_id, $product['not_linked_products'])
1238
- or in_array($p->post_title, $product['not_linked_products'])
1239
- or in_array($p->post_name, $product['not_linked_products'])
1240
- )
1241
- {
1242
- $linked_products = get_post_meta($product['pid'], $product['type'], true);
1243
-
1244
- if (empty($linked_products)) $linked_products = array();
1245
 
1246
- if ( ! in_array($post_to_update_id, $linked_products))
1247
- {
1248
- $linked_products[] = $post_to_update_id;
1249
 
1250
- $importData['logger'] and call_user_func($importData['logger'], sprintf(__('Added to %s list of product ID %d.', 'wpai_woocommerce_addon_plugin'), $product['type'] == '_upsell_ids' ? 'Up-Sells' : 'Cross-Sells', $product['pid']) );
1251
 
1252
- update_post_meta($product['pid'], $product['type'], $linked_products);
1253
-
1254
- }
1255
- }
 
1256
  }
1257
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1258
  }
1259
- // [\associate linked products]
 
1260
 
1261
- wc_delete_product_transients($post_to_update_id);
1262
  }
1263
 
1264
 
@@ -1366,7 +1389,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1366
  wp_cache_delete( $pid, $tx_name . '_relationships' );
1367
 
1368
  //_wc_term_recount( $assign_taxes, $tx_name );
1369
- }
1370
 
1371
  function create_taxonomy($attr_name, $logger){
1372
 
@@ -1426,7 +1449,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1426
  }
1427
  }
1428
  }
1429
- }
1430
 
1431
  public function _filter_has_cap_unfiltered_html($caps)
1432
  {
1147
  $this->pushmeta( $pid, '_stock_status', $stock_status );
1148
  }
1149
 
1150
+ $current_manage_stock = get_post_meta( $pid, '_manage_stock', true );
1151
+
1152
+ if ( $product_manage_stock[$i] == 'yes' || ! $this->is_update_cf('_manage_stock') && $current_manage_stock == 'yes') {
1153
  $this->pushmeta( $pid, '_stock', wc_stock_amount( $product_stock_qty[$i] ) );
1154
  } else {
1155
  $this->pushmeta($pid, '_stock', '');
1200
  if ( isset( $product_download_type[$i] ) )
1201
  $this->pushmeta($pid, '_download_type', esc_attr( $product_download_type[$i] ));
1202
 
1203
+ }
1204
 
1205
  // prepare bulk SQL query
1206
  //$this->executeSQL();
1212
  public function saved_post( $importData )
1213
  {
1214
 
1215
+ if ( ! in_array($importData['import']->options['custom_type'], array('product', 'product_variation'))) return;
1216
 
1217
  $table = $this->wpdb->posts;
1218
 
1220
 
1221
  if ($p)
1222
  {
1223
+ $post_to_update_id = false;
1224
 
1225
+ if ($p->post_type != 'product_variation')
1226
+ {
1227
+ update_post_meta( $importData['pid'], '_product_version', WC_VERSION );
1228
+ $post_to_update_id = $importData['pid'];
1229
 
1230
+ // [associate linked products]
1231
+ $wp_all_import_not_linked_products = get_option('wp_all_import_not_linked_products_' . $importData['import']->id );
1232
 
1233
+ if ( ! empty($wp_all_import_not_linked_products) )
1234
+ {
1235
+ $post_to_update_sku = get_post_meta($post_to_update_id, '_sku', true);
1236
+
1237
+ foreach ($wp_all_import_not_linked_products as $product)
1238
+ {
1239
+ if ( $product['pid'] != $post_to_update_id && ! empty($product['not_linked_products']) )
1240
+ {
1241
+ if ( in_array($post_to_update_sku, $product['not_linked_products'])
1242
+ or in_array( (string) $post_to_update_id, $product['not_linked_products'])
1243
+ or in_array($p->post_title, $product['not_linked_products'])
1244
+ or in_array($p->post_name, $product['not_linked_products'])
1245
+ )
1246
+ {
1247
+ $linked_products = get_post_meta($product['pid'], $product['type'], true);
1248
+
1249
+ if (empty($linked_products)) $linked_products = array();
1250
 
1251
+ if ( ! in_array($post_to_update_id, $linked_products))
1252
+ {
1253
+ $linked_products[] = $post_to_update_id;
1254
 
1255
+ $importData['logger'] and call_user_func($importData['logger'], sprintf(__('Added to %s list of product ID %d.', 'wpai_woocommerce_addon_plugin'), $product['type'] == '_upsell_ids' ? 'Up-Sells' : 'Cross-Sells', $product['pid']) );
1256
 
1257
+ update_post_meta($product['pid'], $product['type'], $linked_products);
1258
+
1259
+ }
1260
+ }
1261
+ }
1262
  }
1263
  }
1264
+ // [\associate linked products]
1265
+ }
1266
+
1267
+ // [update product gallery]
1268
+ $tmp_gallery = explode(",", get_post_meta( $post_to_update_id, '_product_image_gallery_tmp', true));
1269
+ $gallery = explode(",", get_post_meta( $post_to_update_id, '_product_image_gallery', true));
1270
+ if (is_array($gallery)){
1271
+ $gallery = array_filter($gallery);
1272
+ if ( ! empty($tmp_gallery))
1273
+ {
1274
+ $gallery = array_unique(array_merge($gallery, $tmp_gallery));
1275
+ }
1276
+ }
1277
+ elseif ( ! empty($tmp_gallery))
1278
+ {
1279
+ $gallery = $tmp_gallery;
1280
  }
1281
+ update_post_meta( $post_to_update_id, '_product_image_gallery', implode(",", $gallery) );
1282
+ // [\update product gallery]
1283
 
1284
+ wc_delete_product_transients($importData['pid']);
1285
  }
1286
 
1287
 
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){
1395
 
1449
  }
1450
  }
1451
  }
1452
+ }
1453
 
1454
  public function _filter_has_cap_unfiltered_html($caps)
1455
  {
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.2.7
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.2.7');
28
 
29
  define('PMWI_EDITION', 'free');
30
 
@@ -557,7 +557,9 @@ final class PMWI_Plugin {
557
  'multiple_variable_product_tax_class' => 'parent',
558
  'single_variable_product_tax_class' => '',
559
  'variable_stock_status' => 'instock',
560
- 'single_variable_stock_status' => '',
 
 
561
  'is_variable_product_downloadable' => 'no',
562
  'single_variable_product_downloadable' => '',
563
  'variable_attribute_name' => array(),
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.2.8
7
  Author: Soflyy
8
  */
9
  /**
24
  */
25
  define('PMWI_PREFIX', 'pmwi_');
26
 
27
+ define('PMWI_FREE_VERSION', '1.2.8');
28
 
29
  define('PMWI_EDITION', 'free');
30
 
557
  'multiple_variable_product_tax_class' => 'parent',
558
  'single_variable_product_tax_class' => '',
559
  'variable_stock_status' => 'instock',
560
+ 'single_variable_stock_status' => '',
561
+ 'variable_allow_backorders' => 'no',
562
+ 'single_variable_allow_backorders' => '',
563
  'is_variable_product_downloadable' => 'no',
564
  'single_variable_product_downloadable' => '',
565
  'variable_attribute_name' => array(),
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.4.2
5
- Stable tag: 1.2.7
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.2.7 =
87
  * fixed compatibility with WPML ( import multilingual attributes )
88
  * added possibility to import up & cross sells by product SKU, ID, Title
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.5.1
5
+ Stable tag: 1.2.8
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.2.8 =
87
+ * fixed updating stock qty with disabled manage_stock import
88
+
89
  = 1.2.7 =
90
  * fixed compatibility with WPML ( import multilingual attributes )
91
  * added possibility to import up & cross sells by product SKU, ID, Title
views/admin/import/index.php CHANGED
@@ -12,23 +12,23 @@
12
  <h3 class="hndle" style="margin-top:0;">
13
  <span>
14
  <div class="main_choise" style="padding:0px; margin-right:0px;">
15
- <input type="radio" id="multiple_product_type_yes" class="switcher" name="is_multiple_product_type" value="yes" <?php echo 'no' != $post['is_multiple_product_type'] ? 'checked="checked"': '' ?>/>
16
  <label for="multiple_product_type_yes"><?php _e('Product Type', 'wpai_woocommerce_addon_plugin' )?></label>
17
  </div>
18
  <div class="switcher-target-multiple_product_type_yes" style="float:left;">
19
- <div class="input">
20
  <select name="multiple_product_type" id="product-type">
21
  <optgroup label="Product Type">
22
- <option value="simple" <?php echo 'simple' == $post['multiple_product_type'] ? 'selected="selected"': '' ?>><?php _e('Simple product', 'wpai_woocommerce_addon_plugin');?></option>
23
- <option value="grouped" <?php echo 'grouped' == $post['multiple_product_type'] ? 'selected="selected"': '' ?>><?php _e('Grouped product','wpai_woocommerce_addon_plugin');?></option>
24
- <option value="external" <?php echo 'external' == $post['multiple_product_type'] ? 'selected="selected"': '' ?>><?php _e('External/Affiliate product','wpai_woocommerce_addon_plugin');?></option>
25
- <option value="variable" <?php echo 'variable' == $post['multiple_product_type'] ? 'selected="selected"': '' ?>><?php _e('Variable product','wpai_woocommerce_addon_plugin');?></option>
26
  </optgroup>
27
  </select>
28
  </div>
29
  </div>
30
  <div class="main_choise" style="padding:0px; margin-left:40px;">
31
- <input type="radio" id="multiple_product_type_no" class="switcher" name="is_multiple_product_type" value="no" <?php echo 'no' == $post['is_multiple_product_type'] ? 'checked="checked"': '' ?> disabled="disabled"/>
32
  <label for="multiple_product_type_no"><?php _e('Set Product Type With XPath', 'wpai_woocommerce_addon_plugin' )?></label>
33
  </div>
34
  <div class="switcher-target-multiple_product_type_no" style="float:left;">
12
  <h3 class="hndle" style="margin-top:0;">
13
  <span>
14
  <div class="main_choise" style="padding:0px; margin-right:0px;">
15
+ <input type="radio" id="multiple_product_type_yes" class="switcher" name="is_multiple_product_type" value="yes" checked="checked" />
16
  <label for="multiple_product_type_yes"><?php _e('Product Type', 'wpai_woocommerce_addon_plugin' )?></label>
17
  </div>
18
  <div class="switcher-target-multiple_product_type_yes" style="float:left;">
19
+ <div class="input">
20
  <select name="multiple_product_type" id="product-type">
21
  <optgroup label="Product Type">
22
+ <option value="simple" selected="selected"><?php _e('Simple product', 'wpai_woocommerce_addon_plugin');?></option>
23
+ <option value="grouped"><?php _e('Grouped product','wpai_woocommerce_addon_plugin');?></option>
24
+ <option value="external"><?php _e('External/Affiliate product','wpai_woocommerce_addon_plugin');?></option>
25
+ <option value="variable"><?php _e('Variable product','wpai_woocommerce_addon_plugin');?></option>
26
  </optgroup>
27
  </select>
28
  </div>
29
  </div>
30
  <div class="main_choise" style="padding:0px; margin-left:40px;">
31
+ <input type="radio" id="multiple_product_type_no" class="switcher" name="is_multiple_product_type" value="no" disabled="disabled"/>
32
  <label for="multiple_product_type_no"><?php _e('Set Product Type With XPath', 'wpai_woocommerce_addon_plugin' )?></label>
33
  </div>
34
  <div class="switcher-target-multiple_product_type_no" style="float:left;">