diff --git a/src/Plugin/views/sort/ViewsRandomSeedRandom.php b/src/Plugin/views/sort/ViewsRandomSeedRandom.php
index f7a614a97..8053af602 100644
--- a/src/Plugin/views/sort/ViewsRandomSeedRandom.php
+++ b/src/Plugin/views/sort/ViewsRandomSeedRandom.php
@@ -6,6 +6,7 @@
 use Drupal\views\Plugin\views\sort\SortPluginBase;
 use Drupal\views_random_seed\SeedCalculator;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\search_api\Plugin\views\query\SearchApiQuery;
 
 /**
  * Handle a random sort with seed.
@@ -126,8 +127,23 @@ public function query() {
         \Drupal::database()->query("select random()");
         $formula = 'RANDOM()';
         break;
+      default:
+        $formula = NULL;
     }
-    if (!empty($formula)) {
+
+    // Use SearchAPI random sorting with seed if the query object is an instance
+    // of SearchApiViewsQuery (or a subclass of it). Pass along the seed and the
+    // built formula as options for the SearchApiQuery class.
+    // See: https://www.drupal.org/node/1197538#comment-10190520
+    if ($this->view->query instanceof SearchApiQuery) {
+      \Drupal::logger("Random Seed")->notice("inside search_api altering ");
+
+      $this->query->addOrderBy('rand', NULL, NULL, '', [
+        'seed' => $seed,
+        'formula' => $formula,
+      ]);
+    }
+    elseif (!empty($formula)) {
       $this->query->addOrderBy(NULL, $formula, $this->options['order'], '_' . $this->field);
     }
   }
diff --git a/modules/contrib/views_random_seed/src/SeedCalculator.php b/modules/contrib/views_random_seed/src/SeedCalculator.php
index 73ed9ed20..bf753e115 100644
--- a/src/SeedCalculator.php
+++ b/src/SeedCalculator.php
@@ -131,7 +131,7 @@ protected function createInt($time, $db_type) {
    * @return \Symfony\Component\HttpFoundation\Session\SessionInterface
    */
   protected function getSession() {
-    return $this->requestStack->getCurrentRequest()->getSession();
+    return \Drupal::service('session');
   }
 
 }
