more work on translating Asset Products to Sku Products
This commit is contained in:
parent
50a4b564e5
commit
c8e1c3c3d3
3 changed files with 26 additions and 11 deletions
|
|
@ -412,21 +412,34 @@ sub addShippingDrivers {
|
||||||
|
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
sub migrateOldProduct {
|
sub migrateOldProduct {
|
||||||
return;
|
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
print "\tMigrate old Product to new SKU based Products.\n" unless ($quiet);
|
print "\tMigrate old Product to new SKU based Products.\n" unless ($quiet);
|
||||||
# and here's our code
|
# and here's our code
|
||||||
##Grab data from Wobject table, and move it into Sku and Product, as appropriate.
|
##Grab data from Wobject table, and move it into Sku and Product, as appropriate.
|
||||||
my $oldTax = $session->db->prepare('select * from commerceSalesTax');
|
##Have to change the className's in the db, too
|
||||||
my $newTax = $session->db->prepare('insert into tax (taxId, country, state, city, code, taxRate) VALUES (?,?,?,?,?,?)');
|
## Wobject description -> Sku description
|
||||||
my $rmWobject =
|
## Wobject displayTitle -> Sku displayTitle
|
||||||
$oldTax->execute();
|
## Product productNumber -> Sku sku
|
||||||
while (my $oldTaxData = $oldTax->hashRef()) {
|
## asset className WebGUI::Asset::Wobject::Product -> WebGUI::Asset::Sku::Product
|
||||||
$newTax->execute([$oldTaxData->{commerceSalesTaxId}, 'USA', $oldTaxData->{regionIdentifier}, '', '', $oldTaxData->{salesTax}]);
|
my $fromWobject = $session->db->read('select w.assetId, w.revisionDate, w.description, w.displayTitle, p.productNumber from Product as p JOIN wobject as w on p.assetId=w.assetId and p.revisionDate=w.revisionDate');
|
||||||
|
my $toSku = $session->db->prepare('insert into sku (assetId, revisionDate, sku, description, displayTitle) VALUES (?,?,?,?,?)');
|
||||||
|
my $rmWobject = $session->db->prepare('delete from wobject where assetId=? and revisionDate=?');
|
||||||
|
while (my $product = $fromWobject->hashRef()) {
|
||||||
|
$toSku->execute([
|
||||||
|
$product->{assetId},
|
||||||
|
$product->{revisionDate},
|
||||||
|
$product->{productNumber},
|
||||||
|
$product->{description},
|
||||||
|
$product->{displayTitle},
|
||||||
|
]);
|
||||||
|
$rmWobject->execute([$product->{assetId}, $product->{revisionDate}]);
|
||||||
}
|
}
|
||||||
$oldTax->finish;
|
$fromWobject->finish;
|
||||||
$newTax->finish;
|
$toSku->finish;
|
||||||
##Delete data from Wobject table.
|
$rmWobject->finish;
|
||||||
|
## Remove productNumber from Product;
|
||||||
|
## Update config file, deleting Wobject::Product and adding Sku::Product
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1833,7 +1833,8 @@ sub newByDynamicClass {
|
||||||
|
|
||||||
=head2 newByPropertyHashRef ( session, properties )
|
=head2 newByPropertyHashRef ( session, properties )
|
||||||
|
|
||||||
Constructor. This creates a standalone asset with no parent.
|
Constructor. This creates a standalone asset with no parent. It does not update the
|
||||||
|
database.
|
||||||
|
|
||||||
=head3 session
|
=head3 session
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ $tag = WebGUI::VersionTag->getWorking($session);
|
||||||
|
|
||||||
my $product1a = $product1->addRevision({price => 11.11});
|
my $product1a = $product1->addRevision({price => 11.11});
|
||||||
|
|
||||||
|
sleep 1;
|
||||||
$tag->commit;
|
$tag->commit;
|
||||||
|
|
||||||
diag "Done.";
|
diag "Done.";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue