diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index e347b58c7..f20908c74 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -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 diff --git a/docs/upgrades/upgrade_7.10.0-7.10.1.pl b/docs/upgrades/upgrade_7.10.0-7.10.1.pl index 3ade88d51..9c58d26f2 100644 --- a/docs/upgrades/upgrade_7.10.0-7.10.1.pl +++ b/docs/upgrades/upgrade_7.10.0-7.10.1.pl @@ -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 {