We currently create a customer profile for each order. That means lots of duplicates for no reason. It would be far better to consolidate these.

This also might not be a migrate issue - there may be a better way to do it.

Comments

drewish’s picture

does it cause any problems if they're different bundle types? shipping vs billing?

bojanz’s picture

Yes, we can't reference a profile of a different bundle, Commerce will complain, and there's no guarantee that profiles of different bundles have the same field...
We can only consolidate identical profiles of the same bundle.

rfay’s picture

@drewish such a pleasure to have you here working with Commerce Migrate!

drewish’s picture

@rfay, thanks! picked up a side project and you have no idea how excited i was to find this module an not need to start from scratch.

rfay’s picture

Project: Commerce Migrate » Commerce Migrate Ubercart
Component: Commerce Migrate Ubercart » Code
kscheirer’s picture

Version: 7.x-1.x-dev » 7.x-2.0
Category: Feature request » Bug report
Priority: Normal » Major
Issue summary: View changes
Status: Active » Needs review
Related issues: +#2278741: Duplicates when importing customer profiles

Problem

When importing profiles using customer_billing_profile.inc there is no check for duplicate profiles. Both Addressfield and Commerce Profile do have such checks, but they run only during form submits, and are focused on what happens when a user edits a profile or creates a new one. Instead, we are creating new entities directly when migrating.

Reason

The profiles are created from individual uc_orders. Ubercart stores address/billing info directly on the order itself. If a user has ordered more than once, it is quite easy for more than 1 order to have the same address information. We still need to process all the orders to keep the migrate map intact and allow commerce to properly associate the new profile with all the user's orders.

Proposed Solution

In order to prevent a duplicate profile from being created, instead mark the new profile as a revision of the existing profile. This seems to keep the migrate map intact for the later sourceMigration() call in order.inc. The attached patch uses an entity field query to check for the existence of a commerce profile with the same data as the current profile being created.

kscheirer’s picture

StatusFileSize
new1.58 KB

And the actual patch.

Anonymous’s picture

Status: Needs review » Fixed

Thank you! Committed to dev branch today at DrupalCon!

  • Commit fec8ce1 on 7.x-2.x authored by kscheirer, committed by Ryan Weal:
    Issue #1212174 by kscheirer: Consolidate identical Customer Profiles
    
deciphered’s picture

Version: 7.x-2.0 » 7.x-2.x-dev
Status: Fixed » Needs review
StatusFileSize
new1.56 KB
+++ b/customer_billing_profile.inc
@@ -88,5 +88,26 @@ class CommerceMigrateUbercartCustomerBillingProfileMigration extends Migration {
+      ->propertyCondition('uid', $row->uid)

This queries the source UID, not the destination UID, which therefore means that for anyone using a Users migration this will not actually do anything.

New patch resolves the issue.

kscheirer’s picture

Good catch, my migration preserved uids so this wasn't an issue for me. Thanks!

kscheirer’s picture

Status: Needs review » Reviewed & tested by the community
dwkitchen’s picture

Status: Reviewed & tested by the community » Fixed

  • dwkitchen committed c8daf7b on 7.x-2.x authored by Deciphered
    Issue #1212174 by kscheirer, Deciphered: Consolidate identical Customer...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.