Class: ViewItemCatalog
- Inherits:
-
ApplicationViewRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ApplicationViewRecord
- ViewItemCatalog
- 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 :string(20)
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 :integer
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
Belongs to collapse
Class Method Summary collapse
-
.active ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are active.
-
.belongs_to_product_category_id ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are belongs to product category id.
-
.belongs_to_product_line_id ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are belongs to product line id.
-
.excluding_out_of_stock_refurb ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are excluding out of stock refurb.
-
.ransackable_scopes(_auth_object = nil) ⇒ Object
Expose ltree-powered scopes to Ransack for efficient hierarchy filtering.
-
.unrestricted ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are unrestricted.
-
.with_skus ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are with skus.
Methods included from Models::SearchableView
#crm_link, #crm_link_subtitle, #has_columns?, #main_resource, #readonly?
Methods inherited from ApplicationViewRecord
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Class Method Details
.active ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are active. Active Record Scope
58 |
# File 'app/models/view_item_catalog.rb', line 58 scope :active, -> { where.not(item_is_discontinued: true).where(catalog_item_state: %w[active active_hidden]) } |
.belongs_to_product_category_id ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are belongs to product category id. Active Record Scope
69 70 71 72 73 74 |
# File 'app/models/view_item_catalog.rb', line 69 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_id ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are belongs to product line id. Active Record Scope
61 62 63 64 65 66 |
# File 'app/models/view_item_catalog.rb', line 61 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_refurb ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are excluding out of stock refurb. Active Record Scope
77 78 79 |
# File 'app/models/view_item_catalog.rb', line 77 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) ⇒ Object
Expose ltree-powered scopes to Ransack for efficient hierarchy filtering
89 90 91 |
# File 'app/models/view_item_catalog.rb', line 89 def self.ransackable_scopes(_auth_object = nil) %i[belongs_to_product_line_id belongs_to_product_category_id] end |
.unrestricted ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are unrestricted. Active Record Scope
76 |
# File 'app/models/view_item_catalog.rb', line 76 scope :unrestricted, -> { where.not(restricted_for_sales: true) } |
.with_skus ⇒ ActiveRecord::Relation<ViewItemCatalog>
A relation of ViewItemCatalogs that are with skus. Active Record Scope
80 |
# File 'app/models/view_item_catalog.rb', line 80 scope :with_skus, ->(skus) { where(item_sku: skus) } |
Instance Method Details
#catalog_item ⇒ CatalogItem
54 |
# File 'app/models/view_item_catalog.rb', line 54 belongs_to :catalog_item, optional: true |
#store_item ⇒ StoreItem
53 |
# File 'app/models/view_item_catalog.rb', line 53 belongs_to :store_item, optional: true |