Convert variants over to the new collateral API.

Convert the upgrade script to the new API.
Fix a few bugs in the collateral API with "empty" collateral Ids
and add tests for it.
This commit is contained in:
Colin Kuskie 2008-05-18 23:44:43 +00:00
parent d8f12c4c9f
commit affd08990a
3 changed files with 36 additions and 24 deletions

View file

@ -808,7 +808,7 @@ EOSQL1
##Truncate title to 30 chars for short desc
#printf "\t\tAdding variant to %s\n", $productData->{title} unless $quiet;
my $product = WebGUI::Asset::Sku::Product->new($session, $productData->{assetId}, 'WebGUI::Asset::Sku::Product', $productData->{revisionDate});
$product->setCollateral('variantsJSON', 'new', {
$product->setCollateral('variantsJSON', 'variantId', 'new', {
varSku => ($productData->{productNumber} || $session->id->generate),
shortdesc => substr($productData->{title}, 0, 30),
price => $productData->{price},
@ -965,7 +965,7 @@ sub mergeProductsWithCommerce {
$variant->{weight} = $variantData->{weight};
$variant->{quantity} = $variantData->{available};
$variant->{shortdesc} = $shortdesc;
$sku->setCollateral('variantsJSON', 'new', $variant);
$sku->setCollateral('variantsJSON', 'variantId', 'new', $variant);
}
}
$productSth->finish;