GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Interchange6::Schema::Result::Product(3) User Contributed Perl Documentation Interchange6::Schema::Result::Product(3)

Interchange6::Schema::Result::Product

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.

This simple accessor is available to resultset searches which wish to add column "image" to stash an image in the result.

SKU used by shop.

Primary key.

Manufacturer's sku.

Is nullable.

The name used to identify the product.

A brief summary of the product.

Full product description.

Numeric value representing product cost.

Defaults to 0.

When "price" is updated and product has related "discount" in Interchange6::Schema::Result::PriceModifier then also update the related "price" in Interchange6::Schema::Result::PriceModifier. This is done using the method "update_price_modifiers".

Unique product uri. Example "acme-pro-dumbbells". Is nullable.

Numeric weight of the product. Defaults to zero.

Display order priority.

Unique EAN or UPC type data. Is nullable.

The SKU of the main product if this product is a variant of a main product. Is nullable.

Is this product active? Default is yes.

Is this product exempt from inventory? Default is no.

Indicate whether products with the same SKU should be combined in the Cart.

Defaults to true.

Date and time when this record was created returned as DateTime object. Value is auto-set on insert.

Date and time when this record was last modified returned as DateTime object. Value is auto-set on insert and update.

Type: belongs_to

Related object: Interchange6::Schema::Result::Product

Type: has_many

Related object: Interchange6::Schema::Result::Product

Type: has_many

Related object: Interchange6::Schema::Result::CartProduct

Type: has_many

Related object: Interchange6::Schema::Result::PriceModifier

Type: might_have

Related object: Interchange6::Schema::Result::Inventory

Type: has_many

Related object: Interchange6::Schema::Result::MediaProduct

Type: has_many

Related object: Interchange6::Schema::Result::MerchandisingProduct

Type: has_many

Related object: Interchange6::Schema::Result::MerchandisingProduct

Type: has_many

Related object: Interchange6::Schema::Result::NavigationProduct

Type: many_to_many with navigation

Type: has_many

Related object: Interchange6::Schema::Result::Orderline

Type: has_many

Related object: Interchange6::Schema::Result::ProductAttribute

Type: many_to_many with media

Type: has_many

Related object: Interchange6::Schema::Result::ProductMessage

Type: many_to_many

Accessor to related Message results.

Attribute methods are provided by the Interchange6::Schema::Base::Attribute class.

Override inherited method to call "generate_uri" method in case "name" and "sku" have been supplied as arguments but "uri" has not.

Called when "price" is updated.

Called by "new" if no uri is given as an argument.

The following steps are taken:

1. Join "$self->name" and "$self->uri" with "-" and stash in $uri to allow manipulation via filters

2. Remove leading and trailing spaces and replace remaining spaces and "/" with "-"

3. Search for all rows in Interchange6::Schema::Result::Setting where "scope" is "Product" and "name" is <generate_uri_filter>

4. For each row found eval "$row->value"

5. Finally set the value of column "uri" to $uri

Filters stored in Interchange6::Schema::Result::Setting are executed via eval and have access to $uri and also the product result held in $self

Examples of filters stored in Setting might be:

    {
        scope => 'Product',
        name  => 'generate_uri_filter',
        value => '$uri =~ s/badstuff/goodstuff/gi',
    },
    {
        scope => 'Product',
        name  => 'generate_uri_filter',
        value => '$uri = lc($uri)',
    },

Produces navigation path for this product. Returns array reference in scalar context.

Uses $type to select specific taxonomy from navigation if present.

Arguments should be given as a hash reference with the following keys/values:
quantity => $quantity

"quantity" defaults to 1 if not supplied.

PriceModifier rows which have "roles_id" undefined are always included in the search in addition to any "roles" that belonging to "logger_in_user" in Schema. This enables promotional prices to be specified between fixed dates in "price" in Interchange6::Schema::Result::PriceModifier to apply to all classes of user whether logged in or not.

Returns lowest price from "price" and "price" in Interchange6::Schema::Result::PriceModifier.

Throws exception on bad arguments though unexpected keys in the hash reference will be silently discarded.

If the query was constructed using "with_lowest_selling_price" in Interchange6::Schema::ResultSet::Product then the cached value will be used rather than running a new query UNLESS arguments are supplied in which case a new query is performed.

If this is a canonical product without variants or a variant product then this method will return undef. If highest price is the same as "selling_price" then we again return undef.

If the query was constructed using "with_highest_price" in Interchange6::Schema::ResultSet::Product then the cached value will be used rather than running a new query.

This method calls "variant_count" and "selling_price" so when constructing a resultset query consider also chaining the associated ResultSet methods.

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).

Arguments: "hashref => 1"

Return a hashref of attributes keyed on attribute name instead of an arrayref.

Arguments: "selected => $sku"

Set the 'selected' SKU. For a child product this is set automatically.

Arguments: "cond => $cond"

Search condition to use. Default is:

    { 'attribute.type' => 'variant' }
Arguments: "order_by => $order_by"

Ordering to use in query. Default is:

    [
        { -desc => 'attribute.priority' },
        { -asc => 'attribute.title' },
        { -desc => 'attribute_value.priority' },
        { -asc => 'attribute_value.title' },
    ]

Set the 'selected' SKU. For a child product this is set automatically.

Returns: An arrayref of attributes complete with their respective attribute values.

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 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'}

Since there is a risk that attributes names might clash with Product column names (for example "weight") an improved syntax exists to prevent such problems. This is considered to be the preferred syntax:

    {
        sku   => 'ROD00014-2-6-mid',
        uri   => 'fishingrod-weight-2-length-6-flex-mid',
        price => 355,
        attributes => [
            { weight => '2' },
            { length => '6' },
            { action => 'mid' },
        ],
    }

If "selling_price" is lower than "price" returns the rounded percentage discount or undef.

NOTE: for parent products (products that have variants) this will always return undef.

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.

Reviews should only be associated with parent products.

This method returns the related Interchange6::Schema::Result::ProductMessage records for a parent product where the related Interchange6::Schema::Result::Message has "name" in Interchange6::Schema::Result::MessageType of "product_review". For a child product the ProductReview records for the parent are returned.

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: $cond | undef, \%attrs?

Arguments are passed as paremeters to search the related reviews.

Returns the highest-rated approved public reviews for this product. Argument is max number of reviews to return which defaults to 5.

Returns the number of variants of this product.

Alias for "variant_count" for backwards-compatibility.

Returns the average rating across all public and approved product reviews or undef if there are no reviews. Optional argument number of decimal places of precision must be a positive integer less than 10 which defaults to 1.

If the query was constructed using "with_average_rating" in Interchange6::Schema::ResultSet::Product then the cached value will be used rather than running a new query.

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.

Arguments: (\@hashrefs_of_col_data | \@result_objs)
Return Value: not defined

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.

Returns undef if inventory_exempt is true and otherwise returns the quantity of the product in the inventory. For a product variant the quantity returned is for the variant itself whereas for a canonical (parent) product the quantity returned is the total for all variants.

If the query was constructed using "with_quantity_in_stock" in Interchange6::Schema::ResultSet::Product then the cached value will be used rather than running a new query.

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.
2016-07-16 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.