Class: Workarea::Listrak::Models::ProductForm
- Inherits:
-
Object
- Object
- Workarea::Listrak::Models::ProductForm
- Includes:
- ActionView::Helpers::AssetUrlHelper, ApplicationHelper, I18n::DefaultUrlOptions
- Defined in:
- app/services/workarea/listrak/models/product_form.rb
Instance Method Summary collapse
- #as_json(_options) ⇒ Object
-
#brand ⇒ String
Brand name of product.
-
#category ⇒ String
Category or department.
-
#color ⇒ String
Color of product (e.g. green, paisley, etc.).
-
#description ⇒ String
Description of product.
-
#discontinued ⇒ Boolean
Explicit indicator that the item has been discontinued.
-
#gender ⇒ String
Gender of product (if applicable).
-
#image_url ⇒ String
URL for product image.
-
#in_stock ⇒ Boolean
Explicit indicator that the item is in stock.
-
#initialize(product, sku, pricing_sku: nil, inventory_sku: nil) ⇒ ProductForm
constructor
A new instance of ProductForm.
-
#is_clearence ⇒ Boolean
Explicit indicator that the item is a clearance item.
-
#is_outlet ⇒ Boolean
Explicit indicator that the item is an outlet item.
-
#is_purchasable ⇒ Boolean
Explicit indicator that the item can be included in recommendations.
-
#is_viewable ⇒ Boolean
Flag used in some systems to determine if the item should be included in recommendations.
-
#link_url ⇒ String
URL for product webpage.
-
#master_sku ⇒ String
Unique stock number of the master product.
-
#meta1 ⇒ String
Additional meta imformation.
-
#meta2 ⇒ String
Additional meta imformation.
-
#meta3 ⇒ String
Additional meta imformation.
-
#meta4 ⇒ String
Additional meta imformation.
-
#meta5 ⇒ String
Additional meta imformation.
-
#msrp ⇒ Float
Retail price of the product.
-
#on_sale ⇒ Boolean
Explicit indicator that the item is on sale.
-
#price ⇒ Float
List price of product.
-
#quantity_on_hand ⇒ Object
Quantity on hand.
-
#sale_end_date ⇒ String
End date time of sale.
-
#sale_price ⇒ Float
Sale price of product.
-
#sale_start_date ⇒ String
Start date time of sale.
-
#size ⇒ String
Size of product (e.g. small, M, 6 7/8”).
-
#sku ⇒ String
Unique stock number of product.
-
#style ⇒ String
Style of product.
-
#sub_category ⇒ String
Sub-category or sub-department.
-
#title ⇒ String
Product name.
-
#unit_cost ⇒ Float
Price per individual item.
Constructor Details
#initialize(product, sku, pricing_sku: nil, inventory_sku: nil) ⇒ ProductForm
Returns a new instance of ProductForm.
13 14 15 16 17 18 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 13 def initialize(product, sku, pricing_sku: nil, inventory_sku: nil) @product = product @sku = sku @pricing_sku = pricing_sku @inventory_sku = inventory_sku end |
Instance Method Details
#as_json(_options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 20 def as_json() { brand: brand, category: category, color: color, description: description, discontinued: discontinued, gender: gender, imageUrl: image_url, inStock: in_stock, isClearance: is_clearence, isOutlet: is_outlet, isPurchasable: is_purchasable, isViewable: is_viewable, linkUrl: link_url, masterSku: master_sku, meta1: , meta2: , meta3: , meta4: , meta5: , msrp: msrp, onSale: on_sale, price: price, qoh: quantity_on_hand, saleEndDate: sale_end_date, salePrice: sale_price, saleStartDate: sale_start_date, size: size, sku: sku, style: style, subCategory: sub_category, title: title, unitCost: unit_cost }.compact end |
#brand ⇒ String
Brand name of product
limited to 50 characters
63 64 65 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 63 def brand product.try(:brand) end |
#category ⇒ String
Category or department
limited to 50 characters
73 74 75 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 73 def category categorization.default_model.try(:name) end |
#color ⇒ String
Color of product (e.g. green, paisley, etc.)
limited to 100 characters
83 84 85 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 83 def color variant.fetch_detail('color') end |
#description ⇒ String
Description of product
limited to 4000 characters
93 94 95 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 93 def description product.description end |
#discontinued ⇒ Boolean
Explicit indicator that the item has been discontinued
101 102 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 101 def discontinued end |
#gender ⇒ String
Gender of product (if applicable)
limited to 50 characters
110 111 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 110 def gender end |
#image_url ⇒ String
URL for product image
limited to 500 characters
119 120 121 122 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 119 def image_url return unless image = variant_image || product.images.first @image_url ||= product_image_url(image, :detail) end |
#in_stock ⇒ Boolean
Explicit indicator that the item is in stock
128 129 130 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 128 def in_stock quantity_on_hand > 0 end |
#is_clearence ⇒ Boolean
Explicit indicator that the item is a clearance item
136 137 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 136 def is_clearence end |
#is_outlet ⇒ Boolean
Explicit indicator that the item is an outlet item
143 144 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 143 def is_outlet end |
#is_purchasable ⇒ Boolean
Explicit indicator that the item can be included in recommendations
150 151 152 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 150 def is_purchasable product.purchasable? && inventory_sku.purchasable? end |
#is_viewable ⇒ Boolean
Flag used in some systems to determine if the item should be included in recommendations
158 159 160 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 158 def is_viewable product.purchasable? && inventory_sku.purchasable? end |
#link_url ⇒ String
URL for product webpage
limited to 500 characters
168 169 170 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 168 def link_url product_url(product, host: Workarea.config.host) end |
#master_sku ⇒ String
Unique stock number of the master product
limited to 100 characters
178 179 180 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 178 def master_sku product.id.to_s end |
#meta1 ⇒ String
Additional meta imformation
limted to 500 characters
188 189 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 188 def end |
#meta2 ⇒ String
Additional meta imformation
limted to 500 characters
197 198 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 197 def end |
#meta3 ⇒ String
Additional meta imformation
limted to 500 characters
206 207 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 206 def end |
#meta4 ⇒ String
Additional meta imformation
limted to 500 characters
215 216 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 215 def end |
#meta5 ⇒ String
Additional meta imformation
limted to 500 characters
224 225 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 224 def end |
#msrp ⇒ Float
Retail price of the product
231 232 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 231 def msrp end |
#on_sale ⇒ Boolean
Explicit indicator that the item is on sale
238 239 240 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 238 def on_sale pricing_sku.on_sale? end |
#price ⇒ Float
List price of product
246 247 248 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 246 def price pricing_sku.find_price.sell.to_f end |
#quantity_on_hand ⇒ Object
Quantity on hand
return [Integer]
254 255 256 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 254 def quantity_on_hand inventory_sku.available end |
#sale_end_date ⇒ String
End date time of sale
262 263 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 262 def sale_end_date end |
#sale_price ⇒ Float
Sale price of product
269 270 271 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 269 def sale_price pricing_sku.find_price.sale.to_f end |
#sale_start_date ⇒ String
Start date time of sale
277 278 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 277 def sale_start_date end |
#size ⇒ String
Size of product (e.g. small, M, 6 7/8”)
limited to 50 characters
286 287 288 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 286 def size variant.fetch_detail('size') end |
#sku ⇒ String
Unique stock number of product
limited to 100 characters
296 297 298 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 296 def sku @sku end |
#style ⇒ String
Style of product
limited to 100 characters
306 307 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 306 def style end |
#sub_category ⇒ String
Sub-category or sub-department
limited to 50 characters
315 316 317 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 315 def sub_category categorization.secondary_model.try(:name) end |
#title ⇒ String
Product name
limited to 500 characters
325 326 327 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 325 def title product.name end |
#unit_cost ⇒ Float
Price per individual item
333 334 |
# File 'app/services/workarea/listrak/models/product_form.rb', line 333 def unit_cost end |