Class: Item::Materials::CompatibleInstallationKits

Inherits:
BaseCompatibleFinder
  • Object
show all
Defined in:
app/services/item/materials/compatible_installation_kits.rb

Overview

This class is responsible for finding a catalog item's compatible installation kits

Instance Method Summary collapse

Instance Method Details

#process(item:, catalog_items_scope: nil) ⇒ Object

At a minimum you need an item
If you provide a catalog item scope, such as Catalog.catalog_items.for_online_catalog
It will be used to populate the catalog_items results
Without a catalog item scope only the items will be populated in the result



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/item/materials/compatible_installation_kits.rb', line 8

def process(item:, catalog_items_scope: nil)
  items = Item.none
  catalog_items = CatalogItem.none
  messages = []
  
  if item.is_heating_element? &&
     item.is_floor_heating_product? &&
     item.primary_product_line&.get_first_heating_system_type&.slug_ltree&.to_s&.include?('tempzone')
     
     items = Item.by_product_line_path(LtreePaths::PL_FLOOR_HEATING_TEMPZONE_INSTALLATION_KITS)
                  .by_product_category_path(LtreePaths::PC_ACCESSORIES)
  end
  
  return_results(item: item, items: items, catalog_items_scope: catalog_items_scope)

end