Class: Edi::MiraklSeller::ProductDataProcessor
- Inherits:
-
BaseEdiService
- Object
- BaseService
- BaseEdiService
- Edi::MiraklSeller::ProductDataProcessor
- Includes:
- ActionView::Helpers::TextHelper
- Defined in:
- app/services/edi/mirakl_seller/product_data_processor.rb
Constant Summary
Constants included from AddressAbbreviator
AddressAbbreviator::MAX_LENGTH
Instance Attribute Summary
Attributes inherited from BaseEdiService
Instance Method Summary collapse
Methods inherited from BaseEdiService
#duplicate_po_already_notified?, #initialize, #mark_duplicate_po_as_notified, #report_order_creation_issues, #safe_process_edi_communication_log
Methods included from AddressAbbreviator
#abbreviate_street, #collect_street_originals, #record_address_abbreviation_notes
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
This class inherits a constructor from Edi::BaseEdiService
Instance Method Details
#load_results(states: nil) ⇒ Object
34 35 36 37 38 39 |
# File 'app/services/edi/mirakl_seller/product_data_processor.rb', line 34 def load_results(states: nil) catalog_items = CatalogItem.for_orchestrator_keys(orchestrator.config[:orchestrator_keys]) items = Item.where.not(upc: [nil,'']).joins(:catalog_items).merge(catalog_items).distinct { items: items, catalog_items: catalog_items } #CatalogItem.where(id: 46152) #This is a test catalog item end |
#process(catalog_items: nil, states: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/edi/mirakl_seller/product_data_processor.rb', line 5 def process(catalog_items: nil, states: nil) ecl = nil EdiCommunicationLog.transaction do logger.info "Sending product data for partner #{orchestrator.partner}" load_result = load_results items = load_result[:items] catalog_items = load_result[:catalog_items] data_result = orchestrator.product_data_configurator.build_xml(items: items) data_xml = data_result.xml error_list = data_result.errors if error_list.present? InternalMailer.notify_edi_admin_of_mirakl_error(orchestrator.partner, 'product_data', error_list.join(" \n")).deliver_now else ecl = EdiCommunicationLog.create_outbound_file_from_data( data: data_xml, file_extension: 'xml', file_name: "wy-api-product-export-#{Time.now.strftime('%Y%m%d%H%M%S')}.xml", partner: orchestrator.partner, category: 'product_data', data_type: 'xml', file_info: {} ) end end ecl end |