Prior to inserting records into Salesforce Magento MUST make an attempt to locate a record. Customer lookup has several phases:
- Lead Lookup: Attempt to locate a Magento customer in Salesforce Lead collection
- Contact Lookup: Attempt to locate a Magento customer in Salesforce Contact collection
- Attempt to locate a Magento customer in Salesforce PersonAccount collection***
- Account Lookup (B2B Account): Attempt to locate a Salesforce Account based on a company name stored in Billing or Shipping Address in Magento
General Assumptions
Customer Scope:
Magento allows merchants to configure customer account sharing options to either use "Global" or "Per Website". This configuration is found in Magento Admin panel under: System > Configuration > Customer > Customer Configuration > Account Sharing Options block.
If set to "Global" - lookup only uses customer email address in attempt to find a matching record in Salesforce.
If set to "Per Website" - in addition to the email address, "Magento Website" is also used in attempt to uniquely identify a record in Salesforce.
Email Address matching:
Email address lookup in salesforce is case insensitive.
Magento emails ARE case-sensitive. Lookup MUST convert Magento email address into lowercase prior to querying Salesforce for any matching records
Use Cases
Use cases are listed in the order of which the lookup MUST be executed
- Person Accounts are enabled in the Salesforce Organization
- Person Accounts are disabled in the Salesforce Organization
- If a Contact is located
- Take Account from that contact for synchronization
- Perform synchronization and update existing Account and Contact
- IMPORTANT: don't change the owner of existing records in Salesforce
- IMPORTANT: Magento configuration hold a setting which allows Magento to overwrite Account name. If disabled, Magento should retain the existing Account name
- No Contact is found, but system was able to match the Account by name
- Create a new Contact while using the default values from the configuration in Magento
- Attach newly created Contact to the matched Account
- IMPORTANT: Default contact owner is defined in Magento configuration. System will either have to get Account owner and apply same owner to the Contact OR system will use the default owner configured in Magento
- IMPORTANT: Magento configuration hold a setting which allows Magento to overwrite Account name. If disabled, Magento should retain the existing Account name
- No Contact is found, but Magento has configurations under Advanced Lookup which matched an Account
- See 2.b above for requirements
- No Contact and No Account were matched. Check Magento configuration to see if Magento should leverage Leads:
- Leads are turned off in Magento configuration
- A new Contact and an Account should be created
- IMPORTANT: Default Contact owner is defined in Magento configuration. System will either have to get Account owner and apply same owner to the Contact
- IMPORTANT: Magento configuration hold a setting which allows Magento to overwrite Account name. If disabled, Magento should retain the existing Account name
- Leads are turned on in Magento configuration. Lead Lookup should be performed
- If a matching Lead is found
- Perform synchronization and update existing Lead
- IMPORTANT: don't change the owner of existing records in Salesforce
- If matching Lead is NOT found. Magento checks if this customer has placed any orders in Magento
- If a customer has placed at least one order. See 2.d.i for requirements
- If a customer has no orders in Magento
- A new Lead should be created
- IMPORTANT: Default Lead owner is defined in Magento configuration
- If a matching Lead is found
- Leads are turned off in Magento configuration
- If a Contact is located