Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Agata Firlejczyk committed Oct 18, 2019
2 parents fe885b4 + 2b850da commit 98db890
Show file tree
Hide file tree
Showing 21 changed files with 343 additions and 116 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

## [1.5.0]

### Changed/Improved
- Change method `AbstractEavAttributes:canReindex:canReindex` to public ([#136](https://github.com/DivanteLtd/magento2-vsbridge-indexer/pull/136))

### Added
- Add support for aliases ([#3](https://github.com/DivanteLtd/magento2-vsbridge-indexer/issues/3)).

## [1.4.0] (2019.10.15)

### Fixes
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ Sign up for a demo at https://vuestorefront.io/ (Vue Storefront integrated with

## Overview

### Version 1.5.0 - support for aliases.
Command ` php bin/magento vsbridge:reindex` will reindex all data to new index.
It will create new index and update aliases at the end.

If you used previous versions, you will have to delete index (created with this extension) from ES manually:
If you won't do that, you will get error when running
`"error":{"root_cause":[{"type":"invalid_alias_name_exception","reason":"Invalid alias name [vue_storefront_magento_1], an index exists with the same name as the alias"`

## Installation/Getting Started

- Install with composer
```json
composer require divante/magento2-vsbridge-indexer
```

```php
php bin/magento setup:upgrade
```

## Installation/Getting Started - MSI support
- Install second module which will support MSI
```json
Expand Down Expand Up @@ -89,13 +101,17 @@ Go to the new ‘Indexer’ section (Stores → Configuration → Vuestorefront
Batch Indexing Size → select size of packages by which you intend to send data to ElasticSrearch. Depending on the project you might need to adjust package size to the number of products, attributes, configurable products variation, etc). By default Batch, Indexing Size is set up for 1000.
Indicies settings

Index Name Prefix → define prefixes for ElasticSearch indexes. The panel allows adding prefix only to the catalog name e.g.: "vue_storefront_catalog". For each store (store view) index name is generated on the base of defined prefix and either ID or Store Code. Aliases cannot be created.
Index Alias Prefix → define prefixes for ElasticSearch indexes. The panel allows adding prefix only to the catalog name e.g.: "vue_storefront_catalog". For each store (store view) index name is generated on the base of defined prefix and either ID or Store Code. Aliases cannot be created.
Example: When we define following indexes: "vue_storefront_catalog_1", "vue_storefront_catalog_2", "vue_storefront_catalog_3".

Note: change to "vue_storefront_catalog" to make it compatible with [mage2vuestorefront](https://github.com/DivanteLtd/mage2vuestorefront/) import.

**Important**: It is crucial to update this configuration in the VSF and VSF-API (one change at the beginning of the whole configuration process).

Index Identifier → defines the unique store identifier to append to the ElasticSearch indexes. The default value is ID which will append the Store ID to the index name e.g.: "vue_storefront_catalog_1". You can choose to change this to Store Code which will add the Store Code to the index name e.g.: "vue_storefront_catalog_storecode".

Add Index Identifier to Default Store View → defines if we should add Index Identifier to Magento Default Store View. Select "No" - to make it compatible with [mage2vuestorefront](https://github.com/DivanteLtd/mage2vuestorefront/) import.

####Example with Store ID

"vue_storefront_magento_1" - index for store view with id 1
Expand Down Expand Up @@ -146,7 +162,7 @@ Go to the new ‘Indexer’ section (Stores → Configuration → Vuestorefront
],
```

![](docs/images/config-indices.png)
![](docs/images/config-indices-settings.png)

1. Redis Cache Settings

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "Agata",
"email": "[email protected]"
}],
"version": "1.4.0",
"version": "1.5.0",
"keywords": [
"magento",
"magento2",
Expand Down
Binary file added docs/images/config-indices-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/config-indices.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getAttributeOptions(array $attributeData, $storeId)
{
return $this->loadOptions->execute($attributeData['attribute_code'], $storeId);
}

/**
* @param array $attributeData
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function loadAttributesData($storeId, array $entityIds, array $requiredAt
* @return bool
* @throws \Exception
*/
private function canReindex(\Magento\Eav\Model\Entity\Attribute $attribute, array $allowedAttributes = null)
public function canReindex(\Magento\Eav\Model\Entity\Attribute $attribute, array $allowedAttributes = null)
{
if ($attribute->isStatic()) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ interface EavAttributesInterface
* @throws \Exception
*/
public function loadAttributesData($storeId, array $entityIds, array $requiredAttributes = null);

/**
* @param \Magento\Eav\Model\Entity\Attribute $attribute
* @param array|null $allowedAttributes
*
* @return bool
*/
public function canReindex(\Magento\Eav\Model\Entity\Attribute $attribute, array $allowedAttributes = null);
}
7 changes: 7 additions & 0 deletions src/module-vsbridge-indexer-catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,11 @@
</argument>
</arguments>
</type>
<type name="Divante\VsbridgeIndexerCore\Console\Command\RebuildEsIndexCommand">
<arguments>
<argument name="excludeIndices" xsi:type="array">
<item name="product_category" xsi:type="const">Divante\VsbridgeIndexerCatalog\Model\Indexer\ProductCategoryProcessor::INDEXER_ID</item>
</argument>
</arguments>
</type>
</config>
16 changes: 16 additions & 0 deletions src/module-vsbridge-indexer-core/Api/Client/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ public function bulk(array $bulkParams);
*/
public function createIndex($indexName, array $indexSettings);

/**
* Retrieve the list of all index having a specified alias.
*
* @param string $indexAlias Index alias.
*
* @return string[]
*/
public function getIndicesNameByAlias(string $indexAlias): array;

/**
* @param array $aliasActions
*
* @return void
*/
public function updateAliases(array $aliasActions);

/**
* @param string $indexName
*
Expand Down
10 changes: 10 additions & 0 deletions src/module-vsbridge-indexer-core/Api/IndexInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ interface IndexInterface
*/
public function getName();

/**
* @return string
*/
public function getIdentifier();

/**
* @return boolean
*/
public function isNew();

/**
* @return \Divante\VsbridgeIndexerCore\Api\Index\TypeInterface[]
*/
Expand Down
16 changes: 9 additions & 7 deletions src/module-vsbridge-indexer-core/Api/IndexOperationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getIndexByName($indexIdentifier, StoreInterface $store);
*
* @return string
*/
public function getIndexName(StoreInterface $store);
public function getIndexAlias(StoreInterface $store);

/**
* @param string $indexIdentifier
Expand All @@ -60,17 +60,19 @@ public function getIndexName(StoreInterface $store);
public function createIndex($indexIdentifier, StoreInterface $store);

/**
* @param string $indexIdentifier
* @param StoreInterface $store
* @param IndexInterface $index
*
* @return void
*/
public function deleteIndex($indexIdentifier, StoreInterface $store);
public function refreshIndex(IndexInterface $index);

/**
* @param IndexInterface $index
* @param string $indexName
* @param string $indexAlias
*
* @return $this
* @return void
*/
public function refreshIndex(IndexInterface $index);
public function switchIndexer(string $indexName, string $indexAlias);

/**
* @return BulkRequestInterface
Expand Down
8 changes: 8 additions & 0 deletions src/module-vsbridge-indexer-core/Config/IndicesSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public function getIndexIdentifier()
return (string) $this->getConfigParam('index_identifier');
}

/**
* @return bool
*/
public function addIdentifierToDefaultStoreView()
{
return (bool) $this->getConfigParam('add_identifier_to_default');
}

/**
* @return int
*/
Expand Down
Loading

0 comments on commit 98db890

Please sign in to comment.