Has anyone ported the d7 option to re-pull to D8? https://www.drupal.org/node/2223673

We have a similar situation where the rules changed and we would like to update all records.

Comments

michaelpporter created an issue. See original summary.

aaronbauman’s picture

StatusFileSize
new49.87 KB

Yes, both push and pull buttons exist on the mapped object form.

Additionally, for pull, there are now drush commands to populate the pull queue from a query (sf-pull-query) or a file (sf-pull-file), and to forcibly process the push queue (sf-push-queue).

michaelpporter’s picture

Hum `drush sfpq item_to_product_import` is adding items to the queue, 'Queued 2745 items for pull.' The custom PULL_PRESAVE function does not seem to be triggered. If I go to the salesforce tab edit and click 'pull' it does.

Why would a single forced refresh not call PULL_PRESAVE?

aaronbauman’s picture

sfpq only populates the queue, but does not attempt to process it.
You need to run cron to process the queue, or use Drupal core's queue-run command.

michaelpporter’s picture

The queue runs. I ran cron and watched it empty. but node titles did not refresh.

select salesforce_id, title from salesforce_mapped_object join node_field_data on entity_id = nid order by title
aaronbauman’s picture

sounds like a problem with your mapping.

michaelpporter’s picture

How so? the mapping brings in new items just fine and I can force an update which works. I can not do a bulk update.

To me it seems that this is the reason:

      // By default $mapped_object->forceUpdate() is FALSE. To force true, call
      // $mapped_object->setForceUpdate() in the prepull event hook above.
      if ($sf_record_updated > $entity_updated || $mapped_object->forceUpdate()) {

So I should add a call to PULL_PREPULL and add $mapped_object->forceUpdate(). Then remove it as we do not want that standard. Might be nice to have that as part of the drush call.

aaronbauman’s picture

Category: Support request » Feature request

ahhh, sorry I just caught up to what you're asking about.

I'm open to any new feature or change that will accommodate both:
1. being able to force a pull regardless of timestamps
2. preventing pull of stale SF data from overwriting newer Drupal data

FWIW: In 7.x-2.x branch, this was accomplished with a stateful "force" property on the pull-queue-item itself.

michaelpporter’s picture

FYI this worked. Would be nice to have a single use global flag that would do this. Perhaps a entity level flag for do not update.

  /**
   * Force Update.
   *
   * @param \Drupal\salesforce_mapping\Event\SalesforcePullEvent $event
   *    SalesForce pull event data.
   */
  public function pullPrePull(SalesforcePullEvent $event) {
      $event->getMappedObject()->setForceUpdate(TRUE);
  }

  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    $events = [
      SalesforceEvents::PULL_PRESAVE => 'pullPreSave',
      SalesforceEvents::PULL_PREPULL => 'pullPrePull',
    ];
    return $events;
  }
aaronbauman’s picture

Status: Active » Fixed

We've got a few different ways to force a pull now, in addition to the event subscriber described above.

- added a "force-pull" option to drush sfpq, which will add a "force_pull" flag to queue items while populating the pull queue
- added a "sf-pull-reset" drush command, which will reset the pull-trigger timestamps AND set all existing mapped objects to be forcibly re-pulled on the next cron run

I think these will address your use case, so I'll resolve this issue.

Status: Fixed » Closed (fixed)

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