Method: Magenthor::Customer#create

Defined in:
lib/magenthor/customer.rb

#createTrueClass, FalseClass

Create on Magento the local Customer

Returns:

  • (TrueClass, FalseClass)

    true if successful or false



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/magenthor/customer.rb', line 48

def create
    attributes = {}
    methods.grep(/\w=$/).each do |m|
        attributes[m.to_s.gsub('=','')] = send(m.to_s.gsub('=',''))
    end
    response = self.class.commit('customer.create', [attributes])
    return false if response == false

    obj = self.class.find(response)
    methods.grep(/\w=$/).each do |m|
        send(m, obj.send(m.to_s.gsub('=','')))
    end
    self.customer_id = obj.customer_id
    self.increment_id = obj.increment_id
    self.created_at = obj.created_at
    self.updated_at = obj.updated_at
    self.password_hash = obj.password_hash

    return true
end