So I am trying to setup Commerce Orders and Commerce Registrations to go into SF when they complete but I can't because of the one to one mapping which causes only my first 2 mapping structures to go through and then it just stops mapping any further with no error.

There was a lot of work done for 7.x-2.x but was not moved into 3x for some reason (https://www.drupal.org/node/785286) so I am sparking up this discussion again to see if anyone else has accomplished this in the 3.x version or if anyone is skilled and willing enough to give it a try.

Comments

TravisJohnston created an issue. See original summary.

TravisJohnston’s picture

Title: One to many drastically needed » Many to One or Many to Many needed
TravisJohnston’s picture

This is still really needed. Most of the Commerce and Commerce Registration workflows I have been able to combine and do a 1 to 1 mapping, but how are you supposed to handle Payments when there are different Types of payments that people can make?

These are separated out into Entity Bundles of the Payment Transaction Entity.. So I can only choose one payment bundle to send to Salesforce?! Or are bundles an exception and it's only the Entity Type that is 1-1?

TravisJohnston’s picture

To work around the Payment issue, I have created a custom module to add new payment columns to the Commerce Order table and assign the payment information to that, so they are then accessible within the single order entity. I don't want to consider this closed though as this is a big picture issue and is needed for those that should not need to dive into a custom module or stitching together multiple things into one to make it work for larger scope integrations.

sergei_brill’s picture

I'm interested in one-to-many mapping feature. One of usage case for me is mapping one SF object to node type and commerce product since SF object stores images, description, name, price, etc. Also mapping of 2 SF objects to 1 drupal entity would be nice. On SF I have a kind of templates and final objects which references to a template. But in drupal I don't need 2 bundles, I only need to display combined data from both SF objects.
Table salesforce_mapping_object have this configs for unique keys

 'unique keys' => array(
      'salesforce' => array('salesforce_id'),
      'salesforce_drupal' => array('entity_type', 'entity_id'),
      'revision_id' => array('revision_id'),

What if we change it to

 'unique keys' => array(
      'salesforce_drupal' => array('salesforce_id', 'entity_type', 'entity_id'),
      'revision_id' => array('revision_id'),

and update functions which loads data from the table. Does it make sense? Will it bring new problems?
I really need these features and I'm ready to work on patch for the module.

sergei_brill’s picture

Version: 7.x-3.1 » 7.x-3.x-dev
Status: Active » Needs review
StatusFileSize
new53.82 KB
new45.37 KB

I started to work on one-to-many mappings in both directions. First patch is for current stable version 7.x-3.1. It was tested and it works for me at least with simple cases when 2 entities mapped to 1 SF record and vice versa. Second patch is for current dev version of the module.

0livier’s picture

Hi,
In your case we have two content type for one salesforce object. Whe push content type 1 to account object and we pull account object to content type 2. But function salesforce_mapping_object_load_by_sfid() only return one entity, and salesforce_id is unique key in database.
So this patch add entity bundle in salesforce_mapping_object to allow this.

othmen’s picture

Fix issues with path to changed files.

TravisJohnston’s picture

I haven't updated this for awhile but I no longer use the GUI provided by this module. Instead, I use a couple of the methods it provides in a custom module of mine which controls all of the mapping. What's nice about doing it in code is I can also do a lot more validation checks before I do anything. So for Contacts, I can check to see if they exists by looking at things like First Name, Last Name, and Email together before determining if they are new or existing.

What's also nice is the ability to break up a Drupal entity into different objects (Many to Many) in Salesforce and visa versa by using separate API calls for different fields. For instance the same entity in Drupal contains Contact Information for the person and their Company Address. So in code I can check for the person and and look for an existing Account that matches the Company Address.

So much nicer yet it does get a little daunting after awhile... I wrote a little about it here: http://blog.collaborative.org/technology/2016/03/customize-syncing-between-drupal-and-salesforce-part-1/

aaronbauman’s picture

Status: Needs review » Needs work

I think this change makes sense, including changing the mapping object schema to include entity bundle.

But I don't think we should change the signature of salesforce_mapping_object_load_by_sfid() in a way that's not backwards compatible. Contrib modules may rely on this.

The arg order needs to be preserved (ie. make $bundle argument last), and an empty default supplied to preserve existing behavior.

Travis, those blog posts are great!

mèche’s picture

Just check if drupal_bundle is set, to avoid notices

markusa’s picture

This would be a great feature to be in the official release of this module.

I'm working on a new Salesforce integration, and it would be awesome to be able to push sync one Drupal entity type to two different Salesforce objects, programmatically deciding when a entity should be synced to which SF object..

I'm going to try to see if these patches are applicable to 7.x-3.3-beta3

If anyone here has tried this on v3.3-beta3 and wants to share, that would be awesome! Thanks!

aaronbauman’s picture

Component: Code » salesforce.module
Status: Needs work » Closed (won't fix)

7.x is no longer supported

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.