Skip to content

Commit 5826371

Browse files
committed
MAGE-837 Relocate replica constants
1 parent b625777 commit 5826371

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

Api/Product/ReplicaManagerInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
interface ReplicaManagerInterface
1111
{
12+
public const REPLICA_TRANSFORM_MODE_STANDARD = 1;
13+
public const REPLICA_TRANSFORM_MODE_VIRTUAL = 2;
14+
public const REPLICA_TRANSFORM_MODE_ACTUAL = 3;
15+
16+
public const SORT_KEY_VIRTUAL_REPLICA = 'virtualReplica';
17+
1218
/**
1319
* Configure replicas in Algolia based on the sorting configuration in Magento
1420
*

Helper/ConfigHelper.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace Algolia\AlgoliaSearch\Helper;
44

5-
use Algolia\AlgoliaSearch\Model\Product\ReplicaManager;
5+
use Algolia\AlgoliaSearch\Api\Product\ReplicaManagerInterface;
66
use Magento;
7+
use Magento\Cookie\Helper\Cookie as CookieHelper;
8+
use Magento\Customer\Api\GroupExcludedWebsiteRepositoryInterface;
79
use Magento\Customer\Model\ResourceModel\Group\Collection as GroupCollection;
810
use Magento\Directory\Model\Currency as DirCurrency;
911
use Magento\Framework\App\Filesystem\DirectoryList;
@@ -13,9 +15,6 @@
1315
use Magento\Framework\Serialize\SerializerInterface;
1416
use Magento\Store\Model\ScopeInterface;
1517
use Magento\Store\Model\StoreManagerInterface;
16-
use Magento\Customer\Api\GroupExcludedWebsiteRepositoryInterface;
17-
use Magento\Cookie\Helper\Cookie as CookieHelper;
18-
1918

2019
class ConfigHelper
2120
{
@@ -1869,7 +1868,7 @@ public function useVirtualReplica(?int $storeId = null): bool
18691868
return (bool) count(array_filter(
18701869
$this->getSorting($storeId),
18711870
function ($sort) {
1872-
return $sort[ReplicaManager::SORT_KEY_VIRTUAL_REPLICA];
1871+
return $sort[ReplicaManagerInterface::SORT_KEY_VIRTUAL_REPLICA];
18731872
}
18741873
));
18751874
}

Helper/Entity/ProductHelper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Algolia\AlgoliaSearch\Helper\Entity\Product\PriceManager;
1616
use Algolia\AlgoliaSearch\Helper\Image as ImageHelper;
1717
use Algolia\AlgoliaSearch\Helper\Logger;
18-
use Algolia\AlgoliaSearch\Model\Product\ReplicaManager;
1918
use Magento\Bundle\Model\Product\Type as BundleProductType;
2019
use Magento\Catalog\Model\Product;
2120
use Magento\Catalog\Model\Product\Attribute\Source\Status;
@@ -1426,7 +1425,7 @@ protected function decorateReplicasSetting(array $sortingIndices): array {
14261425
return array_map(
14271426
function($sort) {
14281427
$replica = $sort['name'];
1429-
return !! $sort[ReplicaManager::SORT_KEY_VIRTUAL_REPLICA]
1428+
return !! $sort[ReplicaManagerInterface::SORT_KEY_VIRTUAL_REPLICA]
14301429
? "virtual($replica)"
14311430
: $replica;
14321431
},

Model/Source/Sorts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Algolia\AlgoliaSearch\Model\Source;
44

5-
use Algolia\AlgoliaSearch\Model\Product\ReplicaManager;
5+
use Algolia\AlgoliaSearch\Api\Product\ReplicaManagerInterface;
66

77
/**
88
* Algolia custom sort order field
@@ -35,7 +35,7 @@ protected function getTableData()
3535
'sortLabel' => [
3636
'label' => 'Label',
3737
],
38-
ReplicaManager::SORT_KEY_VIRTUAL_REPLICA => [
38+
ReplicaManagerInterface::SORT_KEY_VIRTUAL_REPLICA => [
3939
'label' => 'Enable Virtual Replica?',
4040
'values' => ['0' => __('No'), '1' => __('Yes')],
4141
],

0 commit comments

Comments
 (0)