Skip to content

Commit 8a1a1c5

Browse files
committed
MAGE-1170: add new IndexOptions model
1 parent d138d2d commit 8a1a1c5

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

Api/Data/IndexOptionsInterface.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Api\Data;
4+
5+
interface IndexOptionsInterface
6+
{
7+
const STORE_ID = 'store_id';
8+
9+
const INDEX_SUFFIX = 'index_suffix';
10+
11+
const IS_TMP = 'is_tmp';
12+
13+
const ENFORCED_INDEX_NAME = 'enforced_index_name';
14+
15+
/**
16+
* Get field: store_id
17+
*
18+
* @return int|null
19+
*/
20+
public function getStoreId(): ?int;
21+
22+
/**
23+
* Get field: index_suffix
24+
*
25+
* @return string|null
26+
*/
27+
public function getIndexSuffix(): ?string;
28+
29+
/**
30+
* Get field: is_tmp
31+
*
32+
* @return bool
33+
*/
34+
public function isTmp(): bool;
35+
36+
/**
37+
* Get field: enforced_index_name
38+
*
39+
* @return string|null
40+
*/
41+
public function getEnforcedIndexName(): ?string;
42+
}

Model/IndexOptions.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Model;
4+
5+
use Algolia\AlgoliaSearch\Api\Data\IndexOptionsInterface;
6+
use Magento\Framework\DataObject;
7+
8+
class IndexOptions extends DataObject implements IndexOptionsInterface
9+
{
10+
public function getStoreId(): ?int
11+
{
12+
return $this->hasData(IndexOptionsInterface::STORE_ID) ?
13+
(int) $this->getData(IndexOptionsInterface::STORE_ID) :
14+
null;
15+
}
16+
17+
public function getIndexSuffix(): ?string
18+
{
19+
return $this->hasData(IndexOptionsInterface::INDEX_SUFFIX) ?
20+
(string) $this->getData(IndexOptionsInterface::INDEX_SUFFIX) :
21+
null;
22+
}
23+
24+
public function isTmp(): bool
25+
{
26+
return $this->hasData(IndexOptionsInterface::IS_TMP) ?
27+
(string) $this->getData(IndexOptionsInterface::IS_TMP) :
28+
false;
29+
}
30+
31+
public function getEnforcedIndexName(): ?string
32+
{
33+
return $this->hasData(IndexOptionsInterface::ENFORCED_INDEX_NAME) ?
34+
(string) $this->getData(IndexOptionsInterface::ENFORCED_INDEX_NAME) :
35+
null;
36+
}
37+
}

Service/IndexNameFetcher.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public function __construct(
2121
public const INDEX_QUERY_SUGGESTIONS_SUFFIX = '_query_suggestions';
2222

2323
/**
24+
* Ex: magento2_default_products
25+
*
2426
* @param string $indexSuffix
2527
* @param int|null $storeId
2628
* @param bool $tmp
@@ -33,6 +35,8 @@ public function getIndexName(string $indexSuffix, ?int $storeId = null, bool $tm
3335
}
3436

3537
/**
38+
* Ex: magento2_default
39+
*
3640
* @param int|null $storeId
3741
* @return string
3842
* @throws NoSuchEntityException

0 commit comments

Comments
 (0)