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

Version Description

  • Compatibility with WP 3.8
Download this release

Release Info

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

Code changes from version 1.0.1 to 1.1.0

actions/admin_notices.php CHANGED
@@ -31,6 +31,19 @@ function pmwi_admin_notices() {
31
 
32
  }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  $input = new PMWI_Input();
35
  $messages = $input->get('PMWI_nt', array());
36
  if ($messages) {
31
 
32
  }
33
 
34
+ if ( class_exists( 'PMXI_Plugin' ) and ( version_compare(PMXI_VERSION, '3.3.3') <= 0 and PMXI_EDITION == 'paid' or version_compare(PMXI_VERSION, '3.1.0') < 0 and PMXI_EDITION == 'free') ) {
35
+ ?>
36
+ <div class="error"><p>
37
+ <?php printf(
38
+ __('<b>%s Plugin</b>: Please update your WP All Import to the latest version', 'pmwi_plugin'),
39
+ PMWI_Plugin::getInstance()->getName()
40
+ ) ?>
41
+ </p></div>
42
+ <?php
43
+
44
+ deactivate_plugins( PMWI_FREE_ROOT_DIR . '/plugin.php');
45
+ }
46
+
47
  $input = new PMWI_Input();
48
  $messages = $input->get('PMWI_nt', array());
