add templates to the mix. Product macro template scan and update done
This commit is contained in:
parent
4cf45c289c
commit
e39ae106fd
2 changed files with 37 additions and 0 deletions
|
|
@ -906,6 +906,25 @@ sub updateUsersOfProductMacro {
|
|||
}
|
||||
$snipSth->finish;
|
||||
$fixed->finish;
|
||||
|
||||
my $tempSth = $session->db->read('select assetId, revisionDate, template from template order by assetId, revisionDate');
|
||||
$fixed = $session->db->prepare('update template set template=? where assetId=? and revisionDate=?');
|
||||
while (my $template = $tempSth->hashRef) {
|
||||
while ($template->{template} =~ m/\^Product\('? ([^),']+) /xg) {
|
||||
printf "\t\tWorking on %s\n", $template->{assetId};
|
||||
my $identifier = $1; ##If this is a product sku, need to look up by productId;
|
||||
printf "\t\t\tFound argument of %s\n", $identifier;
|
||||
my $assetId = $session->db->quickScalar('select distinct(assetId) from sku where sku=?',[$identifier]);
|
||||
printf "\t\t\tsku assetId: %s\n", $assetId;
|
||||
my $productAssetId = $assetId ? $assetId : $identifier;
|
||||
$template->{template} =~ s/\^Product\( [^)]+ \)/^AssetProxy($productAssetId)/x;
|
||||
printf "\t\t\tUpdated template to%s\n", $template->{template};
|
||||
$fixed->execute([ $template->{template}, $template->{assetId}, $template->{revisionDate}, ]);
|
||||
}
|
||||
}
|
||||
$tempSth->finish;
|
||||
$fixed->finish;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,24 @@ my $lProperties1 = {
|
|||
|
||||
my $layout1 = $root->addChild($lProperties1);
|
||||
|
||||
my $sProperties1 = {
|
||||
className => 'WebGUI::Asset::Snippet',
|
||||
url => 'oneSnippet',
|
||||
title => 'One Snippet',
|
||||
snippet => q|^Product('South Beach'); ^Product(i-mG8KKBPuPiUA0qq04byQ);|,
|
||||
};
|
||||
|
||||
my $snippet1 = $root->addChild($sProperties1);
|
||||
|
||||
my $tProperties1 = {
|
||||
className => 'WebGUI::Asset::Template',
|
||||
url => 'oneTemplate',
|
||||
title => 'One Template',
|
||||
snippet => q|^Product('Slingshot Dragonfly'); ^Product('jqRw23vjpIDOYuhaFHoBkA');|,
|
||||
};
|
||||
|
||||
my $template1 = $root->addChild($tProperties1);
|
||||
|
||||
$tag->commit;
|
||||
|
||||
diag "Done.";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue