Merge pull request #15309 from woocommerce/feature/product-csv-normalize-names

Normalize importer/exporter column names
This commit is contained in:
Claudio Sanches 2017-05-26 18:44:59 -03:00 committed by GitHub
commit 780006e9c1
2 changed files with 34 additions and 34 deletions

View File

@ -402,11 +402,11 @@ class WC_Product_CSV_Importer_Controller {
'published' => __( 'Published', 'woocommerce' ), 'published' => __( 'Published', 'woocommerce' ),
'featured' => __( 'Is featured?', 'woocommerce' ), 'featured' => __( 'Is featured?', 'woocommerce' ),
'catalog_visibility' => __( 'Visibility in catalog', 'woocommerce' ), 'catalog_visibility' => __( 'Visibility in catalog', 'woocommerce' ),
'short_description' => __( 'Short Description', 'woocommerce' ), 'short_description' => __( 'Short description', 'woocommerce' ),
'description' => __( 'Description', 'woocommerce' ), 'description' => __( 'Description', 'woocommerce' ),
'date_on_sale_from' => __( 'Date sale price starts', 'woocommerce' ), 'date_on_sale_from' => __( 'Date sale price starts', 'woocommerce' ),
'date_on_sale_to' => __( 'Date sale price ends', 'woocommerce' ), 'date_on_sale_to' => __( 'Date sale price ends', 'woocommerce' ),
'tax_status' => __( 'Tax Class', 'woocommerce' ), 'tax_status' => __( 'Tax class', 'woocommerce' ),
'stock_status' => __( 'In stock?', 'woocommerce' ), 'stock_status' => __( 'In stock?', 'woocommerce' ),
'stock' => __( 'Stock', 'woocommerce' ), 'stock' => __( 'Stock', 'woocommerce' ),
'backorders' => __( 'Backorders allowed?', 'woocommerce' ), 'backorders' => __( 'Backorders allowed?', 'woocommerce' ),
@ -416,15 +416,15 @@ class WC_Product_CSV_Importer_Controller {
'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ), 'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ),
'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ), 'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ),
'reviews_allowed' => __( 'Allow customer reviews?', 'woocommerce' ), 'reviews_allowed' => __( 'Allow customer reviews?', 'woocommerce' ),
'purchase_note' => __( 'Purchase Note', 'woocommerce' ), 'purchase_note' => __( 'Purchase note', 'woocommerce' ),
'sale_price' => __( 'Sale Price', 'woocommerce' ), 'sale_price' => __( 'Sale price', 'woocommerce' ),
'regular_price' => __( 'Regular Price', 'woocommerce' ), 'regular_price' => __( 'Regular price', 'woocommerce' ),
'category_ids' => __( 'Categories', 'woocommerce' ), 'category_ids' => __( 'Categories', 'woocommerce' ),
'tag_ids' => __( 'Tags', 'woocommerce' ), 'tag_ids' => __( 'Tags', 'woocommerce' ),
'shipping_class_id' => __( 'Shipping Class', 'woocommerce' ), 'shipping_class_id' => __( 'Shipping class', 'woocommerce' ),
'image_id' => __( 'Images', 'woocommerce' ), 'image_id' => __( 'Images', 'woocommerce' ),
'download_limit' => __( 'Download Limit', 'woocommerce' ), 'download_limit' => __( 'Download limit', 'woocommerce' ),
'download_expiry' => __( 'Download Expiry Days', 'woocommerce' ), 'download_expiry' => __( 'Download expiry days', 'woocommerce' ),
'parent_id' => __( 'Parent', 'woocommerce' ), 'parent_id' => __( 'Parent', 'woocommerce' ),
'upsell_ids' => __( 'Upsells', 'woocommerce' ), 'upsell_ids' => __( 'Upsells', 'woocommerce' ),
'cross_sell_ids' => __( 'Cross-sells', 'woocommerce' ), 'cross_sell_ids' => __( 'Cross-sells', 'woocommerce' ),
@ -436,11 +436,11 @@ class WC_Product_CSV_Importer_Controller {
array( $this, 'sanitize_special_column_name_regex' ), array( $this, 'sanitize_special_column_name_regex' ),
apply_filters( 'woocommerce_csv_product_import_mapping_special_columns', apply_filters( 'woocommerce_csv_product_import_mapping_special_columns',
array( array(
'attributes:name' => __( 'Attribute %d Name', 'woocommerce' ), 'attributes:name' => __( 'Attribute %d name', 'woocommerce' ),
'attributes:value' => __( 'Attribute %d Value(s)', 'woocommerce' ), 'attributes:value' => __( 'Attribute %d value(s)', 'woocommerce' ),
'attributes:visible' => __( 'Attribute %d Visible', 'woocommerce' ), 'attributes:visible' => __( 'Attribute %d visible', 'woocommerce' ),
'attributes:default' => __( 'Attribute %d Default', 'woocommerce' ), 'attributes:default' => __( 'Attribute %d default', 'woocommerce' ),
'downloads:name' => __( 'Download %d Name', 'woocommerce' ), 'downloads:name' => __( 'Download %d name', 'woocommerce' ),
'downloads:url' => __( 'Download %d URL', 'woocommerce' ), 'downloads:url' => __( 'Download %d URL', 'woocommerce' ),
'meta:' => __( 'Meta: %s', 'woocommerce' ), 'meta:' => __( 'Meta: %s', 'woocommerce' ),
) )
@ -505,12 +505,12 @@ class WC_Product_CSV_Importer_Controller {
'published' => __( 'Published', 'woocommerce' ), 'published' => __( 'Published', 'woocommerce' ),
'featured' => __( 'Is featured?', 'woocommerce' ), 'featured' => __( 'Is featured?', 'woocommerce' ),
'catalog_visibility' => __( 'Visibility in catalog', 'woocommerce' ), 'catalog_visibility' => __( 'Visibility in catalog', 'woocommerce' ),
'short_description' => __( 'Short Description', 'woocommerce' ), 'short_description' => __( 'Short description', 'woocommerce' ),
'description' => __( 'Description', 'woocommerce' ), 'description' => __( 'Description', 'woocommerce' ),
'date_on_sale_from' => __( 'Date sale price starts', 'woocommerce' ), 'date_on_sale_from' => __( 'Date sale price starts', 'woocommerce' ),
'date_on_sale_to' => __( 'Date sale price ends', 'woocommerce' ), 'date_on_sale_to' => __( 'Date sale price ends', 'woocommerce' ),
'tax_status' => __( 'Tax Status', 'woocommerce' ), 'tax_status' => __( 'Tax status', 'woocommerce' ),
'tax_class' => __( 'Tax Class', 'woocommerce' ), 'tax_class' => __( 'Tax class', 'woocommerce' ),
'stock_status' => __( 'In stock?', 'woocommerce' ), 'stock_status' => __( 'In stock?', 'woocommerce' ),
'backorders' => __( 'Backorders allowed?', 'woocommerce' ), 'backorders' => __( 'Backorders allowed?', 'woocommerce' ),
'sold_individually' => __( 'Sold individually?', 'woocommerce' ), 'sold_individually' => __( 'Sold individually?', 'woocommerce' ),
@ -528,13 +528,13 @@ class WC_Product_CSV_Importer_Controller {
), ),
), ),
'reviews_allowed' => __( 'Allow customer reviews?', 'woocommerce' ), 'reviews_allowed' => __( 'Allow customer reviews?', 'woocommerce' ),
'purchase_note' => __( 'Purchase Note', 'woocommerce' ), 'purchase_note' => __( 'Purchase note', 'woocommerce' ),
'sale_price' => __( 'Sale Price', 'woocommerce' ), 'sale_price' => __( 'Sale price', 'woocommerce' ),
'regular_price' => __( 'Regular Price', 'woocommerce' ), 'regular_price' => __( 'Regular Price', 'woocommerce' ),
'stock' => __( 'Stock', 'woocommerce' ), 'stock' => __( 'Stock', 'woocommerce' ),
'category_ids' => __( 'Categories', 'woocommerce' ), 'category_ids' => __( 'Categories', 'woocommerce' ),
'tag_ids' => __( 'Tags', 'woocommerce' ), 'tag_ids' => __( 'Tags', 'woocommerce' ),
'shipping_class_id' => __( 'Shipping Class', 'woocommerce' ), 'shipping_class_id' => __( 'Shipping class', 'woocommerce' ),
'image_id' => __( 'Images', 'woocommerce' ), 'image_id' => __( 'Images', 'woocommerce' ),
'parent_id' => __( 'Parent', 'woocommerce' ), 'parent_id' => __( 'Parent', 'woocommerce' ),
'upsell_ids' => __( 'Upsells', 'woocommerce' ), 'upsell_ids' => __( 'Upsells', 'woocommerce' ),
@ -549,10 +549,10 @@ class WC_Product_CSV_Importer_Controller {
'downloads' => array( 'downloads' => array(
'name' => __( 'Downloads', 'woocommerce' ), 'name' => __( 'Downloads', 'woocommerce' ),
'options' => array( 'options' => array(
'downloads:name' . $index => __( 'Download Name', 'woocommerce' ), 'downloads:name' . $index => __( 'Download name', 'woocommerce' ),
'downloads:url' . $index => __( 'Download URL', 'woocommerce' ), 'downloads:url' . $index => __( 'Download URL', 'woocommerce' ),
'download_limit' => __( 'Download Limit', 'woocommerce' ), 'download_limit' => __( 'Download limit', 'woocommerce' ),
'download_expiry' => __( 'Download Expiry Days', 'woocommerce' ), 'download_expiry' => __( 'Download expiry days', 'woocommerce' ),
), ),
), ),
'attributes' => array( 'attributes' => array(

View File

@ -84,11 +84,11 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
'published' => __( 'Published', 'woocommerce' ), 'published' => __( 'Published', 'woocommerce' ),
'featured' => __( 'Is featured?', 'woocommerce' ), 'featured' => __( 'Is featured?', 'woocommerce' ),
'catalog_visibility' => __( 'Visibility in catalog', 'woocommerce' ), 'catalog_visibility' => __( 'Visibility in catalog', 'woocommerce' ),
'short_description' => __( 'Short Description', 'woocommerce' ), 'short_description' => __( 'Short description', 'woocommerce' ),
'description' => __( 'Description', 'woocommerce' ), 'description' => __( 'Description', 'woocommerce' ),
'date_on_sale_from' => __( 'Date sale price starts', 'woocommerce' ), 'date_on_sale_from' => __( 'Date sale price starts', 'woocommerce' ),
'date_on_sale_to' => __( 'Date sale price ends', 'woocommerce' ), 'date_on_sale_to' => __( 'Date sale price ends', 'woocommerce' ),
'tax_status' => __( 'Tax Class', 'woocommerce' ), 'tax_status' => __( 'Tax class', 'woocommerce' ),
'stock_status' => __( 'In stock?', 'woocommerce' ), 'stock_status' => __( 'In stock?', 'woocommerce' ),
'stock' => __( 'Stock', 'woocommerce' ), 'stock' => __( 'Stock', 'woocommerce' ),
'backorders' => __( 'Backorders allowed?', 'woocommerce' ), 'backorders' => __( 'Backorders allowed?', 'woocommerce' ),
@ -98,15 +98,15 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ), 'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ),
'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ), 'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ),
'reviews_allowed' => __( 'Allow customer reviews?', 'woocommerce' ), 'reviews_allowed' => __( 'Allow customer reviews?', 'woocommerce' ),
'purchase_note' => __( 'Purchase Note', 'woocommerce' ), 'purchase_note' => __( 'Purchase note', 'woocommerce' ),
'sale_price' => __( 'Sale Price', 'woocommerce' ), 'sale_price' => __( 'Sale price', 'woocommerce' ),
'regular_price' => __( 'Regular Price', 'woocommerce' ), 'regular_price' => __( 'Regular price', 'woocommerce' ),
'category_ids' => __( 'Categories', 'woocommerce' ), 'category_ids' => __( 'Categories', 'woocommerce' ),
'tag_ids' => __( 'Tags', 'woocommerce' ), 'tag_ids' => __( 'Tags', 'woocommerce' ),
'shipping_class_id' => __( 'Shipping Class', 'woocommerce' ), 'shipping_class_id' => __( 'Shipping class', 'woocommerce' ),
'images' => __( 'Images', 'woocommerce' ), 'images' => __( 'Images', 'woocommerce' ),
'download_limit' => __( 'Download Limit', 'woocommerce' ), 'download_limit' => __( 'Download limit', 'woocommerce' ),
'download_expiry' => __( 'Download Expiry Days', 'woocommerce' ), 'download_expiry' => __( 'Download expiry days', 'woocommerce' ),
'parent_id' => __( 'Parent', 'woocommerce' ), 'parent_id' => __( 'Parent', 'woocommerce' ),
'upsell_ids' => __( 'Upsells', 'woocommerce' ), 'upsell_ids' => __( 'Upsells', 'woocommerce' ),
'cross_sell_ids' => __( 'Cross-sells', 'woocommerce' ), 'cross_sell_ids' => __( 'Cross-sells', 'woocommerce' ),
@ -411,7 +411,7 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
if ( $downloads ) { if ( $downloads ) {
$i = 1; $i = 1;
foreach ( $downloads as $download ) { foreach ( $downloads as $download ) {
$this->column_names[ 'downloads:name' . $i ] = sprintf( __( 'Download %d Name', 'woocommerce' ), $i ); $this->column_names[ 'downloads:name' . $i ] = sprintf( __( 'Download %d name', 'woocommerce' ), $i );
$this->column_names[ 'downloads:url' . $i ] = sprintf( __( 'Download %d URL', 'woocommerce' ), $i ); $this->column_names[ 'downloads:url' . $i ] = sprintf( __( 'Download %d URL', 'woocommerce' ), $i );
$row[ 'downloads:name' . $i ] = $download->get_name(); $row[ 'downloads:name' . $i ] = $download->get_name();
$row[ 'downloads:url' . $i ] = $download->get_file(); $row[ 'downloads:url' . $i ] = $download->get_file();
@ -436,8 +436,8 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
if ( count( $attributes ) ) { if ( count( $attributes ) ) {
$i = 1; $i = 1;
foreach ( $attributes as $attribute_name => $attribute ) { foreach ( $attributes as $attribute_name => $attribute ) {
$this->column_names[ 'attributes:name' . $i ] = sprintf( __( 'Attribute %d Name', 'woocommerce' ), $i ); $this->column_names[ 'attributes:name' . $i ] = sprintf( __( 'Attribute %d name', 'woocommerce' ), $i );
$this->column_names[ 'attributes:value' . $i ] = sprintf( __( 'Attribute %d Value(s)', 'woocommerce' ), $i ); $this->column_names[ 'attributes:value' . $i ] = sprintf( __( 'Attribute %d value(s)', 'woocommerce' ), $i );
if ( is_a( $attribute, 'WC_Product_Attribute' ) ) { if ( is_a( $attribute, 'WC_Product_Attribute' ) ) {
$row[ 'attributes:name' . $i ] = wc_attribute_label( $attribute->get_name(), $product ); $row[ 'attributes:name' . $i ] = wc_attribute_label( $attribute->get_name(), $product );
@ -466,7 +466,7 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
} }
if ( $product->is_type( 'variable' ) && isset( $default_attributes[ sanitize_title( $attribute_name ) ] ) ) { if ( $product->is_type( 'variable' ) && isset( $default_attributes[ sanitize_title( $attribute_name ) ] ) ) {
$this->column_names[ 'attributes:default' . $i ] = sprintf( __( 'Attribute %d Default', 'woocommerce' ), $i ); $this->column_names[ 'attributes:default' . $i ] = sprintf( __( 'Attribute %d default', 'woocommerce' ), $i );
$default_value = $default_attributes[ sanitize_title( $attribute_name ) ]; $default_value = $default_attributes[ sanitize_title( $attribute_name ) ];
if ( 0 === strpos( $attribute_name, 'pa_' ) ) { if ( 0 === strpos( $attribute_name, 'pa_' ) ) {