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

Version Description

  • bug fix: import product attributes
Download this release

Release Info

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

Code changes from version 1.3.4 to 1.3.5

Files changed (3) hide show
  1. models/import/record.php +63 -54
  2. plugin.php +2 -2
  3. readme.txt +5 -2
models/import/record.php CHANGED
@@ -1461,67 +1461,76 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1461
 
1462
  wp_cache_delete( $pid, $tx_name . '_relationships' );
1463
 
1464
- }
1465
-
1466
- function create_taxonomy($attr_name, $logger){
1467
-
1468
- global $woocommerce;
1469
 
1470
- if ( ! taxonomy_exists( wc_attribute_taxonomy_name( $attr_name ) ) ) {
1471
 
1472
- // Grab the submitted data
1473
- $attribute_name = ( isset( $attr_name ) ) ? wc_sanitize_taxonomy_name( stripslashes( (string) $attr_name ) ) : '';
1474
- $attribute_label = stripslashes( (string) $attr_name );
1475
- $attribute_type = 'select';
1476
- $attribute_orderby = 'menu_order';
1477
 
1478
- // if ( in_array( $attribute_name, $this->reserved_terms ) ) {
1479
- // $attribute_name .= 's';
1480
- // }
1481
 
1482
- if ( in_array( $attribute_name, $this->reserved_terms ) ) {
1483
- $logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Slug “%s” is not allowed because it is a reserved term. Change it, please.', 'wpai_woocommerce_addon_plugin'), wc_attribute_taxonomy_name( $attribute_name )));
1484
- }
1485
- else{
1486
 
1487
- // Register the taxonomy now so that the import works!
1488
- $domain = wc_attribute_taxonomy_name( $attr_name );
1489
- if (strlen($domain) <= 32){
 
 
1490
 
1491
- $this->wpdb->insert(
1492
- $this->wpdb->prefix . 'woocommerce_attribute_taxonomies',
1493
- array(
1494
- 'attribute_label' => $attribute_label,
1495
- 'attribute_name' => $attribute_name,
1496
- 'attribute_type' => $attribute_type,
1497
- 'attribute_orderby' => $attribute_orderby,
1498
- )
1499
- );
1500
-
1501
- register_taxonomy( $domain,
1502
- apply_filters( 'woocommerce_taxonomy_objects_' . $domain, array('product') ),
1503
- apply_filters( 'woocommerce_taxonomy_args_' . $domain, array(
1504
- 'hierarchical' => true,
1505
- 'show_ui' => false,
1506
- 'query_var' => true,
1507
- 'rewrite' => false,
1508
- ) )
1509
- );
1510
-
1511
- delete_transient( 'wc_attribute_taxonomies' );
1512
- $attribute_taxonomies = $this->wpdb->get_results( "SELECT * FROM " . $this->wpdb->prefix . "woocommerce_attribute_taxonomies" );
1513
- set_transient( 'wc_attribute_taxonomies', $attribute_taxonomies );
1514
- apply_filters( 'woocommerce_attribute_taxonomies', $attribute_taxonomies );
1515
-
1516
- $logger and call_user_func($logger, sprintf(__('- <b>CREATED</b>: Taxonomy attribute “%s” have been successfully created.', 'wpai_woocommerce_addon_plugin'), wc_attribute_taxonomy_name( $attribute_name )));
 
 
 
 
 
 
 
 
 
 
 
1517
 
1518
- }
1519
- else{
1520
- $logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Taxonomy “%s” name is more than 32 characters. Change it, please.', 'wpai_woocommerce_addon_plugin'), $attr_name));
1521
- }
1522
- }
1523
- }
1524
- }
 
 
 
 
 
 
 
 
 
1525
 
1526
  public function _filter_has_cap_unfiltered_html($caps)
1527
  {
1461
 
1462
  wp_cache_delete( $pid, $tx_name . '_relationships' );
1463
 
1464
+ }
 
 
 
 
1465
 
