public function updateStock($sku, $quantity, $status) {
    // Update the stock now.
    $this->acquireLock($sku);

    // First try to check if stock changed.
    $current = $this->getStock($sku);

    // Update only if value changed.
    if (empty($current) || $current['status'] != $status || $current['quantity'] != $quantity) {
      $new = [
        'quantity' => $quantity,
        'status' => $status,
      ];

      $this->connection->merge('acm_sku_stock')
        ->key(['sku' => $sku])
        ->fields($new)
        ->execute();

      $status_changed = $current
        ? $this->isStockStatusChanged($current, $new)
        : TRUE;

      $sku_entity = SKU::loadFromSku($sku);
      if ($sku_entity instanceof SKUInterface) {
        $low_quantity = $this->isQuantityLow($new);
        $event = new StockUpdatedEvent($sku_entity, $status_changed, $low_quantity);
        $this->dispatcher->dispatch(StockUpdatedEvent::EVENT_NAME, $event);
      }

      return $status_changed;
    }

    $this->releaseLock($sku);
    return FALSE;
  }