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:
Colin Kuskie 2008-09-28 23:59:26 +00:00
parent 1c2993dd86
commit 79c5425bcf
8 changed files with 40 additions and 21 deletions

View file

@ -69,7 +69,7 @@ file will be named siteProductData.csv.
sub exportProducts {
my $self = shift;
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";
@columns = map { $_ eq 'shortdescription' ? 'shortdesc' : $_ } @columns;
my $getAProduct = WebGUI::Asset::Sku::Product->getIsa($session);
@ -109,7 +109,7 @@ mastersku
=item *
sku
varsku
=item *
@ -160,7 +160,7 @@ sub importProducts {
chomp $headers;
my @headers = WebGUI::Text::splitCSV($headers);
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);
my @productData = ();
@ -213,7 +213,7 @@ sub importProducts {
my $collaterals = $product->getAllCollateral('variantsJSON');
my $collateralSet = 0;
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
$product->setCollateral('variantsJSON', 'variantId', $collateral->{variantId}, $collateral);
$collateralSet=1;