more product variants work, i18n, forms and upgrade script

This commit is contained in:
Colin Kuskie 2008-04-30 22:58:42 +00:00
parent 0d5ff270ff
commit fe20db884a
3 changed files with 51 additions and 42 deletions

View file

@ -588,6 +588,18 @@ sub migrateOldProduct {
print "\tMigrate old Product to new SKU based Products.\n" unless ($quiet);
# and here's our code
##Grab data from Wobject table, and move it into Sku and Product, as appropriate.
print "\t\tAdding new product variants table.\n" unless ($quiet);
$session->db->write(<<'EOSQL');
CREATE TABLE Product_variants (
varSku VARCHAR(255) BINARY NOT NULL PRIMARY KEY,
mastersku VARCHAR(22) BINARY NOT NULL,
varTitle VARCHAR(255) BINARY NOT NULL,
shortdesc VARCHAR(30),
price FLOAT,
weight FLOAT,
quantity INT
);
EOSQL
##Have to change the className's in the db, too
## Wobject description -> Sku description
## Wobject displayTitle -> Sku displayTitle
@ -623,17 +635,6 @@ sub migrateOldProduct {
sub mergeProductsWithCommerce {
my $session = shift;
print "\tMerge old Commerce Products to new SKU based Products.\n" unless ($quiet);
$session->db->write(<<'EOSQL');
CREATE TABLE Product_variants (
sku VARCHAR(255) BINARY NOT NULL PRIMARY KEY,
mastersku VARCHAR(255) BINARY NOT NULL,
shortdesc VARCHAR(30),
price FLOAT,
weight FLOAT,
quantity INT
);
EOSQL
## Add the parameter and variants columns
return 1;
}

View file

@ -901,44 +901,45 @@ sub www_editSpecificationSave {
#-------------------------------------------------------------------
sub www_editVariant {
my $self = shift;
my $sku = shift || $self->session->form->process("sku");
my $sku = shift || $self->session->form->process("varSku");
return $self->session->privilege->insufficient() unless ($self->canEdit);
my ($data, $f, $hashRef);
my $i18n = WebGUI::International->new($self->session,'Asset_Product');
$data = $self->getCollateral("Product_specification","Product_specificationId",$sku);
$f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
$f->readonly(
-name => "mastersku",
-value => $data->{mastersku},
);
my $data = $self->getCollateral("Product_variants", "varSku", $sku);
my $f = WebGUI::HTMLForm->new($self->session, -action=>$self->getUrl);
$f->hidden(
-name => "func",
-name => 'func',
-value => "editVariantSave",
);
$f->integer(
-name => "shortdesc",
-size => 30,
-label => $i18n->get('shortdesc'),
$f->text(
-name => 'varSku',
-label => $i18n->get('variant sku'),
-hoverHelp => $i18n->get('variant sku description'),
-value => $data->{price},
);
$f->text(
-name => 'shortdesc',
-size => 30,
-label => $i18n->get('shortdesc'),
-hoverHelp => $i18n->get('shortdesc description'),
-value => $data->{price},
-value => $data->{price},
);
$f->integer(
-name => "price",
-label => $i18n->get(10),
-name => 'price',
-label => $i18n->get(10),
-hoverHelp => $i18n->get('10 description'),
-value => $data->{price},
-value => $data->{price},
);
$f->float(
-name => "weight",
-label => $i18n->get('weight'),
-name => 'weight',
-label => $i18n->get('weight'),
-hoverHelp => $i18n->get('weight description'),
-value => $data->{weight},
-value => $data->{weight},
);
$f->integer(
-name => "quantity",
-label => $i18n->get('quantity'),
-name => 'quantity',
-label => $i18n->get('quantity'),
-hoverHelp => $i18n->get('quantity description'),
-value => $data->{quantity},
-value => $data->{quantity},
);
$f->submit;
return $self->getAdminConsole->render($f->print, 'add variant');
@ -948,8 +949,10 @@ sub www_editVariant {
sub www_editVariantSave {
my $self = shift;
return $self->session->privilege->insufficient() unless ($self->canEdit);
$self->setCollateral("Product_variants", "Product_specificationId", {
Product_specificationId => $self->session->form->process("sid"),
##Mandatory variable check
$self->setCollateral('Product_variants', 'varSku', {
varSku => $self->session->form->process('varSku', 'text'),
mastersku => $self->get('sku'),
shortdesc => $self->session->form->process('shortdesc', 'text'),
price => $self->session->form->process('name', 'float'),
weight => $self->session->form->process('weight', 'float'),

View file

@ -599,11 +599,6 @@ be useful, others may not.|,
lastUpdated => 1164841201
},
'productNumber' => {
message => q|The product number, SKU, ISBN, or other identifier for this product.|,
lastUpdated => 1164841201
},
'image1' => {
message => q|The unique identifier for the storage object for the first image.|,
lastUpdated => 1164841201
@ -636,7 +631,7 @@ be useful, others may not.|,
'weight' => {
message => q|Weight|,
context => q|How much something weighs, with no units|
context => q|How much something weighs, with no units|,
lastUpdated => 1209494301,
},
@ -672,6 +667,16 @@ be useful, others may not.|,
lastUpdated => 1209494298,
},
'variant sku' => {
message => q|SKU|,
lastUpdated => 1209576604,
},
'variant sku description' => {
message => q|A completely unique identifier for this variant of a product. Should be the same as used in your inventory software so you can sync them.|,
lastUpdated => 1209576604,
},
};
1;