Add support for the original sku entry in the header.
This commit is contained in:
parent
84f38558cf
commit
a61bd107fa
3 changed files with 30 additions and 1 deletions
|
|
@ -159,6 +159,7 @@ sub importProducts {
|
||||||
$headers = <$table>;
|
$headers = <$table>;
|
||||||
chomp $headers;
|
chomp $headers;
|
||||||
$headers =~ tr/\r//d;
|
$headers =~ tr/\r//d;
|
||||||
|
$headers =~ s/\bsku\b/varSku/;
|
||||||
my @headers = WebGUI::Text::splitCSV($headers);
|
my @headers = WebGUI::Text::splitCSV($headers);
|
||||||
WebGUI::Error::InvalidFile->throw(error => qq{Bad header found in the CSV file}, brokenFile => $filePath)
|
WebGUI::Error::InvalidFile->throw(error => qq{Bad header found in the CSV file}, brokenFile => $filePath)
|
||||||
unless (join(q{-}, sort @headers) eq 'mastersku-price-quantity-shortdescription-title-varSku-weight')
|
unless (join(q{-}, sort @headers) eq 'mastersku-price-quantity-shortdescription-title-varSku-weight')
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $tests = 48;
|
my $tests = 51;
|
||||||
plan tests => 1 + $tests;
|
plan tests => 1 + $tests;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
@ -415,6 +415,30 @@ SKIP: {
|
||||||
is($shelf2->getChildCount, 2, 'imported 2 children skus for shelf2 with windows line endings fields');
|
is($shelf2->getChildCount, 2, 'imported 2 children skus for shelf2 with windows line endings fields');
|
||||||
|
|
||||||
$shelf2->purge;
|
$shelf2->purge;
|
||||||
|
undef $shelf2;
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
#
|
||||||
|
# import, old sku column header
|
||||||
|
#
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
$shelf2 = WebGUI::Asset->getRoot($session)->addChild({className => $class});
|
||||||
|
|
||||||
|
$pass = 0;
|
||||||
|
eval {
|
||||||
|
$pass = $shelf2->importProducts(
|
||||||
|
WebGUI::Test->getTestCollateralPath('productTables/windowsTable.csv'),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
ok($pass, 'Able to load a table with old style, sku instead of varSku');
|
||||||
|
$e = Exception::Class->caught();
|
||||||
|
is($e, '', 'No exception thrown on a file old headers');
|
||||||
|
is($shelf2->getChildCount, 2, 'imported 2 children skus for shelf2 with old headers');
|
||||||
|
|
||||||
|
$shelf2->purge;
|
||||||
|
undef $shelf2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
4
t/supporting_collateral/productTables/oldHeaderTable.csv
Normal file
4
t/supporting_collateral/productTables/oldHeaderTable.csv
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
mastersku,sku,title,shortdescription,price,weight,quantity
|
||||||
|
Software,Windows-Vista,Windows Vista,Bad software,120,5.00,5000
|
||||||
|
Software,Windows-XP,Windows XP,Mainly bad software,80,4.50,2000
|
||||||
|
Hardware,X-box,X-box,Very expensive hardware,280,10,150
|
||||||
|
Loading…
Add table
Add a link
Reference in a new issue