The SOAP function "create" accepts multiple objects of the same type.

In this patch:
Instead of calling "create" for each iteration over order->products during uc_sf_order_export,
collect the sf product objects and create them all at once.

Also, comment out some calls to "dpm" that were creating fatal errors.

CommentFileSizeAuthor
uc_sf_order.patch2.2 KBaaronbauman

Comments

bibeksahu’s picture

Assigned: Unassigned » bibeksahu

I'll look into this this week.

EvanDonovan’s picture

Assigned: bibeksahu » Unassigned

@aaronbauman: It looks like this is already in your mega-patch for compatibility? If so, can I close this after my re-roll is committed?

cf. lines 703-722 in uc_sf_order_export() (line numbers may be slightly off from what you would get from patching):

if (variable_get('uc_sf_order_auto_sync_product', 0)) {
        $product_objects = array();
        foreach ($order->products as $product) {
          // modify the product
          $user_salesforce = salesforce_api_id_load('user', $order->uid);
          $product->sfautogen_order_sfid = $order_sfid;
          $product->sfautogen_user_sfid = $user_salesforce->sfid;

          $product->salesforce = salesforce_api_id_load('node', $product->nid);
          $product->sfautogen_product_sfid = $product->salesforce ? $product->salesforce->sfid : '';

          // Create an object for export based on the specified fieldmap.
          $product_objects[] = salesforce_api_fieldmap_export_create($uc_order_products_fieldmap_id, $product);
        }
        try {
          $product_responses = $sf->client->create($product_objects, $uc_order_products_fieldmap->salesforce);
        }
        catch (Exception $e) {
          watchdog('uc_sf_order', 'Failed to export Order Product to SalesForce. <pre>' . print_r($e, 1) . '</pre><pre>' . print_r($product, 1) . '</pre><pre>' . print_r($product_objects[$i], 1) . '</pre>');
        }
EvanDonovan’s picture

Status: Active » Reviewed & tested by the community

Actually, I am certain that the code I quoted above is doing this, so marking as RTBC.

EvanDonovan’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in alpha2.

Status: Fixed » Closed (fixed)

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