Programmatically create new Schedule Updates Entity Reference on Node I’m attempting to populate an entity referenced field created by the Scheduled Updates module within a content type, Event. Within Event I have two Scheduled Updates fields to check and uncheck the Sticky at top of list option. 

I also have a product, Promote Event, in which the user is required to add a Begin Promoting Date, an Entity Reference to an Event, and a Quantity. Once a user purchases the Promote Event, I’d like to populate the Scheduled Updates fields within the Event content type with the data used in the purchase. 

I can’t seem to figure out how to programmatically populate the Scheduled Update fields within the Event content type after the purchase of Promote Event. 

Within my custom module I have: 

public function orderCompleteHandler(WorkflowTransitionEvent $event) {
  /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
  $order = $event-&gt;getEntity();

  // Order items in the cart.
  $items = $order-&gt;getItems();
  if($order-&gt;bundle() == 'promoted_event'){    
    $beginPromo = $items[0]-&gt;get('field_begin_promotion')-&gt;getValue();
    $beginPromo = $beginPromo[0]['value'];
    $quantity = $items[0]-&gt;get('quantity')-&gt;getValue();
    $quantity = str_replace('.00', '', $quantity[0]['value']);
    $eventId = $items[0]-&gt;get('field_event_to_promote')-&gt;getValue();
    $eventId = $eventId[0]['target_id'];
    $endPromo = date('Y-m-d', strtotime($beginPromo. ' + '. $quantity .' days'));

    $node = Node::load($eventId);
    // Get the promote_event Entity Reference
    $promoteEvent = $node-&gt;get('promote_event')-&gt;first();
    // Get unPromoteEvent
    $unPromoteEvent = $node-&gt;get('unpromote_event_')-&gt;first();
    if($promoteEvent){

    } else {
      $dateTime = new DrupalDateTime($beginPromo, 'UTC');
      $timestamp = $dateTime-&gt;getTimestamp();
      $node-&gt;promote_event[] = [
        'user_id' =&gt; 1,
         'type' =&gt; 'node__sticky',
         'update_timestamp' =&gt; $timestamp
       ];
       $node-&gt;save();
     }
   }
 }
Here is one example of how to add a ScheduledUpdate to your 'host' entity, in your case a node.

$scheduled_update = ScheduledUpdate::create([
  'type' =&gt; 'node__sticky',
  'status' =&gt; ScheduledUpdateInterface::STATUS_UNRUN,
  'sticky' =&gt; NodeInterface::STICKY,
  'update_timestamp' =&gt; $timestamp,
  'entity_ids' =&gt; [$eventId],
]);
$scheduled_update-&gt;save();
$node-&gt;promote_event = $scheduled_update-&gt;id();
$node-&gt;save();


Good luck!