Guarantee that old revisions of Products have unique storage locations. Fixes bug #11833.

This commit is contained in:
Colin Kuskie 2010-09-13 09:00:14 -07:00
parent f17623624e
commit 3c15058bc6
2 changed files with 30 additions and 0 deletions

View file

@ -2,6 +2,7 @@
- fixed #11851: Story Topic: top story variables should be available all the time
- fixed #11854: CS doesn't return Not Found page
- fixed #11746: Thingy import CSV only supports one line ending
- fixed #11833: Recheck for losing Product Images
7.10.0
- fixed #11812: Checking www_ajaxSave's response in the cart js, urlencoding post parameters

View file

@ -31,10 +31,39 @@ my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
uniqueProductLocations($session);
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
sub uniqueProductLocations {
my $session = shift;
print "\tMake sure each Product revision has its own storage location... " unless $quiet;
use WebGUI::Asset::Sku::Product;
my $get_product = WebGUI::Asset::Sku::Product->getIsa($session);
# and here's our code
PRODUCT: while (1) {
my $product = eval { $get_product->(); };
next PRODUCT if Exception::Class->caught();
last PRODUCT unless $product;
next PRODUCT unless $product->getRevisionCount > 1;
my $products = $product->getRevisions;
##We already have the first revision, so remove it.
shift @{ $products };
foreach my $property (qw/image1 image2 image3 brochure manual warranty/) {
##Check each property. If there's a duplicate, then make copy of the storage location and update the older version.
foreach my $revision (@{ $products }) {
if ($revision->get($property) eq $product->get($property)) {
$product->_duplicateFile($revision, $property,);
}
}
}
}
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {