Fix getThumbnailUrl in the Product, which was called by the Shelf directly causing failures.

Fix getPrice in the Product, which returned undef until a variant was applied to it.
These two fixes fix the Shelf.
This commit is contained in:
Colin Kuskie 2008-06-19 23:12:04 +00:00
parent b338e660ea
commit 68db4f8e46
3 changed files with 19 additions and 5 deletions

View file

@ -24,6 +24,7 @@
- added: Next and Previous GalleryAlbum links in the GalleryAlbum views
- fixed: Shop: Variants in dropdown and on page
- fixed: OLD subscription table still hanging around?
- fixed: Shelf
7.5.12
- skipping this release

View file

@ -400,7 +400,14 @@ Product.
sub getPrice {
my $self = shift;
return $self->getOptions->{price};
if (! keys %{ $self->getOptions} ) {
my $variants = $self->getAllCollateral('variantsJSON');
return '' unless @{ $variants };
return $variants->[0]->{price};
}
else {
return $self->getOptions->{price};
}
}
#-------------------------------------------------------------------
@ -437,8 +444,14 @@ sub getQuantityAvailable {
#-------------------------------------------------------------------
sub getThumbnailUrl {
my $self = shift;
my $store = shift || WebGUI::Storage::Image->get($self->session, $self->get('image1'));
return $store->getThumbnailUrl($store->getFiles->[0]);
my $store = shift;
if (! defined $store and $self->get('image1')) {
$store = WebGUI::Storage::Image->get($self->session, $self->get('image1'));
return $store->getThumbnailUrl($store->getFiles->[0]);
}
else {
return '';
}
}
#-------------------------------------------------------------------

View file

@ -112,8 +112,8 @@ sub view {
if (defined $asset) {
my $sku = $asset->get;
$sku->{url} = $asset->getUrl;
$sku->{thumbnailUrl} = $asset->getThumbnailUrl;
$sku->{price} = sprintf("%.2f", $asset->getPrice);
$sku->{thumbnailUrl} = $asset->getThumbnailUrl;
$sku->{price} = sprintf("%.2f", $asset->getPrice);
push @skus, $sku;
}
else {