The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Interchange6::Schema::ResultSet::Product

SYNOPSIS

Provides extra accessor methods for Interchange6::Schema::Result::Product

METHODS

See also DBIx::Class::Helper::ResultSet::Shortcut which is loaded by this result set.

active

Returns all rows where "active" in Interchange6::Schema::Result::Product is true.

canonical_only

Returns all rows where "canonical_sku" in Interchange6::Schema::Result::Product is null, i.e. only canonical products.

listing

This is just a shortcut for:

  $self->columns( [ 'sku', 'name', 'uri', 'price', 'short_description' ] )
      ->with_average_rating
      ->with_lowest_selling_price
      ->with_highest_price
      ->with_quantity_in_stock
      ->with_variant_count

Though in addition if you pass in arguments these are passed through to the appropriate with_* method so you can do:

  $self->listing({ quantity => 10 })

And the result will be:

  $self->columns( [ 'sku', 'name', 'uri', 'price', 'short_description' ] )
      ->with_average_rating
      ->with_lowest_selling_price({ quantity => 10 })
      ->with_highest_price
      ->with_quantity_in_stock
      ->with_variant_count

with_average_rating

Adds average_rating column which is available to order_by clauses and whose value can be retrieved via "average_rating" in Interchange6::Schema::Result::Product.

This is the average rating across all public and approved product reviews or undef if there are no reviews. Product reviews are only related to canonical products so for variants the value returned is that of the canonical product.

with_media $type?

Prefetch related active Interchange6::Schema::Result::Media where "type" in Interchange6::Schema::Result::MediaType is $type.

$type defaults to image if not provided.

with_quantity_in_stock

Adds quantity_in_stock column which is available to order_by clauses and whose value can be retrieved via "quantity_in_stock" in Interchange6::Schema::Result::Product.

The value is retrieved is "quantity" in Interchange6::Schema::Result::Inventory.

For a product variant and for a canonical product with no variants the quantity returned is for the product itself.

For a canonical (parent) product the quantity returned is the total for all its variants.

with_lowest_selling_price

Arguments should be given as a hash reference with the following keys/values:

  • quantity => $quantity

    quantity defaults to 1 if not supplied.

The lowest of "price" in Interchange6::Schema::Result::PriceModifier and "price" in Interchange6::Schema::Result::Product.

For products with variants this is the lowest variant selling_price.

Value is placed in the column selling_price.

If "current_user" in Schema is defined then any roles assigned to that user will be included in the search of Interchange6::Schema::Result::PriceModifier.

with_highest_price

For canonical products with no variants and for variant products highest_price is always undef. For canonical products that have variants this is the highest of "price" in Interchange6::Schema::Result::Product of the variants.

with_variant_count

Adds column variant_count which is a count of variants of each product.