Version Description
- Bug Fix: Duplicating SKU when updating product with ID
- Tested OK with WC 3.7.1
Download this release
Release Info
Developer | webtoffee |
Plugin | Product Import Export for WooCommerce |
Version | 1.6.8 |
Comparing to | |
See all releases |
Code changes from version 1.6.7 to 1.6.8
- includes/exporter/class-wf-prodimpexpcsv-exporter.php +1 -1
- includes/images/Import-Export-for-WooCommerce-Product-Image.png +0 -0
- includes/images/documentation.png +0 -0
- includes/images/sample_csv.png +0 -0
- includes/images/setup.png +0 -0
- includes/images/stars.png +0 -0
- includes/images/storefrog.png +0 -0
- includes/images/support.png +0 -0
- includes/images/video.png +0 -0
- includes/images/wf-ajax-loader.gif +0 -0
- includes/images/wf-failed.png +0 -0
- includes/images/wf-import.png +0 -0
- includes/images/wf-notice.png +0 -0
- includes/images/wf-success.png +0 -0
- includes/importer/class-wf-prodimpexpcsv-product-import.php +383 -376
- product-import-export-for-woo.php +3 -3
- readme.txt +7 -3
includes/exporter/class-wf-prodimpexpcsv-exporter.php
CHANGED
@@ -128,7 +128,7 @@ class WF_ProdImpExpCsv_Exporter {
|
|
128 |
'post_status' => array( 'publish', 'pending', 'private', 'draft' ),
|
129 |
'post_type' => array('product'),
|
130 |
'orderby' => 'ID',
|
131 |
-
|
132 |
'order' => 'ASC',
|
133 |
'offset' => $current_offset
|
134 |
) );
|
128 |
'post_status' => array( 'publish', 'pending', 'private', 'draft' ),
|
129 |
'post_type' => array('product'),
|
130 |
'orderby' => 'ID',
|
131 |
+
'suppress_filters' => false,
|
132 |
'order' => 'ASC',
|
133 |
'offset' => $current_offset
|
134 |
) );
|
includes/images/Import-Export-for-WooCommerce-Product-Image.png
ADDED
Binary file
|
includes/images/documentation.png
ADDED
Binary file
|
includes/images/sample_csv.png
ADDED
Binary file
|
includes/images/setup.png
ADDED
Binary file
|
includes/images/stars.png
ADDED
Binary file
|
includes/images/storefrog.png
ADDED
Binary file
|
includes/images/support.png
ADDED
Binary file
|
includes/images/video.png
ADDED
Binary file
|
includes/images/wf-ajax-loader.gif
ADDED
Binary file
|
includes/images/wf-failed.png
ADDED
Binary file
|
includes/images/wf-import.png
ADDED
Binary file
|
includes/images/wf-notice.png
ADDED
Binary file
|
includes/images/wf-success.png
ADDED
Binary file
|
includes/importer/class-wf-prodimpexpcsv-product-import.php
CHANGED
@@ -490,6 +490,10 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
490 |
_e( 'Finished. Import complete.', 'product-import-export-for-woo' );
|
491 |
|
492 |
$this->import_end();
|
|
|
|
|
|
|
|
|
493 |
exit;
|
494 |
break;
|
495 |
}
|
@@ -801,89 +805,98 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
801 |
/**
|
802 |
* Create new posts based on import information
|
803 |
*/
|
804 |
-
public function process_product(
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
|
815 |
-
|
816 |
-
|
817 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
818 |
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
825 |
|
826 |
-
if ( ! empty ( $post['post_status'] ) && $post['post_status'] == 'auto-draft' ) {
|
827 |
-
$this->add_import_result( 'skipped', __( 'Skipping auto-draft', 'product-import-export-for-woo' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
828 |
-
$this->hf_log_data_change( 'csv-import', __('> Skipping auto-draft.', 'product-import-export-for-woo'), true );
|
829 |
-
unset( $post );
|
830 |
-
return;
|
831 |
-
}
|
832 |
-
// Check if post exists when importing
|
833 |
-
|
834 |
-
if ( ! $merging ) {
|
835 |
-
/* if ( $this->product_exists( $processing_product_title, $processing_product_sku, $post['post_name'] ) ) {
|
836 |
-
if(!$processing_product_id && empty($processing_product_sku)) {
|
837 |
-
// if no sku , no id and no merge + is product in db with same title -> just give message
|
838 |
-
$usr_msg = 'Product with same title already exist.';
|
839 |
-
}else{
|
840 |
-
$usr_msg = 'Product already exists.';
|
841 |
-
}
|
842 |
-
$this->add_import_result( 'skipped', __( $usr_msg, 'product-import-export-for-woo' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
843 |
-
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s”'.$usr_msg, 'product-import-export-for-woo'), esc_html($processing_product_title) ), true );
|
844 |
-
unset( $post );
|
845 |
-
return;
|
846 |
-
}
|
847 |
-
*/
|
848 |
-
|
849 |
-
$is_post_type_product = get_post_type($processing_product_id);
|
850 |
-
if (!empty($processing_product_id) && (in_array($is_post_type_product, array('product','product_variation')))) {
|
851 |
-
$usr_msg = 'Product with same ID already exists.';
|
852 |
-
$this->add_import_result('skipped', __($usr_msg, 'wf_csv_import_export'), $processing_product_id, $processing_product_title, $processing_product_sku);
|
853 |
-
$this->hf_log_data_change('csv-import', sprintf(__('> “%s”' . $usr_msg, 'wf_csv_import_export'), esc_html($processing_product_title)), true);
|
854 |
-
unset($post);
|
855 |
-
return;
|
856 |
-
}
|
857 |
|
858 |
-
$existing_product = '';
|
859 |
-
if (isset($processing_product_sku) && !empty($processing_product_sku)) {
|
860 |
-
$existing_product = $this->wf_get_product_id_by_sku($processing_product_sku);
|
861 |
-
}
|
862 |
-
if ($existing_product) {
|
863 |
-
if ($this->delete_products == 1) {
|
864 |
-
$product_to_be_deleted[] =$existing_product;
|
865 |
-
}
|
866 |
-
if (!$processing_product_id && empty($processing_product_sku)) {
|
867 |
-
// if no sku , no id and no merge and has same title in DB -> just give message
|
868 |
-
$usr_msg = 'Product with same title already exists.';
|
869 |
-
} else {
|
870 |
-
$usr_msg = 'Product with same SKU already exists.';
|
871 |
-
}
|
872 |
-
$this->add_import_result('skipped', __($usr_msg, 'product-import-export-for-woo'), $existing_product, $processing_product_title, $processing_product_sku);
|
873 |
-
$this->hf_log_data_change('csv-import', sprintf(__('> “%s”' . $usr_msg, 'product-import-export-for-woo'), esc_html($processing_product_title)).' with post ID:'.$existing_product, true);
|
874 |
-
unset($post);
|
875 |
-
return;
|
876 |
-
}
|
877 |
-
|
878 |
-
if ( $processing_product_id && is_string( get_post_status( $processing_product_id ) ) ) {
|
879 |
-
$this->add_import_result( 'skipped', __( 'Importing product(ID) conflicts with an existing post.', 'product-import-export-for-woo' ), $processing_product_id, get_the_title( $processing_product_id ), '' );
|
880 |
-
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” ID already exists.', 'product-import-export-for-woo'), esc_html( $processing_product_id ) ), true );
|
881 |
-
unset( $post );
|
882 |
-
return;
|
883 |
-
}
|
884 |
-
}
|
885 |
-
|
886 |
-
|
887 |
// if ( ! $merging ) {
|
888 |
// error_log('<pre>$this->wf_get_product_id_by_sku( $processing_product_sku ):-' . print_r($this->wf_get_product_id_by_sku( $processing_product_sku ), 1) . '</per>', 3, ABSPATH . "/wp-content/uploads/wc-logs/test-log.txt");
|
889 |
// if ( $this->wf_get_product_id_by_sku( $processing_product_sku ) ) {
|
@@ -912,382 +925,376 @@ class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
|
912 |
// return;
|
913 |
// }
|
914 |
// }
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
|
924 |
-
|
925 |
-
|
926 |
-
// Only merge fields which are set
|
927 |
-
$post_id = $processing_product_id;
|
928 |
|
929 |
-
|
|
|
930 |
|
931 |
-
|
932 |
-
'ID' => $post_id
|
933 |
-
);
|
934 |
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
}
|
939 |
-
if ( isset( $post['post_excerpt'] ) ) {
|
940 |
-
$postdata['post_excerpt'] = $post['post_excerpt'];
|
941 |
-
}
|
942 |
-
if ( isset( $post['post_password'] ) ) {
|
943 |
-
$postdata['post_password'] = $post['post_password'];
|
944 |
-
}
|
945 |
-
if ( isset( $post['post_parent'] ) ) {
|
946 |
-
$postdata['post_parent'] = $post['post_parent'];
|
947 |
-
}
|
948 |
-
} else {
|
949 |
-
if ( ! empty( $post['post_content'] ) ) {
|
950 |
-
$postdata['post_content'] = $post['post_content'];
|
951 |
-
}
|
952 |
-
if ( ! empty( $post['post_excerpt'] ) ) {
|
953 |
-
$postdata['post_excerpt'] = $post['post_excerpt'];
|
954 |
-
}
|
955 |
-
if ( ! empty( $post['post_password'] ) ) {
|
956 |
-
$postdata['post_password'] = $post['post_password'];
|
957 |
-
}
|
958 |
-
if ( isset( $post['post_parent'] ) && $post['post_parent'] !== '' ) {
|
959 |
-
$postdata['post_parent'] = $post['post_parent'];
|
960 |
-
}
|
961 |
-
}
|
962 |
|
963 |
-
|
964 |
-
|
965 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
if ( ! empty( $post['post_date'] ) ) {
|
971 |
-
$postdata['post_date'] = date("Y-m-d H:i:s", strtotime( $post['post_date'] ) );
|
972 |
-
}
|
973 |
-
if ( ! empty( $post['post_date_gmt'] ) ) {
|
974 |
-
$postdata['post_date_gmt'] = date("Y-m-d H:i:s", strtotime( $post['post_date_gmt'] ) );
|
975 |
-
}
|
976 |
-
if ( ! empty( $post['post_name'] ) ) {
|
977 |
-
$postdata['post_name'] = $post['post_name'];
|
978 |
-
}
|
979 |
-
if ( ! empty( $post['post_status'] ) ) {
|
980 |
-
$postdata['post_status'] = $post['post_status'];
|
981 |
-
}
|
982 |
-
if ( ! empty( $post['menu_order'] ) ) {
|
983 |
-
$postdata['menu_order'] = $post['menu_order'];
|
984 |
-
}
|
985 |
-
if ( ! empty( $post['comment_status'] ) ) {
|
986 |
-
$postdata['comment_status'] = $post['comment_status'];
|
987 |
-
}
|
988 |
-
if ( sizeof( $postdata ) > 1 ) {
|
989 |
-
$result = wp_update_post( $postdata );
|
990 |
-
|
991 |
-
if ( ! $result ) {
|
992 |
-
$this->add_import_result( 'failed', __( 'Failed to update product', 'product-import-export-for-woo' ), $post_id, $processing_product_title, $processing_product_sku );
|
993 |
-
$this->hf_log_data_change( 'csv-import', sprintf( __('> Failed to update product %s', 'product-import-export-for-woo'), $post_id ), true );
|
994 |
-
unset( $post );
|
995 |
-
return;
|
996 |
-
} else {
|
997 |
-
$this->hf_log_data_change( 'csv-import', __( '> Merged post data: ', 'product-import-export-for-woo' ) . print_r( $postdata, true ) );
|
998 |
-
}
|
999 |
-
}
|
1000 |
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
'menu_order' => !empty($post['menu_order'])?$post['menu_order']:'',
|
1039 |
-
'post_type' => !empty($post['post_type'])?$post['post_type']:"",
|
1040 |
-
'post_password' => !empty($post['post_password'])?$post['post_password']:'',
|
1041 |
-
'comment_status' => !empty($post['comment_status'])?$post['comment_status']:'',
|
1042 |
-
);
|
1043 |
-
|
1044 |
-
$post_id = wp_insert_post( $postdata, true );
|
1045 |
-
|
1046 |
-
if ( is_wp_error( $post_id ) ) {
|
1047 |
-
|
1048 |
-
$this->add_import_result( 'failed', __( 'Failed to import product', 'product-import-export-for-woo' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
1049 |
-
$this->hf_log_data_change( 'csv-import', sprintf( __( 'Failed to import product “%s”', 'product-import-export-for-woo' ), esc_html($processing_product_title) ) );
|
1050 |
-
unset( $post );
|
1051 |
-
return;
|
1052 |
|
1053 |
-
|
|
|
1054 |
|
1055 |
-
|
|
|
|
|
|
|
1056 |
|
1057 |
-
|
1058 |
-
|
1059 |
|
1060 |
-
|
|
|
|
|
|
|
|
|
1061 |
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1066 |
|
1067 |
-
|
1068 |
|
1069 |
-
|
1070 |
-
if ( ! empty( $post['terms'] ) && is_array( $post['terms'] ) ) {
|
1071 |
|
1072 |
-
|
|
|
|
|
|
|
|
|
1073 |
|
1074 |
-
|
|
|
|
|
1075 |
|
1076 |
-
|
1077 |
-
$terms = $term_group['terms'];
|
1078 |
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
|
|
1082 |
|
1083 |
-
|
1084 |
-
$terms = array( $terms );
|
1085 |
-
}
|
1086 |
|
1087 |
-
|
|
|
1088 |
|
1089 |
-
|
1090 |
|
1091 |
-
|
1092 |
|
1093 |
-
|
1094 |
-
|
1095 |
|
1096 |
-
|
|
|
|
|
1097 |
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
|
1102 |
-
|
1103 |
-
}
|
1104 |
|
1105 |
-
|
1106 |
-
if ( ! empty( $post['postmeta'] ) && is_array( $post['postmeta'] ) ) {
|
1107 |
-
foreach ( $post['postmeta'] as $meta ) {
|
1108 |
-
$key = apply_filters( 'import_post_meta_key', $meta['key'] );
|
1109 |
|
1110 |
-
|
1111 |
-
|
1112 |
-
}
|
1113 |
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
|
1118 |
-
|
|
|
|
|
1119 |
|
1120 |
-
|
1121 |
-
|
1122 |
|
1123 |
-
|
1124 |
-
|
|
|
|
|
1125 |
|
1126 |
-
|
1127 |
-
|
|
|
1128 |
|
1129 |
-
|
|
|
|
|
|
|
1130 |
|
1131 |
-
|
1132 |
-
|
1133 |
|
1134 |
-
|
1135 |
-
|
1136 |
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
$processing_product_object = wc_get_product($post_id);
|
1141 |
-
$attachments = $processing_product_object->get_gallery_attachment_ids();
|
1142 |
-
$post_thumbnail_id = get_post_thumbnail_id($post_id);
|
1143 |
-
if(isset($post_thumbnail_id)&& !empty($post_thumbnail_id)){
|
1144 |
-
$attachments[]=$post_thumbnail_id;
|
1145 |
-
}
|
1146 |
-
|
1147 |
-
foreach ( $attachments as $attachment_key => $attachment ) {
|
1148 |
|
1149 |
-
|
1150 |
-
$attachment_basename = basename( $attachment_url );
|
1151 |
|
1152 |
-
|
1153 |
-
|
1154 |
|
1155 |
-
|
|
|
1156 |
|
1157 |
-
|
1158 |
-
|
1159 |
|
1160 |
-
|
|
|
|
|
|
|
|
|
|
|
1161 |
|
1162 |
-
|
1163 |
-
update_post_meta( $post_id, '_thumbnail_id', $attachment );
|
1164 |
-
$featured = false;
|
1165 |
-
} else {
|
1166 |
-
$gallery_ids[ $key ] = $attachment;
|
1167 |
-
}
|
1168 |
-
}
|
1169 |
|
1170 |
-
|
|
|
1171 |
|
1172 |
-
|
|
|
1173 |
|
1174 |
-
|
1175 |
-
$attachment_post = array();
|
1176 |
-
$attachment_post['ID'] = $attachment;
|
1177 |
-
$attachment_post['post_parent'] = '';
|
1178 |
-
wp_update_post( $attachment_post );
|
1179 |
-
unset( $attachment_post );
|
1180 |
|
1181 |
-
|
|
|
1182 |
|
1183 |
-
|
1184 |
|
1185 |
-
|
1186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1187 |
|
1188 |
-
|
|
|
1189 |
|
1190 |
-
|
|
|
1191 |
|
1192 |
-
|
1193 |
|
1194 |
-
|
1195 |
-
'post_title' => preg_replace( '/\.[^.]+$/', '', $processing_product_title . ' ' . ( $image_key + 1 ) ),
|
1196 |
-
'post_content' => '',
|
1197 |
-
'post_status' => 'inherit',
|
1198 |
-
'post_parent' => $post_id
|
1199 |
-
);
|
1200 |
|
1201 |
-
|
|
|
|
|
|
|
|
|
|
|
1202 |
|
1203 |
-
|
1204 |
|
1205 |
-
|
1206 |
|
1207 |
-
|
1208 |
-
update_post_meta( $attachment_id, '_wp_attachment_image_alt', $processing_product_title );
|
1209 |
|
1210 |
-
|
1211 |
-
|
1212 |
-
} else {
|
1213 |
-
$gallery_ids[ $image_key ] = $attachment_id;
|
1214 |
-
}
|
1215 |
|
1216 |
-
|
|
|
|
|
|
|
|
|
1217 |
|
1218 |
-
|
1219 |
-
} else {
|
1220 |
-
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Error importing image "%s"', 'product-import-export-for-woo' ), $image ) );
|
1221 |
-
$this->hf_log_data_change( 'csv-import', '> > ' . $attachment_id->get_error_message() );
|
1222 |
-
}
|
1223 |
|
1224 |
-
|
1225 |
-
|
|
|
|
|
|
|
1226 |
|
1227 |
-
|
|
|
1228 |
|
1229 |
-
|
1230 |
|
1231 |
-
|
1232 |
|
1233 |
-
|
1234 |
-
}
|
1235 |
|
1236 |
-
|
1237 |
-
|
1238 |
|
1239 |
-
|
1240 |
-
|
1241 |
-
$attributes = array_merge( $attributes, $post['attributes'] );
|
1242 |
-
} else {
|
1243 |
-
$attributes = $post['attributes'];
|
1244 |
-
}
|
1245 |
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
}
|
1253 |
-
uasort( $attributes, 'attributes_cmp' );
|
1254 |
|
1255 |
-
|
|
|
1256 |
|
1257 |
-
|
1258 |
-
|
|
|
|
|
|
|
1259 |
|
1260 |
-
|
1261 |
-
|
1262 |
|
1263 |
-
|
1264 |
|
1265 |
-
|
1266 |
-
|
1267 |
|
1268 |
-
|
1269 |
-
|
1270 |
-
}
|
1271 |
|
1272 |
-
|
1273 |
-
$this->crosssell_skus[ $post_id ] = $post['crosssell_skus'];
|
1274 |
-
}
|
1275 |
|
1276 |
-
|
|
|
1277 |
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
} else {
|
1282 |
-
$this->add_import_result( 'imported', 'Import successful', $post_id, $processing_product_title, $processing_product_sku );
|
1283 |
-
$this->hf_log_data_change( 'csv-import', sprintf( __('> Finished importing post ID %s.', 'product-import-export-for-woo'), $post_id ) );
|
1284 |
-
}
|
1285 |
-
|
1286 |
-
do_action('wf_refresh_after_product_import',$processing_product_object); // hook for forcefully refresh product
|
1287 |
-
unset( $post );
|
1288 |
-
}
|
1289 |
|
1290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1291 |
* Log a row's import status
|
1292 |
*/
|
1293 |
protected function add_import_result( $status, $reason, $post_id = '', $post_title = '', $sku = '' ) {
|
490 |
_e( 'Finished. Import complete.', 'product-import-export-for-woo' );
|
491 |
|
492 |
$this->import_end();
|
493 |
+
if (WC()->version >= '3.6' && !wc_update_product_lookup_tables_is_running()) {
|
494 |
+
wc_update_product_lookup_tables();
|
495 |
+
}
|
496 |
+
|
497 |
exit;
|
498 |
break;
|
499 |
}
|
805 |
/**
|
806 |
* Create new posts based on import information
|
807 |
*/
|
808 |
+
public function process_product($post) {
|
809 |
+
$processing_product_id = absint($post['post_id']);
|
810 |
+
$processing_product = get_post($processing_product_id);
|
811 |
+
$processing_product_title = $processing_product ? $processing_product->post_title : '';
|
812 |
+
$processing_product_sku = $processing_product ? $processing_product->sku : '';
|
813 |
+
$merging = !empty($post['merging']);
|
814 |
+
|
815 |
+
if (!empty($post['post_title'])) {
|
816 |
+
$processing_product_title = $post['post_title'];
|
817 |
+
}
|
818 |
|
819 |
+
if (!empty($post['sku'])) {
|
820 |
+
$id_exist = $this->wf_get_product_id_by_sku($post['sku']);
|
821 |
+
if ($id_exist == $processing_product_id || $processing_product_sku == $post['sku'] || empty($id_exist)) {
|
822 |
+
$processing_product_sku = $post['sku'];
|
823 |
+
} else {
|
824 |
+
$usr_msg = 'Invalid or duplicated SKU.';
|
825 |
+
$this->add_import_result('skipped', __($usr_msg, 'wf_csv_import_export'), $id_exist, get_the_title($id_exist), $post['sku']);
|
826 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> “%s”' . $usr_msg, 'wf_csv_import_export'), esc_html($processing_product_title)) . ' with post ID:' . $existing_product, true);
|
827 |
+
unset($post);
|
828 |
+
return;
|
829 |
+
}
|
830 |
+
}
|
831 |
|
832 |
+
if (!empty($processing_product_id) && isset($this->processed_posts[$processing_product_id])) {
|
833 |
+
$this->add_import_result('skipped', __('Product already processed', 'product-import-export-for-woo'), $processing_product_id, $processing_product_title, $processing_product_sku);
|
834 |
+
$this->hf_log_data_change('csv-import', __('> Post ID already processed. Skipping.', 'product-import-export-for-woo'), true);
|
835 |
+
unset($post);
|
836 |
+
return;
|
837 |
+
}
|
838 |
+
|
839 |
+
if (!empty($post['post_status']) && $post['post_status'] == 'auto-draft') {
|
840 |
+
$this->add_import_result('skipped', __('Skipping auto-draft', 'product-import-export-for-woo'), $processing_product_id, $processing_product_title, $processing_product_sku);
|
841 |
+
$this->hf_log_data_change('csv-import', __('> Skipping auto-draft.', 'product-import-export-for-woo'), true);
|
842 |
+
unset($post);
|
843 |
+
return;
|
844 |
+
}
|
845 |
+
// Check if post exists when importing
|
846 |
+
|
847 |
+
if (!$merging) {
|
848 |
+
/* if ( $this->product_exists( $processing_product_title, $processing_product_sku, $post['post_name'] ) ) {
|
849 |
+
if(!$processing_product_id && empty($processing_product_sku)) {
|
850 |
+
// if no sku , no id and no merge + is product in db with same title -> just give message
|
851 |
+
$usr_msg = 'Product with same title already exist.';
|
852 |
+
}else{
|
853 |
+
$usr_msg = 'Product already exists.';
|
854 |
+
}
|
855 |
+
$this->add_import_result( 'skipped', __( $usr_msg, 'product-import-export-for-woo' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
856 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s”'.$usr_msg, 'product-import-export-for-woo'), esc_html($processing_product_title) ), true );
|
857 |
+
unset( $post );
|
858 |
+
return;
|
859 |
+
}
|
860 |
+
*/
|
861 |
+
|
862 |
+
$is_post_type_product = get_post_type($processing_product_id);
|
863 |
+
if (!empty($processing_product_id) && (in_array($is_post_type_product, array('product', 'product_variation')))) {
|
864 |
+
$usr_msg = 'Product with same ID already exists.';
|
865 |
+
$this->add_import_result('skipped', __($usr_msg, 'wf_csv_import_export'), $processing_product_id, $processing_product_title, $processing_product_sku);
|
866 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> “%s”' . $usr_msg, 'wf_csv_import_export'), esc_html($processing_product_title)), true);
|
867 |
+
unset($post);
|
868 |
+
return;
|
869 |
+
}
|
870 |
+
|
871 |
+
$existing_product = '';
|
872 |
+
if (isset($processing_product_sku) && !empty($processing_product_sku)) {
|
873 |
+
$existing_product = $this->wf_get_product_id_by_sku($processing_product_sku);
|
874 |
+
}
|
875 |
+
if ($existing_product) {
|
876 |
+
/*if ($this->delete_products == 1) {
|
877 |
+
$product_to_be_deleted[] = $existing_product;
|
878 |
+
}*/
|
879 |
+
if (!$processing_product_id && empty($processing_product_sku)) {
|
880 |
+
// if no sku , no id and no merge and has same title in DB -> just give message
|
881 |
+
$usr_msg = 'Product with same title already exists.';
|
882 |
+
} else {
|
883 |
+
$usr_msg = 'Product with same SKU already exists.';
|
884 |
+
}
|
885 |
+
$this->add_import_result('skipped', __($usr_msg, 'product-import-export-for-woo'), $existing_product, $processing_product_title, $processing_product_sku);
|
886 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> “%s”' . $usr_msg, 'product-import-export-for-woo'), esc_html($processing_product_title)) . ' with post ID:' . $existing_product, true);
|
887 |
+
unset($post);
|
888 |
+
return;
|
889 |
+
}
|
890 |
+
|
891 |
+
if ($processing_product_id && is_string(get_post_status($processing_product_id))) {
|
892 |
+
$this->add_import_result('skipped', __('Importing product(ID) conflicts with an existing post.', 'product-import-export-for-woo'), $processing_product_id, get_the_title($processing_product_id), '');
|
893 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> “%s” ID already exists.', 'product-import-export-for-woo'), esc_html($processing_product_id)), true);
|
894 |
+
unset($post);
|
895 |
+
return;
|
896 |
+
}
|
897 |
+
}
|
898 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
899 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
900 |
// if ( ! $merging ) {
|
901 |
// error_log('<pre>$this->wf_get_product_id_by_sku( $processing_product_sku ):-' . print_r($this->wf_get_product_id_by_sku( $processing_product_sku ), 1) . '</per>', 3, ABSPATH . "/wp-content/uploads/wc-logs/test-log.txt");
|
902 |
// if ( $this->wf_get_product_id_by_sku( $processing_product_sku ) ) {
|
925 |
// return;
|
926 |
// }
|
927 |
// }
|
928 |
+
// Check post type to avoid conflicts with IDs
|
929 |
+
$is_post_exist_in_db = get_post_type($processing_product_id);
|
930 |
+
if ($merging && $processing_product_id && !empty($is_post_exist_in_db) && ($is_post_exist_in_db !== $post['post_type'] )) {
|
931 |
+
$this->add_import_result('skipped', __('Importing product(ID) conflicts with an existing post which is not a product.', 'product-import-export-for-woo'), $processing_product_id, $processing_product_title, $processing_product_sku);
|
932 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> “%s” is not a product.', 'product-import-export-for-woo'), esc_html($processing_product_id)), true);
|
933 |
+
unset($post);
|
934 |
+
return;
|
935 |
+
}
|
936 |
|
937 |
+
if ($merging && !empty($is_post_exist_in_db)) {
|
|
|
|
|
|
|
938 |
|
939 |
+
// Only merge fields which are set
|
940 |
+
$post_id = $processing_product_id;
|
941 |
|
942 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> Merging post ID %s.', 'product-import-export-for-woo'), $post_id), true);
|
|
|
|
|
943 |
|
944 |
+
$postdata = array(
|
945 |
+
'ID' => $post_id
|
946 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
947 |
|
948 |
+
if ($this->merge_empty_cells) {
|
949 |
+
if (isset($post['post_content'])) {
|
950 |
+
$postdata['post_content'] = $post['post_content'];
|
951 |
+
}
|
952 |
+
if (isset($post['post_excerpt'])) {
|
953 |
+
$postdata['post_excerpt'] = $post['post_excerpt'];
|
954 |
+
}
|
955 |
+
if (isset($post['post_password'])) {
|
956 |
+
$postdata['post_password'] = $post['post_password'];
|
957 |
+
}
|
958 |
+
if (isset($post['post_parent'])) {
|
959 |
+
$postdata['post_parent'] = $post['post_parent'];
|
960 |
+
}
|
961 |
+
} else {
|
962 |
+
if (!empty($post['post_content'])) {
|
963 |
+
$postdata['post_content'] = $post['post_content'];
|
964 |
+
}
|
965 |
+
if (!empty($post['post_excerpt'])) {
|
966 |
+
$postdata['post_excerpt'] = $post['post_excerpt'];
|
967 |
+
}
|
968 |
+
if (!empty($post['post_password'])) {
|
969 |
+
$postdata['post_password'] = $post['post_password'];
|
970 |
+
}
|
971 |
+
if (isset($post['post_parent']) && $post['post_parent'] !== '') {
|
972 |
+
$postdata['post_parent'] = $post['post_parent'];
|
973 |
+
}
|
974 |
+
}
|
975 |
|
976 |
+
if (!empty($post['post_title'])) {
|
977 |
+
$postdata['post_title'] = $post['post_title'];
|
978 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
979 |
|
980 |
+
if (!empty($post['post_author'])) {
|
981 |
+
$postdata['post_author'] = absint($post['post_author']);
|
982 |
+
}
|
983 |
+
if (!empty($post['post_date'])) {
|
984 |
+
$postdata['post_date'] = date("Y-m-d H:i:s", strtotime($post['post_date']));
|
985 |
+
}
|
986 |
+
if (!empty($post['post_date_gmt'])) {
|
987 |
+
$postdata['post_date_gmt'] = date("Y-m-d H:i:s", strtotime($post['post_date_gmt']));
|
988 |
+
}
|
989 |
+
if (!empty($post['post_name'])) {
|
990 |
+
$postdata['post_name'] = $post['post_name'];
|
991 |
+
}
|
992 |
+
if (!empty($post['post_status'])) {
|
993 |
+
$postdata['post_status'] = $post['post_status'];
|
994 |
+
}
|
995 |
+
if (!empty($post['menu_order'])) {
|
996 |
+
$postdata['menu_order'] = $post['menu_order'];
|
997 |
+
}
|
998 |
+
if (!empty($post['comment_status'])) {
|
999 |
+
$postdata['comment_status'] = $post['comment_status'];
|
1000 |
+
}
|
1001 |
+
if (sizeof($postdata) > 1) {
|
1002 |
+
$result = wp_update_post($postdata);
|
1003 |
|
1004 |
+
if (!$result) {
|
1005 |
+
$this->add_import_result('failed', __('Failed to update product', 'product-import-export-for-woo'), $post_id, $processing_product_title, $processing_product_sku);
|
1006 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> Failed to update product %s', 'product-import-export-for-woo'), $post_id), true);
|
1007 |
+
unset($post);
|
1008 |
+
return;
|
1009 |
+
} else {
|
1010 |
+
$this->hf_log_data_change('csv-import', __('> Merged post data: ', 'product-import-export-for-woo') . print_r($postdata, true));
|
1011 |
+
}
|
1012 |
+
}
|
1013 |
+
} else {
|
1014 |
+
$merging = FALSE;
|
1015 |
+
// Get parent
|
1016 |
+
$post_parent = (isset($post['post_parent']) ? $post['post_parent'] : '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1017 |
|
1018 |
+
if ($post_parent !== "") {
|
1019 |
+
$post_parent = absint($post_parent);
|
1020 |
|
1021 |
+
if ($post_parent > 0) {
|
1022 |
+
// if we already know the parent, map it to the new local ID
|
1023 |
+
if (isset($this->processed_posts[$post_parent])) {
|
1024 |
+
$post_parent = $this->processed_posts[$post_parent];
|
1025 |
|
1026 |
+
// otherwise record the parent for later
|
1027 |
+
} else {
|
1028 |
|
1029 |
+
$this->post_orphans[intval($processing_product_id)] = $post_parent;
|
1030 |
+
//$post_parent = 0;
|
1031 |
+
}
|
1032 |
+
}
|
1033 |
+
}
|
1034 |
|
1035 |
+
// Insert product
|
1036 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> Inserting %s', 'product-import-export-for-woo'), esc_html($processing_product_title)), true);
|
1037 |
+
$postdata = array(
|
1038 |
+
'import_id' => $processing_product_id,
|
1039 |
+
'post_author' => !empty($post['post_author']) ? absint($post['post_author']) : get_current_user_id(),
|
1040 |
+
'post_date' => !empty($post['post_date']) ? date("Y-m-d H:i:s", strtotime($post['post_date'])) : '',
|
1041 |
+
'post_date_gmt' => (!empty($post['post_date_gmt']) && $post['post_date_gmt'] ) ? date('Y-m-d H:i:s', strtotime($post['post_date_gmt'])) : '',
|
1042 |
+
'post_content' => !empty($post['post_content']) ? $post['post_content'] : '',
|
1043 |
+
'post_excerpt' => !empty($post['post_excerpt']) ? $post['post_excerpt'] : '',
|
1044 |
+
'post_title' => $processing_product_title,
|
1045 |
+
'post_name' => !empty($post['post_name']) ? $post['post_name'] : sanitize_title($processing_product_title),
|
1046 |
+
'post_status' => !empty($post['post_status']) ? $post['post_status'] : 'publish',
|
1047 |
+
'post_parent' => $post_parent,
|
1048 |
+
'menu_order' => !empty($post['menu_order']) ? $post['menu_order'] : '',
|
1049 |
+
'post_type' => !empty($post['post_type']) ? $post['post_type'] : "",
|
1050 |
+
'post_password' => !empty($post['post_password']) ? $post['post_password'] : '',
|
1051 |
+
'comment_status' => !empty($post['comment_status']) ? $post['comment_status'] : '',
|
1052 |
+
);
|
1053 |
|
1054 |
+
$post_id = wp_insert_post($postdata, true);
|
1055 |
|
1056 |
+
if (is_wp_error($post_id)) {
|
|
|
1057 |
|
1058 |
+
$this->add_import_result('failed', __('Failed to import product', 'product-import-export-for-woo'), $processing_product_id, $processing_product_title, $processing_product_sku);
|
1059 |
+
$this->hf_log_data_change('csv-import', sprintf(__('Failed to import product “%s”', 'product-import-export-for-woo'), esc_html($processing_product_title)));
|
1060 |
+
unset($post);
|
1061 |
+
return;
|
1062 |
+
} else {
|
1063 |
|
1064 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> Inserted - post ID is %s.', 'product-import-export-for-woo'), $post_id));
|
1065 |
+
}
|
1066 |
+
}
|
1067 |
|
1068 |
+
unset($postdata);
|
|
|
1069 |
|
1070 |
+
// map pre-import ID to local ID
|
1071 |
+
if (empty($processing_product_id)) {
|
1072 |
+
$processing_product_id = (int) $post_id;
|
1073 |
+
}
|
1074 |
|
1075 |
+
$this->processed_posts[intval($processing_product_id)] = (int) $post_id;
|
|
|
|
|
1076 |
|
1077 |
+
// add categories, tags and other terms
|
1078 |
+
if (!empty($post['terms']) && is_array($post['terms'])) {
|
1079 |
|
1080 |
+
$terms_to_set = array();
|
1081 |
|
1082 |
+
foreach ($post['terms'] as $term_group) {
|
1083 |
|
1084 |
+
$taxonomy = $term_group['taxonomy'];
|
1085 |
+
$terms = $term_group['terms'];
|
1086 |
|
1087 |
+
if (!$taxonomy || !taxonomy_exists($taxonomy)) {
|
1088 |
+
continue;
|
1089 |
+
}
|
1090 |
|
1091 |
+
if (!is_array($terms)) {
|
1092 |
+
$terms = array($terms);
|
1093 |
+
}
|
1094 |
|
1095 |
+
$terms_to_set[$taxonomy] = array();
|
|
|
1096 |
|
1097 |
+
foreach ($terms as $term_id) {
|
|
|
|
|
|
|
1098 |
|
1099 |
+
if (!$term_id)
|
1100 |
+
continue;
|
|
|
1101 |
|
1102 |
+
$terms_to_set[$taxonomy][] = intval($term_id);
|
1103 |
+
}
|
1104 |
+
}
|
1105 |
|
1106 |
+
foreach ($terms_to_set as $tax => $ids) {
|
1107 |
+
$tt_ids = wp_set_post_terms($post_id, $ids, $tax, false);
|
1108 |
+
}
|
1109 |
|
1110 |
+
unset($post['terms'], $terms_to_set);
|
1111 |
+
}
|
1112 |
|
1113 |
+
// add/update post meta
|
1114 |
+
if (!empty($post['postmeta']) && is_array($post['postmeta'])) {
|
1115 |
+
foreach ($post['postmeta'] as $meta) {
|
1116 |
+
$key = apply_filters('import_post_meta_key', $meta['key']);
|
1117 |
|
1118 |
+
if ($key) {
|
1119 |
+
update_post_meta($post_id, $key, maybe_unserialize($meta['value']));
|
1120 |
+
}
|
1121 |
|
1122 |
+
if ($key == '_file_paths') {
|
1123 |
+
do_action('woocommerce_process_product_file_download_paths', $post_id, 0, maybe_unserialize($meta['value']));
|
1124 |
+
}
|
1125 |
+
}
|
1126 |
|
1127 |
+
unset($post['postmeta']);
|
1128 |
+
}
|
1129 |
|
1130 |
+
// Import images and add to post
|
1131 |
+
if (!empty($post['images']) && is_array($post['images'])) {
|
1132 |
|
1133 |
+
$featured = true;
|
1134 |
+
$gallery_ids = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1135 |
|
1136 |
+
if ($merging) {
|
|
|
1137 |
|
1138 |
+
// Get basenames
|
1139 |
+
$image_basenames = array();
|
1140 |
|
1141 |
+
foreach ($post['images'] as $image)
|
1142 |
+
$image_basenames[] = basename($image);
|
1143 |
|
1144 |
+
// Loop attachments already attached to the product
|
1145 |
+
//$attachments = get_posts( 'post_parent=' . $post_id . '&post_type=attachment&fields=ids&post_mime_type=image&numberposts=-1' );
|
1146 |
|
1147 |
+
$processing_product_object = wc_get_product($post_id);
|
1148 |
+
$attachments = $processing_product_object->get_gallery_attachment_ids();
|
1149 |
+
$post_thumbnail_id = get_post_thumbnail_id($post_id);
|
1150 |
+
if (isset($post_thumbnail_id) && !empty($post_thumbnail_id)) {
|
1151 |
+
$attachments[] = $post_thumbnail_id;
|
1152 |
+
}
|
1153 |
|
1154 |
+
foreach ($attachments as $attachment_key => $attachment) {
|
|
|
|
|
|
|
|
|
|
|
|
|
1155 |
|
1156 |
+
$attachment_url = wp_get_attachment_url($attachment);
|
1157 |
+
$attachment_basename = basename($attachment_url);
|
1158 |
|
1159 |
+
// Don't import existing images
|
1160 |
+
if (in_array($attachment_url, $post['images']) || in_array($attachment_basename, $image_basenames)) {
|
1161 |
|
1162 |
+
foreach ($post['images'] as $key => $image) {
|
|
|
|
|
|
|
|
|
|
|
1163 |
|
1164 |
+
if ($image == $attachment_url || basename($image) == $attachment_basename) {
|
1165 |
+
unset($post['images'][$key]);
|
1166 |
|
1167 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> > Image exists - skipping %s', 'product-import-export-for-woo'), basename($image)));
|
1168 |
|
1169 |
+
if ($key == 0) {
|
1170 |
+
update_post_meta($post_id, '_thumbnail_id', $attachment);
|
1171 |
+
$featured = false;
|
1172 |
+
} else {
|
1173 |
+
$gallery_ids[$key] = $attachment;
|
1174 |
+
}
|
1175 |
+
}
|
1176 |
+
}
|
1177 |
+
} else {
|
1178 |
+
|
1179 |
+
// Detach image which is not being merged
|
1180 |
+
$attachment_post = array();
|
1181 |
+
$attachment_post['ID'] = $attachment;
|
1182 |
+
$attachment_post['post_parent'] = '';
|
1183 |
+
wp_update_post($attachment_post);
|
1184 |
+
unset($attachment_post);
|
1185 |
+
}
|
1186 |
+
}
|
1187 |
|
1188 |
+
unset($attachments);
|
1189 |
+
}
|
1190 |
|
1191 |
+
if ($post['images'])
|
1192 |
+
foreach ($post['images'] as $image_key => $image) {
|
1193 |
|
1194 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> > Importing image "%s"', 'product-import-export-for-woo'), $image));
|
1195 |
|
1196 |
+
$filename = basename($image);
|
|
|
|
|
|
|
|
|
|
|
1197 |
|
1198 |
+
$attachment = array(
|
1199 |
+
'post_title' => preg_replace('/\.[^.]+$/', '', $processing_product_title . ' ' . ( $image_key + 1 )),
|
1200 |
+
'post_content' => '',
|
1201 |
+
'post_status' => 'inherit',
|
1202 |
+
'post_parent' => $post_id
|
1203 |
+
);
|
1204 |
|
1205 |
+
$attachment_id = $this->process_attachment($attachment, $image, $post_id);
|
1206 |
|
1207 |
+
if (!is_wp_error($attachment_id) && $attachment_id) {
|
1208 |
|
1209 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> > Imported image "%s"', 'product-import-export-for-woo'), $image));
|
|
|
1210 |
|
1211 |
+
// Set alt
|
1212 |
+
update_post_meta($attachment_id, '_wp_attachment_image_alt', $processing_product_title);
|
|
|
|
|
|
|
1213 |
|
1214 |
+
if ($featured) {
|
1215 |
+
update_post_meta($post_id, '_thumbnail_id', $attachment_id);
|
1216 |
+
} else {
|
1217 |
+
$gallery_ids[$image_key] = $attachment_id;
|
1218 |
+
}
|
1219 |
|
1220 |
+
update_post_meta($attachment_id, '_woocommerce_exclude_image', 0);
|
|
|
|
|
|
|
|
|
1221 |
|
1222 |
+
$featured = false;
|
1223 |
+
} else {
|
1224 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> > Error importing image "%s"', 'product-import-export-for-woo'), $image));
|
1225 |
+
$this->hf_log_data_change('csv-import', '> > ' . $attachment_id->get_error_message());
|
1226 |
+
}
|
1227 |
|
1228 |
+
unset($attachment, $attachment_id);
|
1229 |
+
}
|
1230 |
|
1231 |
+
$this->hf_log_data_change('csv-import', __('> > Images set', 'product-import-export-for-woo'));
|
1232 |
|
1233 |
+
ksort($gallery_ids);
|
1234 |
|
1235 |
+
update_post_meta($post_id, '_product_image_gallery', implode(',', $gallery_ids));
|
|
|
1236 |
|
1237 |
+
unset($post['images'], $featured, $gallery_ids);
|
1238 |
+
}
|
1239 |
|
1240 |
+
// Import attributes
|
1241 |
+
if (!empty($post['attributes']) && is_array($post['attributes'])) {
|
|
|
|
|
|
|
|
|
1242 |
|
1243 |
+
if ($merging) {
|
1244 |
+
$attributes = array_filter((array) maybe_unserialize(get_post_meta($post_id, '_product_attributes', true)));
|
1245 |
+
$attributes = array_merge($attributes, $post['attributes']);
|
1246 |
+
} else {
|
1247 |
+
$attributes = $post['attributes'];
|
1248 |
+
}
|
|
|
|
|
1249 |
|
1250 |
+
// Sort attribute positions
|
1251 |
+
if (!function_exists('attributes_cmp')) {
|
1252 |
|
1253 |
+
function attributes_cmp($a, $b) {
|
1254 |
+
if ($a['position'] == $b['position'])
|
1255 |
+
return 0;
|
1256 |
+
return ( $a['position'] < $b['position'] ) ? -1 : 1;
|
1257 |
+
}
|
1258 |
|
1259 |
+
}
|
1260 |
+
uasort($attributes, 'attributes_cmp');
|
1261 |
|
1262 |
+
update_post_meta($post_id, '_product_attributes', $attributes);
|
1263 |
|
1264 |
+
unset($post['attributes'], $attributes);
|
1265 |
+
}
|
1266 |
|
1267 |
+
// Import GPF
|
1268 |
+
if (!empty($post['gpf_data']) && is_array($post['gpf_data'])) {
|
|
|
1269 |
|
1270 |
+
update_post_meta($post_id, '_woocommerce_gpf_data', $post['gpf_data']);
|
|
|
|
|
1271 |
|
1272 |
+
unset($post['gpf_data']);
|
1273 |
+
}
|
1274 |
|
1275 |
+
if (!empty($post['upsell_skus']) && is_array($post['upsell_skus'])) {
|
1276 |
+
$this->upsell_skus[$post_id] = $post['upsell_skus'];
|
1277 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1278 |
|
1279 |
+
if (!empty($post['crosssell_skus']) && is_array($post['crosssell_skus'])) {
|
1280 |
+
$this->crosssell_skus[$post_id] = $post['crosssell_skus'];
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
add_post_meta($post_id, 'total_sales', 0);
|
1284 |
+
|
1285 |
+
if ($merging) {
|
1286 |
+
$this->add_import_result('merged', 'Product updated successfully', $post_id, $processing_product_title, $processing_product_sku);
|
1287 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> Finished merging post ID %s.', 'product-import-export-for-woo'), $post_id));
|
1288 |
+
} else {
|
1289 |
+
$this->add_import_result('imported', 'Import successful', $post_id, $processing_product_title, $processing_product_sku);
|
1290 |
+
$this->hf_log_data_change('csv-import', sprintf(__('> Finished importing post ID %s.', 'product-import-export-for-woo'), $post_id));
|
1291 |
+
}
|
1292 |
+
|
1293 |
+
do_action('wf_refresh_after_product_import', $processing_product_object); // hook for forcefully refresh product
|
1294 |
+
unset($post);
|
1295 |
+
}
|
1296 |
+
|
1297 |
+
/**
|
1298 |
* Log a row's import status
|
1299 |
*/
|
1300 |
protected function add_import_result( $status, $reason, $post_id = '', $post_title = '', $sku = '' ) {
|
product-import-export-for-woo.php
CHANGED
@@ -5,8 +5,8 @@
|
|
5 |
Description: Import and Export Products From and To your WooCommerce Store.
|
6 |
Author: WebToffee
|
7 |
Author URI: https://www.webtoffee.com/product/product-import-export-woocommerce/
|
8 |
-
Version: 1.6.
|
9 |
-
WC tested up to: 3.7.
|
10 |
License: GPLv3
|
11 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
12 |
Text Domain: product-import-export-for-woo
|
@@ -18,7 +18,7 @@ if (!defined('ABSPATH') || !is_admin()) {
|
|
18 |
|
19 |
|
20 |
if (!defined('WF_PIPE_CURRENT_VERSION')) {
|
21 |
-
define("WF_PIPE_CURRENT_VERSION", "1.6.
|
22 |
}
|
23 |
if (!defined('WF_PROD_IMP_EXP_ID')) {
|
24 |
define("WF_PROD_IMP_EXP_ID", "wf_prod_imp_exp");
|
5 |
Description: Import and Export Products From and To your WooCommerce Store.
|
6 |
Author: WebToffee
|
7 |
Author URI: https://www.webtoffee.com/product/product-import-export-woocommerce/
|
8 |
+
Version: 1.6.8
|
9 |
+
WC tested up to: 3.7.1
|
10 |
License: GPLv3
|
11 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
12 |
Text Domain: product-import-export-for-woo
|
18 |
|
19 |
|
20 |
if (!defined('WF_PIPE_CURRENT_VERSION')) {
|
21 |
+
define("WF_PIPE_CURRENT_VERSION", "1.6.8");
|
22 |
}
|
23 |
if (!defined('WF_PROD_IMP_EXP_ID')) {
|
24 |
define("WF_PROD_IMP_EXP_ID", "wf_prod_imp_exp");
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.webtoffee.com/plugins/
|
|
4 |
Tags: woocommerce product import, woocommerce import products, woocommerce export products, export woocommerce products, import products into woocommerce ,product, export, import, woocommerce ,csv
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 5.2.3
|
7 |
-
Stable tag: 1.6.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -20,7 +20,7 @@ Product import export plugin allows you to import or export WooCommerce simple p
|
|
20 |
|
21 |
🔸 Export Simple Products in to a CSV file.
|
22 |
🔸 Import Simple Products in CSV format in to WooCommerce Store.
|
23 |
-
🔸 Tested OK with WooCommerce 3.7.
|
24 |
|
25 |
|
26 |
Highlights: WooCommerce Product Export, WooCommerce Product CSV Import Suite, WooCommerce bulk product upload, WooCommerce import products with images, import amazon products to WooCommerce, Export Products to xls. Pro Version supports both Simple and Variable products.
|
@@ -153,7 +153,11 @@ By default, admin and store manager are given access to export orders from your
|
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
-
= 1.6.
|
|
|
|
|
|
|
|
|
157 |
* Content Update.
|
158 |
|
159 |
= 1.6.6 =
|
4 |
Tags: woocommerce product import, woocommerce import products, woocommerce export products, export woocommerce products, import products into woocommerce ,product, export, import, woocommerce ,csv
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 5.2.3
|
7 |
+
Stable tag: 1.6.8
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
20 |
|
21 |
🔸 Export Simple Products in to a CSV file.
|
22 |
🔸 Import Simple Products in CSV format in to WooCommerce Store.
|
23 |
+
🔸 Tested OK with WooCommerce 3.7.1.
|
24 |
|
25 |
|
26 |
Highlights: WooCommerce Product Export, WooCommerce Product CSV Import Suite, WooCommerce bulk product upload, WooCommerce import products with images, import amazon products to WooCommerce, Export Products to xls. Pro Version supports both Simple and Variable products.
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
+
= 1.6.8 =
|
157 |
+
* Bug Fix: Duplicating SKU when updating product with ID
|
158 |
+
* Tested OK with WC 3.7.1
|
159 |
+
|
160 |
+
= 1.6.7 =
|
161 |
* Content Update.
|
162 |
|
163 |
= 1.6.6 =
|