| 1 | package Nitesi::Product; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Sub::Quote; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Nitesi::Product - Product class for Nitesi Shop Machine | ||
| 12 | |||
| 13 | =head1 DESCRIPTION | ||
| 14 | |||
| 15 | Generic product class for L<Nitesi>. | ||
| 16 | |||
| 17 | =head2 PRODUCTS | ||
| 18 | |||
| 19 | Each product has the following attributes: | ||
| 20 | |||
| 21 | =over 4 | ||
| 22 | |||
| 23 | =item sku | ||
| 24 | |||
| 25 | Unique product identifier. | ||
| 26 | |||
| 27 | =item name | ||
| 28 | |||
| 29 | Product name. | ||
| 30 | |||
| 31 | =item short_description | ||
| 32 | |||
| 33 | Short product description. | ||
| 34 | |||
| 35 | =item description | ||
| 36 | |||
| 37 | Full product description. | ||
| 38 | |||
| 39 | =item price | ||
| 40 | |||
| 41 | Product price. | ||
| 42 | |||
| 43 | =item uri | ||
| 44 | |||
| 45 | Link to Product. | ||
| 46 | |||
| 47 | =item weight | ||
| 48 | |||
| 49 | Product weight in grams. | ||
| 50 | |||
| 51 | =item priority | ||
| 52 | |||
| 53 | The product priority is used for sorting products on | ||
| 54 | search results and category listings. | ||
| 55 | |||
| 56 | =item inactive | ||
| 57 | |||
| 58 | Inactive products are excluded from search results and | ||
| 59 | category listings. | ||
| 60 | |||
| 61 | =back | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | 1 | has sku => ( | |
| 66 | is => 'rw', | ||
| 67 | ); | ||
| 68 | |||
| 69 | 1 | has name => ( | |
| 70 | is => 'rw', | ||
| 71 | ); | ||
| 72 | |||
| 73 | 1 | has short_description => ( | |
| 74 | is => 'rw', | ||
| 75 | ); | ||
| 76 | |||
| 77 | 1 | has description => ( | |
| 78 | is => 'rw', | ||
| 79 | ); | ||
| 80 | |||
| 81 | 1 | has price => ( | |
| 82 | is => 'rw', | ||
| 83 | ); | ||
| 84 | |||
| 85 | 1 | has uri => ( | |
| 86 | is => 'rw', | ||
| 87 | ); | ||
| 88 | |||
| 89 | 1 | has weight => ( | |
| 90 | is => 'rw', | ||
| 91 | lazy => 1, | ||
| 92 | default => quote_sub q{return 0;}, | ||
| 93 | ); | ||
| 94 | |||
| 95 | 1 | has priority => ( | |
| 96 | is => 'rw', | ||
| 97 | lazy => 1, | ||
| 98 | default => quote_sub q{return 0;}, | ||
| 99 | ); | ||
| 100 | |||
| 101 | 1 | has inactive => ( | |
| 102 | is => 'rw', | ||
| 103 | lazy => 1, | ||
| 104 | default => quote_sub q{return 0;}, | ||
| 105 | ); | ||
| 106 | |||
| 107 | =head1 METHODS | ||
| 108 | |||
| 109 | =head2 api_attributes | ||
| 110 | |||
| 111 | API attributes for product class. | ||
| 112 | |||
| 113 | =cut | ||
| 114 | |||
| 115 | 1 | has api_attributes => ( | |
| 116 | is => 'rw', | ||
| 117 | ); | ||
| 118 | |||
| 119 | =head2 api_info | ||
| 120 | |||
| 121 | API information for product class. | ||
| 122 | |||
| 123 | =cut | ||
| 124 | |||
| 125 | 2 | ▶ | sub api_info { |
|
Subroutine
api_info: called CC=1 SCAR=0.0
Pod
documented
| |||
| 126 | 2 | my $self = shift; | |
| 127 | |||
| 128 | 2 | return {base => __PACKAGE__, | |
| 129 | table => 'products', | ||
| 130 | key => 'sku', | ||
| 131 | attributes => $self->api_attributes, | ||
| 132 | foreign => {'Nitesi::Navigation' => { | ||
| 133 | table => 'navigation_products', | ||
| 134 | key => [qw/sku navigation/]} | ||
| 135 | }, | ||
| 136 | }; | ||
| 137 | }; | ||
| 138 | |||
| 139 | =head1 AUTHOR | ||
| 140 | |||
| 141 | Stefan Hornburg (Racke), <racke@linuxia.de> | ||
| 142 | |||
| 143 | =head1 LICENSE AND COPYRIGHT | ||
| 144 | |||
| 145 | Copyright 2012-2013 Stefan Hornburg (Racke) <racke@linuxia.de>. | ||
| 146 | |||
| 147 | This program is free software; you can redistribute it and/or modify it | ||
| 148 | under the terms of either: the GNU General Public License as published | ||
| 149 | by the Free Software Foundation; or the Artistic License. | ||
| 150 | |||
| 151 | See http://dev.perl.org/licenses/ for more information. | ||
| 152 | |||
| 153 | =cut | ||
| 154 | |||
| 155 | 1 | 1; | |