Version Description
bug fix: stock status not importing properly when _backorders custom field is not set bug fix: product dimensions won't import if 'Virtual' field is not set bug fix: compatibility fix WooCommerce 2.6.x bug fix: remove deprecated function calls for PHP 7.2 compatibility bug fix: unable to import 0 as a value for attributes bug fix: mirror new WooCommerce core behavior that forces all uncategorized products to be assigned to the Uncategorized category bug fix: import attributes with special characters bug fix: recount product terms when updating post status
Download this release
Release Info
Developer | soflyy |
Plugin | Import Products from any XML or CSV to WooCommerce |
Version | 1.3.8 |
Comparing to | |
See all releases |
Code changes from version 1.3.7 to 1.3.8
- actions/pmxi_after_xml_import.php +1 -1
- classes/config.php +7 -9
- controllers/controller/admin.php +5 -1
- filters/wp_all_import_set_post_terms.php +18 -0
- models/import/record.php +173 -150
- plugin.php +4 -5
- readme.txt +12 -2
actions/pmxi_after_xml_import.php
CHANGED
@@ -11,7 +11,7 @@ function pmwi_pmxi_after_xml_import($import_id)
|
|
11 |
{
|
12 |
$recount_terms_after_import = true;
|
13 |
$recount_terms_after_import = apply_filters('wp_all_import_recount_terms_after_import', $recount_terms_after_import, $import_id);
|
14 |
-
if ( $recount_terms_after_import && ( ($import->options['create_new_records'] and $import->options['is_keep_former_posts'] == 'yes') or ($import->options['is_keep_former_posts'] == 'no' and ( $import->options['update_all_data'] == 'yes' or $import->options['is_update_categories'])))) {
|
15 |
$product_cats = get_terms( 'product_cat', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
|
16 |
_wc_term_recount( $product_cats, get_taxonomy( 'product_cat' ), true, false );
|
17 |
$product_tags = get_terms( 'product_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
|
11 |
{
|
12 |
$recount_terms_after_import = true;
|
13 |
$recount_terms_after_import = apply_filters('wp_all_import_recount_terms_after_import', $recount_terms_after_import, $import_id);
|
14 |
+
if ( $recount_terms_after_import && ( ($import->options['create_new_records'] and $import->options['is_keep_former_posts'] == 'yes') or ($import->options['is_keep_former_posts'] == 'no' and ( $import->options['update_all_data'] == 'yes' or $import->options['is_update_categories'] or $import->options['is_update_status'])))) {
|
15 |
$product_cats = get_terms( 'product_cat', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
|
16 |
_wc_term_recount( $product_cats, get_taxonomy( 'product_cat' ), true, false );
|
17 |
$product_tags = get_terms( 'product_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
|
classes/config.php
CHANGED
@@ -37,15 +37,13 @@ class PMWI_Config implements IteratorAggregate {
|
|
37 |
if ( ! is_null($section)) {
|
38 |
$this->config[$section] = self::createFromFile($filePath);
|
39 |
} else {
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
$this->config = array_merge($this->config, $config);
|
48 |
-
}
|
49 |
}
|
50 |
return $this;
|
51 |
}
|
37 |
if ( ! is_null($section)) {
|
38 |
$this->config[$section] = self::createFromFile($filePath);
|
39 |
} else {
|
40 |
+
$filePath = realpath($filePath);
|
41 |
+
if ($filePath and ! in_array($filePath, $this->loaded)) {
|
42 |
+
require $filePath;
|
43 |
+
$config = (!isset($config)) ? array() : $config;
|
44 |
+
$this->loaded[] = $filePath;
|
45 |
+
$this->config = array_merge($this->config, $config);
|
46 |
+
}
|
|
|
|
|
47 |
}
|
48 |
return $this;
|
49 |
}
|
controllers/controller/admin.php
CHANGED
@@ -33,7 +33,11 @@ abstract class PMWI_Controller_Admin extends PMWI_Controller {
|
|
33 |
parent::__construct();
|
34 |
|
35 |
// add special filter for url fields
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
|
38 |
// enqueue required sripts and styles
|
39 |
global $wp_styles;
|
33 |
parent::__construct();
|
34 |
|
35 |
// add special filter for url fields
|
36 |
+
if (version_compare(phpversion(), '7.2' , "<")){
|
37 |
+
$filter = create_function('$str', 'return "http://" == $str || "ftp://" == $str ? "" : $str;');
|
38 |
+
// add special filter for url fields
|
39 |
+
$this->input->addFilter($filter);
|
40 |
+
}
|
41 |
|
42 |
// enqueue required sripts and styles
|
43 |
global $wp_styles;
|
filters/wp_all_import_set_post_terms.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @param $assign_taxes
|
5 |
+
* @param $tx_name
|
6 |
+
* @param $pid
|
7 |
+
* @param $import_id
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
function pmwi_wp_all_import_set_post_terms($assign_taxes, $tx_name, $pid, $import_id){
|
11 |
+
if (empty($assign_taxes) && $tx_name == 'product_cat'){
|
12 |
+
$term = is_exists_term('uncategorized', $tx_name, 0);
|
13 |
+
if ( !empty($term) and ! is_wp_error($term) ) {
|
14 |
+
$assign_taxes[] = $term['term_taxonomy_id'];
|
15 |
+
}
|
16 |
+
}
|
17 |
+
return $assign_taxes;
|
18 |
+
}
|
models/import/record.php
CHANGED
@@ -612,7 +612,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
612 |
}
|
613 |
|
614 |
return $this->data;
|
615 |
-
}
|
616 |
|
617 |
public function filtering($var){
|
618 |
return ("" == $var) ? false : true;
|
@@ -627,14 +627,21 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
627 |
|
628 |
public function import( $importData = array() ){
|
629 |
|
|
|
|
|
|
|
|
|
630 |
$this->import = $importData['import'];
|
631 |
-
$this->
|
|
|
|
|
632 |
|
633 |
-
|
|
|
634 |
|
635 |
-
|
636 |
|
637 |
-
$cxpath = $xpath_prefix . $import->xpath;
|
638 |
|
639 |
global $woocommerce;
|
640 |
|
@@ -642,11 +649,11 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
642 |
|
643 |
$is_new_product = empty($articleData['ID']);
|
644 |
|
645 |
-
$product_type = 'simple';
|
646 |
|
647 |
$product = WC()->product_factory->get_product($pid);
|
648 |
|
649 |
-
if ($import->options['update_all_data'] == 'no' and ! $import->options['is_update_product_type'] and ! $is_new_product ){
|
650 |
if ( ! empty($product->product_type) ) $product_type = $product->product_type;
|
651 |
}
|
652 |
|
@@ -661,7 +668,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
661 |
$is_featured = $product_featured[$i];
|
662 |
|
663 |
// Product type + Downloadable/Virtual
|
664 |
-
if ($is_new_product or $import->options['update_all_data'] == 'yes' or ($import->options['update_all_data'] == 'no' and $import->options['is_update_product_type'])) {
|
665 |
$product_type_term = is_exists_term($product_type, 'product_type', 0);
|
666 |
if ( ! empty($product_type_term) and ! is_wp_error($product_type_term) ){
|
667 |
$this->associate_terms( $pid, array( (int) $product_type_term['term_taxonomy_id'] ), 'product_type' );
|
@@ -678,6 +685,12 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
678 |
|
679 |
// Update post meta
|
680 |
$this->pushmeta($pid, '_regular_price', ($product_regular_price[$i] == "") ? '' : stripslashes( $product_regular_price[$i] ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
681 |
$this->pushmeta($pid, '_sale_price', ($product_sale_price[$i] == "") ? '' : stripslashes( $product_sale_price[$i] ) );
|
682 |
$this->pushmeta($pid, '_tax_status', stripslashes( $product_tax_status[$i] ) );
|
683 |
$this->pushmeta($pid, '_tax_class', strtolower($product_tax_class[$i]) == 'standard' ? '' : stripslashes( $product_tax_class[$i] ) );
|
@@ -688,24 +701,25 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
688 |
}
|
689 |
|
690 |
// Dimensions
|
691 |
-
if ( $is_virtual == '
|
692 |
-
$this->pushmeta($pid, '_weight', stripslashes( $product_weight[$i] ) );
|
693 |
-
$this->pushmeta($pid, '_length', stripslashes( $product_length[$i] ) );
|
694 |
-
$this->pushmeta($pid, '_width', stripslashes( $product_width[$i] ) );
|
695 |
-
$this->pushmeta($pid, '_height', stripslashes( $product_height[$i] ) );
|
696 |
-
} else {
|
697 |
$this->pushmeta($pid, '_weight', '' );
|
698 |
$this->pushmeta($pid, '_length', '' );
|
699 |
$this->pushmeta($pid, '_width', '' );
|
700 |
$this->pushmeta($pid, '_height', '' );
|
701 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
702 |
|
703 |
if ($is_new_product or $this->is_update_data_allowed('is_update_comment_status')) $this->wpdb->update( $this->wpdb->posts, array('comment_status' => ( in_array($product_enable_reviews[$i], array('yes', 'open')) ) ? 'open' : 'closed' ), array('ID' => $pid));
|
704 |
|
705 |
if ($is_new_product or $this->is_update_data_allowed('is_update_menu_order')) $this->wpdb->update( $this->wpdb->posts, array('menu_order' => ($product_menu_order[$i] != '') ? (int) $product_menu_order[$i] : 0 ), array('ID' => $pid));
|
706 |
|
707 |
// Save shipping class
|
708 |
-
if ( pmwi_is_update_taxonomy($articleData, $import->options, 'product_shipping_class') )
|
709 |
{
|
710 |
|
711 |
$p_shipping_class = ($product_type != 'external') ? $product_shipping_class[$i] : '';
|
@@ -791,10 +805,10 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
791 |
|
792 |
// Unique SKU
|
793 |
$sku = ($is_new_product) ? '' : get_post_meta($pid, '_sku', true);
|
794 |
-
|
795 |
|
796 |
-
if ( ( in_array($product_type, array('variation', 'variable')) or $product_types[$i] == "variable" ) and ! $import->options['link_all_variations'] ){
|
797 |
-
switch ($import->options['matching_parent']){
|
798 |
case 'first_is_parent_id':
|
799 |
if (!empty($single_product_first_is_parent_id_parent_sku[$i])){
|
800 |
update_post_meta($pid, '_parent_sku', $single_product_first_is_parent_id_parent_sku[$i]);
|
@@ -808,19 +822,19 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
808 |
}
|
809 |
}
|
810 |
|
811 |
-
if ( $new_sku == '' and $import->options['disable_auto_sku_generation'] ) {
|
812 |
$this->pushmeta($pid, '_sku', '' );
|
813 |
}
|
814 |
-
elseif ( $new_sku == '' and ! $import->options['disable_auto_sku_generation'] ) {
|
815 |
if ($is_new_product or $this->is_update_cf('_sku')){
|
816 |
-
$unique_keys = XmlImportParser::factory($xml, $cxpath, $import->options['unique_key'], $file)->parse(); $tmp_files[] = $file;
|
817 |
foreach ($tmp_files as $file) { // remove all temporary files created
|
818 |
@unlink($file);
|
819 |
}
|
820 |
$new_sku = substr(md5($unique_keys[$i]), 0, 12);
|
821 |
|
822 |
-
if ( ( in_array($product_type, array('variation', 'variable')) or $product_types[$i] == "variable" ) and ! $import->options['link_all_variations'] ){
|
823 |
-
switch ($import->options['matching_parent']){
|
824 |
case 'first_is_parent_id':
|
825 |
if (empty($single_product_first_is_parent_id_parent_sku[$i])){
|
826 |
update_post_meta($pid, '_parent_sku', strrev($new_sku));
|
@@ -837,7 +851,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
837 |
}
|
838 |
if ( $new_sku != '' and $new_sku !== $sku ) {
|
839 |
if ( ! empty( $new_sku ) ) {
|
840 |
-
if ( ! $import->options['disable_sku_matching'] and
|
841 |
$this->wpdb->get_var( $this->wpdb->prepare("
|
842 |
SELECT ".$this->wpdb->posts.".ID
|
843 |
FROM ".$this->wpdb->posts."
|
@@ -865,9 +879,9 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
865 |
|
866 |
$is_variation_attributes_defined = false;
|
867 |
|
868 |
-
|
869 |
|
870 |
-
if ( $import->options['update_all_data'] == "yes" or ( $import->options['update_all_data'] == "no" and $import->options['is_update_attributes']) or $is_new_product){ // Update Product Attributes
|
871 |
|
872 |
$is_update_attributes = true;
|
873 |
|
@@ -890,9 +904,9 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
890 |
}
|
891 |
|
892 |
// Update only these Attributes, leave the rest alone
|
893 |
-
if ( ! $is_new_product and $import->options['update_all_data'] == "no" and $import->options['is_update_attributes'] and $import->options['update_attributes_logic'] == 'only'){
|
894 |
-
if ( ! empty($import->options['attributes_list']) and is_array($import->options['attributes_list'])) {
|
895 |
-
if ( ! in_array( ( ($is_taxonomy) ? wc_attribute_taxonomy_name( $attr_name ) : $attr_name ) , array_filter($import->options['attributes_list'], 'trim'))){
|
896 |
$attribute_position++;
|
897 |
continue;
|
898 |
}
|
@@ -904,9 +918,9 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
904 |
}
|
905 |
|
906 |
// Leave these attributes alone, update all other Attributes
|
907 |
-
if ( ! $is_new_product and $import->options['update_all_data'] == "no" and $import->options['is_update_attributes'] and $import->options['update_attributes_logic'] == 'all_except'){
|
908 |
-
if ( ! empty($import->options['attributes_list']) and is_array($import->options['attributes_list'])) {
|
909 |
-
if ( in_array( ( ($is_taxonomy) ? wc_attribute_taxonomy_name( $attr_name ) : $attr_name ) , array_filter($import->options['attributes_list'], 'trim'))){
|
910 |
$attribute_position++;
|
911 |
continue;
|
912 |
}
|
@@ -917,7 +931,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
917 |
|
918 |
if ( isset( $attr_data['value'][$i] ) ) {
|
919 |
|
920 |
-
$values = array_map( 'stripslashes',
|
921 |
|
922 |
// Remove empty items in the array
|
923 |
$values = array_filter( $values, array($this, "filtering") );
|
@@ -1065,6 +1079,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1065 |
}
|
1066 |
else{
|
1067 |
|
|
|
1068 |
if ( ! empty($this->articleData['ID']) and ! $this->is_update_cf('_regular_price') )
|
1069 |
{
|
1070 |
$product_regular_price[$i] = get_post_meta($pid, '_regular_price', true);
|
@@ -1078,16 +1093,14 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1078 |
}
|
1079 |
|
1080 |
if ( $date_to && strtotime( $date_to ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
|
1081 |
-
$this->pushmeta($pid, '_price', ($product_regular_price[$i] == "") ? '' : stripslashes( $product_regular_price[$i] ));
|
1082 |
-
// $this->pushmeta($pid, '_sale_price_dates_from', '');
|
1083 |
-
// $this->pushmeta($pid, '_sale_price_dates_to', '');
|
1084 |
}
|
1085 |
}
|
1086 |
|
1087 |
-
if (in_array( $product_type, array( 'simple', 'external' ) )) {
|
1088 |
|
1089 |
-
if ($import->options['is_multiple_grouping_product'] != 'yes'){
|
1090 |
-
if ($import->options['grouping_indicator'] == 'xpath' and !
|
1091 |
$dpost = pmxi_findDuplicates(array(
|
1092 |
'post_type' => 'product',
|
1093 |
'ID' => $pid,
|
@@ -1099,7 +1112,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1099 |
else
|
1100 |
$product_grouping_parent[$i] = 0;
|
1101 |
}
|
1102 |
-
elseif ($import->options['grouping_indicator'] != 'xpath'){
|
1103 |
$dpost = pmxi_findDuplicates($articleData, $custom_grouping_indicator_name[$i], $custom_grouping_indicator_value[$i], 'custom field');
|
1104 |
if (!empty($dpost))
|
1105 |
$product_grouping_parent[$i] = array_shift($dpost);
|
@@ -1116,6 +1129,10 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1116 |
|
1117 |
if (empty($all_grouped_products)) $all_grouped_products = array();
|
1118 |
|
|
|
|
|
|
|
|
|
1119 |
if ( ! in_array($pid, $all_grouped_products) ){
|
1120 |
$all_grouped_products[] = $pid;
|
1121 |
update_post_meta($product_grouping_parent[$i], '_children', $all_grouped_products);
|
@@ -1167,49 +1184,13 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1167 |
}
|
1168 |
|
1169 |
// Stock Data
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
$stock_status = 'instock';
|
1179 |
-
|
1180 |
-
} elseif ( 'variable' === $product_type and ! $import->options['link_all_variations'] ) {
|
1181 |
-
|
1182 |
-
// Stock status is always determined by children so sync later
|
1183 |
-
// $stock_status = '';
|
1184 |
-
|
1185 |
-
if ( $product_manage_stock[$i] == 'yes' ) {
|
1186 |
-
$manage_stock = 'yes';
|
1187 |
-
$backorders = wc_clean( $product_allow_backorders[$i] );
|
1188 |
-
}
|
1189 |
-
|
1190 |
-
} elseif ( 'grouped' !== $product_type && $product_manage_stock[$i] == 'yes' ) {
|
1191 |
-
$manage_stock = 'yes';
|
1192 |
-
$backorders = wc_clean( $product_allow_backorders[$i] );
|
1193 |
-
}
|
1194 |
-
|
1195 |
-
$this->pushmeta($pid, '_manage_stock', $manage_stock);
|
1196 |
-
$this->pushmeta($pid, '_backorders', $backorders);
|
1197 |
-
|
1198 |
-
if ( $this->is_update_cf('_stock') && $stock_status ) {
|
1199 |
-
update_post_meta( $pid, '_stock_status', $stock_status );
|
1200 |
-
}
|
1201 |
-
|
1202 |
-
$current_manage_stock = get_post_meta( $pid, '_manage_stock', true );
|
1203 |
-
|
1204 |
-
if ( $product_manage_stock[$i] == 'yes' || ! $this->is_update_cf('_manage_stock') && $current_manage_stock == 'yes') {
|
1205 |
-
$this->pushmeta( $pid, '_stock', wc_stock_amount( $product_stock_qty[$i] ) );
|
1206 |
-
} else {
|
1207 |
-
$this->pushmeta($pid, '_stock', '');
|
1208 |
-
}
|
1209 |
-
|
1210 |
-
} else {
|
1211 |
-
update_post_meta( $pid, '_stock_status', wc_clean( $product_stock_status[$i] ) );
|
1212 |
-
}
|
1213 |
|
1214 |
// Upsells
|
1215 |
$this->import_linked_products($pid, $product_up_sells[$i], '_upsell_ids', $is_new_product);
|
@@ -1232,8 +1213,8 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1232 |
if ( !empty( $product_files[$i] ) ) {
|
1233 |
$_file_paths = array();
|
1234 |
|
1235 |
-
$file_paths = explode( $import->options['product_files_delim'] , $product_files[$i] );
|
1236 |
-
$file_names = explode( $import->options['product_files_names_delim'] , $product_files_names[$i] );
|
1237 |
|
1238 |
foreach ( $file_paths as $fn => $file_path ) {
|
1239 |
$file_path = trim( $file_path );
|
@@ -1253,17 +1234,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1253 |
$this->pushmeta($pid, '_download_type', esc_attr( $product_download_type[$i] ));
|
1254 |
|
1255 |
}
|
1256 |
-
|
1257 |
-
// Product url
|
1258 |
-
if ( $product_type == 'external' ) {
|
1259 |
-
if ( isset( $product_url[$i] ) && $product_url[$i] ){
|
1260 |
-
$this->auto_cloak_links($import, $product_url[$i]);
|
1261 |
-
$this->pushmeta($pid, '_product_url', esc_url_raw( $product_url[$i] ));
|
1262 |
-
}
|
1263 |
-
if ( isset( $product_button_text[$i] ) && $product_button_text[$i] ){
|
1264 |
-
$this->pushmeta($pid, '_button_text', esc_attr( $product_button_text[$i] ));
|
1265 |
-
}
|
1266 |
-
}
|
1267 |
// Update product visibility term WC 3.0.0
|
1268 |
if ( version_compare(WOOCOMMERCE_VERSION, '3.0') >= 0 ) {
|
1269 |
|
@@ -1274,7 +1245,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1274 |
// If Not Update Featured Status checking for current featured status
|
1275 |
if ( ! empty($articleData['ID']) && ( ! $this->is_update_data_allowed('is_update_advanced_options') || ! $this->is_update_data_allowed('is_update_featured_status'))) {
|
1276 |
$featured_term = get_term_by( 'name', 'featured', 'product_visibility' );
|
1277 |
-
if ( ! empty($featured_term) && ! is_wp_error($featured_term) && in_array($featured_term->
|
1278 |
$associate_terms[] = $featured_term->term_taxonomy_id;
|
1279 |
}
|
1280 |
}
|
@@ -1290,23 +1261,23 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1290 |
// If Not Update Product Visibility checking for current product visibility
|
1291 |
if ( ! empty($articleData['ID']) && ( ! $this->is_update_data_allowed('is_update_advanced_options') || ! $this->is_update_data_allowed('is_update_catalog_visibility'))) {
|
1292 |
$exclude_search_term = get_term_by( 'name', 'exclude-from-search', 'product_visibility' );
|
1293 |
-
if (!empty($exclude_search_term) && !is_wp_error($exclude_search_term) && in_array($exclude_search_term->
|
1294 |
$associate_terms[] = $exclude_search_term->term_taxonomy_id;
|
1295 |
}
|
1296 |
$exclude_catalog_term = get_term_by( 'name', 'exclude-from-catalog', 'product_visibility' );
|
1297 |
-
if (!empty($exclude_catalog_term) && !is_wp_error($exclude_catalog_term) && in_array($exclude_catalog_term->
|
1298 |
$associate_terms[] = $exclude_catalog_term->term_taxonomy_id;
|
1299 |
}
|
1300 |
}
|
1301 |
else{
|
1302 |
-
if (in_array($product_visibility[$i], array('hidden', '
|
1303 |
-
$exclude_search_term = get_term_by( 'name', 'exclude-from-
|
1304 |
if (!empty($exclude_search_term) && !is_wp_error($exclude_search_term)){
|
1305 |
$associate_terms[] = $exclude_search_term->term_taxonomy_id;
|
1306 |
}
|
1307 |
}
|
1308 |
-
if (in_array($product_visibility[$i], array('hidden', '
|
1309 |
-
$exclude_catalog_term = get_term_by( 'name', 'exclude-from-
|
1310 |
if (!empty($exclude_catalog_term) && !is_wp_error($exclude_catalog_term)){
|
1311 |
$associate_terms[] = $exclude_catalog_term->term_taxonomy_id;
|
1312 |
}
|
@@ -1404,11 +1375,64 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1404 |
// [\update product gallery]
|
1405 |
|
1406 |
wc_delete_product_transients($importData['pid']);
|
1407 |
-
}
|
1408 |
-
|
1409 |
-
|
1410 |
}
|
1411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1412 |
protected function executeSQL(){
|
1413 |
// prepare bulk SQL query
|
1414 |
$table = _get_meta_table('post');
|
@@ -1459,9 +1483,9 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1459 |
|
1460 |
}
|
1461 |
|
1462 |
-
protected function associate_terms($pid, $assign_taxes, $tx_name, $logger = false){
|
1463 |
|
1464 |
-
|
1465 |
$term_ids = array();
|
1466 |
|
1467 |
$assign_taxes = (is_array($assign_taxes)) ? array_filter($assign_taxes) : false;
|
@@ -1501,36 +1525,36 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1501 |
}
|
1502 |
|
1503 |
wp_cache_delete( $pid, $tx_name . '_relationships' );
|
1504 |
-
|
1505 |
-
}
|
1506 |
|
1507 |
-
|
1508 |
|
1509 |
-
|
|
|
|
|
1510 |
|
1511 |
$attr_name_real = $prefix > 1 ? $attr_name . " " . $prefix : $attr_name;
|
1512 |
|
1513 |
-
|
1514 |
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
|
1521 |
-
|
1522 |
$prefix++;
|
1523 |
return $this->create_taxonomy($attr_name, $logger, $prefix);
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
|
1532 |
-
|
1533 |
-
|
1534 |
array(
|
1535 |
'attribute_label' => $attribute_label,
|
1536 |
'attribute_name' => $attribute_name,
|
@@ -1538,32 +1562,31 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1538 |
'attribute_orderby' => $attribute_orderby,
|
1539 |
'attribute_public' => 1
|
1540 |
)
|
1541 |
-
|
1542 |
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
apply_filters( 'woocommerce_attribute_taxonomies', $attribute_taxonomies );
|
1557 |
|
1558 |
-
|
1559 |
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
if ( in_array( wc_sanitize_taxonomy_name( stripslashes( (string) $attr_name_real)), $this->reserved_terms ) ) {
|
1568 |
$prefix++;
|
1569 |
return $this->create_taxonomy($attr_name, $logger, $prefix);
|
@@ -1572,7 +1595,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
|
|
1572 |
}
|
1573 |
|
1574 |
return $attr_name_real;
|
1575 |
-
|
1576 |
|
1577 |
public function _filter_has_cap_unfiltered_html($caps)
|
1578 |
{
|
612 |
}
|
613 |
|
614 |
return $this->data;
|
615 |
+
}
|
616 |
|
617 |
public function filtering($var){
|
618 |
return ("" == $var) ? false : true;
|
627 |
|
628 |
public function import( $importData = array() ){
|
629 |
|
630 |
+
global $wpdb;
|
631 |
+
|
632 |
+
$this->wpdb = $wpdb;
|
633 |
+
|
634 |
$this->import = $importData['import'];
|
635 |
+
$this->xml = $importData['xml'];
|
636 |
+
$this->logger = $importData['logger'];
|
637 |
+
$this->xpath = $importData['xpath_prefix'];
|
638 |
|
639 |
+
$product_taxonomies = array('post_format', 'product_type', 'product_shipping_class');
|
640 |
+
$this->product_taxonomies = array_diff_key(get_taxonomies_by_object_type(array('product'), 'object'), array_flip($product_taxonomies));
|
641 |
|
642 |
+
extract($importData);
|
643 |
|
644 |
+
$cxpath = $xpath_prefix . $this->import->xpath;
|
645 |
|
646 |
global $woocommerce;
|
647 |
|
649 |
|
650 |
$is_new_product = empty($articleData['ID']);
|
651 |
|
652 |
+
$product_type = empty( $product_types[$i] ) ? 'simple' : sanitize_title( stripslashes( $product_types[$i] ) );
|
653 |
|
654 |
$product = WC()->product_factory->get_product($pid);
|
655 |
|
656 |
+
if ($this->import->options['update_all_data'] == 'no' and ! $this->import->options['is_update_product_type'] and ! $is_new_product ){
|
657 |
if ( ! empty($product->product_type) ) $product_type = $product->product_type;
|
658 |
}
|
659 |
|
668 |
$is_featured = $product_featured[$i];
|
669 |
|
670 |
// Product type + Downloadable/Virtual
|
671 |
+
if ($is_new_product or $this->import->options['update_all_data'] == 'yes' or ($this->import->options['update_all_data'] == 'no' and $this->import->options['is_update_product_type'])) {
|
672 |
$product_type_term = is_exists_term($product_type, 'product_type', 0);
|
673 |
if ( ! empty($product_type_term) and ! is_wp_error($product_type_term) ){
|
674 |
$this->associate_terms( $pid, array( (int) $product_type_term['term_taxonomy_id'] ), 'product_type' );
|
685 |
|
686 |
// Update post meta
|
687 |
$this->pushmeta($pid, '_regular_price', ($product_regular_price[$i] == "") ? '' : stripslashes( $product_regular_price[$i] ) );
|
688 |
+
if ( $product_sale_price[$i] != '' ){
|
689 |
+
$_regular_price = get_post_meta($pid, '_regular_price', true);
|
690 |
+
if ($product_sale_price[$i] > $_regular_price){
|
691 |
+
$product_sale_price[$i] = '';
|
692 |
+
}
|
693 |
+
}
|
694 |
$this->pushmeta($pid, '_sale_price', ($product_sale_price[$i] == "") ? '' : stripslashes( $product_sale_price[$i] ) );
|
695 |
$this->pushmeta($pid, '_tax_status', stripslashes( $product_tax_status[$i] ) );
|
696 |
$this->pushmeta($pid, '_tax_class', strtolower($product_tax_class[$i]) == 'standard' ? '' : stripslashes( $product_tax_class[$i] ) );
|
701 |
}
|
702 |
|
703 |
// Dimensions
|
704 |
+
if ( $is_virtual == 'yes' ) {
|
|
|
|
|
|
|
|
|
|
|
705 |
$this->pushmeta($pid, '_weight', '' );
|
706 |
$this->pushmeta($pid, '_length', '' );
|
707 |
$this->pushmeta($pid, '_width', '' );
|
708 |
$this->pushmeta($pid, '_height', '' );
|
709 |
}
|
710 |
+
else{
|
711 |
+
$this->pushmeta($pid, '_weight', stripslashes( $product_weight[$i] ) );
|
712 |
+
$this->pushmeta($pid, '_length', stripslashes( $product_length[$i] ) );
|
713 |
+
$this->pushmeta($pid, '_width', stripslashes( $product_width[$i] ) );
|
714 |
+
$this->pushmeta($pid, '_height', stripslashes( $product_height[$i] ) );
|
715 |
+
}
|
716 |
|
717 |
if ($is_new_product or $this->is_update_data_allowed('is_update_comment_status')) $this->wpdb->update( $this->wpdb->posts, array('comment_status' => ( in_array($product_enable_reviews[$i], array('yes', 'open')) ) ? 'open' : 'closed' ), array('ID' => $pid));
|
718 |
|
719 |
if ($is_new_product or $this->is_update_data_allowed('is_update_menu_order')) $this->wpdb->update( $this->wpdb->posts, array('menu_order' => ($product_menu_order[$i] != '') ? (int) $product_menu_order[$i] : 0 ), array('ID' => $pid));
|
720 |
|
721 |
// Save shipping class
|
722 |
+
if ( pmwi_is_update_taxonomy($articleData, $this->import->options, 'product_shipping_class') )
|
723 |
{
|
724 |
|
725 |
$p_shipping_class = ($product_type != 'external') ? $product_shipping_class[$i] : '';
|
805 |
|
806 |
// Unique SKU
|
807 |
$sku = ($is_new_product) ? '' : get_post_meta($pid, '_sku', true);
|
808 |
+
$new_sku = wc_clean(addslashes($product_sku[$i]));
|
809 |
|
810 |
+
if ( ( in_array($product_type, array('variation', 'variable')) or $product_types[$i] == "variable" ) and ! $this->import->options['link_all_variations'] ){
|
811 |
+
switch ($this->import->options['matching_parent']){
|
812 |
case 'first_is_parent_id':
|
813 |
if (!empty($single_product_first_is_parent_id_parent_sku[$i])){
|
814 |
update_post_meta($pid, '_parent_sku', $single_product_first_is_parent_id_parent_sku[$i]);
|
822 |
}
|
823 |
}
|
824 |
|
825 |
+
if ( $new_sku == '' and $this->import->options['disable_auto_sku_generation'] ) {
|
826 |
$this->pushmeta($pid, '_sku', '' );
|
827 |
}
|
828 |
+
elseif ( $new_sku == '' and ! $this->import->options['disable_auto_sku_generation'] ) {
|
829 |
if ($is_new_product or $this->is_update_cf('_sku')){
|
830 |
+
$unique_keys = XmlImportParser::factory($xml, $cxpath, $this->import->options['unique_key'], $file)->parse(); $tmp_files[] = $file;
|
831 |
foreach ($tmp_files as $file) { // remove all temporary files created
|
832 |
@unlink($file);
|
833 |
}
|
834 |
$new_sku = substr(md5($unique_keys[$i]), 0, 12);
|
835 |
|
836 |
+
if ( ( in_array($product_type, array('variation', 'variable')) or $product_types[$i] == "variable" ) and ! $this->import->options['link_all_variations'] ){
|
837 |
+
switch ($this->import->options['matching_parent']){
|
838 |
case 'first_is_parent_id':
|
839 |
if (empty($single_product_first_is_parent_id_parent_sku[$i])){
|
840 |
update_post_meta($pid, '_parent_sku', strrev($new_sku));
|
851 |
}
|
852 |
if ( $new_sku != '' and $new_sku !== $sku ) {
|
853 |
if ( ! empty( $new_sku ) ) {
|
854 |
+
if ( ! $this->import->options['disable_sku_matching'] and
|
855 |
$this->wpdb->get_var( $this->wpdb->prepare("
|
856 |
SELECT ".$this->wpdb->posts.".ID
|
857 |
FROM ".$this->wpdb->posts."
|
879 |
|
880 |
$is_variation_attributes_defined = false;
|
881 |
|
882 |
+
$max_attribute_length = apply_filters('wp_all_import_max_woo_attribute_term_length', 199);
|
883 |
|
884 |
+
if ( $this->import->options['update_all_data'] == "yes" or ( $this->import->options['update_all_data'] == "no" and $this->import->options['is_update_attributes']) or $is_new_product){ // Update Product Attributes
|
885 |
|
886 |
$is_update_attributes = true;
|
887 |
|
904 |
}
|
905 |
|
906 |
// Update only these Attributes, leave the rest alone
|
907 |
+
if ( ! $is_new_product and $this->import->options['update_all_data'] == "no" and $this->import->options['is_update_attributes'] and $this->import->options['update_attributes_logic'] == 'only'){
|
908 |
+
if ( ! empty($this->import->options['attributes_list']) and is_array($this->import->options['attributes_list'])) {
|
909 |
+
if ( ! in_array( ( ($is_taxonomy) ? wc_attribute_taxonomy_name( $attr_name ) : $attr_name ) , array_filter($this->import->options['attributes_list'], 'trim'))){
|
910 |
$attribute_position++;
|
911 |
continue;
|
912 |
}
|
918 |
}
|
919 |
|
920 |
// Leave these attributes alone, update all other Attributes
|
921 |
+
if ( ! $is_new_product and $this->import->options['update_all_data'] == "no" and $this->import->options['is_update_attributes'] and $this->import->options['update_attributes_logic'] == 'all_except'){
|
922 |
+
if ( ! empty($this->import->options['attributes_list']) and is_array($this->import->options['attributes_list'])) {
|
923 |
+
if ( in_array( ( ($is_taxonomy) ? wc_attribute_taxonomy_name( $attr_name ) : $attr_name ) , array_filter($this->import->options['attributes_list'], 'trim'))){
|
924 |
$attribute_position++;
|
925 |
continue;
|
926 |
}
|
931 |
|
932 |
if ( isset( $attr_data['value'][$i] ) ) {
|
933 |
|
934 |
+
$values = array_map( 'stripslashes', explode( '|', $attr_data['value'][$i] ) );
|
935 |
|
936 |
// Remove empty items in the array
|
937 |
$values = array_filter( $values, array($this, "filtering") );
|
1079 |
}
|
1080 |
else{
|
1081 |
|
1082 |
+
// Update price if on sale
|
1083 |
if ( ! empty($this->articleData['ID']) and ! $this->is_update_cf('_regular_price') )
|
1084 |
{
|
1085 |
$product_regular_price[$i] = get_post_meta($pid, '_regular_price', true);
|
1093 |
}
|
1094 |
|
1095 |
if ( $date_to && strtotime( $date_to ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
|
1096 |
+
$this->pushmeta($pid, '_price', ($product_regular_price[$i] == "") ? '' : stripslashes( $product_regular_price[$i] ));
|
|
|
|
|
1097 |
}
|
1098 |
}
|
1099 |
|
1100 |
+
if (in_array( $product_type, array( 'simple', 'external', 'variable' ) )) {
|
1101 |
|
1102 |
+
if ($this->import->options['is_multiple_grouping_product'] != 'yes'){
|
1103 |
+
if ($this->import->options['grouping_indicator'] == 'xpath' and ! preg_match("%^[0-9]*$%", $product_grouping_parent[$i])){
|
1104 |
$dpost = pmxi_findDuplicates(array(
|
1105 |
'post_type' => 'product',
|
1106 |
'ID' => $pid,
|
1112 |
else
|
1113 |
$product_grouping_parent[$i] = 0;
|
1114 |
}
|
1115 |
+
elseif ($this->import->options['grouping_indicator'] != 'xpath'){
|
1116 |
$dpost = pmxi_findDuplicates($articleData, $custom_grouping_indicator_name[$i], $custom_grouping_indicator_value[$i], 'custom field');
|
1117 |
if (!empty($dpost))
|
1118 |
$product_grouping_parent[$i] = array_shift($dpost);
|
1129 |
|
1130 |
if (empty($all_grouped_products)) $all_grouped_products = array();
|
1131 |
|
1132 |
+
if (!empty($all_grouped_products) & !is_array($all_grouped_products)){
|
1133 |
+
$all_grouped_products = array($all_grouped_products);
|
1134 |
+
}
|
1135 |
+
|
1136 |
if ( ! in_array($pid, $all_grouped_products) ){
|
1137 |
$all_grouped_products[] = $pid;
|
1138 |
update_post_meta($product_grouping_parent[$i], '_children', $all_grouped_products);
|
1184 |
}
|
1185 |
|
1186 |
// Stock Data
|
1187 |
+
$stock_data_args = array(
|
1188 |
+
'stock_status' => $product_stock_status[$i],
|
1189 |
+
'manage_stock' => $product_manage_stock[$i],
|
1190 |
+
'allow_backorders' => $product_allow_backorders[$i],
|
1191 |
+
'qty' => $product_stock_qty[$i]
|
1192 |
+
);
|
1193 |
+
$this->import_stock_data($pid, $product_type, $stock_data_args );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1194 |
|
1195 |
// Upsells
|
1196 |
$this->import_linked_products($pid, $product_up_sells[$i], '_upsell_ids', $is_new_product);
|
1213 |
if ( !empty( $product_files[$i] ) ) {
|
1214 |
$_file_paths = array();
|
1215 |
|
1216 |
+
$file_paths = explode( $this->import->options['product_files_delim'] , $product_files[$i] );
|
1217 |
+
$file_names = explode( $this->import->options['product_files_names_delim'] , $product_files_names[$i] );
|
1218 |
|
1219 |
foreach ( $file_paths as $fn => $file_path ) {
|
1220 |
$file_path = trim( $file_path );
|
1234 |
$this->pushmeta($pid, '_download_type', esc_attr( $product_download_type[$i] ));
|
1235 |
|
1236 |
}
|
1237 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1238 |
// Update product visibility term WC 3.0.0
|
1239 |
if ( version_compare(WOOCOMMERCE_VERSION, '3.0') >= 0 ) {
|
1240 |
|
1245 |
// If Not Update Featured Status checking for current featured status
|
1246 |
if ( ! empty($articleData['ID']) && ( ! $this->is_update_data_allowed('is_update_advanced_options') || ! $this->is_update_data_allowed('is_update_featured_status'))) {
|
1247 |
$featured_term = get_term_by( 'name', 'featured', 'product_visibility' );
|
1248 |
+
if ( ! empty($featured_term) && ! is_wp_error($featured_term) && in_array($featured_term->term_id, $term_ids) ){
|
1249 |
$associate_terms[] = $featured_term->term_taxonomy_id;
|
1250 |
}
|
1251 |
}
|
1261 |
// If Not Update Product Visibility checking for current product visibility
|
1262 |
if ( ! empty($articleData['ID']) && ( ! $this->is_update_data_allowed('is_update_advanced_options') || ! $this->is_update_data_allowed('is_update_catalog_visibility'))) {
|
1263 |
$exclude_search_term = get_term_by( 'name', 'exclude-from-search', 'product_visibility' );
|
1264 |
+
if (!empty($exclude_search_term) && !is_wp_error($exclude_search_term) && in_array($exclude_search_term->term_id, $term_ids)){
|
1265 |
$associate_terms[] = $exclude_search_term->term_taxonomy_id;
|
1266 |
}
|
1267 |
$exclude_catalog_term = get_term_by( 'name', 'exclude-from-catalog', 'product_visibility' );
|
1268 |
+
if (!empty($exclude_catalog_term) && !is_wp_error($exclude_catalog_term) && in_array($exclude_catalog_term->term_id, $term_ids)){
|
1269 |
$associate_terms[] = $exclude_catalog_term->term_taxonomy_id;
|
1270 |
}
|
1271 |
}
|
1272 |
else{
|
1273 |
+
if (in_array($product_visibility[$i], array('hidden', 'search'))){
|
1274 |
+
$exclude_search_term = get_term_by( 'name', 'exclude-from-catalog', 'product_visibility' );
|
1275 |
if (!empty($exclude_search_term) && !is_wp_error($exclude_search_term)){
|
1276 |
$associate_terms[] = $exclude_search_term->term_taxonomy_id;
|
1277 |
}
|
1278 |
}
|
1279 |
+
if (in_array($product_visibility[$i], array('hidden', 'catalog'))){
|
1280 |
+
$exclude_catalog_term = get_term_by( 'name', 'exclude-from-search', 'product_visibility' );
|
1281 |
if (!empty($exclude_catalog_term) && !is_wp_error($exclude_catalog_term)){
|
1282 |
$associate_terms[] = $exclude_catalog_term->term_taxonomy_id;
|
1283 |
}
|
1375 |
// [\update product gallery]
|
1376 |
|
1377 |
wc_delete_product_transients($importData['pid']);
|
1378 |
+
}
|
|
|
|
|
1379 |
}
|
1380 |
|
1381 |
+
function import_stock_data($pid, $product_type, $stock_data_args){
|
1382 |
+
|
1383 |
+
if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
|
1384 |
+
$manage_stock = 'no';
|
1385 |
+
$backorders = 'no';
|
1386 |
+
$stock_status = wc_clean( $stock_data_args['stock_status'] );
|
1387 |
+
|
1388 |
+
if ( 'external' === $product_type ) {
|
1389 |
+
|
1390 |
+
$stock_status = 'instock';
|
1391 |
+
|
1392 |
+
} elseif ( 'variable' === $product_type and ! $this->import->options['link_all_variations'] ) {
|
1393 |
+
|
1394 |
+
// Stock status is always determined by children so sync later
|
1395 |
+
if ( $stock_data_args['manage_stock'] == 'yes' ) {
|
1396 |
+
$manage_stock = 'yes';
|
1397 |
+
$backorders = wc_clean( $stock_data_args['allow_backorders'] );
|
1398 |
+
}
|
1399 |
+
|
1400 |
+
} elseif ( 'grouped' !== $product_type && $stock_data_args['manage_stock'] == 'yes' ) {
|
1401 |
+
$manage_stock = 'yes';
|
1402 |
+
$backorders = wc_clean( $stock_data_args['allow_backorders'] );
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
$this->pushmeta($pid, '_manage_stock', $manage_stock);
|
1406 |
+
|
1407 |
+
$current_manage_stock = get_post_meta( $pid, '_manage_stock', true );
|
1408 |
+
|
1409 |
+
if ($current_manage_stock == 'yes' && ! in_array($product_type, array('external', 'grouped')) ){
|
1410 |
+
$backorders = wc_clean( $stock_data_args['allow_backorders'] );
|
1411 |
+
}
|
1412 |
+
|
1413 |
+
$this->pushmeta($pid, '_backorders', $backorders);
|
1414 |
+
|
1415 |
+
// Set Stock Status to instock if backorders are enabled #24
|
1416 |
+
$_backorders = get_post_meta( $pid, '_backorders', true );
|
1417 |
+
if ( in_array($_backorders, array('notify', 'yes')) ) {
|
1418 |
+
$stock_status = 'instock';
|
1419 |
+
}
|
1420 |
+
|
1421 |
+
if ( $this->is_update_cf('_stock') && $stock_status ) {
|
1422 |
+
update_post_meta( $pid, '_stock_status', $stock_status );
|
1423 |
+
}
|
1424 |
+
|
1425 |
+
if ( $stock_data_args['manage_stock'] == 'yes' || ! $this->is_update_cf('_manage_stock') && $current_manage_stock == 'yes') {
|
1426 |
+
$this->pushmeta( $pid, '_stock', wc_stock_amount( $stock_data_args['qty'] ) );
|
1427 |
+
} else {
|
1428 |
+
$this->pushmeta($pid, '_stock', '');
|
1429 |
+
}
|
1430 |
+
|
1431 |
+
} else {
|
1432 |
+
update_post_meta( $pid, '_stock_status', wc_clean( $stock_data_args['stock_status'] ) );
|
1433 |
+
}
|
1434 |
+
}
|
1435 |
+
|
1436 |
protected function executeSQL(){
|
1437 |
// prepare bulk SQL query
|
1438 |
$table = _get_meta_table('post');
|
1483 |
|
1484 |
}
|
1485 |
|
1486 |
+
protected function associate_terms($pid, $assign_taxes, $tx_name, $logger = false){
|
1487 |
|
1488 |
+
$terms = wp_get_object_terms( $pid, $tx_name );
|
1489 |
$term_ids = array();
|
1490 |
|
1491 |
$assign_taxes = (is_array($assign_taxes)) ? array_filter($assign_taxes) : false;
|
1525 |
}
|
1526 |
|
1527 |
wp_cache_delete( $pid, $tx_name . '_relationships' );
|
|
|
|
|
1528 |
|
1529 |
+
}
|
1530 |
|
1531 |
+
function create_taxonomy($attr_name, $logger, $prefix = 1){
|
1532 |
+
|
1533 |
+
global $woocommerce;
|
1534 |
|
1535 |
$attr_name_real = $prefix > 1 ? $attr_name . " " . $prefix : $attr_name;
|
1536 |
|
1537 |
+
if ( ! taxonomy_exists( wc_attribute_taxonomy_name( $attr_name_real ) ) ) {
|
1538 |
|
1539 |
+
// Grab the submitted data
|
1540 |
+
$attribute_name = ( isset( $attr_name ) ) ? wc_sanitize_taxonomy_name( stripslashes( (string) $attr_name_real ) ) : '';
|
1541 |
+
$attribute_label = stripslashes( (string) $attr_name );
|
1542 |
+
$attribute_type = 'select';
|
1543 |
+
$attribute_orderby = 'menu_order';
|
1544 |
|
1545 |
+
if ( in_array( wc_sanitize_taxonomy_name( stripslashes( (string) $attr_name_real)), $this->reserved_terms ) ) {
|
1546 |
$prefix++;
|
1547 |
return $this->create_taxonomy($attr_name, $logger, $prefix);
|
1548 |
+
//$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Slug “%s” is not allowed because it is a reserved term. Change it, please.', 'wpai_woocommerce_addon_plugin'), wc_attribute_taxonomy_name( $attribute_name )));
|
1549 |
+
}
|
1550 |
+
else{
|
1551 |
|
1552 |
+
// Register the taxonomy now so that the import works!
|
1553 |
+
$domain = wc_attribute_taxonomy_name( $attr_name_real );
|
1554 |
+
if (strlen($domain) < 31){
|
1555 |
|
1556 |
+
$this->wpdb->insert(
|
1557 |
+
$this->wpdb->prefix . 'woocommerce_attribute_taxonomies',
|
1558 |
array(
|
1559 |
'attribute_label' => $attribute_label,
|
1560 |
'attribute_name' => $attribute_name,
|
1562 |
'attribute_orderby' => $attribute_orderby,
|
1563 |
'attribute_public' => 1
|
1564 |
)
|
1565 |
+
);
|
1566 |
|
1567 |
+
register_taxonomy( $domain,
|
1568 |
+
apply_filters( 'woocommerce_taxonomy_objects_' . $domain, array('product') ),
|
1569 |
+
apply_filters( 'woocommerce_taxonomy_args_' . $domain, array(
|
1570 |
+
'hierarchical' => true,
|
1571 |
+
'show_ui' => false,
|
1572 |
+
'query_var' => true,
|
1573 |
+
'rewrite' => false,
|
1574 |
+
) )
|
1575 |
+
);
|
1576 |
|
1577 |
+
delete_transient( 'wc_attribute_taxonomies' );
|
1578 |
+
$attribute_taxonomies = $this->wpdb->get_results( "SELECT * FROM " . $this->wpdb->prefix . "woocommerce_attribute_taxonomies" );
|
1579 |
+
set_transient( 'wc_attribute_taxonomies', $attribute_taxonomies );
|
|
|
1580 |
|
1581 |
+
$logger and call_user_func($logger, sprintf(__('- <b>CREATED</b>: Taxonomy attribute “%s” have been successfully created.', 'wpai_woocommerce_addon_plugin'), wc_attribute_taxonomy_name( $attribute_name )));
|
1582 |
|
1583 |
+
}
|
1584 |
+
else{
|
1585 |
+
$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Taxonomy “%s” name is more than 28 characters. Change it, please.', 'wpai_woocommerce_addon_plugin'), $attr_name));
|
1586 |
+
}
|
1587 |
+
}
|
1588 |
+
}
|
1589 |
+
else{
|
1590 |
if ( in_array( wc_sanitize_taxonomy_name( stripslashes( (string) $attr_name_real)), $this->reserved_terms ) ) {
|
1591 |
$prefix++;
|
1592 |
return $this->create_taxonomy($attr_name, $logger, $prefix);
|
1595 |
}
|
1596 |
|
1597 |
return $attr_name_real;
|
1598 |
+
}
|
1599 |
|
1600 |
public function _filter_has_cap_unfiltered_html($caps)
|
1601 |
{
|
plugin.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
Plugin Name: WP All Import - WooCommerce Add-On
|
4 |
Plugin URI: http://www.wpallimport.com/
|
5 |
Description: An extremely easy, drag & drop importer to import WooCommerce simple products. A paid upgrade is available for premium support and support for Variable, Grouped, and External/Affiliate products
|
6 |
-
Version: 1.3.
|
7 |
Author: Soflyy
|
8 |
-
WC tested up to: 3.
|
9 |
*/
|
10 |
/**
|
11 |
* Plugin root dir with forward slashes as directory separator regardless of actuall DIRECTORY_SEPARATOR value
|
@@ -25,7 +25,7 @@ define('PMWI_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
|
|
25 |
*/
|
26 |
define('PMWI_PREFIX', 'pmwi_');
|
27 |
|
28 |
-
define('PMWI_FREE_VERSION', '1.3.
|
29 |
|
30 |
define('PMWI_EDITION', 'free');
|
31 |
|
@@ -404,7 +404,6 @@ final class PMWI_Plugin {
|
|
404 |
'is_user' => is_user_admin(),
|
405 |
);
|
406 |
add_filter('current_screen', array($this, 'getAdminCurrentScreen'));
|
407 |
-
add_filter('admin_body_class', create_function('', 'return "' . PMWI_Plugin::PREFIX . 'plugin";'));
|
408 |
|
409 |
$controller = new $controllerName();
|
410 |
if ( ! $controller instanceof PMWI_Controller_Admin) {
|
@@ -508,7 +507,7 @@ final class PMWI_Plugin {
|
|
508 |
public function activation() {
|
509 |
|
510 |
// uncaught exception doesn't prevent plugin from being activated, therefore replace it with fatal error so it does
|
511 |
-
|
512 |
|
513 |
// create plugin options
|
514 |
$option_name = get_class($this) . '_Options';
|
3 |
Plugin Name: WP All Import - WooCommerce Add-On
|
4 |
Plugin URI: http://www.wpallimport.com/
|
5 |
Description: An extremely easy, drag & drop importer to import WooCommerce simple products. A paid upgrade is available for premium support and support for Variable, Grouped, and External/Affiliate products
|
6 |
+
Version: 1.3.8
|
7 |
Author: Soflyy
|
8 |
+
WC tested up to: 3.4.0
|
9 |
*/
|
10 |
/**
|
11 |
* Plugin root dir with forward slashes as directory separator regardless of actuall DIRECTORY_SEPARATOR value
|
25 |
*/
|
26 |
define('PMWI_PREFIX', 'pmwi_');
|
27 |
|
28 |
+
define('PMWI_FREE_VERSION', '1.3.8');
|
29 |
|
30 |
define('PMWI_EDITION', 'free');
|
31 |
|
404 |
'is_user' => is_user_admin(),
|
405 |
);
|
406 |
add_filter('current_screen', array($this, 'getAdminCurrentScreen'));
|
|
|
407 |
|
408 |
$controller = new $controllerName();
|
409 |
if ( ! $controller instanceof PMWI_Controller_Admin) {
|
507 |
public function activation() {
|
508 |
|
509 |
// uncaught exception doesn't prevent plugin from being activated, therefore replace it with fatal error so it does
|
510 |
+
set_exception_handler(function($e){trigger_error($e->getMessage(), E_USER_ERROR);});
|
511 |
|
512 |
// create plugin options
|
513 |
$option_name = get_class($this) . '_Options';
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
=== Import Products from any XML or CSV to WooCommerce ===
|
2 |
Contributors: soflyy, wpallimport
|
3 |
Requires at least: 4.1
|
4 |
-
Tested up to: 4.9
|
5 |
-
Stable tag: 1.3.
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
Tags: woocommerce xml import, woocommerce csv import, woocommerce, import, xml, csv, wp all import, csv import, import csv, xml import, import xml, woocommerce csv importer, woocommerce xml importer, csv importer, csv import suite
|
@@ -83,6 +83,16 @@ The WooCommerce add-on will appear in the Step 4 of WP All Import.
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
= 1.3.7 =
|
87 |
* improvement: added new filter wp_all_import_recount_terms_after_import
|
88 |
* bug fix: compatibility with woo commerce 2.6
|
1 |
=== Import Products from any XML or CSV to WooCommerce ===
|
2 |
Contributors: soflyy, wpallimport
|
3 |
Requires at least: 4.1
|
4 |
+
Tested up to: 4.9.6
|
5 |
+
Stable tag: 1.3.8
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
Tags: woocommerce xml import, woocommerce csv import, woocommerce, import, xml, csv, wp all import, csv import, import csv, xml import, import xml, woocommerce csv importer, woocommerce xml importer, csv importer, csv import suite
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 1.3.8 =
|
87 |
+
bug fix: stock status not importing properly when _backorders custom field is not set
|
88 |
+
bug fix: product dimensions won't import if 'Virtual' field is not set
|
89 |
+
bug fix: compatibility fix WooCommerce 2.6.x
|
90 |
+
bug fix: remove deprecated function calls for PHP 7.2 compatibility
|
91 |
+
bug fix: unable to import 0 as a value for attributes
|
92 |
+
bug fix: mirror new WooCommerce core behavior that forces all uncategorized products to be assigned to the Uncategorized category
|
93 |
+
bug fix: import attributes with special characters
|
94 |
+
bug fix: recount product terms when updating post status
|
95 |
+
|
96 |
= 1.3.7 =
|
97 |
* improvement: added new filter wp_all_import_recount_terms_after_import
|
98 |
* bug fix: compatibility with woo commerce 2.6
|