예제 #1
0
 public static function generateImportTemplate(&$export, $file_path = '', $foundPosts = 0, $link_to_import = true)
 {
     $exportOptions = $export->options;
     $custom_type = empty($exportOptions['cpt']) ? 'post' : $exportOptions['cpt'][0];
     // Do not create an import template for WooCommerce Refunds
     // if ( empty($export->parent_id) and in_array($custom_type, array('shop_order_refund'))) return false;
     // Generate template for WP All Import
     if ($exportOptions['is_generate_templates']) {
         self::$templateOptions = array('type' => (!empty($exportOptions['cpt']) and $exportOptions['cpt'][0] == 'page') ? 'page' : 'post', 'wizard_type' => 'new', 'deligate' => 'wpallexport', 'custom_type' => XmlExportEngine::$is_user_export ? 'import_users' : $custom_type, 'status' => 'xpath', 'is_multiple_page_parent' => 'no', 'unique_key' => '', 'acf' => array(), 'fields' => array(), 'is_multiple_field_value' => array(), 'multiple_value' => array(), 'fields_delimiter' => array(), 'update_all_data' => 'no', 'is_update_status' => 0, 'is_update_title' => 0, 'is_update_author' => 0, 'is_update_slug' => 0, 'is_update_content' => 0, 'is_update_excerpt' => 0, 'is_update_dates' => 0, 'is_update_menu_order' => 0, 'is_update_parent' => 0, 'is_update_attachments' => 0, 'is_update_acf' => 0, 'update_acf_logic' => 'only', 'acf_list' => '', 'is_update_product_type' => 1, 'is_update_attributes' => 0, 'update_attributes_logic' => 'only', 'attributes_list' => '', 'is_update_images' => 0, 'is_update_custom_fields' => 0, 'update_custom_fields_logic' => 'only', 'custom_fields_list' => '', 'is_update_categories' => 0, 'update_categories_logic' => 'only', 'taxonomies_list' => '', 'export_id' => $export->id);
         if (in_array('product', $exportOptions['cpt'])) {
             $default = array('is_multiple_product_type' => 'yes', 'multiple_product_type' => 'simple', 'is_product_virtual' => 'no', 'is_product_downloadable' => 'no', 'is_product_enabled' => 'yes', 'is_variation_enabled' => 'yes', 'is_product_featured' => 'no', 'is_product_visibility' => 'visible', 'is_multiple_product_tax_status' => 'yes', 'multiple_product_tax_status' => 'none', 'is_multiple_product_tax_class' => 'yes', 'is_product_manage_stock' => 'no', 'product_stock_status' => 'auto', 'product_allow_backorders' => 'no', 'product_sold_individually' => 'no', 'is_multiple_product_shipping_class' => 'yes', 'is_multiple_grouping_product' => 'yes', 'is_product_enable_reviews' => 'no', 'single_sale_price_dates_from' => 'now', 'single_sale_price_dates_to' => 'now', 'product_files_delim' => ',', 'product_files_names_delim' => ',', 'matching_parent' => 'auto', 'parent_indicator' => 'custom field', 'missing_records_stock_status' => 0, 'is_variable_sale_price_shedule' => 0, 'is_variable_product_virtual' => 'no', 'is_variable_product_manage_stock' => 'no', 'is_multiple_variable_product_shipping_class' => 'yes', 'is_multiple_variable_product_tax_class' => 'yes', 'multiple_variable_product_tax_class' => 'parent', 'variable_stock_status' => 'instock', 'variable_allow_backorders' => 'no', 'is_variable_product_downloadable' => 'no', 'variable_product_files_delim' => ',', 'variable_product_files_names_delim' => ',', 'is_variable_product_enabled' => 'yes', 'first_is_parent' => 'yes', 'default_attributes_type' => 'first', 'disable_sku_matching' => 1, 'disable_prepare_price' => 1, 'convert_decimal_separator' => 1, 'grouping_indicator' => 'xpath', 'is_update_product_type' => 1, 'make_simple_product' => 1, 'single_product_regular_price_adjust_type' => '%', 'single_product_sale_price_adjust_type' => '%', 'is_variation_product_manage_stock' => 'no', 'variation_stock_status' => 'auto');
             self::$templateOptions = array_replace_recursive(self::$templateOptions, $default);
             self::$templateOptions['_virtual'] = 1;
             self::$templateOptions['_downloadable'] = 1;
             self::$templateOptions['put_variation_image_to_gallery'] = 1;
             self::$templateOptions['disable_auto_sku_generation'] = 1;
         }
         if (in_array('shop_order', $exportOptions['cpt'])) {
             self::$templateOptions['update_all_data'] = 'no';
             self::$templateOptions['is_update_status'] = 0;
             self::$templateOptions['is_update_dates'] = 0;
             self::$templateOptions['is_update_excerpt'] = 0;
             // $default = PMWI_Plugin::get_default_import_options();
             // self::$templateOptions['pmwi_order'] = $default['pmwi_order'];
             self::$templateOptions['pmwi_order'] = array();
             self::$templateOptions['pmwi_order']['is_update_billing_details'] = 0;
             self::$templateOptions['pmwi_order']['is_update_shipping_details'] = 0;
             self::$templateOptions['pmwi_order']['is_update_payment'] = 0;
             self::$templateOptions['pmwi_order']['is_update_notes'] = 0;
             self::$templateOptions['pmwi_order']['is_update_products'] = 0;
             self::$templateOptions['pmwi_order']['is_update_fees'] = 0;
             self::$templateOptions['pmwi_order']['is_update_coupons'] = 0;
             self::$templateOptions['pmwi_order']['is_update_shipping'] = 0;
             self::$templateOptions['pmwi_order']['is_update_taxes'] = 0;
             self::$templateOptions['pmwi_order']['is_update_refunds'] = 0;
             self::$templateOptions['pmwi_order']['is_update_total'] = 0;
             self::$templateOptions['pmwi_order']['status'] = 'wc-pending';
             self::$templateOptions['pmwi_order']['billing_source'] = 'existing';
             self::$templateOptions['pmwi_order']['billing_source_match_by'] = 'username';
             self::$templateOptions['pmwi_order']['shipping_source'] = 'copy';
             self::$templateOptions['pmwi_order']['products_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['products_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['products_source'] = 'existing';
             self::$templateOptions['pmwi_order']['fees_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['fees_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['coupons_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['coupons_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['shipping_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['shipping_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['taxes_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['taxes_repeater_mode_separator'] = '|';
             self::$templateOptions['pmwi_order']['order_total_logic'] = 'auto';
             self::$templateOptions['pmwi_order']['order_refund_date'] = 'now';
             self::$templateOptions['pmwi_order']['order_refund_issued_source'] = 'existing';
             self::$templateOptions['pmwi_order']['order_refund_issued_match_by'] = 'username';
             self::$templateOptions['pmwi_order']['notes_repeater_mode'] = 'csv';
             self::$templateOptions['pmwi_order']['notes_repeater_mode_separator'] = '|';
         }
         if (XmlExportEngine::$is_user_export) {
             self::$templateOptions['is_update_first_name'] = 0;
             self::$templateOptions['is_update_last_name'] = 0;
             self::$templateOptions['is_update_role'] = 0;
             self::$templateOptions['is_update_nickname'] = 0;
             self::$templateOptions['is_update_description'] = 0;
             self::$templateOptions['is_update_login'] = 0;
             self::$templateOptions['is_update_password'] = 0;
             self::$templateOptions['is_update_nicename'] = 0;
             self::$templateOptions['is_update_email'] = 0;
             self::$templateOptions['is_update_registered'] = 0;
             self::$templateOptions['is_update_display_name'] = 0;
             self::$templateOptions['is_update_url'] = 0;
         }
         self::prepare_import_template($exportOptions);
         $tpl_options = self::$templateOptions;
         if ('csv' == $exportOptions['export_to']) {
             $tpl_options['delimiter'] = $exportOptions['delimiter'];
             $tpl_options['root_element'] = 'node';
         } else {
             $tpl_options['root_element'] = $exportOptions['record_xml_tag'];
         }
         $tpl_options['update_all_data'] = 'yes';
         $tpl_options['is_update_status'] = 1;
         $tpl_options['is_update_title'] = 1;
         $tpl_options['is_update_author'] = 1;
         $tpl_options['is_update_slug'] = 1;
         $tpl_options['is_update_content'] = 1;
         $tpl_options['is_update_excerpt'] = 1;
         $tpl_options['is_update_dates'] = 1;
         $tpl_options['is_update_menu_order'] = 1;
         $tpl_options['is_update_parent'] = 1;
         $tpl_options['is_update_attachments'] = 1;
         $tpl_options['is_update_acf'] = 1;
         $tpl_options['update_acf_logic'] = 'full_update';
         $tpl_options['acf_list'] = '';
         $tpl_options['is_update_product_type'] = 1;
         $tpl_options['is_update_attributes'] = 1;
         $tpl_options['update_attributes_logic'] = 'full_update';
         $tpl_options['attributes_list'] = '';
         $tpl_options['is_update_images'] = 1;
         $tpl_options['is_update_custom_fields'] = 1;
         $tpl_options['update_custom_fields_logic'] = 'full_update';
         $tpl_options['custom_fields_list'] = '';
         $tpl_options['is_update_categories'] = 1;
         $tpl_options['update_categories_logic'] = 'full_update';
         $tpl_options['taxonomies_list'] = '';
         $tpl_data = array('name' => $exportOptions['template_name'], 'is_keep_linebreaks' => 1, 'is_leave_html' => 0, 'fix_characters' => 0, 'options' => $tpl_options);
         $exportOptions['tpl_data'] = $tpl_data;
         $export->set(array('options' => $exportOptions))->save();
     }
     $link_to_import and $export->options['is_generate_import'] and self::link_template_to_import($export, $file_path, $foundPosts);
 }
예제 #2
0
 public static function generateImportTemplate(&$export, $file_path = '', $foundPosts = 0, $link_to_import = true)
 {
     $exportOptions = $export->options;
     $custom_type = empty($exportOptions['cpt']) ? 'post' : $exportOptions['cpt'][0];
     // Do not create an import template for WooCommerce Refunds
     // if ( empty($export->parent_id) and in_array($custom_type, array('shop_order_refund'))) return false;
     // Generate template for WP All Import
     if ($exportOptions['is_generate_templates']) {
         self::$templateOptions = array('type' => (!empty($exportOptions['cpt']) and $exportOptions['cpt'][0] == 'page') ? 'page' : 'post', 'wizard_type' => 'new', 'deligate' => 'wpallexport', 'custom_type' => XmlExportEngine::$is_user_export ? 'import_users' : $custom_type, 'status' => 'xpath', 'is_multiple_page_parent' => 'no', 'unique_key' => '', 'acf' => array(), 'fields' => array(), 'is_multiple_field_value' => array(), 'multiple_value' => array(), 'fields_delimiter' => array(), 'update_all_data' => 'no', 'is_update_status' => 0, 'is_update_title' => 0, 'is_update_author' => 0, 'is_update_slug' => 0, 'is_update_content' => 0, 'is_update_excerpt' => 0, 'is_update_dates' => 0, 'is_update_menu_order' => 0, 'is_update_parent' => 0, 'is_update_attachments' => 0, 'is_update_acf' => 0, 'update_acf_logic' => 'only', 'acf_list' => '', 'is_update_product_type' => 1, 'is_update_attributes' => 0, 'update_attributes_logic' => 'only', 'attributes_list' => '', 'is_update_images' => 0, 'is_update_custom_fields' => 0, 'update_custom_fields_logic' => 'only', 'custom_fields_list' => '', 'is_update_categories' => 0, 'update_categories_logic' => 'only', 'taxonomies_list' => '', 'export_id' => $export->id);
         if (in_array('product', $exportOptions['cpt']) and class_exists('PMWI_Plugin')) {
             $default = PMWI_Plugin::get_default_import_options();
             self::$templateOptions = array_replace_recursive(self::$templateOptions, $default);
             self::$templateOptions['_virtual'] = 1;
             self::$templateOptions['_downloadable'] = 1;
             self::$templateOptions['put_variation_image_to_gallery'] = 1;
             self::$templateOptions['disable_auto_sku_generation'] = 1;
         }
         if (in_array('shop_order', $exportOptions['cpt']) and class_exists('PMWI_Plugin')) {
             self::$templateOptions['update_all_data'] = 'no';
             self::$templateOptions['is_update_status'] = 0;
             self::$templateOptions['is_update_dates'] = 0;
             self::$templateOptions['is_update_excerpt'] = 0;
             $default = PMWI_Plugin::get_default_import_options();
             self::$templateOptions['pmwi_order'] = $default['pmwi_order'];
             self::$templateOptions['pmwi_order']['is_update_billing_details'] = 0;
             self::$templateOptions['pmwi_order']['is_update_shipping_details'] = 0;
             self::$templateOptions['pmwi_order']['is_update_payment'] = 0;
             self::$templateOptions['pmwi_order']['is_update_notes'] = 0;
             self::$templateOptions['pmwi_order']['is_update_products'] = 0;
             self::$templateOptions['pmwi_order']['is_update_fees'] = 0;
             self::$templateOptions['pmwi_order']['is_update_coupons'] = 0;
             self::$templateOptions['pmwi_order']['is_update_shipping'] = 0;
             self::$templateOptions['pmwi_order']['is_update_taxes'] = 0;
             self::$templateOptions['pmwi_order']['is_update_refunds'] = 0;
             self::$templateOptions['pmwi_order']['is_update_total'] = 0;
         }
         if (XmlExportEngine::$is_user_export) {
             self::$templateOptions['is_update_first_name'] = 0;
             self::$templateOptions['is_update_last_name'] = 0;
             self::$templateOptions['is_update_role'] = 0;
             self::$templateOptions['is_update_nickname'] = 0;
             self::$templateOptions['is_update_description'] = 0;
             self::$templateOptions['is_update_login'] = 0;
             self::$templateOptions['is_update_password'] = 0;
             self::$templateOptions['is_update_nicename'] = 0;
             self::$templateOptions['is_update_email'] = 0;
             self::$templateOptions['is_update_registered'] = 0;
             self::$templateOptions['is_update_display_name'] = 0;
             self::$templateOptions['is_update_url'] = 0;
         }
         self::prepare_import_template($exportOptions);
         $tpl_options = self::$templateOptions;
         if ('csv' == $exportOptions['export_to']) {
             $tpl_options['delimiter'] = $exportOptions['delimiter'];
             $tpl_options['root_element'] = 'node';
         } else {
             $tpl_options['root_element'] = $exportOptions['record_xml_tag'];
         }
         $tpl_options['update_all_data'] = 'yes';
         $tpl_options['is_update_status'] = 1;
         $tpl_options['is_update_title'] = 1;
         $tpl_options['is_update_author'] = 1;
         $tpl_options['is_update_slug'] = 1;
         $tpl_options['is_update_content'] = 1;
         $tpl_options['is_update_excerpt'] = 1;
         $tpl_options['is_update_dates'] = 1;
         $tpl_options['is_update_menu_order'] = 1;
         $tpl_options['is_update_parent'] = 1;
         $tpl_options['is_update_attachments'] = 1;
         $tpl_options['is_update_acf'] = 1;
         $tpl_options['update_acf_logic'] = 'full_update';
         $tpl_options['acf_list'] = '';
         $tpl_options['is_update_product_type'] = 1;
         $tpl_options['is_update_attributes'] = 1;
         $tpl_options['update_attributes_logic'] = 'full_update';
         $tpl_options['attributes_list'] = '';
         $tpl_options['is_update_images'] = 1;
         $tpl_options['is_update_custom_fields'] = 1;
         $tpl_options['update_custom_fields_logic'] = 'full_update';
         $tpl_options['custom_fields_list'] = '';
         $tpl_options['is_update_categories'] = 1;
         $tpl_options['update_categories_logic'] = 'full_update';
         $tpl_options['taxonomies_list'] = '';
         $tpl_data = array('name' => $exportOptions['template_name'], 'is_keep_linebreaks' => 0, 'is_leave_html' => 0, 'fix_characters' => 0, 'options' => $tpl_options);
         $exportOptions['tpl_data'] = $tpl_data;
         $export->set(array('options' => $exportOptions))->save();
     }
     $link_to_import and $export->options['is_generate_import'] and self::link_template_to_import($export, $file_path, $foundPosts);
 }