Fix bad characters in the price column when importing products into a Shelf. Fixes bug #12001.

This commit is contained in:
Colin Kuskie 2011-01-03 19:11:40 -08:00
parent cb7ffb3a21
commit 67264660f7
4 changed files with 51 additions and 1 deletions

View file

@ -17,6 +17,7 @@
- fixed #11994: recurring calendar entries
- fixed #11995: recurring calendar entries in trash
- fixed #11986: Finance::Quote can give invalid dates to StockData asset
- fixed #12001: Shelf product import mangles price
7.10.6
- fixed #11974: Toolbar icons unclickable in Webkit using HTML5

View file

@ -190,6 +190,7 @@ sub importProducts {
my %productRow;
##Order the data according to the headers, in whatever order they exist.
@productRow{ @headers } = @{ $productRow };
$productRow{price} =~ tr/0-9.//cd;
##Isolate just the collateral from the other product information
my %productCollateral;
@productCollateral{ @collateralFields } = @productRow{ @collateralFields };

View file

@ -35,7 +35,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 61;
my $tests = 65;
plan tests => 1 + $tests;
#----------------------------------------------------------------------------
@ -449,6 +449,52 @@ SKIP: {
$tag->commit;
WebGUI::Test->addToCleanup($tag);
#######################################################################
#
# import, funky data in the price column
#
#######################################################################
my $shelf3 = WebGUI::Asset->getRoot($session)->addChild({className => $class});
$pass = 0;
eval {
$pass = $shelf3->importProducts(
WebGUI::Test->getTestCollateralPath('productTables/dollarsigns.csv'),
);
};
ok($pass, 'Able to load a table with odd characters in the price column');
$e = Exception::Class->caught();
is($e, '', '... no exception thrown');
is($shelf3->getChildCount, 1, '...imported 1 child sku for shelf3 with old headers');
my $sign = $shelf3->getFirstChild();
my $signCollateral = $sign->getAllCollateral('variantsJSON');
cmp_deeply(
$signCollateral,
[
{
varSku => 'dollar signs',
shortdesc => 'Silver Dollar Signs',
price => '5.00',
weight => '0.33',
quantity => '1000',
variantId => ignore(),
},
],
'collateral set correctly for sign'
);
$shelf3->purge;
undef $shelf3;
##Clear out this tag so we can do downstream work.
my $tag = WebGUI::VersionTag->getWorking($session);
$tag->commit;
WebGUI::Test->addToCleanup($tag);
#######################################################################
#
# Template variables

View file

@ -0,0 +1,2 @@
mastersku,varSku,title,shortdescription,price,weight,quantity
signs,dollar signs,Silver Dollar Signs,Silver Dollar Signs, $5.00 ,0.33,1000
1 mastersku varSku title shortdescription price weight quantity
2 signs dollar signs Silver Dollar Signs Silver Dollar Signs $5.00 0.33 1000