Sha256: a20e03cf251e627880676db20688ac5523f3157feb91147332a790e2922d9161

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

module Gemgento
  class Magento::AddressAdapter

    attr_accessor :source, :addressable

    def initialize(source, addressable)
      @source = source
      @addressable = addressable
    end

    def import
      address = Gemgento::Address.find_or_initialize_by(addressable: addressable, magento_id: self.source[:address_id])
      address.increment_id = self.source[:increment_id]
      address.city = self.source[:city]
      address.company = self.source[:company]
      address.country = Gemgento::Country.find_by(magento_id: self.source[:country_id])
      address.fax = self.source[:fax]
      address.first_name = self.source[:firstname]
      address.middle_name = self.source[:middlename]
      address.last_name = self.source[:lastname]
      address.postcode = self.source[:postcode]
      address.prefix = self.source[:prefix]
      address.region_name = self.source[:region]
      address.region = Gemgento::Region.find_by(magento_id: self.source[:region_id])
      address.street = self.source[:street]
      address.suffix = self.source[:suffix]
      address.telephone = self.source[:telephone]
      address.is_billing = (self.source[:address_type] == 'billing')
      address.is_shipping = (self.source[:address_type] == 'shipping')
      address.sync_needed = false
      address.save! validate: false

      return address
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/adapters/gemgento/magento/address_adapter.rb