Skip to content

Commit

Permalink
Merge pull request #36 from algolia/fix_search_adapter
Browse files Browse the repository at this point in the history
Fix search adapter to work on both Magento ~2.0.0 and ~2.1.0
  • Loading branch information
Jan Petr authored Aug 10, 2016
2 parents e145649 + 87817d5 commit d44bd4a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Adapter/Algolia.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,17 @@ public function query(RequestInterface $request)
}

$getDocumentMethod = 'getDocument21';
$storeDocumentsMethod = 'storeApiDocuments';
if (version_compare($this->config->getMagentoVersion(), '2.1.0', '<') === true) {
$getDocumentMethod = 'getDocument20';
$storeDocumentsMethod = 'storeDocuments';
}

$apiDocuments = array_map(function ($document) use ($getDocumentMethod) {
return $this->{$getDocumentMethod}($document);
}, $documents);

$table = $temporaryStorage->storeApiDocuments($apiDocuments);
$table = $temporaryStorage->{$storeDocumentsMethod}($apiDocuments);
}

$aggregations = $this->aggregationBuilder->build($request, $table);
Expand Down

0 comments on commit d44bd4a

Please sign in to comment.