diff --git a/src/Indexer/DefaultIndexer.php b/src/Indexer/DefaultIndexer.php
index a434aa6..cd50a29 100644
--- a/src/Indexer/DefaultIndexer.php
+++ b/src/Indexer/DefaultIndexer.php
@@ -24,7 +24,6 @@
use Setono\SyliusMeilisearchPlugin\Repository\IndexableResourceRepositoryInterface;
use Setono\SyliusMeilisearchPlugin\Resolver\IndexName\IndexNameResolverInterface;
use Setono\SyliusMeilisearchPlugin\Settings\IndexSettings;
-use Setono\SyliusMeilisearchPlugin\Settings\SortableReplica;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Webmozart\Assert\Assert;
@@ -226,21 +225,6 @@ protected function prepareIndex(string $indexName, IndexSettings $indexSettings)
/** @psalm-suppress MixedAssignment,MixedArrayAccess */
$indexSettings->ranking = $index->getSettings()['ranking'];
- foreach ($indexSettings->replicas as $replica) {
- if (!$replica instanceof SortableReplica) {
- continue;
- }
-
- $replicaIndex = $this->client->initIndex($replica->name);
- Assert::isInstanceOf($replicaIndex, SearchIndex::class);
-
- $replicaIndexSettings = clone $indexSettings;
- $replicaIndexSettings->replicas = [];
- array_unshift($replicaIndexSettings->ranking, $replica->ranking());
-
- $replicaIndex->setSettings($replicaIndexSettings->toArray());
- }
-
return $index;
}
}
diff --git a/src/Provider/IndexSettings/IndexSettingsProvider.php b/src/Provider/IndexSettings/IndexSettingsProvider.php
index 41b3071..a1e3242 100644
--- a/src/Provider/IndexSettings/IndexSettingsProvider.php
+++ b/src/Provider/IndexSettings/IndexSettingsProvider.php
@@ -5,39 +5,13 @@
namespace Setono\SyliusMeilisearchPlugin\Provider\IndexSettings;
use Setono\SyliusMeilisearchPlugin\IndexScope\IndexScope;
-use Setono\SyliusMeilisearchPlugin\Resolver\IndexName\IndexNameResolverInterface;
-use Setono\SyliusMeilisearchPlugin\Resolver\ReplicaIndexName\ReplicaIndexNameResolverInterface;
use Setono\SyliusMeilisearchPlugin\Settings\IndexSettings;
-use Setono\SyliusMeilisearchPlugin\Settings\SortableReplica;
final class IndexSettingsProvider implements IndexSettingsProviderInterface
{
- public function __construct(
- private readonly IndexNameResolverInterface $indexNameResolver,
- private readonly ReplicaIndexNameResolverInterface $replicaIndexNameResolver,
- )
- {
- }
-
// todo implement an easier way to set settings decoupled from the document. This could be by dispatching an IndexSettingsEvent
public function getSettings(IndexScope $indexScope): IndexSettings
{
- $settings = $indexScope->index->document::getDefaultSettings($indexScope);
- $indexName = $this->indexNameResolver->resolveFromIndexScope($indexScope);
-
- foreach ($settings->replicas as &$replica) {
- $replica = $this->replicaIndexNameResolver->resolveFromIndexNameAndExistingValue($indexName, (string) $replica);
- }
- unset($replica);
-
- foreach ($indexScope->index->document::getSortableAttributes() as $attribute => $order) {
- $settings->replicas[] = new SortableReplica(
- $this->replicaIndexNameResolver->resolveFromIndexNameAndSortableAttribute($indexName, $attribute, $order),
- $attribute,
- $order,
- );
- }
-
- return $settings;
+ return $indexScope->index->document::getDefaultSettings($indexScope);
}
}
diff --git a/src/Resolver/ReplicaIndexName/ReplicaIndexNameResolver.php b/src/Resolver/ReplicaIndexName/ReplicaIndexNameResolver.php
deleted file mode 100644
index 692628d..0000000
--- a/src/Resolver/ReplicaIndexName/ReplicaIndexNameResolver.php
+++ /dev/null
@@ -1,21 +0,0 @@
-indexNameResolver->resolve($index);
- $sortBys = [
+ return [
new SortBy(
$this->translator->trans('setono_sylius_meilisearch.ui.sort_by.relevance', [], null, $locale),
$indexName,
),
];
-
- foreach ($index->document::getSortableAttributes() as $attribute => $order) {
- $sortBys[] = new SortBy(
- $this->translator->trans(sprintf('setono_sylius_meilisearch.ui.sort_by.%s_%s', $attribute, $order), [], null, $locale),
- $this->replicaIndexNameResolver->resolveFromIndexNameAndSortableAttribute(
- $indexName,
- $attribute,
- $order,
- ),
- );
- }
-
- return $sortBys;
}
}
diff --git a/src/Resources/config/services/provider.xml b/src/Resources/config/services/provider.xml
index 7866b94..89ecc53 100644
--- a/src/Resources/config/services/provider.xml
+++ b/src/Resources/config/services/provider.xml
@@ -31,9 +31,6 @@
-
-
-
+ class="Setono\SyliusMeilisearchPlugin\Provider\IndexSettings\IndexSettingsProvider"/>
diff --git a/src/Resources/config/services/resolver.xml b/src/Resources/config/services/resolver.xml
index 8fbee39..e6e8ec0 100644
--- a/src/Resources/config/services/resolver.xml
+++ b/src/Resources/config/services/resolver.xml
@@ -9,13 +9,9 @@
%kernel.environment%
-
-
-
diff --git a/src/SetonoSyliusMeilisearchPlugin.php b/src/SetonoSyliusMeilisearchPlugin.php
index 0183c23..b66847e 100644
--- a/src/SetonoSyliusMeilisearchPlugin.php
+++ b/src/SetonoSyliusMeilisearchPlugin.php
@@ -6,7 +6,6 @@
use Setono\CompositeCompilerPass\CompositeCompilerPass;
use Setono\SyliusMeilisearchPlugin\DependencyInjection\Compiler\RegisterIndexesPass;
-use Setono\SyliusMeilisearchPlugin\DependencyInjection\Compiler\RegisterTwigVariablePass;
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
@@ -19,7 +18,6 @@ public function build(ContainerBuilder $container): void
{
parent::build($container);
- $container->addCompilerPass(new RegisterTwigVariablePass());
$container->addCompilerPass(new RegisterIndexesPass());
// Register services in composite services
diff --git a/src/Settings/IndexSettings.php b/src/Settings/IndexSettings.php
index 7ade666..1ed5d60 100644
--- a/src/Settings/IndexSettings.php
+++ b/src/Settings/IndexSettings.php
@@ -28,28 +28,6 @@ class IndexSettings extends Settings
/** @var list */
public array $customRanking = [];
- /**
- * If you add replica indexes they will automatically be prefixed with the primary index name
- *
- * Example:
- * Your primary index name: prod__products__fashion_web__en_us__usd
- * You set $replicas = ['a_b']
- *
- * When sent to Algolia, $replicas will be ['prod__products__fashion_web__en_us__usd__a_b']
- *
- * ----
- *
- * Also notice that if you have implemented \Setono\SyliusMeilisearchPlugin\Document\Document::getSortableAttributes()
- * the $replicas will be automatically populated by the plugin. You don't have to do anything.
- *
- * Example:
- * Your document's getSortableAttributes method returns ['price' => 'asc'] then the $replicas will automatically
- * be set to [prod__products__fashion_web__en_us__usd__price_asc]
- *
- * @var list
- */
- public array $replicas = [];
-
public ?int $paginationLimitedTo = null;
/** @var list */
diff --git a/src/Settings/SortableReplica.php b/src/Settings/SortableReplica.php
deleted file mode 100644
index 38de62f..0000000
--- a/src/Settings/SortableReplica.php
+++ /dev/null
@@ -1,22 +0,0 @@
-order, $this->attribute);
- }
-
- public function __toString(): string
- {
- return $this->name;
- }
-}