Class: Rawbotz::ProductUpdater
- Inherits:
-
Object
- Object
- Rawbotz::ProductUpdater
- Defined in:
- lib/rawbotz/processors/product_updater.rb
Instance Attribute Summary collapse
-
#active_attribute_id ⇒ Object
Returns the value of attribute active_attribute_id.
-
#change_text ⇒ Object
Returns the value of attribute change_text.
-
#local_products ⇒ Object
Returns the value of attribute local_products.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#name_attribute_id ⇒ Object
Returns the value of attribute name_attribute_id.
-
#order_info_attribute_id ⇒ Object
Returns the value of attribute order_info_attribute_id.
-
#organic_attribute_id ⇒ Object
Returns the value of attribute organic_attribute_id.
-
#packsize_attribute_id ⇒ Object
Returns the value of attribute packsize_attribute_id.
-
#purchase_price_attribute_id ⇒ Object
Returns the value of attribute purchase_price_attribute_id.
-
#shelve_attribute_id ⇒ Object
Returns the value of attribute shelve_attribute_id.
-
#supplier_attribute_id ⇒ Object
Returns the value of attribute supplier_attribute_id.
-
#supplier_prod_name_attribute_id ⇒ Object
Returns the value of attribute supplier_prod_name_attribute_id.
-
#supplier_sku_attribute_id ⇒ Object
Returns the value of attribute supplier_sku_attribute_id.
Instance Method Summary collapse
-
#initialize(logger) ⇒ ProductUpdater
constructor
A new instance of ProductUpdater.
- #sync(dry_run = false) ⇒ Object
Constructor Details
#initialize(logger) ⇒ ProductUpdater
Returns a new instance of ProductUpdater.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rawbotz/processors/product_updater.rb', line 12 def initialize logger @local_products = {} @logger = logger # Attribute mapping from conf @name_attribute_id = Rawbotz.attribute_ids["name"] @supplier_attribute_id = Rawbotz.attribute_ids["supplier_name"] @shelve_attribute_id = Rawbotz.attribute_ids["shelve_nr"] @packsize_attribute_id = Rawbotz.attribute_ids["packsize"] @order_info_attribute_id = Rawbotz.attribute_ids["order_info"] @supplier_sku_attribute_id = Rawbotz.attribute_ids["supplier_sku"] @purchase_price_attribute_id = Rawbotz.attribute_ids["purchase_price"] @supplier_prod_name_attribute_id = Rawbotz.attribute_ids["supplier_prod_name"] @active_attribute_id = Rawbotz.attribute_ids["active_attribute_id"] @organic_attribute_id = Rawbotz.attribute_ids["organic"] @logger.debug "Attribute-ids: Name: #{@name_attribute_id}, "\ "Supplier: #{@supplier_attribute_id}, "\ "Shelve-Nr: #{@shelve_attribute_id}, "\ "Packsize: #{@packsize_attribute_id}"\ "Order Info: #{@order_info_attribute_id}"\ "Purchase Price: #{@purchase_price_attribute_id}"\ "Active: #{@active_attribute_id}"\ "Supplier-SKU: #{@supplier_sku_attribute_id}"\ "Supplier-Prod-Name: #{@supplier_prod_name_attribute_id}"\ "Organic: #{@organic_attribute_id}" end |
Instance Attribute Details
#active_attribute_id ⇒ Object
Returns the value of attribute active_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def active_attribute_id @active_attribute_id end |
#change_text ⇒ Object
Returns the value of attribute change_text.
10 11 12 |
# File 'lib/rawbotz/processors/product_updater.rb', line 10 def change_text @change_text end |
#local_products ⇒ Object
Returns the value of attribute local_products.
3 4 5 |
# File 'lib/rawbotz/processors/product_updater.rb', line 3 def local_products @local_products end |
#logger ⇒ Object
Returns the value of attribute logger.
4 5 6 |
# File 'lib/rawbotz/processors/product_updater.rb', line 4 def logger @logger end |
#name_attribute_id ⇒ Object
Returns the value of attribute name_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def name_attribute_id @name_attribute_id end |
#order_info_attribute_id ⇒ Object
Returns the value of attribute order_info_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def order_info_attribute_id @order_info_attribute_id end |
#organic_attribute_id ⇒ Object
Returns the value of attribute organic_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def organic_attribute_id @organic_attribute_id end |
#packsize_attribute_id ⇒ Object
Returns the value of attribute packsize_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def packsize_attribute_id @packsize_attribute_id end |
#purchase_price_attribute_id ⇒ Object
Returns the value of attribute purchase_price_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def purchase_price_attribute_id @purchase_price_attribute_id end |
#shelve_attribute_id ⇒ Object
Returns the value of attribute shelve_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def shelve_attribute_id @shelve_attribute_id end |
#supplier_attribute_id ⇒ Object
Returns the value of attribute supplier_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def supplier_attribute_id @supplier_attribute_id end |
#supplier_prod_name_attribute_id ⇒ Object
Returns the value of attribute supplier_prod_name_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def supplier_prod_name_attribute_id @supplier_prod_name_attribute_id end |
#supplier_sku_attribute_id ⇒ Object
Returns the value of attribute supplier_sku_attribute_id.
5 6 7 |
# File 'lib/rawbotz/processors/product_updater.rb', line 5 def supplier_sku_attribute_id @supplier_sku_attribute_id end |
Instance Method Details
#sync(dry_run = false) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rawbotz/processors/product_updater.rb', line 38 def sync(dry_run=false) ensure_existence @logger.info "#{@local_products.count} products" # Name #update_attribute(@name_attribute_id, :name) update_names # Supplier update_supplier_from_option(@supplier_attribute_id) # Shelve update_attribute(@shelve_attribute_id, :shelve_nr) # Packsize update_attribute(@packsize_attribute_id, :packsize, :integer) # Supplier SKU update_attribute(@supplier_sku_attribute_id, :supplier_sku) # Supplier Product name update_attribute(@supplier_prod_name_attribute_id, :supplier_prod_name) # Order Info update_attribute(@order_info_attribute_id, :order_info) # Purchase Price update_attribute(@purchase_price_attribute_id, :purchase_price) # Active? update_attribute_int_bool(@active_attribute_id, :active) # Organic? update_attribute_int_bool(@organic_attribute_id, :organic) unhide_if_reactivated log_changes @change_text = changes save_changes if !dry_run end |