Merge pull request #16843 from woocommerce/fix/16800
Make importer columns case-insensitive
This commit is contained in:
commit
de1eceb95e
|
@ -408,26 +408,33 @@ class WC_Product_CSV_Importer_Controller {
|
|||
__( 'Position', 'woocommerce' ) => 'menu_order',
|
||||
) );
|
||||
|
||||
// Normalize the columns so they are case-insensitive.
|
||||
$normalized_default_columns = array();
|
||||
foreach ( $default_columns as $key => $val ) {
|
||||
$normalized_default_columns[ strtolower( $key ) ] = $val;
|
||||
}
|
||||
|
||||
$special_columns = $this->get_special_columns( apply_filters( 'woocommerce_csv_product_import_mapping_special_columns',
|
||||
array(
|
||||
__( 'Attribute %d name', 'woocommerce' ) => 'attributes:name',
|
||||
__( 'Attribute %d value(s)', 'woocommerce' ) => 'attributes:value',
|
||||
__( 'Attribute %d visible', 'woocommerce' ) => 'attributes:visible',
|
||||
__( 'Attribute %d global', 'woocommerce' ) => 'attributes:taxonomy',
|
||||
__( 'Attribute %d default', 'woocommerce' ) => 'attributes:default',
|
||||
__( 'Download %d name', 'woocommerce' ) => 'downloads:name',
|
||||
__( 'Download %d URL', 'woocommerce' ) => 'downloads:url',
|
||||
__( 'Meta: %s', 'woocommerce' ) => 'meta:',
|
||||
__( 'attribute %d name', 'woocommerce' ) => 'attributes:name',
|
||||
__( 'attribute %d value(s)', 'woocommerce' ) => 'attributes:value',
|
||||
__( 'attribute %d visible', 'woocommerce' ) => 'attributes:visible',
|
||||
__( 'attribute %d global', 'woocommerce' ) => 'attributes:taxonomy',
|
||||
__( 'attribute %d default', 'woocommerce' ) => 'attributes:default',
|
||||
__( 'download %d name', 'woocommerce' ) => 'downloads:name',
|
||||
__( 'download %d url', 'woocommerce' ) => 'downloads:url',
|
||||
__( 'meta: %s', 'woocommerce' ) => 'meta:',
|
||||
)
|
||||
) );
|
||||
|
||||
$headers = array();
|
||||
foreach ( $raw_headers as $key => $field ) {
|
||||
$field = strtolower( $field );
|
||||
$index = $num_indexes ? $key : $field;
|
||||
$headers[ $index ] = $field;
|
||||
|
||||
if ( isset( $default_columns[ $field ] ) ) {
|
||||
$headers[ $index ] = $default_columns[ $field ];
|
||||
if ( isset( $normalized_default_columns[ $field ] ) ) {
|
||||
$headers[ $index ] = $normalized_default_columns[ $field ];
|
||||
} else {
|
||||
foreach ( $special_columns as $regex => $special_key ) {
|
||||
if ( preg_match( $regex, $field, $matches ) ) {
|
||||
|
|
|
@ -66,10 +66,10 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
|
|||
'Cross-sells' => 'cross_sell_ids',
|
||||
'Grouped products' => 'grouped_products',
|
||||
'External URL' => 'product_url',
|
||||
'Button text' => 'button_text',
|
||||
'BUTTON TEXT' => 'button_text',
|
||||
'Position' => 'menu_order',
|
||||
'Attribute 1 name' => 'attributes:name1',
|
||||
'Attribute 1 value(s)' => 'attributes:value2',
|
||||
'Attribute 1 Name' => 'attributes:name1',
|
||||
'Attribute 1 Value(s)' => 'attributes:value2',
|
||||
'Attribute 2 name' => 'attributes:name2',
|
||||
'Attribute 2 value(s)' => 'attributes:value2',
|
||||
'Attribute 1 default' => 'attributes:default1',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Type,SKU,Name,Published,Is featured?,Visibility in catalog,Short description,Description,Date sale price starts,Date sale price ends,Tax status,Tax class,In stock?,Stock,Backorders allowed?,Sold individually?,Weight (kg),Length (cm),Width (cm),Height (cm),Allow customer reviews?,Purchase note,Sale price,Regular price,Categories,Tags,Shipping class,Images,Download limit,Download expiry days,Parent,Upsells,Cross-sells,Grouped products,External URL,Button text,Position,Attribute 1 name,Attribute 1 value(s),Attribute 2 name,Attribute 2 value(s),Attribute 1 default,Attribute 2 default,Download 1 name,Download 1 URL
|
||||
Type,SKU,Name,Published,Is featured?,Visibility in catalog,Short description,Description,Date sale price starts,Date sale price ends,Tax status,Tax class,In stock?,Stock,Backorders allowed?,Sold individually?,Weight (kg),Length (cm),Width (cm),Height (cm),Allow customer reviews?,Purchase note,Sale price,Regular price,Categories,Tags,Shipping class,Images,Download limit,Download expiry days,Parent,Upsells,Cross-sells,Grouped products,External URL,BUTTON TEXT,Position,Attribute 1 Name,Attribute 1 Value(s),Attribute 2 name,Attribute 2 value(s),Attribute 1 default,Attribute 2 default,Download 1 name,Download 1 URL
|
||||
simple,WOOLOGO,Woo Logo,1,,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",2017-01-01,2030-01-01 0:00:00,taxable,standard,1,5,notify,1,1,1,20,40,1,Lorem ipsum dolor sit amet.,18,20,"Clothing, Clothing > T-shirts",,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_1_front.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_1_back.jpg",,,,WOOALBUM,WOOALBUM,,,,0,Color,Red,,,,,,
|
||||
"simple, downloadable, virtual",WOOALBUM,Woo Album #1,1,1,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,,,,,,,,1,Lorem ipsum dolor sit amet.,,5,"Music > Albums, Music",Woo,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_1_angle.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_1_flat.jpg",10,90,,WOOLOGO,WOOLOGO,,,,1,Label,WooCommerce,Vinyl,180-Gram,,,Album flac,http://woo.dev/albums/album.flac
|
||||
external,,WooCommerce Product CSV Suite,1,,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,,,,,,,,0,Lorem ipsum dolor sit amet.,,199,Software,WooCommerce,,,,,,,,,https://woocommerce.com/products/product-csv-import-suite/,Buy on WooCommerce.com,2,,,,,,,,
|
||||
|
|
|
Loading…
Reference in New Issue