49
  if ($messages) {
actions/pmxi_extend_options_main.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function pmwi_pmxi_extend_options_main($entry){
3
+
4
+ if ($entry != 'product') return;
5
+
6
+ $woo_controller = new PMWI_Admin_Import();
7
+ $woo_controller->index();
8
+
9
+ }
10
+ ?>
actions/pmxi_reimport.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function pmwi_pmxi_reimport($entry, $post){
3
+
4
+ if ( $entry != "product" ) return;
5
+
6
+ $all_existing_attributes = array();
7
+ $hide_taxonomies = array('product_type');
8
+ $post_taxonomies = array_diff_key(get_taxonomies_by_object_type(array($entry), 'object'), array_flip($hide_taxonomies));
9
+ if (!empty($post_taxonomies)):
10
+ foreach ($post_taxonomies as $ctx): if ("" == $ctx->labels->name or strpos($ctx->name, "pa_") === false) continue;
11
+ $all_existing_attributes[] = $ctx->name;
12
+ endforeach;
13
+ endif;
14
+ if (!empty($existing_attributes)):
15
+ foreach ($existing_attributes as $key => $attr) {
16
+ $all_existing_attributes[] = $attr;
17
+ }
18
+ endif;
19
+
20
+ ?>
21
+ <div class="input">
22
+ <input type="hidden" name="attributes_list" value="0" />
23
+ <input type="hidden" name="is_update_attributes" value="0" />
24
+ <input type="checkbox" id="is_update_attributes_<?php echo $entry; ?>" name="is_update_attributes" value="1" <?php echo $post['is_update_attributes'] ? 'checked="checked"': '' ?> class="switcher"/>
25
+ <label for="is_update_attributes_<?php echo $entry; ?>"><?php _e('Attributes', 'pmxi_plugin') ?></label>
26
+ <!--a href="#help" class="help" title="<?php _e('If Keep Custom Fields box is checked, it will keep all Custom Fields, and add any new Custom Fields specified in Custom Fields section, as long as they do not overwrite existing fields. If \'Only keep this Custom Fields\' is specified, it will only keep the specified fields.', 'pmxi_plugin') ?>">?</a-->
27
+ <div class="switcher-target-is_update_attributes_<?php echo $entry; ?>" style="padding-left:17px;">
28
+ <div class="input">
29
+ <input type="radio" id="update_attributes_logic_full_update_<?php echo $entry; ?>" name="update_attributes_logic" value="full_update" <?php echo ( "full_update" == $post['update_attributes_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
30
+ <label for="update_attributes_logic_full_update_<?php echo $entry; ?>"><?php _e('Update all Attributes', 'pmxi_plugin') ?></label>
31
+ </div>
32
+ <div class="input">
33
+ <input type="radio" id="update_attributes_logic_only_<?php echo $entry; ?>" name="update_attributes_logic" value="only" <?php echo ( "only" == $post['update_attributes_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
34
+ <label for="update_attributes_logic_only_<?php echo $entry; ?>"><?php _e('Update only these Attributes, leave the rest alone', 'pmxi_plugin') ?></label>
35
+ <div class="switcher-target-update_attributes_logic_only_<?php echo $entry; ?> pmxi_choosen" style="padding-left:17px;">
36
+
37
+ <span class="hidden choosen_values"><?php if (!empty($all_existing_attributes)) echo implode(',', $all_existing_attributes);?></span>
38
+ <input class="choosen_input" value="<?php if (!empty($post['attributes_list']) and "only" == $post['update_attributes_logic']) echo implode(',', $post['attributes_list']); ?>" type="hidden" name="attributes_only_list"/>
39
+ </div>
40
+ </div>
41
+ <div class="input">
42
+ <input type="radio" id="update_attributes_logic_all_except_<?php echo $entry; ?>" name="update_attributes_logic" value="all_except" <?php echo ( "all_except" == $post['update_attributes_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
43
+ <label for="update_attributes_logic_all_except_<?php echo $entry; ?>"><?php _e('Leave these attributes alone, update all other Attributes', 'pmxi_plugin') ?></label>
44
+ <div class="switcher-target-update_attributes_logic_all_except_<?php echo $entry; ?> pmxi_choosen" style="padding-left:17px;">
45
+
46
+ <span class="hidden choosen_values"><?php if (!empty($all_existing_attributes)) echo implode(',', $all_existing_attributes);?></span>
47
+ <input class="choosen_input" value="<?php if (!empty($post['attributes_list']) and "all_except" == $post['update_attributes_logic']) echo implode(',', $post['attributes_list']); ?>" type="hidden" name="attributes_except_list"/>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ <?php
53
+ }
54
+ ?>
config/options.php CHANGED
@@ -4,5 +4,5 @@
4
  * and can be changed by corresponding wordpress function calls
5
  */
6
  $config = array(
7
- "info_api_url" => "",
8
  );
4
  * and can be changed by corresponding wordpress function calls
5
  */
6
  $config = array(
7
+ /*"info_api_url" => "http://www.wpallimport.com/adminpanel/wooco-update/info.php", */
8
  );
controllers/controller/admin.php CHANGED
@@ -42,6 +42,9 @@ abstract class PMWI_Controller_Admin extends PMWI_Controller {
42
 
43
  wp_enqueue_style('pmwi-admin-style', PMWI_FREE_ROOT_URL . '/static/css/admin.css');
44
 
 
 
 
45
 
46
  wp_enqueue_script('pmwi-script', PMWI_FREE_ROOT_URL . '/static/js/pmwi.js', array('jquery'));
47
  wp_enqueue_script('pmwi-admin-script', PMWI_FREE_ROOT_URL . '/static/js/admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-resizable', 'jquery-ui-dialog', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'pmxi-admin-script'));
42
 
43
  wp_enqueue_style('pmwi-admin-style', PMWI_FREE_ROOT_URL . '/static/css/admin.css');
44
 
45
+ if ( version_compare(get_bloginfo('version'), '3.8-RC1') >= 0 ){
46
+ wp_enqueue_style('pmwi-admin-style-wp-3.8', PMWI_FREE_ROOT_URL . '/static/css/admin-wp-3.8.css');
47
+ }
48
 
49
  wp_enqueue_script('pmwi-script', PMWI_FREE_ROOT_URL . '/static/js/pmwi.js', array('jquery'));
50
  wp_enqueue_script('pmwi-admin-script', PMWI_FREE_ROOT_URL . '/static/js/admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-resizable', 'jquery-ui-dialog', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'pmxi-admin-script'));
filters/pmxi_custom_field_to_delete.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function pmwi_pmxi_custom_field_to_delete($field_to_delete, $pid, $post_type, $options, $cur_meta_key){
3
+
4
+ if ($field_to_delete === false || $post_type != "product") return $field_to_delete;
5
+
6
+ // Do not update attributes
7
+ if ($options['update_all_data'] == 'no' and ! $options['is_update_attributes'] and (in_array($cur_meta_key, array('_default_attributes', '_product_attributes')) or strpos($cur_meta_key, "attribute_") === 0)) return false;
8
+
9
+ // Update only these Attributes, leave the rest alone
10
+ if ($options['update_all_data'] == 'no' and $options['is_update_attributes'] and $options['update_attributes_logic'] == 'only'){
11
+
12
+ if ($cur_meta_key == '_product_attributes'){
13
+ $current_product_attributes = get_post_meta($pid, '_product_attributes', true);
14
+ if ( ! empty($current_product_attributes) and ! empty($options['attributes_list']) and is_array($options['attributes_list']))
15
+ foreach ($current_product_attributes as $attr_name => $attr_value) {
16
+ if ( in_array($attr_name, array_filter($options['attributes_list'], 'trim'))) unset($current_product_attributes[$attr_name]);
17
+ }
18
+
19
+ update_post_meta($pid, '_product_attributes', $current_product_attributes);
20
+ return false;
21
+ }
22
+
23
+ if ( strpos($cur_meta_key, "attribute_") === 0 and ! empty($options['attributes_list']) and is_array($options['attributes_list']) and ! in_array(str_replace("attribute_", "", $cur_meta_key), array_filter($options['attributes_list'], 'trim'))) return false;
24
+
25
+ if (in_array($cur_meta_key, array('_default_attributes'))) return false;
26
+
27
+ }
28
+
29
+ // Leave these attributes alone, update all other Attributes
30
+ if ($options['update_all_data'] == 'no' and $options['is_update_attributes'] and $options['update_attributes_logic'] == 'all_except'){
31
+
32
+ if ($cur_meta_key == '_product_attributes'){
33
+
34
+ if (empty($options['attributes_list'])) { delete_post_meta($pid, $cur_meta_key); return false; }
35
+
36
+ $current_product_attributes = get_post_meta($pid, '_product_attributes', true);
37
+ if ( ! empty($current_product_attributes) and ! empty($options['attributes_list']) and is_array($options['attributes_list']))
38
+ foreach ($current_product_attributes as $attr_name => $attr_value) {
39
+ if ( ! in_array($attr_name, array_filter($options['attributes_list'], 'trim'))) unset($current_product_attributes[$attr_name]);
40
+ }
41
+
42
+ update_post_meta($pid, '_product_attributes', $current_product_attributes);
43
+ return false;
44
+ }
45
+
46
+ if ( strpos($cur_meta_key, "attribute_") === 0 and ! empty($options['attributes_list']) and is_array($options['attributes_list']) and in_array(str_replace("attribute_", "", $cur_meta_key), array_filter($options['attributes_list'], 'trim'))) return false;
47
+
48
+ if (in_array($cur_meta_key, array('_default_attributes'))) return false;
49
+ }
50
+
51
+ return true;
52
+ }
53
+ ?>
filters/pmxi_custom_field_to_update.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function pmwi_pmxi_custom_field_to_update( $field_to_update, $post_type, $options, $m_key ){
3
+
4
+ if ($field_to_update === false || $post_type != 'product') return $field_to_update;
5
+
6
+ if ($options['update_attributes_logic'] == 'full_update') return true;
7
+ if ($options['is_update_attributes'] and $options['update_attributes_logic'] == "only" and ! empty($options['attributes_list']) and is_array($options['attributes_list']) and in_array(str_replace("attribute_", "", $m_key), $options['attributes_list']) ) return true;
8
+ if ($options['is_update_attributes'] and $options['update_attributes_logic'] == "all_except" and ( empty($options['attributes_list']) or ! in_array(str_replace("attribute_", "", $m_key), $options['attributes_list']) )) return true;
9
+
10
+ return false;
11
+ }
12
+ ?>
filters/pmxi_custom_types.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ function pmwi_pmxi_custom_types($custom_types){
3
+ if ( ! empty($custom_types['product']) ) $custom_types['product']->labels->name = __('WooCommerce Products','pmxi_plugin');
4
+ return $custom_types;
5
+ }
6
+ ?>
filters/pmxi_do_not_update_existing.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function pmwi_pmxi_do_not_update_existing($current_post_ids, $post_to_update_id){
3
+ $children = get_posts( array(
4
+ 'post_parent' => $post_to_update_id,
5
+ 'posts_per_page'=> -1,
6
+ 'post_type' => 'product_variation',
7
+ 'fields' => 'ids',
8
+ 'post_status' => 'publish'
9
+ ) );
10
+
11
+ if ( $children ) {
12
+ foreach ( $children as $child ) {
13
+ if ( ! in_array($child, $current_post_ids) ) $current_post_ids[] = $child;
14
+ }
15
+ }
16
+ return $current_post_ids;
17
+ }
18
+ ?>
filters/pmxi_save_options.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function pmwi_pmxi_save_options($post){
3
+ if ($post['update_attributes_logic'] == 'only'){
4
+ $post['attributes_list'] = explode(",", $post['attributes_only_list']);
5
+ }
6
+ elseif ($post['update_attributes_logic'] == 'all_except'){
7
+ $post['attributes_list'] = explode(",", $post['attributes_except_list']);
8
+ }
9
+ return $post;
10
+ }
11
+ ?>
models/import/record.php CHANGED
@@ -24,18 +24,25 @@ class PMWI_Import_Record extends PMWI_Model_Record {
24
  * @return PMWI_Import_Record
25
  * @chainable
26
  */
27
- public function process($import, $count, $xml, $logger = NULL, $chunk = false) {
 
 
 
 
 
28
  add_filter('user_has_cap', array($this, '_filter_has_cap_unfiltered_html')); kses_init(); // do not perform special filtering for imported content
29
 
30
- $this->data = array();
31
 
 
32
  $records = array();
 
33
 
34
- ($chunk == 1 or (empty($import->large_import) or $import->large_import == 'No')) and $logger and call_user_func($logger, __('Composing product data...', 'pmxi_plugin'));
35
 
36
  // Composing product types
37
  if ($import->options['is_multiple_product_type'] != 'yes' and "" != $import->options['single_product_type']){
38
- $this->data['product_types'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_type'], $file)->parse($records); $tmp_files[] = $file;
39
  }
40
  else{
41
  $count and $this->data['product_types'] = array_fill(0, $count, $import->options['multiple_product_type']);
@@ -43,7 +50,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
43
 
44
  // Composing product is Virtual
45
  if ($import->options['is_product_virtual'] == 'xpath' and "" != $import->options['single_product_virtual']){
46
- $this->data['product_virtual'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_virtual'], $file)->parse($records); $tmp_files[] = $file;
47
  }
48
  else{
49
  $count and $this->data['product_virtual'] = array_fill(0, $count, $import->options['is_product_virtual']);
@@ -51,7 +58,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
51
 
52
  // Composing product is Downloadable
53
  if ($import->options['is_product_downloadable'] == 'xpath' and "" != $import->options['single_product_downloadable']){
54
- $this->data['product_downloadable'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_downloadable'], $file)->parse($records); $tmp_files[] = $file;
55
  }
56
  else{
57
  $count and $this->data['product_downloadable'] = array_fill(0, $count, $import->options['is_product_downloadable']);
@@ -59,7 +66,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
59
 
60
  // Composing product is Variable Enabled
61
  if ($import->options['is_product_enabled'] == 'xpath' and "" != $import->options['single_product_enabled']){
62
- $this->data['product_enabled'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_enabled'], $file)->parse($records); $tmp_files[] = $file;
63
  }
64
  else{
65
  $count and $this->data['product_enabled'] = array_fill(0, $count, $import->options['is_product_enabled']);
@@ -67,7 +74,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
67
 
68
  // Composing product is Featured
69
  if ($import->options['is_product_featured'] == 'xpath' and "" != $import->options['single_product_featured']){
70
- $this->data['product_featured'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_featured'], $file)->parse($records); $tmp_files[] = $file;
71
  }
72
  else{
73
  $count and $this->data['product_featured'] = array_fill(0, $count, $import->options['is_product_featured']);
@@ -75,84 +82,84 @@ class PMWI_Import_Record extends PMWI_Model_Record {
75
 
76
  // Composing product is Visibility
77
  if ($import->options['is_product_visibility'] == 'xpath' and "" != $import->options['single_product_visibility']){
78
- $this->data['product_visibility'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_visibility'], $file)->parse($records); $tmp_files[] = $file;
79
  }
80
  else{
81
  $count and $this->data['product_visibility'] = array_fill(0, $count, $import->options['is_product_visibility']);
82
  }
83
 
84
  if ("" != $import->options['single_product_sku']){
85
- $this->data['product_sku'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_sku'], $file)->parse($records); $tmp_files[] = $file;
86
  }
87
  else{
88
  $count and $this->data['product_sku'] = array_fill(0, $count, "");
89
  }
90
 
91
  if ("" != $import->options['single_product_url']){
92
- $this->data['product_url'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_url'], $file)->parse($records); $tmp_files[] = $file;
93
  }
94
  else{
95
  $count and $this->data['product_url'] = array_fill(0, $count, "");
96
  }
97
 
98
  if ("" != $import->options['single_product_button_text']){
99
- $this->data['product_button_text'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_button_text'], $file)->parse($records); $tmp_files[] = $file;
100
  }
101
  else{
102
  $count and $this->data['product_button_text'] = array_fill(0, $count, "");
103
  }
104
 
105
  if ("" != $import->options['single_product_regular_price']){
106
- $this->data['product_regular_price'] = array_map(array($this, 'prepare_price'), XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_regular_price'], $file)->parse($records)); $tmp_files[] = $file;
107
  }
108
  else{
109
  $count and $this->data['product_regular_price'] = array_fill(0, $count, "");
110
  }
111
 
112
  if ($import->options['is_regular_price_shedule'] and "" != $import->options['single_sale_price_dates_from']){
113
- $this->data['product_sale_price_dates_from'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_sale_price_dates_from'], $file)->parse($records); $tmp_files[] = $file;
114
  }
115
  else{
116
  $count and $this->data['product_sale_price_dates_from'] = array_fill(0, $count, "");
117
  }
118
 
119
  if ($import->options['is_regular_price_shedule'] and "" != $import->options['single_sale_price_dates_to']){
120
- $this->data['product_sale_price_dates_to'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_sale_price_dates_to'], $file)->parse($records); $tmp_files[] = $file;
121
  }
122
  else{
123
  $count and $this->data['product_sale_price_dates_to'] = array_fill(0, $count, "");
124
  }
125
 
126
  if ("" != $import->options['single_product_sale_price']){
127
- $this->data['product_sale_price'] = array_map(array($this, 'prepare_price'), XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_sale_price'], $file)->parse($records)); $tmp_files[] = $file;
128
  }
129
  else{
130
  $count and $this->data['product_sale_price'] = array_fill(0, $count, "");
131
  }
132
 
133
  if ("" != $import->options['single_product_whosale_price']){
134
- $this->data['product_whosale_price'] = array_map(array($this, 'prepare_price'), XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_whosale_price'], $file)->parse($records)); $tmp_files[] = $file;
135
  }
136
  else{
137
  $count and $this->data['product_whosale_price'] = array_fill(0, $count, "");
138
  }
139
 
140
  if ("" != $import->options['single_product_files']){
141
- $this->data['product_files'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_files'], $file)->parse($records); $tmp_files[] = $file;
142
  }
143
  else{
144
  $count and $this->data['product_files'] = array_fill(0, $count, "");
145
  }
146
 
147
  if ("" != $import->options['single_product_download_limit']){
148
- $this->data['product_download_limit'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_download_limit'], $file)->parse($records); $tmp_files[] = $file;
149
  }
150
  else{
151
  $count and $this->data['product_download_limit'] = array_fill(0, $count, "");
152
  }
153
 
154
  if ("" != $import->options['single_product_download_expiry']){
155
- $this->data['product_download_expiry'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_download_expiry'], $file)->parse($records); $tmp_files[] = $file;
156
  }
157
  else{
158
  $count and $this->data['product_download_expiry'] = array_fill(0, $count, "");
@@ -160,7 +167,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
160
 
161
  // Composing product Tax Status
162
  if ($import->options['is_multiple_product_tax_status'] != 'yes' and "" != $import->options['single_product_tax_status']){
163
- $this->data['product_tax_status'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_tax_status'], $file)->parse($records); $tmp_files[] = $file;
164
  }
165
  else{
166
  $count and $this->data['product_tax_status'] = array_fill(0, $count, $import->options['multiple_product_tax_status']);
@@ -168,7 +175,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
168
 
169
  // Composing product Tax Class
170
  if ($import->options['is_multiple_product_tax_class'] != 'yes' and "" != $import->options['single_product_tax_class']){
171
- $this->data['product_tax_class'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_tax_class'], $file)->parse($records); $tmp_files[] = $file;
172
  }
173
  else{
174
  $count and $this->data['product_tax_class'] = array_fill(0, $count, $import->options['multiple_product_tax_class']);
@@ -176,14 +183,14 @@ class PMWI_Import_Record extends PMWI_Model_Record {
176
 
177
  // Composing product Manage stock?
178
  if ($import->options['is_product_manage_stock'] == 'xpath' and "" != $import->options['single_product_manage_stock']){
179
- $this->data['product_manage_stock'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_manage_stock'], $file)->parse($records); $tmp_files[] = $file;
180
  }
181
  else{
182
  $count and $this->data['product_manage_stock'] = array_fill(0, $count, $import->options['is_product_manage_stock']);
183
  }
184
 
185
  if ("" != $import->options['single_product_stock_qty']){
186
- $this->data['product_stock_qty'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_stock_qty'], $file)->parse($records); $tmp_files[] = $file;
187
  }
188
  else{
189
  $count and $this->data['product_stock_qty'] = array_fill(0, $count, "");
@@ -191,7 +198,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
191
 
192
  // Composing product Stock status
193
  if ($import->options['product_stock_status'] == 'xpath' and "" != $import->options['single_product_stock_status']){
194
- $this->data['product_stock_status'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_stock_status'], $file)->parse($records); $tmp_files[] = $file;
195
  }
196
  else{
197
  $count and $this->data['product_stock_status'] = array_fill(0, $count, $import->options['product_stock_status']);
@@ -199,7 +206,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
199
 
200
  // Composing product Allow Backorders?
201
  if ($import->options['product_allow_backorders'] == 'xpath' and "" != $import->options['single_product_allow_backorders']){
202
- $this->data['product_allow_backorders'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_allow_backorders'], $file)->parse($records); $tmp_files[] = $file;
203
  }
204
  else{
205
  $count and $this->data['product_allow_backorders'] = array_fill(0, $count, $import->options['product_allow_backorders']);
@@ -207,32 +214,32 @@ class PMWI_Import_Record extends PMWI_Model_Record {
207
 
208
  // Composing product Sold Individually?
209
  if ($import->options['product_sold_individually'] == 'xpath' and "" != $import->options['single_product_sold_individually']){
210
- $this->data['product_sold_individually'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_sold_individually'], $file)->parse($records); $tmp_files[] = $file;
211
  }
212
  else{
213
  $count and $this->data['product_sold_individually'] = array_fill(0, $count, $import->options['product_sold_individually']);
214
  }
215
 
216
  if ("" != $import->options['single_product_weight']){
217
- $this->data['product_weight'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_weight'], $file)->parse($records); $tmp_files[] = $file;
218
  }
219
  else{
220
  $count and $this->data['product_weight'] = array_fill(0, $count, "");
221
  }
222
  if ("" != $import->options['single_product_length']){
223
- $this->data['product_length'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_length'], $file)->parse($records); $tmp_files[] = $file;
224
  }
225
  else{
226
  $count and $this->data['product_length'] = array_fill(0, $count, "");
227
  }
228
  if ("" != $import->options['single_product_width']){
229
- $this->data['product_width'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_width'], $file)->parse($records); $tmp_files[] = $file;
230
  }
231
  else{
232
  $count and $this->data['product_width'] = array_fill(0, $count, "");
233
  }
234
  if ("" != $import->options['single_product_height']){
235
- $this->data['product_height'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_height'], $file)->parse($records); $tmp_files[] = $file;
236
  }
237
  else{
238
  $count and $this->data['product_height'] = array_fill(0, $count, "");
@@ -240,40 +247,40 @@ class PMWI_Import_Record extends PMWI_Model_Record {
240
 
241
  // Composing product Shipping Class
242
  if ($import->options['is_multiple_product_shipping_class'] != 'yes' and "" != $import->options['single_product_shipping_class']){
243
- $this->data['product_shipping_class'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_shipping_class'], $file)->parse($records); $tmp_files[] = $file;
244
  }
245
  else{
246
  $count and $this->data['product_shipping_class'] = array_fill(0, $count, $import->options['multiple_product_shipping_class']);
247
  }
248
 
249
  if ("" != $import->options['single_product_up_sells']){
250
- $this->data['product_up_sells'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_up_sells'], $file)->parse($records); $tmp_files[] = $file;
251
  }
252
  else{
253
  $count and $this->data['product_up_sells'] = array_fill(0, $count, "");
254
  }
255
  if ("" != $import->options['single_product_cross_sells']){
256
- $this->data['product_cross_sells'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_cross_sells'], $file)->parse($records); $tmp_files[] = $file;
257
  }
258
  else{
259
  $count and $this->data['product_cross_sells'] = array_fill(0, $count, "");
260
  }
261
 
262
  if ("" != $import->options['grouping_product']){
263
- $this->data['product_grouping_parent'] = XmlImportParser::factory($xml, $import->xpath, $import->options['grouping_product'], $file)->parse($records); $tmp_files[] = $file;
264
  }
265
  else{
266
  $count and $this->data['product_grouping_parent'] = array_fill(0, $count, "");
267
  }
268
 
269
  if ("" != $import->options['single_product_purchase_note']){
270
- $this->data['product_purchase_note'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_purchase_note'], $file)->parse($records); $tmp_files[] = $file;
271
  }
272
  else{
273
  $count and $this->data['product_purchase_note'] = array_fill(0, $count, "");
274
  }
275
  if ("" != $import->options['single_product_menu_order']){
276
- $this->data['product_menu_order'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_menu_order'], $file)->parse($records); $tmp_files[] = $file;
277
  }
278
  else{
279
  $count and $this->data['product_menu_order'] = array_fill(0, $count, "");
@@ -281,14 +288,74 @@ class PMWI_Import_Record extends PMWI_Model_Record {
281
 
282
  // Composing product Enable reviews
283
  if ($import->options['is_product_enable_reviews'] == 'xpath' and "" != $import->options['single_product_enable_reviews']){
284
- $this->data['product_enable_reviews'] = XmlImportParser::factory($xml, $import->xpath, $import->options['single_product_enable_reviews'], $file)->parse($records); $tmp_files[] = $file;
285
  }
286
  else{
287
  $count and $this->data['product_enable_reviews'] = array_fill(0, $count, $import->options['is_product_enable_reviews']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
  // Composing variations attributes
291
- ($chunk == 1 or (empty($import->large_import) or $import->large_import == 'No')) and $logger and call_user_func($logger, __('Composing variations attributes...', 'pmxi_plugin'));
292
  $attribute_keys = array();
293
  $attribute_values = array();
294
  $attribute_in_variation = array();
@@ -298,12 +365,12 @@ class PMWI_Import_Record extends PMWI_Model_Record {
298
 
299
  if (!empty($import->options['attribute_name'][0])){
300
  foreach ($import->options['attribute_name'] as $j => $attribute_name) { if ($attribute_name == "") continue;
301
- $attribute_keys[$j] = XmlImportParser::factory($xml, $import->xpath, $attribute_name, $file)->parse($records); $tmp_files[] = $file;
302
- $attribute_values[$j] = XmlImportParser::factory($xml, $import->xpath, $import->options['attribute_value'][$j], $file)->parse($records); $tmp_files[] = $file;
303
- $attribute_in_variation[$j] = XmlImportParser::factory($xml, $import->xpath, $import->options['in_variations'][$j], $file)->parse($records); $tmp_files[] = $file;
304
- $attribute_is_visible[$j] = XmlImportParser::factory($xml, $import->xpath, $import->options['is_visible'][$j], $file)->parse($records); $tmp_files[] = $file;
305
- $attribute_is_taxonomy[$j] = XmlImportParser::factory($xml, $import->xpath, $import->options['is_taxonomy'][$j], $file)->parse($records); $tmp_files[] = $file;
306
- $attribute_create_taxonomy_terms[$j] = XmlImportParser::factory($xml, $import->xpath, $import->options['create_taxonomy_in_not_exists'][$j], $file)->parse($records); $tmp_files[] = $file;
307
  }
308
  }
309
 
@@ -336,9 +403,13 @@ class PMWI_Import_Record extends PMWI_Model_Record {
336
  return ("" == $var) ? false : true;
337
  }
338
 
339
- public function import($pid, $i, $import, $articleData, $xml, $is_cron = false){
 
 
 
 
340
 
341
- $logger = create_function('$m', 'echo "<div class=\\"progress-msg\\">$m</div>\\n"; if ( "" != strip_tags(pmxi_strip_tags_content($m))) { PMXI_Plugin::$session[\'pmxi_import\'][\'log\'] .= "<p>".strip_tags(pmxi_strip_tags_content($m))."</p>"; flush(); }');
342
 
343
  global $woocommerce;
344
 
@@ -363,38 +434,33 @@ class PMWI_Import_Record extends PMWI_Model_Record {
363
 
364
  // Product type + Downloadable/Virtual
365
  wp_set_object_terms( $pid, $product_type, 'product_type' );
366
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_downloadable')) update_post_meta( $pid, '_downloadable', ($is_downloadable == "yes") ? 'yes' : 'no' );
367
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_virtual')) update_post_meta( $pid, '_virtual', ($is_virtual == "yes") ? 'yes' : 'no' );
368
 
369
  // Update post meta
370
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_regular_price')) update_post_meta( $pid, '_regular_price', stripslashes( $product_regular_price[$i] ) );
371
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sale_price')) update_post_meta( $pid, '_sale_price', stripslashes( $product_sale_price[$i] ) );
372
- if ( class_exists('woocommerce_wholesale_pricing') and $this->keep_custom_fields($existing_meta_keys, $import->options, 'wholesale_price')) update_post_meta( $pid, 'pmxi_wholesale_price', stripslashes( $product_whosale_price[$i] ) );
373
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_tax_status')) update_post_meta( $pid, '_tax_status', stripslashes( $product_tax_status[$i] ) );
374
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_tax_class')) update_post_meta( $pid, '_tax_class', stripslashes( $product_tax_class[$i] ) );
375
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_visibility')) update_post_meta( $pid, '_visibility', stripslashes( $product_visibility[$i] ) );
376
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_purchase_note')) update_post_meta( $pid, '_purchase_note', stripslashes( $product_purchase_note[$i] ) );
377
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_featured')) update_post_meta( $pid, '_featured', ($is_featured == "yes") ? 'yes' : 'no' );
378
 
379
  // Dimensions
380
  if ( $is_virtual == 'no' ) {
381
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_weight')) update_post_meta( $pid, '_weight', stripslashes( $product_weight[$i] ) );
382
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_length')) update_post_meta( $pid, '_length', stripslashes( $product_length[$i] ) );
383
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_width')) update_post_meta( $pid, '_width', stripslashes( $product_width[$i] ) );
384
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_height')) update_post_meta( $pid, '_height', stripslashes( $product_height[$i] ) );
385
  } else {
386
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_weight')) update_post_meta( $pid, '_weight', '' );
387
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_length')) update_post_meta( $pid, '_length', '' );
388
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_width')) update_post_meta( $pid, '_width', '' );
389
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_height')) update_post_meta( $pid, '_height', '' );
390
- }
391
 
392
- // Enable reviews
393
- wp_update_post(array(
394
- 'ID' => $pid,
395
- 'comment_status' => ($product_enable_reviews[$i] == 'yes') ? 'open' : 'closed',
396
- 'menu_order' => ($product_menu_order[$i] != '') ? $product_menu_order[$i] : 0
397
- ));
398
 
399
  // Save shipping class
400
  $product_shipping_class = is_numeric($product_shipping_class[$i]) && $product_shipping_class[$i] > 0 && $product_type != 'external' ? absint( $product_shipping_class[$i] ) : $product_shipping_class[$i];
@@ -405,12 +471,12 @@ class PMWI_Import_Record extends PMWI_Model_Record {
405
  $new_sku = esc_html( trim( stripslashes( $product_sku[$i] ) ) );
406
 
407
  if ( $new_sku == '' and $import->options['disable_auto_sku_generation'] ) {
408
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sku'))
409
  update_post_meta( $pid, '_sku', '' );
410
  }
411
  elseif ( $new_sku == '' and ! $import->options['disable_auto_sku_generation'] ) {
412
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sku')){
413
- $unique_keys = XmlImportParser::factory($xml, $import->xpath, $import->options['unique_key'], $file)->parse($records); $tmp_files[] = $file;
414
  foreach ($tmp_files as $file) { // remove all temporary files created
415
  unlink($file);
416
  }
@@ -419,7 +485,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
419
  }
420
  if ( $new_sku != '' and $new_sku !== $sku ) {
421
  if ( ! empty( $new_sku ) ) {
422
- if (
423
  $this->wpdb->get_var( $this->wpdb->prepare("
424
  SELECT ".$this->wpdb->posts.".ID
425
  FROM ".$this->wpdb->posts."
@@ -430,184 +496,211 @@ class PMWI_Import_Record extends PMWI_Model_Record {
430
  ", $new_sku ) )
431
  ) {
432
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Product SKU must be unique.', 'pmxi_plugin')));
433
-
434
  } else {
435
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sku')) update_post_meta( $pid, '_sku', $new_sku );
436
  }
437
  } else {
438
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sku')) update_post_meta( $pid, '_sku', '' );
439
  }
440
  }
441
 
442
  // Save Attributes
443
  $attributes = array();
444
-
445
- if ( !empty($serialized_attributes) ) {
446
-
447
- $attribute_position = 0;
448
 
449
- foreach ($serialized_attributes as $attr_name => $attr_data) { $attr_name = strtolower($attr_name);
 
 
450
 
451
- $is_visible = intval( $attr_data['is_visible'][$i] );
452
- $is_variation = intval( $attr_data['in_variation'][$i] );
453
- $is_taxonomy = intval( $attr_data['in_taxonomy'][$i] );
454
 
455
- if ( $is_taxonomy ) {
456
 
457
- if ( isset( $attr_data['value'][$i] ) ) {
458
-
459
- $values = array_map( 'stripslashes', array_map( 'strip_tags', explode( '|', $attr_data['value'][$i] ) ) );
460
 
461
- // Remove empty items in the array
462
- $values = array_filter( $values, array($this, "filtering") );
463
-
464
- if ( ! taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attr_name ) ) and intval($attr_data['is_create_taxonomy_terms'][$i])) {
465
-
466
- // Grab the submitted data
467
- $attribute_name = ( isset( $attr_name ) ) ? woocommerce_sanitize_taxonomy_name( stripslashes( (string) $attr_name ) ) : '';
468
- $attribute_label = ucwords( stripslashes( (string) $attr_name ));
469
- $attribute_type = 'select';
470
- $attribute_orderby = 'menu_order';
471
-
472
- $reserved_terms = array(
473
- 'attachment', 'attachment_id', 'author', 'author_name', 'calendar', 'cat', 'category', 'category__and',
474
- 'category__in', 'category__not_in', 'category_name', 'comments_per_page', 'comments_popup', 'cpage', 'day',
475
- 'debug', 'error', 'exact', 'feed', 'hour', 'link_category', 'm', 'minute', 'monthnum', 'more', 'name',
476
- 'nav_menu', 'nopaging', 'offset', 'order', 'orderby', 'p', 'page', 'page_id', 'paged', 'pagename', 'pb', 'perm',
477
- 'post', 'post__in', 'post__not_in', 'post_format', 'post_mime_type', 'post_status', 'post_tag', 'post_type',
478
- 'posts', 'posts_per_archive_page', 'posts_per_page', 'preview', 'robots', 's', 'search', 'second', 'sentence',
479
- 'showposts', 'static', 'subpost', 'subpost_id', 'tag', 'tag__and', 'tag__in', 'tag__not_in', 'tag_id',
480
- 'tag_slug__and', 'tag_slug__in', 'taxonomy', 'tb', 'term', 'w', 'withcomments', 'withoutcomments', 'year',
481
- );
482
-
483
- if ( in_array( $attribute_name, $reserved_terms ) ) {
484
- $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Slug “%s” is not allowed because it is a reserved term. Change it, please.', 'pmxi_plugin'), sanitize_title( $attribute_name )));
485
- }
486
- else{
487
- $this->wpdb->insert(
488
- $this->wpdb->prefix . 'woocommerce_attribute_taxonomies',
489
- array(
490
- 'attribute_label' => $attribute_label,
491
- 'attribute_name' => $attribute_name,
492
- 'attribute_type' => $attribute_type,
493
- 'attribute_orderby' => $attribute_orderby,
494
- )
495
- );
496
-
497
- $logger and call_user_func($logger, sprintf(__('<b>CREATED</b>: Taxonomy attribute “%s” have been successfully created.', 'pmxi_plugin'), $attribute_label));
498
-
499
- // Register the taxonomy now so that the import works!
500
- $domain = $woocommerce->attribute_taxonomy_name( $attr_name );
501
- register_taxonomy( $domain,
502
- apply_filters( 'woocommerce_taxonomy_objects_' . $domain, array('product') ),
503
- apply_filters( 'woocommerce_taxonomy_args_' . $domain, array(
504
- 'hierarchical' => true,
505
- 'show_ui' => false,
506
- 'query_var' => true,
507
- 'rewrite' => false,
508
- ) )
509
- );
510
-
511
- delete_transient( 'wc_attribute_taxonomies' );
512
-
513
- $attribute_taxonomies = $this->wpdb->get_results( "SELECT * FROM " . $this->wpdb->prefix . "woocommerce_attribute_taxonomies" );
514
-
515
- set_transient( 'wc_attribute_taxonomies', $attribute_taxonomies );
516
-
517
- apply_filters( 'woocommerce_attribute_taxonomies', $attribute_taxonomies );
518
  }
 
 
 
 
 
 
519
 
520
- }
 
 
 
 
 
 
 
 
521
 
522
- if ( ! empty($values) and taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attr_name ) )){
523
 
524
- $attr_values = array();
525
-
526
- $terms = get_terms( $woocommerce->attribute_taxonomy_name( $attr_name ), array('hide_empty' => false));
527
 
528
- if ( ! is_wp_error($terms) ){
529
-
530
- foreach ($values as $key => $value) {
531
- $term_founded = false;
532
- if ( count($terms) > 0 ){
533
- foreach ( $terms as $term ) {
534
- if ( strtolower($term->name) == trim(strtolower($value)) ) {
535
- $attr_values[] = $term->slug;
536
- $term_founded = true;
537
- break;
538
- }
539
- }
540
- }
541
- if ( ! $term_founded and intval($attr_data['is_create_taxonomy_terms'][$i]) ){
542
- $term = wp_insert_term(
543
- $value, // the term
544
- $woocommerce->attribute_taxonomy_name( $attr_name ) // the taxonomy
545
- );
546
- if ( ! is_wp_error($term) ){
547
- $term = get_term_by( 'id', $term['term_id'], $woocommerce->attribute_taxonomy_name( $attr_name ));
548
- $attr_values[] = $term->slug;
549
- }
550
-
551
- }
552
- }
553
- }
554
- else {
555
- $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: %s.', 'pmxi_plugin'), $terms->get_error_message()));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
556
  }
557
 
558
- $values = $attr_values;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
 
560
- }
561
- else {
562
- $values = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
563
  }
564
 
565
- }
566
-
567
- // Update post terms
568
- if ( taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attr_name ) ))
569
- wp_set_object_terms( $pid, $values, $woocommerce->attribute_taxonomy_name( $attr_name ) );
570
-
571
- if ( $values ) {
572
-
573
- // Add attribute to array, but don't set values
574
- $attributes[ $woocommerce->attribute_taxonomy_name( $attr_name ) ] = array(
575
- 'name' => $woocommerce->attribute_taxonomy_name( $attr_name ),
576
- 'value' => '',
577
- 'position' => $attribute_position,
578
- 'is_visible' => $is_visible,
579
- 'is_variation' => $is_variation,
580
- 'is_taxonomy' => 1,
581
- 'is_create_taxonomy_terms' => (!empty($attr_data['is_create_taxonomy_terms'][$i])) ? 1 : 0
582
- );
583
 
584
- }
 
585
 
586
- } else {
587
 
588
- if ( taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attr_name ) ))
589
- wp_set_object_terms( $pid, NULL, $woocommerce->attribute_taxonomy_name( $attr_name ) );
 
 
 
 
 
 
 
 
590
 
591
- // Text based, separate by pipe
592
- //$values = implode( ' | ', array_map( 'sanitize_text_field', explode( '|', $attr_data['value'][$i] ) ) );
593
 
594
- // Custom attribute - Add attribute to array and set the values
595
- $attributes[ sanitize_title( $attr_name ) ] = array(
596
- 'name' => sanitize_text_field( $attr_name ),
597
- 'value' => $attr_data['value'][$i],
598
- 'position' => $attribute_position,
599
- 'is_visible' => $is_visible,
600
- 'is_variation' => $is_variation,
601
- 'is_taxonomy' => 0
602
- );
603
 
604
- }
 
605
 
606
- $attribute_position++;
607
- }
608
- }
609
-
610
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_product_attributes')) update_post_meta( $pid, '_product_attributes', $attributes );
611
 
612
  // Sales and prices
613
  if ( ! in_array( $product_type, array( 'grouped' ) ) ) {
@@ -617,39 +710,39 @@ class PMWI_Import_Record extends PMWI_Model_Record {
617
 
618
  // Dates
619
  if ( $date_from ){
620
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', strtotime( $date_from ) );
621
  }
622
  else{
623
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', '' );
624
  }
625
 
626
  if ( $date_to ){
627
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sale_price_dates_to')) update_post_meta( $pid, '_sale_price_dates_to', strtotime( $date_to ) );
628
  }
629
  else{
630
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sale_price_dates_to')) update_post_meta( $pid, '_sale_price_dates_to', '' );
631
  }
632
 
633
  if ( $date_to && ! $date_from ){
634
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', strtotime( 'NOW', current_time( 'timestamp' ) ) );
635
  }
636
 
637
  // Update price if on sale
638
  if ( $product_sale_price[$i] != '' && $date_to == '' && $date_from == '' ){
639
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes( $product_sale_price[$i] ) );
640
  }
641
  else{
642
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes( $product_regular_price[$i] ) );
643
  }
644
 
645
  if ( $product_sale_price[$i] != '' && $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ){
646
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes($product_sale_price[$i]) );
647
  }
648
 
649
  if ( $date_to && strtotime( $date_to ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
650
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes($product_regular_price[$i]) );
651
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', '');
652
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sale_price_dates_to')) update_post_meta( $pid, '_sale_price_dates_to', '');
653
  }
654
  }
655
 
@@ -691,9 +784,9 @@ class PMWI_Import_Record extends PMWI_Model_Record {
691
 
692
  // Sold Individuall
693
  if ( "yes" == $product_sold_individually[$i] ) {
694
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sold_individually')) update_post_meta( $pid, '_sold_individually', 'yes' );
695
  } else {
696
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_sold_individually')) update_post_meta( $pid, '_sold_individually', '' );
697
  }
698
 
699
  // Stock Data
@@ -701,44 +794,44 @@ class PMWI_Import_Record extends PMWI_Model_Record {
701
 
702
  if ( $product_type == 'grouped' ) {
703
 
704
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
705
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', '' );
706
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'no' );
707
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', 'no' );
708
 
709
  } elseif ( $product_type == 'external' ) {
710
 
711
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', 'instock' );
712
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', '' );
713
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'no' );
714
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', 'no' );
715
 
716
  } elseif ( ! empty( $product_manage_stock[$i] ) ) {
717
 
718
  // Manage stock
719
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', (int) $product_stock_qty[$i] );
720
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
721
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', stripslashes( $product_allow_backorders[$i] ) );
722
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'yes' );
723
 
724
  // Check stock level
725
  if ( $product_type !== 'variable' && $product_allow_backorders[$i] == 'no' && (int) $product_stock_qty[$i] < 1 ){
726
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', 'outofstock' );
727
  }
728
 
729
  } else {
730
 
731
  // Don't manage stock
732
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', '' );
733
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
734
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', stripslashes( $product_allow_backorders[$i] ) );
735
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'no' );
736
 
737
  }
738
 
739
  } else {
740
 
741
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
742
 
743
  }
744
 
@@ -763,9 +856,9 @@ class PMWI_Import_Record extends PMWI_Model_Record {
763
  wp_reset_postdata();
764
  }
765
 
766
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_upsell_ids')) update_post_meta( $pid, '_upsell_ids', $upsells );
767
  } else {
768
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_upsell_ids')) delete_post_meta( $pid, '_upsell_ids' );
769
  }
770
 
771
  // Cross sells
@@ -789,9 +882,9 @@ class PMWI_Import_Record extends PMWI_Model_Record {
789
  wp_reset_postdata();
790
  }
791
 
792
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_crosssell_ids')) update_post_meta( $pid, '_crosssell_ids', $crosssells );
793
  } else {
794
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_crosssell_ids')) delete_post_meta( $pid, '_crosssell_ids' );
795
  }
796
 
797
  // Downloadable options
@@ -817,37 +910,283 @@ class PMWI_Import_Record extends PMWI_Model_Record {
817
  }
818
 
819
  // grant permission to any newly added files on any existing orders for this product
820
- do_action( 'woocommerce_process_product_file_download_paths', $pid, 0, $_file_paths );
821
 
822
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_file_paths')) update_post_meta( $pid, '_file_paths', $_file_paths );
823
  }
824
  if ( isset( $product_download_limit[$i] ) )
825
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_download_limit')) update_post_meta( $pid, '_download_limit', esc_attr( $_download_limit ) );
826
  if ( isset( $product_download_expiry[$i] ) )
827
- if ($this->keep_custom_fields($existing_meta_keys, $import->options, '_download_expiry')) update_post_meta( $pid, '_download_expiry', esc_attr( $_download_expiry ) );
828
- }
829
-
830
- // Do action for product type
831
- do_action( 'woocommerce_process_product_meta_' . $product_type, $pid );
832
 
833
  // Clear cache/transients
834
  $woocommerce->clear_product_transients( $pid );
835
 
836
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
837
 
838
  public function _filter_has_cap_unfiltered_html($caps)
839
  {
840
  $caps['unfiltered_html'] = true;
841
  return $caps;
842
- }
 
 
 
 
 
843
 
844
- function keep_custom_fields($existing_meta_keys, $options, $meta_key){
 
845
 
846
- $keep_custom_fields_specific = ( ! $options['keep_custom_fields'] and ! empty($options['keep_custom_fields_specific'])) ? array_map('trim', explode(',', $options['keep_custom_fields_specific'])) : array();
847
- $keep_custom_fields_except = ($options['keep_custom_fields'] and !empty($options['keep_custom_fields_except'])) ? array_map('trim', explode(',', $options['keep_custom_fields_except'])) : array();
 
 
 
 
848
 
849
- return (($options['keep_custom_fields'] and in_array($meta_key, $existing_meta_keys) and !in_array($meta_key, $keep_custom_fields_except)) or (in_array($meta_key, $existing_meta_keys) and ! $options['keep_custom_fields'] and in_array($meta_key, $keep_custom_fields_specific))) ? false : true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
850
 
 
 
 
 
 
 
 
 
 
851
  }
852
 
853
  // process simple product meta
24
  * @return PMWI_Import_Record
25
  * @chainable
26
  */
27
+ public function parse($parsing_data = array()) { //$import, $count, $xml, $logger = NULL, $chunk = false, $xpath_prefix = ""
28
+
29
+ extract($parsing_data);
30
+
31
+ if ($import->options['custom_type'] != 'product') return;
32
+
33
  add_filter('user_has_cap', array($this, '_filter_has_cap_unfiltered_html')); kses_init(); // do not perform special filtering for imported content
34
 
35
+ $cxpath = $xpath_prefix . $import->xpath;
36
 
37
+ $this->data = array();
38
  $records = array();
39
+ $tmp_files = array();
40
 
41
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing product data...', 'pmxi_plugin'));
42
 
43
  // Composing product types
44
  if ($import->options['is_multiple_product_type'] != 'yes' and "" != $import->options['single_product_type']){
45
+ $this->data['product_types'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_type'], $file)->parse($records); $tmp_files[] = $file;
46
  }
47
  else{
48
  $count and $this->data['product_types'] = array_fill(0, $count, $import->options['multiple_product_type']);
50
 
51
  // Composing product is Virtual
52
  if ($import->options['is_product_virtual'] == 'xpath' and "" != $import->options['single_product_virtual']){
53
+ $this->data['product_virtual'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_virtual'], $file)->parse($records); $tmp_files[] = $file;
54
  }
55
  else{
56
  $count and $this->data['product_virtual'] = array_fill(0, $count, $import->options['is_product_virtual']);
58
 
59
  // Composing product is Downloadable
60
  if ($import->options['is_product_downloadable'] == 'xpath' and "" != $import->options['single_product_downloadable']){
61
+ $this->data['product_downloadable'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_downloadable'], $file)->parse($records); $tmp_files[] = $file;
62
  }
63
  else{
64
  $count and $this->data['product_downloadable'] = array_fill(0, $count, $import->options['is_product_downloadable']);
66
 
67
  // Composing product is Variable Enabled
68
  if ($import->options['is_product_enabled'] == 'xpath' and "" != $import->options['single_product_enabled']){
69
+ $this->data['product_enabled'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_enabled'], $file)->parse($records); $tmp_files[] = $file;
70
  }
71
  else{
72
  $count and $this->data['product_enabled'] = array_fill(0, $count, $import->options['is_product_enabled']);
74
 
75
  // Composing product is Featured
76
  if ($import->options['is_product_featured'] == 'xpath' and "" != $import->options['single_product_featured']){
77
+ $this->data['product_featured'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_featured'], $file)->parse($records); $tmp_files[] = $file;
78
  }
79
  else{
80
  $count and $this->data['product_featured'] = array_fill(0, $count, $import->options['is_product_featured']);
82
 
83
  // Composing product is Visibility
84
  if ($import->options['is_product_visibility'] == 'xpath' and "" != $import->options['single_product_visibility']){
85
+ $this->data['product_visibility'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_visibility'], $file)->parse($records); $tmp_files[] = $file;
86
  }
87
  else{
88
  $count and $this->data['product_visibility'] = array_fill(0, $count, $import->options['is_product_visibility']);
89
  }
90
 
91
  if ("" != $import->options['single_product_sku']){
92
+ $this->data['product_sku'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_sku'], $file)->parse($records); $tmp_files[] = $file;
93
  }
94
  else{
95
  $count and $this->data['product_sku'] = array_fill(0, $count, "");
96
  }
97
 
98
  if ("" != $import->options['single_product_url']){
99
+ $this->data['product_url'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_url'], $file)->parse($records); $tmp_files[] = $file;
100
  }
101
  else{
102
  $count and $this->data['product_url'] = array_fill(0, $count, "");
103
  }
104
 
105
  if ("" != $import->options['single_product_button_text']){
106
+ $this->data['product_button_text'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_button_text'], $file)->parse($records); $tmp_files[] = $file;
107
  }
108
  else{
109
  $count and $this->data['product_button_text'] = array_fill(0, $count, "");
110
  }
111
 
112
  if ("" != $import->options['single_product_regular_price']){
113
+ $this->data['product_regular_price'] = array_map(array($this, 'prepare_price'), XmlImportParser::factory($xml, $cxpath, $import->options['single_product_regular_price'], $file)->parse($records)); $tmp_files[] = $file;
114
  }
115
  else{
116
  $count and $this->data['product_regular_price'] = array_fill(0, $count, "");
117
  }
118
 
119
  if ($import->options['is_regular_price_shedule'] and "" != $import->options['single_sale_price_dates_from']){
120
+ $this->data['product_sale_price_dates_from'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_sale_price_dates_from'], $file)->parse($records); $tmp_files[] = $file;
121
  }
122
  else{
123
  $count and $this->data['product_sale_price_dates_from'] = array_fill(0, $count, "");
124
  }
125
 
126
  if ($import->options['is_regular_price_shedule'] and "" != $import->options['single_sale_price_dates_to']){
127
+ $this->data['product_sale_price_dates_to'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_sale_price_dates_to'], $file)->parse($records); $tmp_files[] = $file;
128
  }
129
  else{
130
  $count and $this->data['product_sale_price_dates_to'] = array_fill(0, $count, "");
131
  }
132
 
133
  if ("" != $import->options['single_product_sale_price']){
134
+ $this->data['product_sale_price'] = array_map(array($this, 'prepare_price'), XmlImportParser::factory($xml, $cxpath, $import->options['single_product_sale_price'], $file)->parse($records)); $tmp_files[] = $file;
135
  }
136
  else{
137
  $count and $this->data['product_sale_price'] = array_fill(0, $count, "");
138
  }
139
 
140
  if ("" != $import->options['single_product_whosale_price']){
141
+ $this->data['product_whosale_price'] = array_map(array($this, 'prepare_price'), XmlImportParser::factory($xml, $cxpath, $import->options['single_product_whosale_price'], $file)->parse($records)); $tmp_files[] = $file;
142
  }
143
  else{
144
  $count and $this->data['product_whosale_price'] = array_fill(0, $count, "");
145
  }
146
 
147
  if ("" != $import->options['single_product_files']){
148
+ $this->data['product_files'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_files'], $file)->parse($records); $tmp_files[] = $file;
149
  }
150
  else{
151
  $count and $this->data['product_files'] = array_fill(0, $count, "");
152
  }
153
 
154
  if ("" != $import->options['single_product_download_limit']){
155
+ $this->data['product_download_limit'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_download_limit'], $file)->parse($records); $tmp_files[] = $file;
156
  }
157
  else{
158
  $count and $this->data['product_download_limit'] = array_fill(0, $count, "");
159
  }
160
 
161
  if ("" != $import->options['single_product_download_expiry']){
162
+ $this->data['product_download_expiry'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_download_expiry'], $file)->parse($records); $tmp_files[] = $file;
163
  }
164
  else{
165
  $count and $this->data['product_download_expiry'] = array_fill(0, $count, "");
167
 
168
  // Composing product Tax Status
169
  if ($import->options['is_multiple_product_tax_status'] != 'yes' and "" != $import->options['single_product_tax_status']){
170
+ $this->data['product_tax_status'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_tax_status'], $file)->parse($records); $tmp_files[] = $file;
171
  }
172
  else{
173
  $count and $this->data['product_tax_status'] = array_fill(0, $count, $import->options['multiple_product_tax_status']);
175
 
176
  // Composing product Tax Class
177
  if ($import->options['is_multiple_product_tax_class'] != 'yes' and "" != $import->options['single_product_tax_class']){
178
+ $this->data['product_tax_class'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_tax_class'], $file)->parse($records); $tmp_files[] = $file;
179
  }
180
  else{
181
  $count and $this->data['product_tax_class'] = array_fill(0, $count, $import->options['multiple_product_tax_class']);
183
 
184
  // Composing product Manage stock?
185
  if ($import->options['is_product_manage_stock'] == 'xpath' and "" != $import->options['single_product_manage_stock']){
186
+ $this->data['product_manage_stock'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_manage_stock'], $file)->parse($records); $tmp_files[] = $file;
187
  }
188
  else{
189
  $count and $this->data['product_manage_stock'] = array_fill(0, $count, $import->options['is_product_manage_stock']);
190
  }
191
 
192
  if ("" != $import->options['single_product_stock_qty']){
193
+ $this->data['product_stock_qty'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_stock_qty'], $file)->parse($records); $tmp_files[] = $file;
194
  }
195
  else{
196
  $count and $this->data['product_stock_qty'] = array_fill(0, $count, "");
198
 
199
  // Composing product Stock status
200
  if ($import->options['product_stock_status'] == 'xpath' and "" != $import->options['single_product_stock_status']){
201
+ $this->data['product_stock_status'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_stock_status'], $file)->parse($records); $tmp_files[] = $file;
202
  }
203
  else{
204
  $count and $this->data['product_stock_status'] = array_fill(0, $count, $import->options['product_stock_status']);
206
 
207
  // Composing product Allow Backorders?
208
  if ($import->options['product_allow_backorders'] == 'xpath' and "" != $import->options['single_product_allow_backorders']){
209
+ $this->data['product_allow_backorders'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_allow_backorders'], $file)->parse($records); $tmp_files[] = $file;
210
  }
211
  else{
212
  $count and $this->data['product_allow_backorders'] = array_fill(0, $count, $import->options['product_allow_backorders']);
214
 
215
  // Composing product Sold Individually?
216
  if ($import->options['product_sold_individually'] == 'xpath' and "" != $import->options['single_product_sold_individually']){
217
+ $this->data['product_sold_individually'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_sold_individually'], $file)->parse($records); $tmp_files[] = $file;
218
  }
219
  else{
220
  $count and $this->data['product_sold_individually'] = array_fill(0, $count, $import->options['product_sold_individually']);
221
  }
222
 
223
  if ("" != $import->options['single_product_weight']){
224
+ $this->data['product_weight'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_weight'], $file)->parse($records); $tmp_files[] = $file;
225
  }
226
  else{
227
  $count and $this->data['product_weight'] = array_fill(0, $count, "");
228
  }
229
  if ("" != $import->options['single_product_length']){
230
+ $this->data['product_length'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_length'], $file)->parse($records); $tmp_files[] = $file;
231
  }
232
  else{
233
  $count and $this->data['product_length'] = array_fill(0, $count, "");
234
  }
235
  if ("" != $import->options['single_product_width']){
236
+ $this->data['product_width'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_width'], $file)->parse($records); $tmp_files[] = $file;
237
  }
238
  else{
239
  $count and $this->data['product_width'] = array_fill(0, $count, "");
240
  }
241
  if ("" != $import->options['single_product_height']){
242
+ $this->data['product_height'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_height'], $file)->parse($records); $tmp_files[] = $file;
243
  }
244
  else{
245
  $count and $this->data['product_height'] = array_fill(0, $count, "");
247
 
248
  // Composing product Shipping Class
249
  if ($import->options['is_multiple_product_shipping_class'] != 'yes' and "" != $import->options['single_product_shipping_class']){
250
+ $this->data['product_shipping_class'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_shipping_class'], $file)->parse($records); $tmp_files[] = $file;
251
  }
252
  else{
253
  $count and $this->data['product_shipping_class'] = array_fill(0, $count, $import->options['multiple_product_shipping_class']);
254
  }
255
 
256
  if ("" != $import->options['single_product_up_sells']){
257
+ $this->data['product_up_sells'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_up_sells'], $file)->parse($records); $tmp_files[] = $file;
258
  }
259
  else{
260
  $count and $this->data['product_up_sells'] = array_fill(0, $count, "");
261
  }
262
  if ("" != $import->options['single_product_cross_sells']){
263
+ $this->data['product_cross_sells'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_cross_sells'], $file)->parse($records); $tmp_files[] = $file;
264
  }
265
  else{
266
  $count and $this->data['product_cross_sells'] = array_fill(0, $count, "");
267
  }
268
 
269
  if ("" != $import->options['grouping_product']){
270
+ $this->data['product_grouping_parent'] = XmlImportParser::factory($xml, $cxpath, $import->options['grouping_product'], $file)->parse($records); $tmp_files[] = $file;
271
  }
272
  else{
273
  $count and $this->data['product_grouping_parent'] = array_fill(0, $count, "");
274
  }
275
 
276
  if ("" != $import->options['single_product_purchase_note']){
277
+ $this->data['product_purchase_note'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_purchase_note'], $file)->parse($records); $tmp_files[] = $file;
278
  }
279
  else{
280
  $count and $this->data['product_purchase_note'] = array_fill(0, $count, "");
281
  }
282
  if ("" != $import->options['single_product_menu_order']){
283
+ $this->data['product_menu_order'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_menu_order'], $file)->parse($records); $tmp_files[] = $file;
284
  }
285
  else{
286
  $count and $this->data['product_menu_order'] = array_fill(0, $count, "");
288
 
289
  // Composing product Enable reviews
290
  if ($import->options['is_product_enable_reviews'] == 'xpath' and "" != $import->options['single_product_enable_reviews']){
291
+ $this->data['product_enable_reviews'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_enable_reviews'], $file)->parse($records); $tmp_files[] = $file;
292
  }
293
  else{
294
  $count and $this->data['product_enable_reviews'] = array_fill(0, $count, $import->options['is_product_enable_reviews']);
295
+ }
296
+
297
+ if ("" != $import->options['single_product_id']){
298
+ $this->data['single_product_ID'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_id'], $file)->parse($records); $tmp_files[] = $file;
299
+ }
300
+ else{
301
+ $count and $this->data['single_product_ID'] = array_fill(0, $count, "");
302
+ }
303
+ if ("" != $import->options['single_product_parent_id']){
304
+ $this->data['single_product_parent_ID'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_parent_id'], $file)->parse($records); $tmp_files[] = $file;
305
+ }
306
+ else{
307
+ $count and $this->data['single_product_parent_ID'] = array_fill(0, $count, "");
308
+ }
309
+ if ("" != $import->options['single_product_id_first_is_parent_id']){
310
+ $this->data['single_product_id_first_is_parent_ID'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_id_first_is_parent_id'], $file)->parse($records); $tmp_files[] = $file;
311
+ }
312
+ else{
313
+ $count and $this->data['single_product_id_first_is_parent_ID'] = array_fill(0, $count, "");
314
  }
315
+ if ("" != $import->options['single_product_id_first_is_parent_title']){
316
+ $this->data['single_product_id_first_is_parent_title'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_id_first_is_parent_title'], $file)->parse($records); $tmp_files[] = $file;
317
+ }
318
+ else{
319
+ $count and $this->data['single_product_id_first_is_parent_title'] = array_fill(0, $count, "");
320
+ }
321
+ if ("" != $import->options['single_product_id_first_is_variation']){
322
+ $this->data['single_product_id_first_is_variation'] = XmlImportParser::factory($xml, $cxpath, $import->options['single_product_id_first_is_variation'], $file)->parse($records); $tmp_files[] = $file;
323
+ }
324
+ else{
325
+ $count and $this->data['single_product_id_first_is_variation'] = array_fill(0, $count, "");
326
+ }
327
+
328
+ if ($import->options['matching_parent'] != "auto") {
329
+ switch ($import->options['matching_parent']) {
330
+ case 'first_is_parent_id':
331
+ $this->data['single_product_parent_ID'] = $this->data['single_product_ID'] = $this->data['single_product_id_first_is_parent_ID'];
332
+ break;
333
+ case 'first_is_parent_title':
334
+ $this->data['single_product_parent_ID'] = $this->data['single_product_ID'] = $this->data['single_product_id_first_is_parent_title'];
335
+ break;
336
+ case 'first_is_variation':
337
+ $this->data['single_product_parent_ID'] = $this->data['single_product_ID'] = $this->data['single_product_id_first_is_variation'];
338
+ break;
339
+ }
340
+ }
341
+
342
+ if ($import->options['matching_parent'] == 'manual' and $import->options['parent_indicator'] == "custom field"){
343
+ if ("" != $import->options['custom_parent_indicator_name']){
344
+ $this->data['custom_parent_indicator_name'] = XmlImportParser::factory($xml, $cxpath, $import->options['custom_parent_indicator_name'], $file)->parse($records); $tmp_files[] = $file;
345
+ }
346
+ else{
347
+ $count and $this->data['custom_parent_indicator_name'] = array_fill(0, $count, "");
348
+ }
349
+ if ("" != $import->options['custom_parent_indicator_value']){
350
+ $this->data['custom_parent_indicator_value'] = XmlImportParser::factory($xml, $cxpath, $import->options['custom_parent_indicator_value'], $file)->parse($records); $tmp_files[] = $file;
351
+ }
352
+ else{
353
+ $count and $this->data['custom_parent_indicator_value'] = array_fill(0, $count, "");
354
+ }
355
+ }
356
 
357
  // Composing variations attributes
358
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing variations attributes...', 'pmxi_plugin'));
359
  $attribute_keys = array();
360
  $attribute_values = array();
361
  $attribute_in_variation = array();
365
 
366
  if (!empty($import->options['attribute_name'][0])){
367
  foreach ($import->options['attribute_name'] as $j => $attribute_name) { if ($attribute_name == "") continue;
368
+ $attribute_keys[$j] = XmlImportParser::factory($xml, $cxpath, $attribute_name, $file)->parse($records); $tmp_files[] = $file;
369
+ $attribute_values[$j] = XmlImportParser::factory($xml, $cxpath, $import->options['attribute_value'][$j], $file)->parse($records); $tmp_files[] = $file;
370
+ $attribute_in_variation[$j] = XmlImportParser::factory($xml, $cxpath, $import->options['in_variations'][$j], $file)->parse($records); $tmp_files[] = $file;
371
+ $attribute_is_visible[$j] = XmlImportParser::factory($xml, $cxpath, $import->options['is_visible'][$j], $file)->parse($records); $tmp_files[] = $file;
372
+ $attribute_is_taxonomy[$j] = XmlImportParser::factory($xml, $cxpath, $import->options['is_taxonomy'][$j], $file)->parse($records); $tmp_files[] = $file;
373
+ $attribute_create_taxonomy_terms[$j] = XmlImportParser::factory($xml, $cxpath, $import->options['create_taxonomy_in_not_exists'][$j], $file)->parse($records); $tmp_files[] = $file;
374
  }
375
  }
376
 
403
  return ("" == $var) ? false : true;
404
  }
405
 
406
+ public function import($importData = array()){ //$pid, $i, $import, $articleData, $xml, $is_cron = false, $xpath_prefix = ""
407
+
408
+ extract($importData);
409
+
410
+ if ($import->options['custom_type'] != 'product') return;
411
 
412
+ $cxpath = $xpath_prefix . $import->xpath;
413
 
414
  global $woocommerce;
415
 
434
 
435
  // Product type + Downloadable/Virtual
436
  wp_set_object_terms( $pid, $product_type, 'product_type' );
437
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_downloadable')) update_post_meta( $pid, '_downloadable', ($is_downloadable == "yes") ? 'yes' : 'no' );
438
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_virtual')) update_post_meta( $pid, '_virtual', ($is_virtual == "yes") ? 'yes' : 'no' );
439
 
440
  // Update post meta
441
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_regular_price')) update_post_meta( $pid, '_regular_price', stripslashes( $product_regular_price[$i] ) );
442
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price')) update_post_meta( $pid, '_sale_price', stripslashes( $product_sale_price[$i] ) );
443
+ if ( class_exists('woocommerce_wholesale_pricing') and (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, 'wholesale_price'))) update_post_meta( $pid, 'pmxi_wholesale_price', stripslashes( $product_whosale_price[$i] ) );
444
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_tax_status')) update_post_meta( $pid, '_tax_status', stripslashes( $product_tax_status[$i] ) );
445
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_tax_class')) update_post_meta( $pid, '_tax_class', stripslashes( $product_tax_class[$i] ) );
446
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_visibility')) update_post_meta( $pid, '_visibility', stripslashes( $product_visibility[$i] ) );
447
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_purchase_note')) update_post_meta( $pid, '_purchase_note', stripslashes( $product_purchase_note[$i] ) );
448
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_featured')) update_post_meta( $pid, '_featured', ($is_featured == "yes") ? 'yes' : 'no' );
449
 
450
  // Dimensions
451
  if ( $is_virtual == 'no' ) {
452
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_weight')) update_post_meta( $pid, '_weight', stripslashes( $product_weight[$i] ) );
453
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_length')) update_post_meta( $pid, '_length', stripslashes( $product_length[$i] ) );
454
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_width')) update_post_meta( $pid, '_width', stripslashes( $product_width[$i] ) );
455
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_height')) update_post_meta( $pid, '_height', stripslashes( $product_height[$i] ) );
456
  } else {
457
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_weight')) update_post_meta( $pid, '_weight', '' );
458
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_length')) update_post_meta( $pid, '_length', '' );
459
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_width')) update_post_meta( $pid, '_width', '' );
460
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_height')) update_post_meta( $pid, '_height', '' );
461
+ }
462
 
463
+ $this->wpdb->update( $this->wpdb->posts, array('comment_status' => ($product_enable_reviews[$i] == 'yes') ? 'open' : 'closed','menu_order' => ($product_menu_order[$i] != '') ? $product_menu_order[$i] : 0 ), array('ID' => $pid) );
 
 
 
 
 
464
 
465
  // Save shipping class
466
  $product_shipping_class = is_numeric($product_shipping_class[$i]) && $product_shipping_class[$i] > 0 && $product_type != 'external' ? absint( $product_shipping_class[$i] ) : $product_shipping_class[$i];
471
  $new_sku = esc_html( trim( stripslashes( $product_sku[$i] ) ) );
472
 
473
  if ( $new_sku == '' and $import->options['disable_auto_sku_generation'] ) {
474
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sku'))
475
  update_post_meta( $pid, '_sku', '' );
476
  }
477
  elseif ( $new_sku == '' and ! $import->options['disable_auto_sku_generation'] ) {
478
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sku')){
479
+ $unique_keys = XmlImportParser::factory($xml, $cxpath, $import->options['unique_key'], $file)->parse($records); $tmp_files[] = $file;
480
  foreach ($tmp_files as $file) { // remove all temporary files created
481
  unlink($file);
482
  }
485
  }
486
  if ( $new_sku != '' and $new_sku !== $sku ) {
487
  if ( ! empty( $new_sku ) ) {
488
+ if ( ! $import->options['disable_sku_matching'] and
489
  $this->wpdb->get_var( $this->wpdb->prepare("
490
  SELECT ".$this->wpdb->posts.".ID
491
  FROM ".$this->wpdb->posts."
496
  ", $new_sku ) )
497
  ) {
498
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Product SKU must be unique.', 'pmxi_plugin')));
499
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
500
  } else {
501
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sku')) update_post_meta( $pid, '_sku', $new_sku );
502
  }
503
  } else {
504
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sku')) update_post_meta( $pid, '_sku', '' );
505
  }
506
  }
507
 
508
  // Save Attributes
509
  $attributes = array();
 
 
 
 
510
 
511
+ if ( $import->options['update_all_data'] == "yes" or ( $import->options['update_all_data'] == "no" and $import->options['is_update_attributes']) or empty($articleData['ID'])): // Update Product Attributes
512
+
513
+ if ( !empty($serialized_attributes) ) {
514
 
515
+ $attribute_position = 0; $is_update_attributes = true;
 
 
516
 
517
+ foreach ($serialized_attributes as $attr_name => $attr_data) { $attr_name = strtolower($attr_name);
518
 
519
+ $is_visible = intval( $attr_data['is_visible'][$i] );
520
+ $is_variation = intval( $attr_data['in_variation'][$i] );
521
+ $is_taxonomy = intval( $attr_data['in_taxonomy'][$i] );
522
 
523
+ // Update only these Attributes, leave the rest alone
524
+ if ($import->options['update_all_data'] == "no" and $import->options['update_attributes_logic'] == 'only'){
525
+ if ( ! empty($import->options['attributes_list']) and is_array($import->options['attributes_list'])) {
526
+ if ( ! in_array( ( ($is_taxonomy) ? "pa_" . $attr_name : $attr_name ) , array_filter($import->options['attributes_list'], 'trim'))){
527
+ $attribute_position++;
528
+ continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  }
530
+ }
531
+ else {
532
+ $is_update_attributes = false;
533
+ break;
534
+ }
535
+ }
536
 
537
+ // Leave these attributes alone, update all other Attributes
538
+ if ($import->options['update_all_data'] == "no" and $import->options['update_attributes_logic'] == 'all_except'){
539
+ if ( ! empty($import->options['attributes_list']) and is_array($import->options['attributes_list'])) {
540
+ if ( in_array( ( ($is_taxonomy) ? "pa_" . $attr_name : $attr_name ) , array_filter($import->options['attributes_list'], 'trim'))){
541
+ $attribute_position++;
542
+ continue;
543
+ }
544
+ }
545
+ }
546
 
547
+ if ( $is_taxonomy ) {
548
 
549
+ if ( isset( $attr_data['value'][$i] ) ) {
 
 
550
 
551
+ $values = array_map( 'stripslashes', array_map( 'strip_tags', explode( '|', $attr_data['value'][$i] ) ) );
552
+
553
+ // Remove empty items in the array
554
+ $values = array_filter( $values, array($this, "filtering") );
555
+
556
+ if ( ! taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attr_name ) ) and intval($attr_data['is_create_taxonomy_terms'][$i])) {
557
+
558
+ // Grab the submitted data
559
+ $attribute_name = ( isset( $attr_name ) ) ? woocommerce_sanitize_taxonomy_name( stripslashes( (string) $attr_name ) ) : '';
560
+ $attribute_label = ucwords( stripslashes( (string) $attr_name ));
561
+ $attribute_type = 'select';
562
+ $attribute_orderby = 'menu_order';
563
+
564
+ $reserved_terms = array(
565
+ 'attachment', 'attachment_id', 'author', 'author_name', 'calendar', 'cat', 'category', 'category__and',
566
+ 'category__in', 'category__not_in', 'category_name', 'comments_per_page', 'comments_popup', 'cpage', 'day',
567
+ 'debug', 'error', 'exact', 'feed', 'hour', 'link_category', 'm', 'minute', 'monthnum', 'more', 'name',
568
+ 'nav_menu', 'nopaging', 'offset', 'order', 'orderby', 'p', 'page', 'page_id', 'paged', 'pagename', 'pb', 'perm',
569
+ 'post', 'post__in', 'post__not_in', 'post_format', 'post_mime_type', 'post_status', 'post_tag', 'post_type',
570
+ 'posts', 'posts_per_archive_page', 'posts_per_page', 'preview', 'robots', 's', 'search', 'second', 'sentence',
571
+ 'showposts', 'static', 'subpost', 'subpost_id', 'tag', 'tag__and', 'tag__in', 'tag__not_in', 'tag_id',
572
+ 'tag_slug__and', 'tag_slug__in', 'taxonomy', 'tb', 'term', 'w', 'withcomments', 'withoutcomments', 'year',
573
+ );
574
+
575
+ if ( in_array( $attribute_name, $reserved_terms ) ) {
576
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Slug “%s” is not allowed because it is a reserved term. Change it, please.', 'pmxi_plugin'), sanitize_title( $attribute_name )));
577
+ }
578
+ else{
579
+ $this->wpdb->insert(
580
+ $this->wpdb->prefix . 'woocommerce_attribute_taxonomies',
581
+ array(
582
+ 'attribute_label' => $attribute_label,
583
+ 'attribute_name' => $attribute_name,
584
+ 'attribute_type' => $attribute_type,
585
+ 'attribute_orderby' => $attribute_orderby,
586
+ )
587
+ );
588
+
589
+ $logger and call_user_func($logger, sprintf(__('<b>CREATED</b>: Taxonomy attribute “%s” have been successfully created.', 'pmxi_plugin'), $attribute_label));
590
+
591
+ // Register the taxonomy now so that the import works!
592
+ $domain = $woocommerce->attribute_taxonomy_name( $attr_name );
593
+ register_taxonomy( $domain,
594
+ apply_filters( 'woocommerce_taxonomy_objects_' . $domain, array('product') ),
595
+ apply_filters( 'woocommerce_taxonomy_args_' . $domain, array(
596
+ 'hierarchical' => true,
597
+ 'show_ui' => false,
598
+ 'query_var' => true,
599
+ 'rewrite' => false,
600
+ ) )
601
+ );
602
+
603
+ delete_transient( 'wc_attribute_taxonomies' );
604
+ $attribute_taxonomies = $this->wpdb->get_results( "SELECT * FROM " . $this->wpdb->prefix . "woocommerce_attribute_taxonomies" );
605
+ set_transient( 'wc_attribute_taxonomies', $attribute_taxonomies );
606
+ apply_filters( 'woocommerce_attribute_taxonomies', $attribute_taxonomies );
607
+ }
608
+
609
  }
610
 
611
+ if ( ! empty($values) and taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attr_name ) )){
612
+
613
+ $attr_values = array();
614
+
615
+ $terms = get_terms( $woocommerce->attribute_taxonomy_name( $attr_name ), array('hide_empty' => false));
616
+
617
+ if ( ! is_wp_error($terms) ){
618
+
619
+ foreach ($values as $key => $value) {
620
+ $term_founded = false;
621
+ if ( count($terms) > 0 ){
622
+ foreach ( $terms as $term ) {
623
+ if ( strtolower($term->name) == trim(strtolower($value)) ) {
624
+ $attr_values[] = $term->slug;
625
+ $term_founded = true;
626
+ break;
627
+ }
628
+ }
629
+ }
630
+ if ( ! $term_founded and intval($attr_data['is_create_taxonomy_terms'][$i]) ){
631
+ $term = wp_insert_term(
632
+ $value, // the term
633
+ $woocommerce->attribute_taxonomy_name( $attr_name ) // the taxonomy
634
+ );
635
+ if ( ! is_wp_error($term) ){
636
+ $term = get_term_by( 'id', $term['term_id'], $woocommerce->attribute_taxonomy_name( $attr_name ));
637
+ $attr_values[] = $term->slug;
638
+ }
639
+
640
+ }
641
+ }
642
+ }
643
+ else {
644
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: %s.', 'pmxi_plugin'), $terms->get_error_message()));
645
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
646
+ }
647
+
648
+ $values = $attr_values;
649
 
650
+ }
651
+ else $values = array();
652
+
653
+ }
654
+
655
+ // Update post terms
656
+ if ( taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attr_name ) ))
657
+ wp_set_object_terms( $pid, $values, $woocommerce->attribute_taxonomy_name( $attr_name ) );
658
+
659
+ if ( !empty($values) ) {
660
+ // Add attribute to array, but don't set values
661
+ $attributes[ $woocommerce->attribute_taxonomy_name( $attr_name ) ] = array(
662
+ 'name' => $woocommerce->attribute_taxonomy_name( $attr_name ),
663
+ 'value' => '',
664
+ 'position' => $attribute_position,
665
+ 'is_visible' => $is_visible,
666
+ 'is_variation' => $is_variation,
667
+ 'is_taxonomy' => 1,
668
+ 'is_create_taxonomy_terms' => (!empty($attr_data['is_create_taxonomy_terms'][$i])) ? 1 : 0
669
+ );
670
  }
671
 
672
+ } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
673
 
674
+ if ( taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attr_name ) ))
675
+ wp_set_object_terms( $pid, NULL, $woocommerce->attribute_taxonomy_name( $attr_name ) );
676
 
677
+ if (!empty($attr_data['value'][$i])){
678
 
679
+ // Custom attribute - Add attribute to array and set the values
680
+ $attributes[ sanitize_title( $attr_name ) ] = array(
681
+ 'name' => sanitize_text_field( $attr_name ),
682
+ 'value' => $attr_data['value'][$i],
683
+ 'position' => $attribute_position,
684
+ 'is_visible' => $is_visible,
685
+ 'is_variation' => $is_variation,
686
+ 'is_taxonomy' => 0
687
+ );
688
+ }
689
 
690
+ }
 
691
 
692
+ $attribute_position++;
693
+ }
694
+ }
695
+
696
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_product_attributes') and $is_update_attributes) {
697
+
698
+ $current_product_attributes = get_post_meta($pid, '_product_attributes', true);
 
 
699
 
700
+ update_post_meta( $pid, '_product_attributes', (( ! empty($current_product_attributes)) ? array_merge($current_product_attributes, $attributes) : $attributes) );
701
+ }
702
 
703
+ endif; // is update attributes
 
 
 
 
704
 
705
  // Sales and prices
706
  if ( ! in_array( $product_type, array( 'grouped' ) ) ) {
710
 
711
  // Dates
712
  if ( $date_from ){
713
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', strtotime( $date_from ) );
714
  }
715
  else{
716
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', '' );
717
  }
718
 
719
  if ( $date_to ){
720
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_to')) update_post_meta( $pid, '_sale_price_dates_to', strtotime( $date_to ) );
721
  }
722
  else{
723
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_to')) update_post_meta( $pid, '_sale_price_dates_to', '' );
724
  }
725
 
726
  if ( $date_to && ! $date_from ){
727
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', strtotime( 'NOW', current_time( 'timestamp' ) ) );
728
  }
729
 
730
  // Update price if on sale
731
  if ( $product_sale_price[$i] != '' && $date_to == '' && $date_from == '' ){
732
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes( $product_sale_price[$i] ) );
733
  }
734
  else{
735
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes( $product_regular_price[$i] ) );
736
  }
737
 
738
  if ( $product_sale_price[$i] != '' && $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ){
739
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes($product_sale_price[$i]) );
740
  }
741
 
742
  if ( $date_to && strtotime( $date_to ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
743
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes($product_regular_price[$i]) );
744
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', '');
745
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_to')) update_post_meta( $pid, '_sale_price_dates_to', '');
746
  }
747
  }
748
 
784
 
785
  // Sold Individuall
786
  if ( "yes" == $product_sold_individually[$i] ) {
787
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sold_individually')) update_post_meta( $pid, '_sold_individually', 'yes' );
788
  } else {
789
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sold_individually')) update_post_meta( $pid, '_sold_individually', '' );
790
  }
791
 
792
  // Stock Data
794
 
795
  if ( $product_type == 'grouped' ) {
796
 
797
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
798
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', '' );
799
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'no' );
800
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', 'no' );
801
 
802
  } elseif ( $product_type == 'external' ) {
803
 
804
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', 'instock' );
805
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', '' );
806
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'no' );
807
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', 'no' );
808
 
809
  } elseif ( ! empty( $product_manage_stock[$i] ) ) {
810
 
811
  // Manage stock
812
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', (int) $product_stock_qty[$i] );
813
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
814
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', stripslashes( $product_allow_backorders[$i] ) );
815
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'yes' );
816
 
817
  // Check stock level
818
  if ( $product_type !== 'variable' && $product_allow_backorders[$i] == 'no' && (int) $product_stock_qty[$i] < 1 ){
819
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', 'outofstock' );
820
  }
821
 
822
  } else {
823
 
824
  // Don't manage stock
825
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', '' );
826
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
827
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', stripslashes( $product_allow_backorders[$i] ) );
828
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'no' );
829
 
830
  }
831
 
832
  } else {
833
 
834
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
835
 
836
  }
837
 
856
  wp_reset_postdata();
857
  }
858
 
859
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_upsell_ids')) update_post_meta( $pid, '_upsell_ids', $upsells );
860
  } else {
861
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_upsell_ids')) delete_post_meta( $pid, '_upsell_ids' );
862
  }
863
 
864
  // Cross sells
882
  wp_reset_postdata();
883
  }
884
 
885
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_crosssell_ids')) update_post_meta( $pid, '_crosssell_ids', $crosssells );
886
  } else {
887
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_crosssell_ids')) delete_post_meta( $pid, '_crosssell_ids' );
888
  }
889
 
890
  // Downloadable options
910
  }
911
 
912
  // grant permission to any newly added files on any existing orders for this product
913
+ //do_action( 'woocommerce_process_product_file_download_paths', $pid, 0, $_file_paths );
914
 
915
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_file_paths')) update_post_meta( $pid, '_file_paths', $_file_paths );
916
  }
917
  if ( isset( $product_download_limit[$i] ) )
918
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_download_limit')) update_post_meta( $pid, '_download_limit', esc_attr( $_download_limit ) );
919
  if ( isset( $product_download_expiry[$i] ) )
920
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_download_expiry')) update_post_meta( $pid, '_download_expiry', esc_attr( $_download_expiry ) );
921
+ }
 
 
 
922
 
923
  // Clear cache/transients
924
  $woocommerce->clear_product_transients( $pid );
925
 
926
+ }
927
+
928
+
929
+ function pmwi_link_all_variations($product_id, $options = array()) {
930
+
931
+ global $woocommerce;
932
+
933
+ @set_time_limit(0);
934
+
935
+ $post_id = intval( $product_id );
936
+
937
+ if ( ! $post_id ) return 0;
938
+
939
+ $variations = array();
940
+
941
+ $_product = get_product( $post_id, array( 'product_type' => 'variable' ) );
942
+
943
+ $v = $_product->get_attributes();
944
+
945
+ // Put variation attributes into an array
946
+ foreach ( $_product->get_attributes() as $attribute ) {
947
+
948
+ if ( ! $attribute['is_variation'] ) continue;
949
+
950
+ $attribute_field_name = 'attribute_' . sanitize_title( $attribute['name'] );
951
+
952
+ if ( $attribute['is_taxonomy'] ) {
953
+ $post_terms = wp_get_post_terms( $post_id, $attribute['name'] );
954
+ $options = array();
955
+ foreach ( $post_terms as $term ) {
956
+ $options[] = $term->slug;
957
+ }
958
+ } else {
959
+ $options = explode( '|', $attribute['value'] );
960
+ }
961
+
962
+ $options = array_map( 'sanitize_title', array_map( 'trim', $options ) );
963
+
964
+ $variations[ $attribute_field_name ] = $options;
965
+ }
966
+
967
+ // Quit out if none were found
968
+ if ( sizeof( $variations ) == 0 ) return 0;
969
+
970
+ // Get existing variations so we don't create duplicates
971
+ $available_variations = array();
972
+
973
+ foreach( $_product->get_children() as $child_id ) {
974
+ $child = $_product->get_child( $child_id );
975
+
976
+ if ( ! empty( $child->variation_id ) ) {
977
+ $available_variations[] = $child->get_variation_attributes();
978
+ }
979
+ }
980
+
981
+ // Created posts will all have the following data
982
+ $variation_post_data = array(
983
+ 'post_title' => 'Product #' . $post_id . ' Variation',
984
+ 'post_content' => '',
985
+ 'post_status' => 'publish',
986
+ 'post_author' => get_current_user_id(),
987
+ 'post_parent' => $post_id,
988
+ 'post_type' => 'product_variation'
989
+ );
990
+
991
+ $variation_ids = array();
992
+ $added = 0;
993
+ $possible_variations = $this->array_cartesian( $variations );
994
+
995
+ foreach ( $possible_variations as $variation ) {
996
+
997
+ // Check if variation already exists
998
+ if ( in_array( $variation, $available_variations ) )
999
+ continue;
1000
+
1001
+ $variation_id = ($options['is_fast_mode']) ? pmxi_insert_post($variation_post_data) : wp_insert_post( $variation_post_data );
1002
+
1003
+ update_post_meta( $variation_id, '_regular_price', get_post_meta( $post_id, '_regular_price', true ) );
1004
+ update_post_meta( $variation_id, '_sale_price', get_post_meta( $post_id, '_sale_price', true ) );
1005
+ if ( class_exists('woocommerce_wholesale_pricing') ) update_post_meta( $variation_id, 'pmxi_wholesale_price', get_post_meta( $post_id, 'pmxi_wholesale_price', true ) );
1006
+ update_post_meta( $variation_id, '_sale_price_dates_from', get_post_meta( $post_id, '_sale_price_dates_from', true ) );
1007
+ update_post_meta( $variation_id, '_sale_price_dates_to', get_post_meta( $post_id, '_sale_price_dates_to', true ) );
1008
+ update_post_meta( $variation_id, '_price', get_post_meta( $post_id, '_price', true ) );
1009
+
1010
+ $variation_ids[] = $variation_id;
1011
+
1012
+ foreach ( $variation as $key => $value ) {
1013
+ update_post_meta( $variation_id, $key, $value );
1014
+ }
1015
+
1016
+ $added++;
1017
+
1018
+ //do_action( 'product_variation_linked', $variation_id );
1019
+
1020
+ }
1021
+
1022
+ $woocommerce->clear_product_transients( $post_id );
1023
+
1024
+ return $added;
1025
+ }
1026
+
1027
+
1028
+ function array_cartesian( $input ) {
1029
+
1030
+ $result = array();
1031
+
1032
+ while ( list( $key, $values ) = each( $input ) ) {
1033
+ // If a sub-array is empty, it doesn't affect the cartesian product
1034
+ if ( empty( $values ) ) {
1035
+ continue;
1036
+ }
1037
+
1038
+ // Special case: seeding the product array with the values from the first sub-array
1039
+ if ( empty( $result ) ) {
1040
+ foreach ( $values as $value ) {
1041
+ $result[] = array( $key => $value );
1042
+ }
1043
+ }
1044
+ else {
1045
+ // Second and subsequent input sub-arrays work like this:
1046
+ // 1. In each existing array inside $product, add an item with
1047
+ // key == $key and value == first item in input sub-array
1048
+ // 2. Then, for each remaining item in current input sub-array,
1049
+ // add a copy of each existing array inside $product with
1050
+ // key == $key and value == first item in current input sub-array
1051
+
1052
+ // Store all items to be added to $product here; adding them on the spot
1053
+ // inside the foreach will result in an infinite loop
1054
+ $append = array();
1055
+ foreach( $result as &$product ) {
1056
+ // Do step 1 above. array_shift is not the most efficient, but it
1057
+ // allows us to iterate over the rest of the items with a simple
1058
+ // foreach, making the code short and familiar.
1059
+ $product[ $key ] = array_shift( $values );
1060
+
1061
+ // $product is by reference (that's why the key we added above
1062
+ // will appear in the end result), so make a copy of it here
1063
+ $copy = $product;
1064
+
1065
+ // Do step 2 above.
1066
+ foreach( $values as $item ) {
1067
+ $copy[ $key ] = $item;
1068
+ $append[] = $copy;
1069
+ }
1070
+
1071
+ // Undo the side effecst of array_shift
1072
+ array_unshift( $values, $product[ $key ] );
1073
+ }
1074
+
1075
+ // Out of the foreach, we can add to $results now
1076
+ $result = array_merge( $result, $append );
1077
+ }
1078
+ }
1079
+
1080
+ return $result;
1081
+ }
1082
 
1083
  public function _filter_has_cap_unfiltered_html($caps)
1084
  {
1085
  $caps['unfiltered_html'] = true;
1086
  return $caps;
1087
+ }
1088
+
1089
+ function duplicate_post_copy_post_meta_info($new_id, $post) {
1090
+ $post_meta_keys = get_post_custom_keys($post->ID);
1091
+ $meta_blacklist = array();
1092
+ $meta_keys = array_diff($post_meta_keys, $meta_blacklist);
1093
 
1094
+ foreach ($meta_keys as $meta_key) {
1095
+ $meta_values = get_post_custom_values($meta_key, $post->ID);
1096
 
1097
+ foreach ($meta_values as $meta_value) {
1098
+ $meta_value = maybe_unserialize($meta_value);
1099
+ update_post_meta($new_id, $meta_key, $meta_value);
1100
+ }
1101
+ }
1102
+ }
1103
 
1104
+ function auto_cloak_links($import, &$url){
1105
+ $url = trim($url);
1106
+ // cloak urls with `WP Wizard Cloak` if corresponding option is set
1107
+ if ( ! empty($import->options['is_cloak']) and class_exists('PMLC_Plugin')) {
1108
+ if (preg_match('%^\w+://%i', $url)) { // mask only links having protocol
1109
+ // try to find matching cloaked link among already registered ones
1110
+ $list = new PMLC_Link_List(); $linkTable = $list->getTable();
1111
+ $rule = new PMLC_Rule_Record(); $ruleTable = $rule->getTable();
1112
+ $dest = new PMLC_Destination_Record(); $destTable = $dest->getTable();
1113
+ $list->join($ruleTable, "$ruleTable.link_id = $linkTable.id")
1114
+ ->join($destTable, "$destTable.rule_id = $ruleTable.id")
1115
+ ->setColumns("$linkTable.*")
1116
+ ->getBy(array(
1117
+ "$linkTable.destination_type =" => 'ONE_SET',
1118
+ "$linkTable.is_trashed =" => 0,
1119
+ "$linkTable.preset =" => '',
1120
+ "$linkTable.expire_on =" => '0000-00-00',
1121
+ "$ruleTable.type =" => 'ONE_SET',
1122
+ "$destTable.weight =" => 100,
1123
+ "$destTable.url LIKE" => $url,
1124
+ ), NULL, 1, 1)->convertRecords();
1125
+ if ($list->count()) { // matching link found
1126
+ $link = $list[0];
1127
+ } else { // register new cloaked link
1128
+ global $wpdb;
1129
+ $slug = max(
1130
+ intval($wpdb->get_var("SELECT MAX(CONVERT(name, SIGNED)) FROM $linkTable")),
1131
+ intval($wpdb->get_var("SELECT MAX(CONVERT(slug, SIGNED)) FROM $linkTable")),
1132
+ 0
1133
+ );
1134
+ $i = 0; do {
1135
+ is_int(++$slug) and $slug > 0 or $slug = 1;
1136
+ $is_slug_found = ! intval($wpdb->get_var("SELECT COUNT(*) FROM $linkTable WHERE name = '$slug' OR slug = '$slug'"));
1137
+ } while( ! $is_slug_found and $i++ < 100000);
1138
+ if ($is_slug_found) {
1139
+ $link = new PMLC_Link_Record(array(
1140
+ 'name' => strval($slug),
1141
+ 'slug' => strval($slug),
1142
+ 'header_tracking_code' => '',
1143
+ 'footer_tracking_code' => '',
1144
+ 'redirect_type' => '301',
1145
+ 'destination_type' => 'ONE_SET',
1146
+ 'preset' => '',
1147
+ 'forward_url_params' => 1,
1148
+ 'no_global_tracking_code' => 0,
1149
+ 'expire_on' => '0000-00-00',
1150
+ 'created_on' => date('Y-m-d H:i:s'),
1151
+ 'is_trashed' => 0,
1152
+ ));
1153
+ $link->insert();
1154
+ $rule = new PMLC_Rule_Record(array(
1155
+ 'link_id' => $link->id,
1156
+ 'type' => 'ONE_SET',
1157
+ 'rule' => '',
1158
+ ));
1159
+ $rule->insert();
1160
+ $dest = new PMLC_Destination_Record(array(
1161
+ 'rule_id' => $rule->id,
1162
+ 'url' => $url,
1163
+ 'weight' => 100,
1164
+ ));
1165
+ $dest->insert();
1166
+ } else {
1167
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to create cloaked link for %s', 'pmxi_plugin'), $url));
1168
+ PMXI_Plugin::$session['pmxi_import']['warnings'] = PMXI_Plugin::$session->data['pmxi_import']['warnings']++;
1169
+ $link = NULL;
1170
+ }
1171
+ }
1172
+ if ($link) { // cloaked link is found or created for url
1173
+ $url = preg_replace('%' . preg_quote($url, '%') . '(?=([\s\'"]|$))%i', $link->getUrl(), $url);
1174
+ }
1175
+ }
1176
+ }
1177
+ }
1178
+
1179
+ function is_update_custom_field($existing_meta_keys, $options, $meta_key){
1180
 
1181
+ if ($options['update_all_data'] == 'yes') return true;
1182
+
1183
+ if ( ! $options['is_update_custom_fields'] ) return false;
1184
+
1185
+ if ($options['update_custom_fields_logic'] == "full_update") return true;
1186
+ if ($options['update_custom_fields_logic'] == "only" and ! empty($options['custom_fields_list']) and is_array($options['custom_fields_list']) and in_array($meta_key, $options['custom_fields_list']) ) return true;
1187
+ if ($options['update_custom_fields_logic'] == "all_except" and ( empty($options['custom_fields_list']) or ! in_array($meta_key, $options['custom_fields_list']) )) return true;
1188
+
1189
+ return false;
1190
  }
1191
 
1192
  // process simple product meta
plugin.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: WP All Import - WooCommerce Add-On
4
  Plugin URI: http://www.wpallimport.com/
5
- Description: Free edition. An extremely easy, drag & drop importer to import WooCommerce simple products. Works with WP All Import free or paid editions.
6
- Version: 1.0.1
7
  Author: Soflyy
8
  */
9
  /**
@@ -24,7 +24,7 @@ define('PMWI_FREE_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
24
  */
25
  define('PMWI_PREFIX', 'pmwi_');
26
 
27
- define('PMWI_FREE_VERSION', '1.0.1');
28
 
29
  define('PMWI_EDITION', 'free');
30
 
@@ -34,6 +34,7 @@ define('PMWI_EDITION', 'free');
34
  * @singletone
35
  * @author Pavel Kulbakin <p.kulbakin@gmail.com>
36
  */
 
37
  final class PMWI_Plugin {
38
  /**
39
  * Singletone instance
@@ -518,9 +519,16 @@ final class PMWI_Plugin {
518
  'variable_whosale_price' => '',
519
  'variable_whosale_price_use_parent' => 0,
520
  'disable_auto_sku_generation' => 0,
521
- 'is_default_attributes' => 1
 
 
 
 
 
 
 
522
  );
523
  }
524
  }
525
 
526
- PMWI_Plugin::getInstance();
2
  /*
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.1.0
7
  Author: Soflyy
8
  */
9
  /**
24
  */
25
  define('PMWI_PREFIX', 'pmwi_');
26
 
27
+ define('PMWI_FREE_VERSION', '1.1.0');
28
 
29
  define('PMWI_EDITION', 'free');
30
 
34
  * @singletone
35
  * @author Pavel Kulbakin <p.kulbakin@gmail.com>
36
  */
37
+
38
  final class PMWI_Plugin {
39
  /**
40
  * Singletone instance
519
  'variable_whosale_price' => '',
520
  'variable_whosale_price_use_parent' => 0,
521
  'disable_auto_sku_generation' => 0,
522
+ 'is_default_attributes' => 1,
523
+ 'disable_sku_matching' => 1,
524
+
525
+ 'is_update_attributes' => 1,
526
+ 'update_attributes_logic' => 'full_update',
527
+ 'attributes_list' => array(),
528
+ 'attributes_only_list' => array(),
529
+ 'attributes_except_list' => array()
530
  );
531
  }
532
  }
533
 
534
+ PMWI_Plugin::getInstance();
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Import Products from any XML or CSV to WooCommerce ===
2
  Contributors: soflyy
3
  Requires at least: 3.5
4
- Tested up to: 3.7
5
- Stable tag: 1.0.1
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
@@ -11,7 +11,10 @@ Easily import products from any XML or CSV file to WooCommerce with the WooComme
11
 
12
  == Description ==
13
 
14
- **Bulk import your products to WooCommerce in less than 10 minutes with the WooCommerce add-on for WP All Import.**
 
 
 
15
 
16
  The left side of the plugin looks just like WooCommerce, and the right side displays a product from your XML/CSV file.
17
 
@@ -24,14 +27,18 @@ Why use the WooCommerce add-on for WP All Import?
24
  - Supports files in any format and structure. There are no requirements that the data in your file be organized in a certain way.
25
  - Supports files of practically unlimited size by automatically splitting them into chunks. Import 200Mb+ product catalogs with ease, even on shared hosting.
26
 
 
27
  [youtube http://www.youtube.com/watch?v=7xL4RGT-JRc]
28
- *demo video shows some pro version only features*
29
 
30
- Upgrade to the professional edition of **WP All Import + the WooCommerce add-on** to:
 
 
31
 
32
- * Import External/Affiliate products, Grouped products, and Variable products.
33
 
34
- * Import files from a URL or FTP server - Download and import files from external websites or FTP servers, even if they are password protected. FTP imports support wildcard patterns, i.e. *.xml, so for example you could download and import all XML files in a certain folder.
 
 
35
 
36
  * Cron Job/Recurring Imports - WP All Import pro can check periodically check a file for updates, and add, edit, delete, and update the stock status of the imported products accordingly.
37
 
@@ -66,6 +73,9 @@ The WooCommerce add-on will appear in the Step 4 of WP All Import.
66
 
67
  == Changelog ==
68
 
 
 
 
69
  = 1.0.1 =
70
  * Fixed import product shipping class
71
  * Fixed import attributes;
1
  === Import Products from any XML or CSV to WooCommerce ===
2
  Contributors: soflyy
3
  Requires at least: 3.5
4
+ Tested up to: 3.8
5
+ Stable tag: 1.1.0
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
11
 
12
  == Description ==
13
 
14
+ *“I've been doing eCommerce sites for almost a decade. The combination of WP All Import and WooCommerce is a game changer! I can now get clients into eCommerce sites that could never afford the time/energy or money it took to administrate a site. It has opened up a whole new client base for me.”*
15
+ **Mike Tidmore** -Founder, Successful Online Stores
16
+
17
+ The WooCommerce add-on for [WP All Import](http://wordpress.org/plugins/wp-all-import/) makes it easy to bulk import your products to WooCommerce in less than 10 minutes.
18
 
19
  The left side of the plugin looks just like WooCommerce, and the right side displays a product from your XML/CSV file.
20
 
27
  - Supports files in any format and structure. There are no requirements that the data in your file be organized in a certain way.
28
  - Supports files of practically unlimited size by automatically splitting them into chunks. Import 200Mb+ product catalogs with ease, even on shared hosting.
29
 
30
+ = WooCommerce Add-On Professional Edition =
31
  [youtube http://www.youtube.com/watch?v=7xL4RGT-JRc]
 
32
 
33
+ The professional edition of *WP All Import + the WooCommerce add-on* is a paid upgrade that includes premium support and adds the following features:
34
+
35
+ * [In-depth support for Variable products](http://www.wpallimport.com/documentation/woocommerce/variable-products/) - example CSV files, ability to import variations from properly formatted XML, and much more.
36
 
37
+ * Import External/Affiliate products
38
 
39
+ * Import Grouped products
40
+
41
+ * Import files from a URL - Download and import files from external websites, even if they are password protected with HTTP authentication.
42
 
43
  * Cron Job/Recurring Imports - WP All Import pro can check periodically check a file for updates, and add, edit, delete, and update the stock status of the imported products accordingly.
44
 
73
 
74
  == Changelog ==
75
 
76
+ = 1.1.0 =
77
+ * Compatibility with WP 3.8
78
+
79
  = 1.0.1 =
80
  * Fixed import product shipping class
81
  * Fixed import attributes;
static/css/admin-wp-3.8.css ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .pmxi_plugin .woocommerce_options_panel .options_group{
2
+ overflow: hidden;
3
+ }
4
+ .pmxi_plugin .woocommerce_options_panel input{
5
+ float: left !important;
6
+ }
7
+ .pmxi_plugin .form-table input.tog, .pmxi_plugin .form-table input[type="radio"]{
8
+ margin-top: 0px !important;
9
+ }
10
+ .pmxi_plugin #woocommerce_attributes label{
11
+ top:0px !important;
12
+ margin-bottom: 10px !important;
13
+ }
14
+ .pmxi_plugin .form-table,.pmxi_plugin .form-table td,.pmxi_plugin .form-table th,.pmxi_plugin .form-table td p,.pmxi_plugin .form-wrap label{
15
+ font-size: 12px !important ;
16
+ }
17
+ .pmxi_plugin #close_xml_tree{
18
+ top:0px;
19
+ right:0px;
20
+ }
static/css/admin.css CHANGED
@@ -41,7 +41,7 @@
41
  padding: 5px 0;
42
  }
43
  .pmxi_plugin .set_with_xpath{
44
- padding-left:20px;
45
  position:absolute;
46
  left:0px;
47
  top:-15px;
41
  padding: 5px 0;
42
  }
43
  .pmxi_plugin .set_with_xpath{
44
+ /*padding-left:20px; */
45
  position:absolute;
46
  left:0px;
47
  top:-15px;
static/js/admin.js CHANGED
@@ -175,22 +175,25 @@
175
  var $prev_element = $('#prev_variation_element');
176
  var $goto_element = $('#goto_variation_element');
177
  var $variation_tagno = 0;
 
178
  // tag preview
179
- $.fn.variation_tag = function () {
180
  this.each(function () {
181
  var $tag = $(this);
182
  $tag.xml('dragable');
183
  var tagno = parseInt($tag.find('input[name="tagno"]').val());
 
 
184
  $tag.find('.navigation a').click(function () {
185
  tagno += '#variation_prev' == $(this).attr('href') ? -1 : 1;
186
  $tag.addClass('loading').css('opacity', 0.7);
187
 
188
- $('#variations_console').load('admin.php?page=pmxi-admin-import&action=evaluate_variations', {xpath: $input.val(), tagno: tagno}, function () {
189
  var $indicator = $('<span />').insertBefore($tag);
190
  $xml.variation_tag();
191
  });
192
 
193
- $.post('admin.php?page=pmxi-admin-import&action=evaluate_variations', {xpath: $input.val(), tagno: tagno}, function (data) {
194
  var $indicator = $('<span />').insertBefore($tag);
195
  $tag.replaceWith(data);
196
  $indicator.next().tag().prevObject.remove();
@@ -199,7 +202,7 @@
199
  });
200
  });
201
  return this;
202
- };
203
 
204
  var variationsXPathChanged = function () {
205
 
@@ -208,7 +211,9 @@
208
  // request server to return elements which correspond to xpath entered
209
  $input.attr('readonly', true).unbind('change', variationsXPathChanged).data('checkedValue', $input.val());
210
 
211
- $('#variations_console').load('admin.php?page=pmxi-admin-import&action=evaluate_variations', {xpath: $input.val(), tagno: $variation_tagno}, function () {
 
 
212
  $input.attr('readonly', false);
213
  $xml.xml('dragable');
214
  if ($('.error').length){
@@ -268,5 +273,21 @@
268
  $('#close_xml_tree').click(function(){
269
  $('#variations_tag').hide();
270
  });
 
 
271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  });})(jQuery);
175
  var $prev_element = $('#prev_variation_element');
176
  var $goto_element = $('#goto_variation_element');
177
  var $variation_tagno = 0;
178
+
179
  // tag preview
180
+ /*$.fn.variation_tag = function () {
181
  this.each(function () {
182
  var $tag = $(this);
183
  $tag.xml('dragable');
184
  var tagno = parseInt($tag.find('input[name="tagno"]').val());
185
+ var parent_tagno = parseInt($parent_tag.find('input[name="tagno"]').val());
186
+ console.log(parent_tagno);
187
  $tag.find('.navigation a').click(function () {
188
  tagno += '#variation_prev' == $(this).attr('href') ? -1 : 1;
189
  $tag.addClass('loading').css('opacity', 0.7);
190
 
191
+ $('#variations_console').load('admin.php?page=pmxi-admin-import&action=evaluate_variations', {xpath: $input.val(), tagno: tagno, parent_tagno: parent_tagno}, function () {
192
  var $indicator = $('<span />').insertBefore($tag);
193
  $xml.variation_tag();
194
  });
195
 
196
+ $.post('admin.php?page=pmxi-admin-import&action=evaluate_variations', {xpath: $input.val(), tagno: tagno, parent_tagno: parent_tagno}, function (data) {
197
  var $indicator = $('<span />').insertBefore($tag);
198
  $tag.replaceWith(data);
199
  $indicator.next().tag().prevObject.remove();
202
  });
203
  });
204
  return this;
205
+ }; */
206
 
207
  var variationsXPathChanged = function () {
208
 
211
  // request server to return elements which correspond to xpath entered
212
  $input.attr('readonly', true).unbind('change', variationsXPathChanged).data('checkedValue', $input.val());
213
 
214
+ var parent_tagno = parseInt($('.tag').find('input[name="tagno"]').val());
215
+
216
+ $('#variations_console').load('admin.php?page=pmxi-admin-import&action=evaluate_variations', {xpath: $input.val(), tagno: $variation_tagno, parent_tagno: parent_tagno}, function () {
217
  $input.attr('readonly', false);
218
  $xml.xml('dragable');
219
  if ($('.error').length){
273
  $('#close_xml_tree').click(function(){
274
  $('#variations_tag').hide();
275
  });
276
+
277
+ var $unique_key = $('input[name=unique_key]:first').val();
278
 
279
+ $('.auto_generate_unique_key').click(function(){
280
+
281
+ var attrs = new Array();
282
+ $('#attributes_table').find('textarea[name^=attribute_value]').each(function(){
283
+ if ("" != $(this).val() && $(this).val() != undefined) attrs.push($(this).val());
284
+ });
285
+ if (attrs.length){
286
+ $(this).parents('#product:first').find('input[name=unique_key]').val($unique_key + attrs.join('-'));
287
+ alert('The unique key has been successfully generated');
288
+ }
289
+ else
290
+ alert('At first, you should add minimum one attribute on the "Attributes" tab.');
291
+ });
292
+
293
  });})(jQuery);
views/admin/import/index.php CHANGED
@@ -59,6 +59,8 @@
59
 
60
  <li class="options_tab advanced_options"><a title="Variations for variable products are defined here." href="javascript:void(0);" rel="add_on_options"><?php _e('Add-On Options', 'pmxi_plugin');?></a></li>
61
 
 
 
62
  </ul>
63
 
64
  <div class="panel woocommerce_options_panel" id="general_product_data">
@@ -490,7 +492,7 @@
490
  <tr class="form-field">
491
  <td><input type="text" name="attribute_name[]" value="<?php echo esc_attr($name) ?>" style="width:100%;"/></td>
492
  <td>
493
- <textarea name="attribute_value[]" placeholder="Enter some text, or some attributes by pipe (|) separating values."><?php echo esc_html($post['attribute_value'][$i]) ?></textarea>
494
  <br>
495
  <span class='in_variations'>
496
  <input type="checkbox" name="in_variations[]" id="in_variations_<?php echo $i; ?>" <?php echo ($post['in_variations'][$i]) ? 'checked="checked"' : ''; ?> style="width: auto; position: relative; top: 1px; left: 0px;" value="1"/>
@@ -684,7 +686,7 @@
684
  </p>
685
  <div class="options_group" style="padding-bottom:0px;">
686
  <div class="input" style="padding-bottom:10px;">
687
- <input type="radio" id="auto_matching_parent" class="switcher" name="matching_parent" value="auto" <?php echo 'auto' == $post['matching_parent'] ? 'checked="checked"': '' ?>/>
688
  <label for="auto_matching_parent" style="width:95%"><?php _e('All my variable products have SKUs or some other unique identifier. Each variation is linked to its parent with its parent\'s SKU or other unique identifier.', 'pmxi_plugin' )?></label><br>
689
  <div class="switcher-target-auto_matching_parent" style="padding-left:17px;">
690
  <p class="form-field">
@@ -697,7 +699,7 @@
697
  <input type="text" class="short" placeholder="" name="single_product_parent_id" value="<?php echo esc_attr($post['single_product_parent_id']) ?>"/>
698
  <a href="#help" class="help" title="<?php _e('Parent SKU column in the below example.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
699
  </p>
700
- <p><strong><?php _e("Example Data For Use With This Option","pmxi_plugin");?> </strong> - <a href="http://www.wpallimport.com/variations-data/data-example-1.csv" tatger="_blank"><?php _e("download","pmxi_plugin");?></a></p>
701
  <img src="<?php echo PMWI_FREE_ROOT_URL; ?>/static/img/data-example-1.png"/>
702
  <p class="highlight">
703
  <strong><?php _e("Important: Your Unique Key must be unique for each variation.","pmxi_plugin");?></strong> <a href="#help" class="help" title="<?php _e('If each variation doesn’t have a unique ID/SKU, it is recommended that you construct your Unique Key using your variation attribute values. You can set your Unique Key at the top of the Record Matching section below.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
@@ -707,7 +709,7 @@
707
  <?php endif; ?>
708
  </div>
709
  <div class="clear" style="margin-top:5px;"></div>
710
- <input type="radio" id="auto_matching_parent_first_is_parent_id" class="switcher" name="matching_parent" value="first_is_parent_id" <?php echo 'first_is_parent_id' == $post['matching_parent'] ? 'checked="checked"': '' ?>/>
711
  <label for="auto_matching_parent_first_is_parent_id" style="width:95%"><?php _e('All products with variations are grouped with a unique identifier that is the same for each variation and unique for each product.', 'pmxi_plugin' )?></label><br>
712
  <div class="switcher-target-auto_matching_parent_first_is_parent_id" style="padding-left:17px;">
713
  <p class="form-field">
@@ -715,7 +717,7 @@
715
  <input type="text" class="short" placeholder="" name="single_product_id_first_is_parent_id" value="<?php echo esc_attr($post['single_product_id_first_is_parent_id']) ?>"/>
716
  <a href="#help" class="help" title="<?php _e('Group ID column in the below example.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
717
  </p>
718
- <p><strong><?php _e("Example Data For Use With This Option","pmxi_plugin");?> </strong> - <a href="http://www.wpallimport.com/variations-data/data-example-2.csv" tatger="_blank"><?php _e("download","pmxi_plugin");?></a></p>
719
  <img src="<?php echo PMWI_FREE_ROOT_URL; ?>/static/img/data-example-2.png"/>
720
  <p class="highlight"><strong><?php _e("Important: Your Unique Key must be unique for each variation.","pmxi_plugin");?></strong> <a href="#help" class="help" title="<?php _e('If each variation doesn’t have a unique ID/SKU, it is recommended that you construct your Unique Key using your variation attribute values. You can set your Unique Key at the top of the Record Matching section below.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a></p>
721
  <?php if ( ! $id ): ?>
@@ -723,14 +725,14 @@
723
  <?php endif; ?>
724
  </div>
725
  <div class="clear" style="margin-top:5px;"></div>
726
- <input type="radio" id="auto_matching_parent_first_is_parent_title" class="switcher" name="matching_parent" value="first_is_parent_title" <?php echo 'first_is_parent_title' == $post['matching_parent'] ? 'checked="checked"': '' ?>/>
727
  <label for="auto_matching_parent_first_is_parent_title"><?php _e('All variations for a particular product have the same title as the parent product.', 'pmxi_plugin' )?></label><br>
728
  <div class="switcher-target-auto_matching_parent_first_is_parent_title" style="padding-left:17px;">
729
  <p class="form-field">
730
  <label style="width:75px;"><?php _e("Product Title", "pmxi_plugin"); ?></label>
731
  <input type="text" class="short" placeholder="" name="single_product_id_first_is_parent_title" value="<?php echo ($post['single_product_id_first_is_parent_title']) ? esc_attr($post['single_product_id_first_is_parent_title']) : ((!empty(PMXI_Plugin::$session->data['pmxi_import']['template']['title'])) ? esc_attr(PMXI_Plugin::$session->data['pmxi_import']['template']['title']) : ''); ?>"/>
732
  </p>
733
- <p><strong><?php _e("Example Data For Use With This Option","pmxi_plugin");?> </strong> - <a href="http://www.wpallimport.com/variations-data/data-example-3.csv" tatger="_blank"><?php _e("download","pmxi_plugin");?></a></p>
734
  <img src="<?php echo PMWI_FREE_ROOT_URL; ?>/static/img/data-example-3.png"/>
735
  <p class="highlight"><strong><?php _e("Important: Your Unique Key must be unique for each variation.","pmxi_plugin");?></strong> <a href="#help" class="help" title="<?php _e('If each variation doesn’t have a unique ID/SKU, it is recommended that you construct your Unique Key using your variation attribute values. You can set your Unique Key at the top of the Record Matching section below.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a></p>
736
  <?php if ( ! $id ): ?>
@@ -738,14 +740,14 @@
738
  <?php endif; ?>
739
  </div>
740
  <div class="clear" style="margin-top:5px;"></div>
741
- <input type="radio" id="auto_matching_parent_first_is_variation" class="switcher" name="matching_parent" value="first_is_variation" <?php echo 'first_is_variation' == $post['matching_parent'] ? 'checked="checked"': '' ?>/>
742
  <label for="auto_matching_parent_first_is_variation"><?php _e('All variations for a particular product have the same title. There are no parent products.', 'pmxi_plugin' )?></label><br>
743
  <div class="switcher-target-auto_matching_parent_first_is_variation" style="padding-left:17px;">
744
  <p class="form-field">
745
  <label style="width:75px;"><?php _e("Product Title"); ?></label>
746
  <input type="text" class="short" placeholder="" name="single_product_id_first_is_variation" value="<?php echo ($post['single_product_id_first_is_variation']) ? esc_attr($post['single_product_id_first_is_variation']) : ((!empty(PMXI_Plugin::$session->data['pmxi_import']['template']['title'])) ? esc_attr(PMXI_Plugin::$session->data['pmxi_import']['template']['title']) : ''); ?>"/>
747
  </p>
748
- <p><strong><?php _e("Example Data For Use With This Option","pmxi_plugin");?> </strong> - <a href="http://www.wpallimport.com/variations-data/data-example-4.csv" tatger="_blank"><?php _e("download","pmxi_plugin");?></a></p>
749
  <img src="<?php echo PMWI_FREE_ROOT_URL; ?>/static/img/data-example-4.png"/>
750
  <p class="highlight"><strong><?php _e("Important: Your Unique Key must be unique for each variation.","pmxi_plugin");?></strong> <a href="#help" class="help" title="<?php _e('If each variation doesn’t have a unique ID/SKU, it is recommended that you construct your Unique Key using your variation attribute values. You can set your Unique Key at the top of the Record Matching section below.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a></p>
751
  <?php if ( ! $id ): ?>
@@ -754,7 +756,7 @@
754
  </div>
755
  <div class="clear" style="margin-top:5px;"></div>
756
 
757
- <input type="radio" id="xml_matching_parent" class="switcher" name="matching_parent" value="xml" <?php echo 'xml' == $post['matching_parent'] ? 'checked="checked"': '' ?>/>
758
  <label for="xml_matching_parent"><?php _e('I\'m importing XML and my variations are child XML elements', 'pmxi_plugin' )?> </label>
759
  <a href="#help" class="help" title="<?php _e('This allows you to set variations that are stored as children XML elements.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
760
  <div class="switcher-target-xml_matching_parent" style="padding-left:17px; position:relative;">
@@ -1052,7 +1054,7 @@
1052
  <label for="variable_product_enabled_xpath"><?php _e('Set with XPath', 'pmxi_plugin' )?></label><br>
1053
  <div class="switcher-target-variable_product_enabled_xpath set_with_xpath">
1054
  <div class="input">
1055
- <input type="text" class="smaller-text" name="single_variable_product_enabled" style="width:300px;" value="<?php echo esc_attr($post['single_variable_product_enabled']) ?>"/>
1056
  <a href="#help" class="help" title="<?php _e('The value of presented XPath should be one of the following: (\'yes\', \'no\').', 'pmxi_plugin') ?>" style="position:relative; top:2px;">?</a>
1057
  </div>
1058
  </div>
@@ -1079,7 +1081,7 @@
1079
  <?php foreach ($post['variable_attribute_name'] as $i => $name): if ("" == $name) continue; ?>
1080
  <tr class="form-field">
1081
  <td><input type="text" name="variable_attribute_name[]" value="<?php echo esc_attr($name) ?>" style="width:95% !important;"/></td>
1082
- <td><textarea name="variable_attribute_value[]" placeholder="Enter some text, or some attributes by pipe (|) separating values."><?php echo esc_html($post['variable_attribute_value'][$i]) ?></textarea>
1083
  <br>
1084
  <span class='in_variations' style="margin-left:0px;">
1085
  <input type="checkbox" name="variable_in_variations[]" id="variable_in_variations_<?php echo $i; ?>" <?php echo ($post['variable_in_variations'][$i]) ? 'checked="checked"' : ''; ?> style="width: auto; position: relative; top: 1px; left: 0px;" value="1"/>
@@ -1181,7 +1183,7 @@
1181
 
1182
  <div class="clear" style="margin-top:5px;"></div>
1183
 
1184
- <input type="radio" id="manual_matching_parent" class="switcher" name="matching_parent" value="manual" <?php echo 'manual' == $post['matching_parent'] ? 'checked="checked"': '' ?>/>
1185
  <label for="manual_matching_parent"><?php _e('I\'m an advanced user and will match my variations with my parent products manually. (Advanced)', 'pmxi_plugin' )?></label>
1186
  <a href="#help" class="help" title="<?php _e('This allows you to match products as you would in the Manual Record Matching section of WP All Import.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
1187
  <div class="switcher-target-manual_matching_parent" style="padding-left:17px;">
@@ -1202,7 +1204,7 @@
1202
  </div>
1203
  </div>
1204
  </div>
1205
- <div class="options_group">
1206
  <p class="form-field"><?php _e('Variable Enabled','pmxi_plugin');?></p>
1207
  <div class="input" style="margin-top:-10px;">
1208
  <div class="input fleft">
@@ -1239,6 +1241,7 @@
1239
  </div>
1240
  </div><!-- End Product Panel -->
1241
 
 
1242
 
1243
  <!-- OPTIONS -->
1244
 
@@ -1260,6 +1263,12 @@
1260
  <label for="disable_auto_sku_generation"><?php _e('Disable auto SKU generation', 'pmxi_plugin') ?></label>
1261
  <a href="#help" class="help" title="<?php _e('Plugin will NOT automaticaly generate the SKU for each product based on md5 algorithm, if SKU option is empty.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
1262
  </div>
 
 
 
 
 
 
1263
  </div>
1264
  </div>
1265
  </div>
59
 
60
  <li class="options_tab advanced_options"><a title="Variations for variable products are defined here." href="javascript:void(0);" rel="add_on_options"><?php _e('Add-On Options', 'pmxi_plugin');?></a></li>
61
 
62
+ <?php do_action('pmwi_tab_header'); ?>
63
+
64
  </ul>
65
 
66
  <div class="panel woocommerce_options_panel" id="general_product_data">
492
  <tr class="form-field">
493
  <td><input type="text" name="attribute_name[]" value="<?php echo esc_attr($name) ?>" style="width:100%;"/></td>
494
  <td>
495
+ <textarea name="attribute_value[]" placeholder="Enter some text, or some attributes by pipe (|) separating values."><?php echo str_replace("&amp;","&", htmlentities(htmlentities($post['attribute_value'][$i]))); ?></textarea>
496
  <br>
497
  <span class='in_variations'>
498
  <input type="checkbox" name="in_variations[]" id="in_variations_<?php echo $i; ?>" <?php echo ($post['in_variations'][$i]) ? 'checked="checked"' : ''; ?> style="width: auto; position: relative; top: 1px; left: 0px;" value="1"/>
686
  </p>
687
  <div class="options_group" style="padding-bottom:0px;">
688
  <div class="input" style="padding-bottom:10px;">
689
+ <input type="radio" id="auto_matching_parent" class="switcher" name="matching_parent" value="auto" <?php echo 'auto' == $post['matching_parent'] ? 'checked="checked"': '' ?> style="float:left;"/>
690
  <label for="auto_matching_parent" style="width:95%"><?php _e('All my variable products have SKUs or some other unique identifier. Each variation is linked to its parent with its parent\'s SKU or other unique identifier.', 'pmxi_plugin' )?></label><br>
691
  <div class="switcher-target-auto_matching_parent" style="padding-left:17px;">
692
  <p class="form-field">
699
  <input type="text" class="short" placeholder="" name="single_product_parent_id" value="<?php echo esc_attr($post['single_product_parent_id']) ?>"/>
700
  <a href="#help" class="help" title="<?php _e('Parent SKU column in the below example.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
701
  </p>
702
+ <p><strong><?php _e("Example Data For Use With This Option","pmxi_plugin");?> </strong> - <a href="http://www.wpallimport.com/wp-content/uploads/2013/12/data-example-1.csv" tatger="_blank"><?php _e("download","pmxi_plugin");?></a></p>
703
  <img src="<?php echo PMWI_FREE_ROOT_URL; ?>/static/img/data-example-1.png"/>
704
  <p class="highlight">
705
  <strong><?php _e("Important: Your Unique Key must be unique for each variation.","pmxi_plugin");?></strong> <a href="#help" class="help" title="<?php _e('If each variation doesn’t have a unique ID/SKU, it is recommended that you construct your Unique Key using your variation attribute values. You can set your Unique Key at the top of the Record Matching section below.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
709
  <?php endif; ?>
710
  </div>
711
  <div class="clear" style="margin-top:5px;"></div>
712
+ <input type="radio" id="auto_matching_parent_first_is_parent_id" class="switcher" name="matching_parent" value="first_is_parent_id" <?php echo 'first_is_parent_id' == $post['matching_parent'] ? 'checked="checked"': '' ?> style="float:left;"/>
713
  <label for="auto_matching_parent_first_is_parent_id" style="width:95%"><?php _e('All products with variations are grouped with a unique identifier that is the same for each variation and unique for each product.', 'pmxi_plugin' )?></label><br>
714
  <div class="switcher-target-auto_matching_parent_first_is_parent_id" style="padding-left:17px;">
715
  <p class="form-field">
717
  <input type="text" class="short" placeholder="" name="single_product_id_first_is_parent_id" value="<?php echo esc_attr($post['single_product_id_first_is_parent_id']) ?>"/>
718
  <a href="#help" class="help" title="<?php _e('Group ID column in the below example.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
719
  </p>
720
+ <p><strong><?php _e("Example Data For Use With This Option","pmxi_plugin");?> </strong> - <a href="http://www.wpallimport.com/wp-content/uploads/2013/12/data-example-2.csv" tatger="_blank"><?php _e("download","pmxi_plugin");?></a></p>
721
  <img src="<?php echo PMWI_FREE_ROOT_URL; ?>/static/img/data-example-2.png"/>
722
  <p class="highlight"><strong><?php _e("Important: Your Unique Key must be unique for each variation.","pmxi_plugin");?></strong> <a href="#help" class="help" title="<?php _e('If each variation doesn’t have a unique ID/SKU, it is recommended that you construct your Unique Key using your variation attribute values. You can set your Unique Key at the top of the Record Matching section below.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a></p>
723
  <?php if ( ! $id ): ?>
725
  <?php endif; ?>
726
  </div>
727
  <div class="clear" style="margin-top:5px;"></div>
728
+ <input type="radio" id="auto_matching_parent_first_is_parent_title" class="switcher" name="matching_parent" value="first_is_parent_title" <?php echo 'first_is_parent_title' == $post['matching_parent'] ? 'checked="checked"': '' ?> style="float:left;"/>
729
  <label for="auto_matching_parent_first_is_parent_title"><?php _e('All variations for a particular product have the same title as the parent product.', 'pmxi_plugin' )?></label><br>
730
  <div class="switcher-target-auto_matching_parent_first_is_parent_title" style="padding-left:17px;">
731
  <p class="form-field">
732
  <label style="width:75px;"><?php _e("Product Title", "pmxi_plugin"); ?></label>
733
  <input type="text" class="short" placeholder="" name="single_product_id_first_is_parent_title" value="<?php echo ($post['single_product_id_first_is_parent_title']) ? esc_attr($post['single_product_id_first_is_parent_title']) : ((!empty(PMXI_Plugin::$session->data['pmxi_import']['template']['title'])) ? esc_attr(PMXI_Plugin::$session->data['pmxi_import']['template']['title']) : ''); ?>"/>
734
  </p>
735
+ <p><strong><?php _e("Example Data For Use With This Option","pmxi_plugin");?> </strong> - <a href="http://www.wpallimport.com/wp-content/uploads/2013/12/data-example-3.csv" tatger="_blank"><?php _e("download","pmxi_plugin");?></a></p>
736
  <img src="<?php echo PMWI_FREE_ROOT_URL; ?>/static/img/data-example-3.png"/>
737
  <p class="highlight"><strong><?php _e("Important: Your Unique Key must be unique for each variation.","pmxi_plugin");?></strong> <a href="#help" class="help" title="<?php _e('If each variation doesn’t have a unique ID/SKU, it is recommended that you construct your Unique Key using your variation attribute values. You can set your Unique Key at the top of the Record Matching section below.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a></p>
738
  <?php if ( ! $id ): ?>
740
  <?php endif; ?>
741
  </div>
742
  <div class="clear" style="margin-top:5px;"></div>
743
+ <input type="radio" id="auto_matching_parent_first_is_variation" class="switcher" name="matching_parent" value="first_is_variation" <?php echo 'first_is_variation' == $post['matching_parent'] ? 'checked="checked"': '' ?> style="float:left;"/>
744
  <label for="auto_matching_parent_first_is_variation"><?php _e('All variations for a particular product have the same title. There are no parent products.', 'pmxi_plugin' )?></label><br>
745
  <div class="switcher-target-auto_matching_parent_first_is_variation" style="padding-left:17px;">
746
  <p class="form-field">
747
  <label style="width:75px;"><?php _e("Product Title"); ?></label>
748
  <input type="text" class="short" placeholder="" name="single_product_id_first_is_variation" value="<?php echo ($post['single_product_id_first_is_variation']) ? esc_attr($post['single_product_id_first_is_variation']) : ((!empty(PMXI_Plugin::$session->data['pmxi_import']['template']['title'])) ? esc_attr(PMXI_Plugin::$session->data['pmxi_import']['template']['title']) : ''); ?>"/>
749
  </p>
750
+ <p><strong><?php _e("Example Data For Use With This Option","pmxi_plugin");?> </strong> - <a href="http://www.wpallimport.com/wp-content/uploads/2013/12/data-example-4.csv" tatger="_blank"><?php _e("download","pmxi_plugin");?></a></p>
751
  <img src="<?php echo PMWI_FREE_ROOT_URL; ?>/static/img/data-example-4.png"/>
752
  <p class="highlight"><strong><?php _e("Important: Your Unique Key must be unique for each variation.","pmxi_plugin");?></strong> <a href="#help" class="help" title="<?php _e('If each variation doesn’t have a unique ID/SKU, it is recommended that you construct your Unique Key using your variation attribute values. You can set your Unique Key at the top of the Record Matching section below.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a></p>
753
  <?php if ( ! $id ): ?>
756
  </div>
757
  <div class="clear" style="margin-top:5px;"></div>
758
 
759
+ <input type="radio" id="xml_matching_parent" class="switcher" name="matching_parent" value="xml" <?php echo 'xml' == $post['matching_parent'] ? 'checked="checked"': '' ?> style="float:left;"/>
760
  <label for="xml_matching_parent"><?php _e('I\'m importing XML and my variations are child XML elements', 'pmxi_plugin' )?> </label>
761
  <a href="#help" class="help" title="<?php _e('This allows you to set variations that are stored as children XML elements.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
762
  <div class="switcher-target-xml_matching_parent" style="padding-left:17px; position:relative;">
1054
  <label for="variable_product_enabled_xpath"><?php _e('Set with XPath', 'pmxi_plugin' )?></label><br>
1055
  <div class="switcher-target-variable_product_enabled_xpath set_with_xpath">
1056
  <div class="input">
1057
+ <input type="text" class="smaller-text" name="single_variable_product_enabled" style="width:300px; " value="<?php echo esc_attr($post['single_variable_product_enabled']) ?>"/>
1058
  <a href="#help" class="help" title="<?php _e('The value of presented XPath should be one of the following: (\'yes\', \'no\').', 'pmxi_plugin') ?>" style="position:relative; top:2px;">?</a>
1059
  </div>
1060
  </div>
1081
  <?php foreach ($post['variable_attribute_name'] as $i => $name): if ("" == $name) continue; ?>
1082
  <tr class="form-field">
1083
  <td><input type="text" name="variable_attribute_name[]" value="<?php echo esc_attr($name) ?>" style="width:95% !important;"/></td>
1084
+ <td><textarea name="variable_attribute_value[]" placeholder="Enter some text, or some attributes by pipe (|) separating values."><?php echo str_replace("&amp;","&", htmlentities(htmlentities($post['variable_attribute_value'][$i]))); ?></textarea>
1085
  <br>
1086
  <span class='in_variations' style="margin-left:0px;">
1087
  <input type="checkbox" name="variable_in_variations[]" id="variable_in_variations_<?php echo $i; ?>" <?php echo ($post['variable_in_variations'][$i]) ? 'checked="checked"' : ''; ?> style="width: auto; position: relative; top: 1px; left: 0px;" value="1"/>
1183
 
1184
  <div class="clear" style="margin-top:5px;"></div>
1185
 
1186
+ <input type="radio" id="manual_matching_parent" class="switcher" name="matching_parent" value="manual" <?php echo 'manual' == $post['matching_parent'] ? 'checked="checked"': '' ?> style="float:left;"/>
1187
  <label for="manual_matching_parent"><?php _e('I\'m an advanced user and will match my variations with my parent products manually. (Advanced)', 'pmxi_plugin' )?></label>
1188
  <a href="#help" class="help" title="<?php _e('This allows you to match products as you would in the Manual Record Matching section of WP All Import.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
1189
  <div class="switcher-target-manual_matching_parent" style="padding-left:17px;">
1204
  </div>
1205
  </div>
1206
  </div>
1207
+ <div class="options_group">
1208
  <p class="form-field"><?php _e('Variable Enabled','pmxi_plugin');?></p>
1209
  <div class="input" style="margin-top:-10px;">
1210
  <div class="input fleft">
1241
  </div>
1242
  </div><!-- End Product Panel -->
1243
 
1244
+ <?php do_action('pmwi_tab_content'); ?>
1245
 
1246
  <!-- OPTIONS -->
1247
 
1263
  <label for="disable_auto_sku_generation"><?php _e('Disable auto SKU generation', 'pmxi_plugin') ?></label>
1264
  <a href="#help" class="help" title="<?php _e('Plugin will NOT automaticaly generate the SKU for each product based on md5 algorithm, if SKU option is empty.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
1265
  </div>
1266
+ <div class="input" style="padding-left:20px;">
1267
+ <input type="hidden" name="disable_sku_matching" value="0" />
1268
+ <input type="checkbox" id="disable_sku_matching" name="disable_sku_matching" value="1" <?php echo $post['disable_sku_matching'] ? 'checked="checked"' : '' ?> />
1269
+ <label for="disable_sku_matching"><?php _e('Disable SKU matching', 'pmxi_plugin') ?></label>
1270
+ <a href="#help" class="help" title="<?php _e('Plugin will NOT search matches for SKU. This option will speed up import process.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
1271
+ </div>
1272
  </div>
1273
  </div>
1274
  </div>