Hi,
I am integrating Salesforce suit module and trying to map salesforce products into drupal product content type.
My drupal "product content type" has following field:
Title, body, prod code, price

When i go to salesforce mapping page and add mapping by choosing "product" object, it display fields to map title, body and code but nor for price.
I know SF keep price in Pricebook2 entity. but how can I get that mapping into my drupal content type?
So my only question is there any way to sync SF price book into drupal content type?
Please let me know if this module has nay feature that provide support to pricebook sync?

Thanks

CommentFileSizeAuthor
#2 uc_sf_product.module.patch5.21 KBkenorb
sf.png38.98 KBcrabsoul

Comments

kenorb’s picture

StatusFileSize
new5.21 KB

This could be solved in Drupal 6 in the following way:

/**
 * Bulk price import handler.
 */
function uc_sf_product_salesforce_bulk_price_import_submit($form, &$form_state) {
  $fieldmap = variable_get('uc_sf_order_order_product_export_fieldmap', FALSE);

  foreach ($form_state['values']['nodes'] as $nid => $prices) {
    $node = node_load($nid);
    foreach ($prices as $currency => $data) {
      if ($currency == variable_get('uc_currency_code', 'USD')) {
        $node->sell_price = $data['price'];
      }
      elseif (module_exists('uc_multicurrency')) {
        $node->multicurrency[$currency]['sell_price'] = $data['price'];
      }

      // Store the pricebook ID
      if ($fieldmap) {
        salesforce_api_id_save('uc_sf_pricebook_' . $currency, $nid, $data['sfid'], $fieldmap);
      }
    }
    node_save($node);
  }

  drupal_set_message(t('Product prices have been imported from Salesforce.'));
  drupal_goto('admin/store/products');
}

/**
 * Implementation of hook_fieldmap_objects_alter().
 */
function uc_sf_product_fieldmap_objects_alter(&$objects) {
  // makes the same fields available for export to a contact as they are to an order
  $objects['drupal']['uc_order_products']['fields']['pricebook_sfid'] = array(
    'label' => t('Pricebook Entry Salesforce ID'),
    'group' => t('Order Line Item Information'),
    'type' => SALESFORCE_FIELD_SOURCE_ONLY,
    'export' => '_uc_sf_product_export_pricebook_sfid',
  );
}

function _uc_sf_product_export_pricebook_sfid($product) {
  static $currency = array();

  if (!isset($currency[$product->order_id])) {
    $order = uc_order_load($product->order_id);
    $currency[$product->order_id] = $order->currency;
  }

  $pricebook = salesforce_api_id_load('uc_sf_pricebook_' . $currency[$product->order_id], $product->nid);
  return $pricebook->sfid;
}

Find the full module code in the attachment.

aaronbauman’s picture

Status: Active » 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.