Class: ViewItemCatalog

Inherits:
ApplicationViewRecord show all
Includes:
Models::SearchableView, PgSearch::Model
Defined in:
app/models/view_item_catalog.rb

Overview

== Schema Information

Table name: view_item_catalogs
Database name: primary

id :integer primary key
all_pl_paths_ids :ltree is an Array
all_pl_paths_slugs :ltree is an Array
catalog_item_amount :decimal(8, 2)
catalog_item_is_discontinued :boolean
catalog_item_max_discount :integer
catalog_item_state :string(30)
catalog_item_stock_reserved :integer
inherited_item_product_category_ids :integer is an Array
inherited_item_product_line_ids :integer is an Array
item_condition :enum
item_dropship :boolean
item_is_available_to_public :boolean
item_is_discontinued :boolean
item_name :string(255)
item_oversize :boolean
item_qty_out_of_stock :integer
item_require_reservation :boolean
item_shipping_class :enum
item_sku :string
item_unlimited_inventory :boolean
item_warn_on_stock :integer
pc_path_ids :ltree
pc_path_slugs :ltree
primary_pl_path_ids :ltree
primary_pl_path_slugs :ltree
product_category_lineage_expanded :text
product_category_name :string(255)
product_category_priority :integer
product_line_ids :integer is an Array
restricted_for_sales :boolean
store_item_qty_available :integer
store_item_qty_committed :integer
store_item_qty_on_hand :integer
store_item_unit_cogs :decimal(, )
catalog_id :integer
catalog_item_id :integer
item_id :integer
item_product_category_id :integer
literature_id :integer
store_item_id :integer

Constant Summary

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Belongs to collapse

Class Method Summary collapse

Methods included from Models::SearchableView

#crm_link, #crm_link_subtitle, #has_columns?, #readonly?

Methods inherited from ApplicationViewRecord

create, create!, #readonly?

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.activeActiveRecord::Relation<ViewItemCatalog>

A relation of ViewItemCatalogs that are active. Active Record Scope

Returns:

See Also:



70
# File 'app/models/view_item_catalog.rb', line 70

scope :active, -> { where.not(item_is_discontinued: true).where(catalog_item_state: %w[active active_hidden]) }

.belongs_to_product_category_idActiveRecord::Relation<ViewItemCatalog>

A relation of ViewItemCatalogs that are belongs to product category id. Active Record Scope

Returns:

See Also:



81
82
83
84
85
86
# File 'app/models/view_item_catalog.rb', line 81

scope :belongs_to_product_category_id, ->(pcid) {
  ids = [pcid].flatten.compact.uniq
  return none if ids.empty?

  where.ltree_contains(:pc_path_ids, ids, array: false)
}

.belongs_to_product_line_idActiveRecord::Relation<ViewItemCatalog>

A relation of ViewItemCatalogs that are belongs to product line id. Active Record Scope

Returns:

See Also:



73
74
75
76
77
78
# File 'app/models/view_item_catalog.rb', line 73

scope :belongs_to_product_line_id, ->(plid) {
  ids = [plid].flatten.compact.uniq
  return none if ids.empty?

  where.ltree_contains(:all_pl_paths_ids, ids)
}

.excluding_out_of_stock_refurbActiveRecord::Relation<ViewItemCatalog>

A relation of ViewItemCatalogs that are excluding out of stock refurb. Active Record Scope

Returns:

See Also:



89
90
91
# File 'app/models/view_item_catalog.rb', line 89

scope :excluding_out_of_stock_refurb, -> {
  where("view_item_catalogs.item_condition = 'new' OR (view_item_catalogs.item_condition = 'refurbished' AND view_item_catalogs.store_item_qty_available > 0)")
}

.ransackable_scopes(_auth_object = nil) ⇒ Array<Symbol>

Expose ltree-powered scopes to Ransack for efficient hierarchy filtering.

Parameters:

  • _auth_object (Object) (defaults to: nil)

    unused Ransack auth object

Returns:

  • (Array<Symbol>)


104
105
106
# File 'app/models/view_item_catalog.rb', line 104

def self.ransackable_scopes(_auth_object = nil)
  %i[belongs_to_product_line_id belongs_to_product_category_id]
end

.unrestrictedActiveRecord::Relation<ViewItemCatalog>

A relation of ViewItemCatalogs that are unrestricted. Active Record Scope

Returns:

See Also:



88
# File 'app/models/view_item_catalog.rb', line 88

scope :unrestricted, -> { where.not(restricted_for_sales: true) }

.with_skusActiveRecord::Relation<ViewItemCatalog>

A relation of ViewItemCatalogs that are with skus. Active Record Scope

Returns:

See Also:



92
# File 'app/models/view_item_catalog.rb', line 92

scope :with_skus, ->(skus) { where(item_sku: skus) }

Instance Method Details

#catalog_itemCatalogItem

Returns:



57
# File 'app/models/view_item_catalog.rb', line 57

belongs_to :catalog_item, optional: true

#itemItem

Returns:



53
# File 'app/models/view_item_catalog.rb', line 53

belongs_to :item, optional: true

#store_itemStoreItem

Returns:



55
# File 'app/models/view_item_catalog.rb', line 55

belongs_to :store_item, optional: true