Fix product exporting and importing through the Shelf.
Note that sku entries in the import and export file are now varSku.
This commit is contained in:
parent
1c2993dd86
commit
79c5425bcf
8 changed files with 40 additions and 21 deletions
|
|
@ -60,6 +60,7 @@
|
||||||
- fixed: Utility script skeleton now more complete and less annoying
|
- fixed: Utility script skeleton now more complete and less annoying
|
||||||
- rfe: Teach Thingy to be a Web Service (SDH Consulting Group)
|
- rfe: Teach Thingy to be a Web Service (SDH Consulting Group)
|
||||||
- fixed: ~~~ showing up on my site.
|
- fixed: ~~~ showing up on my site.
|
||||||
|
- fixed: Shelf/Product import export does not work
|
||||||
|
|
||||||
7.5.21
|
7.5.21
|
||||||
- fixed: purchase detail screen shows incorrectly in Safari
|
- fixed: purchase detail screen shows incorrectly in Safari
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ use Getopt::Long;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::Storage;
|
use WebGUI::Storage;
|
||||||
use WebGUI::Asset;
|
use WebGUI::Asset;
|
||||||
|
use WebGUI::Asset::Sku::Product;
|
||||||
|
|
||||||
|
|
||||||
my $toVersion = '7.6.0';
|
my $toVersion = '7.6.0';
|
||||||
|
|
@ -41,6 +42,7 @@ addAdHocMailGroups( $session );
|
||||||
makeAdminConsolePluggable( $session );
|
makeAdminConsolePluggable( $session );
|
||||||
migrateAssetsToNewConfigFormat($session);
|
migrateAssetsToNewConfigFormat($session);
|
||||||
deleteAdminBarTemplates($session);
|
deleteAdminBarTemplates($session);
|
||||||
|
repairBrokenProductSkus($session);
|
||||||
|
|
||||||
finish($session); # this line required
|
finish($session); # this line required
|
||||||
|
|
||||||
|
|
@ -58,6 +60,22 @@ sub deleteAdminBarTemplates {
|
||||||
print "DONE!\n" unless $quiet;
|
print "DONE!\n" unless $quiet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
sub repairBrokenProductSkus {
|
||||||
|
my $session = shift;
|
||||||
|
print "\tRepairing broken Products that were imported... " unless $quiet;
|
||||||
|
my $getAProduct = WebGUI::Asset::Sku::Product->getIsa($session);
|
||||||
|
while (my $product = $getAProduct->()) {
|
||||||
|
COLLATERAL: foreach my $collateral ($product->getAllCollateral('variantsJSON')) {
|
||||||
|
next COLLATERAL unless exists $collateral->{sku};
|
||||||
|
$collateral->{varSku} = $collateral->{sku};
|
||||||
|
delete $collateral->{sku};
|
||||||
|
$product->setCollateral('variantsJSON', 'variantId', $collateral->{variantId}, $collateral);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print "DONE!\n" unless $quiet;
|
||||||
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
sub migrateAssetsToNewConfigFormat {
|
sub migrateAssetsToNewConfigFormat {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ file will be named siteProductData.csv.
|
||||||
sub exportProducts {
|
sub exportProducts {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
my @columns = qw{sku shortdescription price weight quantity};
|
my @columns = qw{varSku shortdescription price weight quantity};
|
||||||
my $productData = WebGUI::Text::joinCSV(qw{mastersku title}, @columns) . "\n";
|
my $productData = WebGUI::Text::joinCSV(qw{mastersku title}, @columns) . "\n";
|
||||||
@columns = map { $_ eq 'shortdescription' ? 'shortdesc' : $_ } @columns;
|
@columns = map { $_ eq 'shortdescription' ? 'shortdesc' : $_ } @columns;
|
||||||
my $getAProduct = WebGUI::Asset::Sku::Product->getIsa($session);
|
my $getAProduct = WebGUI::Asset::Sku::Product->getIsa($session);
|
||||||
|
|
@ -109,7 +109,7 @@ mastersku
|
||||||
|
|
||||||
=item *
|
=item *
|
||||||
|
|
||||||
sku
|
varsku
|
||||||
|
|
||||||
=item *
|
=item *
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ sub importProducts {
|
||||||
chomp $headers;
|
chomp $headers;
|
||||||
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-sku-title-weight')
|
unless (join(q{-}, sort @headers) eq 'mastersku-price-quantity-shortdescription-title-varSku-weight')
|
||||||
and (scalar @headers == 7);
|
and (scalar @headers == 7);
|
||||||
|
|
||||||
my @productData = ();
|
my @productData = ();
|
||||||
|
|
@ -213,7 +213,7 @@ sub importProducts {
|
||||||
my $collaterals = $product->getAllCollateral('variantsJSON');
|
my $collaterals = $product->getAllCollateral('variantsJSON');
|
||||||
my $collateralSet = 0;
|
my $collateralSet = 0;
|
||||||
ROW: foreach my $collateral (@{ $collaterals }) {
|
ROW: foreach my $collateral (@{ $collaterals }) {
|
||||||
next ROW unless $collateral->{sku} eq $productRow{sku};
|
next ROW unless $collateral->{varSku} eq $productRow{varSku};
|
||||||
@{ $collateral}{ @collateralFields } = @productCollateral{ @collateralFields }; ##preserve the variant Id field, assign all others
|
@{ $collateral}{ @collateralFields } = @productCollateral{ @collateralFields }; ##preserve the variant Id field, assign all others
|
||||||
$product->setCollateral('variantsJSON', 'variantId', $collateral->{variantId}, $collateral);
|
$product->setCollateral('variantsJSON', 'variantId', $collateral->{variantId}, $collateral);
|
||||||
$collateralSet=1;
|
$collateralSet=1;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $tests = 44;
|
my $tests = 45;
|
||||||
plan tests => 1 + $tests;
|
plan tests => 1 + $tests;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
@ -153,7 +153,7 @@ SKIP: {
|
||||||
$sodaCollateral,
|
$sodaCollateral,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
sku => 'soda-sweet',
|
varSku => 'soda-sweet',
|
||||||
shortdesc => 'Sweet Soda',
|
shortdesc => 'Sweet Soda',
|
||||||
price => 0.95,
|
price => 0.95,
|
||||||
weight => 0.95,
|
weight => 0.95,
|
||||||
|
|
@ -172,7 +172,7 @@ SKIP: {
|
||||||
$shirtCollateral,
|
$shirtCollateral,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
sku => 'red-t-shirt',
|
varSku => 'red-t-shirt',
|
||||||
shortdesc => 'Red T-Shirt',
|
shortdesc => 'Red T-Shirt',
|
||||||
price => '5.00',
|
price => '5.00',
|
||||||
weight => '1.33',
|
weight => '1.33',
|
||||||
|
|
@ -180,7 +180,7 @@ SKIP: {
|
||||||
variantId => ignore(),
|
variantId => ignore(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sku => 'blue-t-shirt',
|
varSku => 'blue-t-shirt',
|
||||||
shortdesc => 'Blue T-Shirt',
|
shortdesc => 'Blue T-Shirt',
|
||||||
price => '5.25',
|
price => '5.25',
|
||||||
weight => '1.33',
|
weight => '1.33',
|
||||||
|
|
@ -204,7 +204,7 @@ SKIP: {
|
||||||
my $productData = $productsOut->getFileContentsAsScalar($productsOut->getFiles->[0]);
|
my $productData = $productsOut->getFileContentsAsScalar($productsOut->getFiles->[0]);
|
||||||
my @productData = split /\n/, $productData;
|
my @productData = split /\n/, $productData;
|
||||||
is(scalar @productData, 4, 'productData should have 4 entries, 1 header + 3 data');
|
is(scalar @productData, 4, 'productData should have 4 entries, 1 header + 3 data');
|
||||||
is($productData[0], 'mastersku,title,sku,shortdescription,price,weight,quantity', 'header line is okay');
|
is($productData[0], 'mastersku,title,varSku,shortdescription,price,weight,quantity', 'header line is okay');
|
||||||
@productData = map { [ WebGUI::Text::splitCSV($_) ] } @productData[1..3];
|
@productData = map { [ WebGUI::Text::splitCSV($_) ] } @productData[1..3];
|
||||||
my ($sodas, $shirts) = ([], []);
|
my ($sodas, $shirts) = ([], []);
|
||||||
foreach my $productData (@productData) {
|
foreach my $productData (@productData) {
|
||||||
|
|
@ -246,7 +246,7 @@ SKIP: {
|
||||||
$sodaCollateral,
|
$sodaCollateral,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
sku => 'soda-sweet',
|
varSku => 'soda-sweet',
|
||||||
shortdesc => 'Sweet Soda',
|
shortdesc => 'Sweet Soda',
|
||||||
price => '1.00',
|
price => '1.00',
|
||||||
weight => 0.85,
|
weight => 0.85,
|
||||||
|
|
@ -263,7 +263,7 @@ SKIP: {
|
||||||
$shirtCollateral,
|
$shirtCollateral,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
sku => 'red-t-shirt',
|
varSku => 'red-t-shirt',
|
||||||
shortdesc => 'Red T-Shirt',
|
shortdesc => 'Red T-Shirt',
|
||||||
price => '5.00',
|
price => '5.00',
|
||||||
weight => '1.33',
|
weight => '1.33',
|
||||||
|
|
@ -271,7 +271,7 @@ SKIP: {
|
||||||
variantId => ignore(),
|
variantId => ignore(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sku => 'blue-t-shirt',
|
varSku => 'blue-t-shirt',
|
||||||
shortdesc => 'Blue T-Shirt',
|
shortdesc => 'Blue T-Shirt',
|
||||||
price => '5.25',
|
price => '5.25',
|
||||||
weight => '1.33',
|
weight => '1.33',
|
||||||
|
|
@ -289,7 +289,7 @@ SKIP: {
|
||||||
$recordCollateral,
|
$recordCollateral,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
sku => 'track-16',
|
varSku => 'track-16',
|
||||||
shortdesc => 'Track 16',
|
shortdesc => 'Track 16',
|
||||||
price => '3.25',
|
price => '3.25',
|
||||||
weight => '0.00',
|
weight => '0.00',
|
||||||
|
|
@ -323,7 +323,7 @@ SKIP: {
|
||||||
$shirtCollateral,
|
$shirtCollateral,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
sku => 'red-t-shirt',
|
varSku => 'red-t-shirt',
|
||||||
shortdesc => 'Red T-Shirt',
|
shortdesc => 'Red T-Shirt',
|
||||||
price => '5.00',
|
price => '5.00',
|
||||||
weight => '1.33',
|
weight => '1.33',
|
||||||
|
|
@ -331,7 +331,7 @@ SKIP: {
|
||||||
variantId => ignore(),
|
variantId => ignore(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sku => 'blue-t-shirt',
|
varSku => 'blue-t-shirt',
|
||||||
shortdesc => 'Blue T-Shirt',
|
shortdesc => 'Blue T-Shirt',
|
||||||
price => '5.25',
|
price => '5.25',
|
||||||
weight => '1.33',
|
weight => '1.33',
|
||||||
|
|
@ -348,7 +348,7 @@ SKIP: {
|
||||||
$recordCollateral,
|
$recordCollateral,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
sku => 'track-16',
|
varSku => 'track-16',
|
||||||
shortdesc => 'Track 16',
|
shortdesc => 'Track 16',
|
||||||
price => '3.25',
|
price => '3.25',
|
||||||
weight => '0.00',
|
weight => '0.00',
|
||||||
|
|
@ -356,7 +356,7 @@ SKIP: {
|
||||||
variantId => ignore(),
|
variantId => ignore(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sku => 'track-9',
|
varSku => 'track-9',
|
||||||
shortdesc => 'Track 9',
|
shortdesc => 'Track 9',
|
||||||
price => '3.25',
|
price => '3.25',
|
||||||
weight => '0.00',
|
weight => '0.00',
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
mastersku,sku,title,shortdescription,price,weight,quantity
|
mastersku,varSku,title,shortdescription,price,weight,quantity
|
||||||
t-shirt,red-t-shirt,Colored T-Shirts,Red T-Shirt,5.00,1.33,1000
|
t-shirt,red-t-shirt,Colored T-Shirts,Red T-Shirt,5.00,1.33,1000
|
||||||
t-shirt,blue-t-shirt,Colored T-Shirts,Blue T-Shirt,5.25,1.33,2000
|
t-shirt,blue-t-shirt,Colored T-Shirts,Blue T-Shirt,5.25,1.33,2000
|
||||||
soda,soda-sweet,Sweet Soda-bottled in Oregon,Sweet Soda,0.95,0.95,500
|
soda,soda-sweet,Sweet Soda-bottled in Oregon,Sweet Soda,0.95,0.95,500
|
||||||
|
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"mastersku","sku","title","shortdescription","price","weight","quantity"
|
"mastersku","varSku","title","shortdescription","price","weight","quantity"
|
||||||
"Kids-lashed","red-t-shirt","Colored T-Shirts","Red T-Shirt",5,1.33,1000
|
"Kids-lashed","red-t-shirt","Colored T-Shirts","Red T-Shirt",5,1.33,1000
|
||||||
"Kids-lashed","blue-t-shirt","Colored T-Shirts","Blue T-Shirt",5.25,1.33,2000
|
"Kids-lashed","blue-t-shirt","Colored T-Shirts","Blue T-Shirt",5.25,1.33,2000
|
||||||
"soda","soda-sweet","Sweet Soda-bottled in Oregon","Sweet Soda",0.95,0.95,500
|
"soda","soda-sweet","Sweet Soda-bottled in Oregon","Sweet Soda",0.95,0.95,500
|
||||||
|
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
mastersku,sku,title,shortdescription,price,weight,quantity
|
mastersku,varSku,title,shortdescription,price,weight,quantity
|
||||||
##alter existing with two collateral
|
##alter existing with two collateral
|
||||||
t-shirt,red-t-shirt,Colored T-Shirts,Red T-Shirt,5.00,1.33,500
|
t-shirt,red-t-shirt,Colored T-Shirts,Red T-Shirt,5.00,1.33,500
|
||||||
##alter existing with one collateral
|
##alter existing with one collateral
|
||||||
|
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
mastersku,sku,title,shortdescription,price,weight,quantity
|
mastersku,varSku,title,shortdescription,price,weight,quantity
|
||||||
##alter a title
|
##alter a title
|
||||||
soda,soda-sweet,Sweet Soda-totally organic,Sweet Soda,1.00,0.85,500
|
soda,soda-sweet,Sweet Soda-totally organic,Sweet Soda,1.00,0.85,500
|
||||||
##add new collateral to an existing product
|
##add new collateral to an existing product
|
||||||
|
|
|
||||||
|
Loading…
Add table
Add a link
Reference in a new issue