#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2009 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#---------------------------------------------------------------
package BookPub::Catalog::Book::WithAuthor::WithProductCount;

# Extending an extended class even further, to include the count of products.
#
use strict;
use warnings;

use lib '/app/tools/common/lib';
use lib '/app/tools/bookpub/lib';
use BookPub::DB::Item::BookContributor;
use BookPub::DB::Item::BookProduct;
use Common::Assert;

use base 'BookPub::Catalog::Book::WithAuthor';

sub _initProperties {
    my ( $self, $props ) = @_;

    $self->SUPER::_initProperties($props);

    my $productCount = 0;
    if ( $props->{book_id} ) {
        my $collection = BookPub::DB::Item::BookProduct->GetAllByBookID( $props->{book_id} );
        if ($collection) {
            $productCount = $collection->size();
        }
    }
    $self->{ProductCount} = $productCount;
}

###
1;    #
###
