Class: Spree::Exports::Products
- Inherits:
-
Spree::Export
- Object
- Spree::Export
- Spree::Exports::Products
- Defined in:
- app/models/spree/exports/products.rb
Constant Summary
Constants inherited from Spree::Export
Spree::Export::SUPPORTED_FILE_FORMATS
Instance Method Summary collapse
- #csv_headers ⇒ Object
- #multi_line_csv? ⇒ Boolean
-
#scope ⇒ Object
when doing full product export, we want to exclude archived products.
-
#scope_includes ⇒ Object
to avoid N+1 queries.
- #variant_includes ⇒ Object
Methods inherited from Spree::Export
available_models, available_types, #build_csv_line, #current_ability, #decode_prefixed_id_filters, #decode_search_value, #done?, #event_serializer_class, #export_file_name, #export_tmp_file_path, #generate, #generate_async, #generate_csv, #handle_attachment, #metafields_headers, #model_class, model_class, #normalize_search_params, #records_to_export, required_scope, #results_url, #results_url=, #send_export_done_email, type_for_model
Instance Method Details
#csv_headers ⇒ Object
28 29 30 31 32 |
# File 'app/models/spree/exports/products.rb', line 28 def csv_headers headers = Spree::CSV::ProductVariantPresenter::CSV_HEADERS.dup headers += @csv_headers ||= headers end |
#multi_line_csv? ⇒ Boolean
15 16 17 |
# File 'app/models/spree/exports/products.rb', line 15 def multi_line_csv? true end |
#scope ⇒ Object
when doing full product export, we want to exclude archived products
20 21 22 23 24 25 26 |
# File 'app/models/spree/exports/products.rb', line 20 def scope if search_params.nil? super.where.not(status: 'archived') else super end end |
#scope_includes ⇒ Object
to avoid N+1 queries
5 6 7 8 9 |
# File 'app/models/spree/exports/products.rb', line 5 def scope_includes includes = [:tax_category, :master, :option_types, { taxons: :taxonomy }, { variants_including_master: variant_includes }] includes << { metafields: :metafield_definition } includes end |
#variant_includes ⇒ Object
11 12 13 |
# File 'app/models/spree/exports/products.rb', line 11 def variant_includes [:images, :prices, :stock_items, :stock_locations, { option_values: [:option_type] }] end |