NAME
Interchange6::Schema::Result::Product
DESCRIPTION
The products table contains three product types parent, child and single.
Parent Product A parent product is a container product in which variations of parent product or "child products" are linked.
Child Product A child product for example "Acme Pro 10lb Dumbbell" would include the canonical_sku of the parent item whose description might be something like "Acme Pro Dumbbell". In general a child product would contain attributes while a parent product would not.
Single Product A single product does not have child products and will become a parent product if a child product exists.
ACCESSORS
sku
data_type: 'varchar'
is_nullable: 0
size: 64
primary key
name
data_type: 'varchar'
is_nullable: 0
size: 255
short_description
data_type: 'varchar'
default_value: (empty string)
is_nullable: 0
size: 500
description
data_type: 'text'
is_nullable: 0
price
data_type: 'numeric'
default_value: 0.0
is_nullable: 0
size: [10,2]
uri
Unique product uri. Example "acme-pro-dumbbells".
data_type: 'varchar'
is_nullable: 1
size: 255
unique constraint
weight
data_type: 'numeric'
default_value: 0.0
is_nullable: 0
size: [10,2]
priority
Display order priority.
data_type: 'integer'
default_value: 0
is_nullable: 0
gtin
EAN or UPC type data.
data_type: 'varchar'
is_nullable: 1
size: 32
unique constraint
canonical_sku
The SKU of the main product if this product is a variant of a main product, otherwise NULL.
data_type: 'varchar'
is_nullable: 1
size: 64
active
data_type: 'boolean'
default_value: 1
is_nullable: 0
inventory_exempt
data_type: 'boolean'
default_value: 0
is_nullable: 0
created
data_type: 'datetime'
set_on_create: 1
is_nullable: 0
last_modified
data_type: 'datetime'
set_on_create: 1
set_on_update: 1
is_nullable: 0
RELATIONS
canonical
Type: belongs_to
Related object: Interchange6::Schema::Result::Product
variants
Type: has_many
Related object: Interchange6::Schema::Result::Product
cart_products
Type: has_many
Related object: Interchange6::Schema::Result::CartProduct
price_modifiers
Type: has_many
Related object: Interchange6::Schema::Result::PriceModifier
inventory
Type: might_have
Related object: Interchange6::Schema::Result::Inventory
media_products
Type: has_many
Related object: Interchange6::Schema::Result::MediaProduct
merchandising_products
Type: has_many
Related object: Interchange6::Schema::Result::MerchandisingProduct
merchandising_product_related
Type: has_many
Related object: Interchange6::Schema::Result::MerchandisingProduct
navigation_products
Type: has_many
Related object: Interchange6::Schema::Result::NavigationProduct
orderlines
Type: has_many
Related object: Interchange6::Schema::Result::Orderline
product_attributes
Type: has_many
Related object: Interchange6::Schema::Result::ProductAttribute
media
Type: many_to_many with media
_product_reviews
Type: has_many
Related object: Interchange6::Schema::Result::ProductReview
This is considered a private method. Please see public "product_reviews" method.
_reviews
Type: many_to_many
This is considered a private method. Accessor to related Message results. Please see public "reviews" and "add_to_reviews" methods.
METHODS
Attribute methods are provided by the Interchange6::Schema::Base::Attribute class.
path
Produces navigation path for this product. Returns array reference in scalar context.
Uses $type to select specific taxonomy from navigation if present.
tier_pricing
Tier pricing can be calculated for a single role and also a combination of several roles. The default anonymous
role is always added to the list of roles used in the search.
- Arguments: array reference of Role names
- Return Value: in scalar context an array reference ordered by quantity ascending of hash references of quantity and price, in list context returns an array instead of array reference
my $aref = $product->tier_pricing( 'trade' );
# [
# { quantity => 1, price => 20 },
# { quantity => 10, price => 19 },
# { quantity => 100, price => 18 },
# ]
selling_price
Arguments should be given as a hash reference with the following keys/values:
quantity => $quantity
roles => array reference of Role names
The default anonymous
role is always added to roles
. This enables promotional prices to be specified between fixed dates in Pricing price to apply to all classes of user.
quantity
defaults to 1 if not supplied.
Returns lowest price from "price" and Pricing price.
Throws exception on bad arguments though unexpected keys in the hash reference will be silently discarded.
find_variant \%input [\%match_info]
Find product variant with the given attribute values in $input.
Returns variant in case of success.
Returns undef in case of failure.
You can pass an optional hash reference \%match_info which is filled with attribute matches (only valid in case of failure).
attribute_iterator( %args )
Return a hashref of attributes keyed on attribute name instead of an arrayref.
Set the 'selected' SKU. For a child product this is set automatically.
For canonical products, it shows all the attributes of the child products.
For a child product, it shows all the attributes of the siblings.
Example of returned arrayref:
[
{
attribute_values => [
{
priority => 2,
selected => 0,
title => "Pink",
value => "pink"
},
{
priority => 1,
selected => 0,
title => "Yellow",
value => "yellow"
}
],
name => "color",
priority => 2,
title => "Color"
},
{
attribute_values => [
{
priority => 2,
selected => 0,
title => "Small",
value => "small"
},
{
priority => 1,
selected => 0,
title => "Medium",
value => "medium"
},
],
name => "size",
priority => 1,
title => "Size"
}
]
add_variants @variants
Add variants from a list of hash references.
Returns product object.
Each hash reference contains attributes and column data which overrides data from the canonical product.
The canonical sku of the variant is automatically set.
Example for the hash reference (attributes in the first line):
{color => 'yellow', size => 'small',
sku => 'G0001-YELLOW-S',
name => 'Six Small Yellow Tulips',
uri => 'six-small-yellow-tulips'}
media_by_type
Return a Media resultset with the related media, filtered by type (e.g. video or image). On the results you can call display_uri("type")
to get the actual uri.
product_reviews
Reviews should only be associated with parent products. This method returns the related ProductReview records for a parent product. For a child product the ProductReview records for the parent are returned.
reviews
Reviews should only be associated with parent products. This method returns the related Message (reviews) records for a parent product. For a child product the Message records for the parent are returned.
Arguments are passed as paremeters to search the related reviews.
top_reviews
Returns the highest-rated approved public reviews for this product. Argument is max number of reviews to return which defaults to 5.
average_rating
Returns the average rating across all public and approved product reviews.
add_to_reviews
Reviews should only be associated with parent products. This method returns the related ProductReview records for a parent product. For a child product the ProductReview records for the parent are returned.
set_reviews
Similar to "set_$rel" in DBIx::Class::Relationship::Base except that this method DOES delete objects in the table on the right side of the relation.
delete
Overload delete to force removal of any product reviews. Only parent products should have reviews so in the case of child products no attempt is made to delete reviews.