1466
+ function create_taxonomy($attr_name, $logger, $prefix = 1){
1467
 
1468
+ global $woocommerce;
 
 
 
 
1469
 
1470
+ $attr_name_real = $prefix > 1 ? $attr_name . " " . $prefix : $attr_name;
 
 
1471
 
1472
+ if ( ! taxonomy_exists( wc_attribute_taxonomy_name( $attr_name_real ) ) ) {
 
 
 
1473
 
1474
+ // Grab the submitted data
1475
+ $attribute_name = ( isset( $attr_name ) ) ? wc_sanitize_taxonomy_name( stripslashes( (string) $attr_name_real ) ) : '';
1476
+ $attribute_label = stripslashes( (string) $attr_name );
1477
+ $attribute_type = 'select';
1478
+ $attribute_orderby = 'menu_order';
1479
 
1480
+ if ( in_array( wc_sanitize_taxonomy_name( stripslashes( (string) $attr_name_real)), $this->reserved_terms ) ) {
1481
+ $prefix++;
1482
+ return $this->create_taxonomy($attr_name, $logger, $prefix);
1483
+ //$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Slug “%s” is not allowed because it is a reserved term. Change it, please.', 'wpai_woocommerce_addon_plugin'), wc_attribute_taxonomy_name( $attribute_name )));
1484
+ }
1485
+ else{
1486
+
1487
+ // Register the taxonomy now so that the import works!
1488
+ $domain = wc_attribute_taxonomy_name( $attr_name_real );
1489
+ if (strlen($domain) <= 28){
1490
+
1491
+ $this->wpdb->insert(
1492
+ $this->wpdb->prefix . 'woocommerce_attribute_taxonomies',
1493
+ array(
1494
+ 'attribute_label' => $attribute_label,
1495
+ 'attribute_name' => $attribute_name,
1496
+ 'attribute_type' => $attribute_type,
1497
+ 'attribute_orderby' => $attribute_orderby,
1498
+ )
1499
+ );
1500
+
1501
+ register_taxonomy( $domain,
1502
+ apply_filters( 'woocommerce_taxonomy_objects_' . $domain, array('product') ),
1503
+ apply_filters( 'woocommerce_taxonomy_args_' . $domain, array(
1504
+ 'hierarchical' => true,
1505
+ 'show_ui' => false,
1506
+ 'query_var' => true,
1507
+ 'rewrite' => false,
1508
+ ) )
1509
+ );
1510
+
1511
+ delete_transient( 'wc_attribute_taxonomies' );
1512
+ $attribute_taxonomies = $this->wpdb->get_results( "SELECT * FROM " . $this->wpdb->prefix . "woocommerce_attribute_taxonomies" );
1513
+ set_transient( 'wc_attribute_taxonomies', $attribute_taxonomies );
1514
+ apply_filters( 'woocommerce_attribute_taxonomies', $attribute_taxonomies );
1515
+
1516
+ $logger and call_user_func($logger, sprintf(__('- <b>CREATED</b>: Taxonomy attribute “%s” have been successfully created.', 'wpai_woocommerce_addon_plugin'), wc_attribute_taxonomy_name( $attribute_name )));
1517
 
1518
+ }
1519
+ else{
1520
+ $logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Taxonomy “%s” name is more than 28 characters. Change it, please.', 'wpai_woocommerce_addon_plugin'), $attr_name));
1521
+ }
1522
+ }
1523
+ }
1524
+ else{
1525
+ if ( in_array( wc_sanitize_taxonomy_name( stripslashes( (string) $attr_name_real)), $this->reserved_terms ) ) {
1526
+ $prefix++;
1527
+ return $this->create_taxonomy($attr_name, $logger, $prefix);
1528
+ //$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Slug “%s” is not allowed because it is a reserved term. Change it, please.', 'wpai_woocommerce_addon_plugin'), wc_attribute_taxonomy_name( $attribute_name )));
1529
+ }
1530
+ }
1531
+
1532
+ return $attr_name_real;
1533
+ }
1534
 
1535
  public function _filter_has_cap_unfiltered_html($caps)
1536
  {
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.4
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.4');
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.5
7
  Author: Soflyy
8
  */
9
  /**
24
  */
25
  define('PMWI_PREFIX', 'pmwi_');
26
 
27
+ define('PMWI_FREE_VERSION', '1.3.5');
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.5
5
- Stable tag: 1.3.4
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.4 =
87
  - bug fix: import product visibility WC 3.0
88
  - bug fix: stock threshold
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.8
5
+ Stable tag: 1.3.5
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.5 =
87
+ - bug fix: import product attributes
88
+
89
  = 1.3.4 =
90
  - bug fix: import product visibility WC 3.0
91
  - bug fix: stock threshold