Class: Catalog::AmazonImageBackfillService
- Inherits:
-
BaseService
- Object
- BaseService
- Catalog::AmazonImageBackfillService
- Defined in:
- app/services/catalog/amazon_image_backfill_service.rb
Overview
Imports missing Amazon images from live Amazon catalog data
Creates Image records and links them via ImageProfile
Usage:
result = Catalog::AmazonImageBackfillService.new(item).process
result # => { imported: 3, skipped: 2, errors: [] }
Constant Summary collapse
- AMAZON_TO_PROFILE_MAPPING =
Mapping of Amazon image variants to our image profile types
Amazon uses MAIN, PT01, PT02, etc. { 'MAIN' => 'AMZ_MAIN', 'PT01' => 'AMZ_PT01', 'PT02' => 'AMZ_PT02', 'PT03' => 'AMZ_PT03', 'PT04' => 'AMZ_PT04', 'PT05' => 'AMZ_PT05', 'PT06' => 'AMZ_PT06', 'PT07' => 'AMZ_PT07', 'PT08' => 'AMZ_PT08', 'PT09' => 'AMZ_PT09', 'PT10' => 'AMZ_PT10', 'PT11' => 'AMZ_PT11' }.freeze
- IMPORT_TAGS =
%w[amazon amazon-imported backfill].freeze
Instance Method Summary collapse
-
#initialize(item, locale: 'en', catalog_item: nil) ⇒ AmazonImageBackfillService
constructor
A new instance of AmazonImageBackfillService.
- #process ⇒ Object
Methods inherited from BaseService
#log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
#initialize(item, locale: 'en', catalog_item: nil) ⇒ AmazonImageBackfillService
Returns a new instance of AmazonImageBackfillService.
32 33 34 35 36 37 38 39 40 |
# File 'app/services/catalog/amazon_image_backfill_service.rb', line 32 def initialize(item, locale: 'en', catalog_item: nil) super() @item = item @locale = locale @catalog_item = catalog_item @imported = 0 @skipped = 0 @errors = [] end |
Instance Method Details
#process ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/services/catalog/amazon_image_backfill_service.rb', line 42 def process amazon_images = find_amazon_images if amazon_images.blank? @errors << 'No Amazon live images found for this item' return result end amazon_images.each do |amazon_variant, amazon_url| process_slot(amazon_variant, amazon_url) end result end |