diff --git a/CHANGELOG.MD b/CHANGELOG.MD index dd653bc3..30829102 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -2,19 +2,84 @@ ## Unreleased -## [1.5.2] +## [1.6.0] (2019.11.07) + +### Added +- Add support for Visual Swatches. ([#15](https://github.com/DivanteLtd/magento2-vsbridge-indexer/issues/15)) +Attribute options +```json +"options": [ + { + "swatch": { + "type": 1, + "value": "#ffd500" + }, + "value": "60", + "label": "Yellow", + "sort_order": 12 + }, + { + "swatch": { + "type": 3, + "value": null + }, + "value": "105", + "label": "purple", + "sort_order": 13 + }, + { + "swatch": { + "type": 2, + "value": "/4/2/4245592.png" + }, + "value": "106", + "label": "File", + "sort_order": 14 + } +] +``` + +Product configurable option values +```json +"values": [ + { + "value_index": "50", + "label": "blue defaul", + "swatch": { + "type": 1, + "value": "#1857f7" + } + }, + { + "value_index": "49", + "label": "Black", + "swatch": { + "type": 1, + "value": "#000000" + } + } + ] +``` +- Add new command `vsbridge:index` to run indexer for one product, cms block, etc. +`bin/magento vsbridge:index vsbridge_product_indexer default 1` +vsbridge_product_indexer -> indexer code +default -> store code +1 -> entity id (in this particular example - product id) +Useful for testing. + +## [1.5.2] (2019.10.24) ### Fixes - Run `vsbridge:reindex` command only if all indices has valid status. -## [1.5.1] +## [1.5.1] (2019.10.23) ### Fixes - Fix Notice: Undefined index: value in ConfigurableData.php on line 254 ([#139](https://github.com/DivanteLtd/magento2-vsbridge-indexer/issues/139)) - Switch indices when all types will be reindex ([#138](https://github.com/DivanteLtd/magento2-vsbridge-indexer/pull/138)) - Change method name `AbstractEavAttributes:canReindex` to '`AbstractEavAttributes:canIndexAttribute` -## [1.5.0] +## [1.5.0] (2019.10.18) ### Changed/Improved - Change method `AbstractEavAttributes:canReindex` to public ([#136](https://github.com/DivanteLtd/magento2-vsbridge-indexer/pull/136)) diff --git a/README.md b/README.md index 541ad12d..72c90abc 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,9 @@ Go to the new ‘Indexer’ section (Stores → Configuration → Vuestorefront Sync Tier Prices → by default this option is disabled. Used to sync products tier prices. - Types of products to index → by default all product will be exported to ElasticSearch. This option allows for selecting certain product types that should be exported. + Types of products to index → by default all product will be exported to ElasticSearch. This option allows for selecting certain product types that should be exported. + + Add swatches to `product.configurable_options` → by default No. Use to export information about swatches directly for a product type. ![](docs/images/config-catalog.png) diff --git a/composer.json b/composer.json index 0881846b..eab330b2 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "name": "Agata", "email": "afirlejczyk@divante.pl" }], - "version": "1.5.2", + "version": "1.6.0", "keywords": [ "magento", "magento2", diff --git a/docs/images/config-catalog.png b/docs/images/config-catalog.png index 9638ac4d..7013d70c 100644 Binary files a/docs/images/config-catalog.png and b/docs/images/config-catalog.png differ diff --git a/src/module-vsbridge-indexer-catalog/Api/Data/CatalogConfigurationInterface.php b/src/module-vsbridge-indexer-catalog/Api/Data/CatalogConfigurationInterface.php index 84bf6ee6..5bd4bb9e 100644 --- a/src/module-vsbridge-indexer-catalog/Api/Data/CatalogConfigurationInterface.php +++ b/src/module-vsbridge-indexer-catalog/Api/Data/CatalogConfigurationInterface.php @@ -30,6 +30,11 @@ public function useUrlKeyToGenerateSlug(); */ public function syncTierPrices(); + /** + * @return bool + */ + public function addSwatchesToConfigurableOptions(); + /** * @param int $storeId * diff --git a/src/module-vsbridge-indexer-catalog/Index/Mapping/Attribute.php b/src/module-vsbridge-indexer-catalog/Index/Mapping/Attribute.php index 2f8cb1c9..d0885ab7 100644 --- a/src/module-vsbridge-indexer-catalog/Index/Mapping/Attribute.php +++ b/src/module-vsbridge-indexer-catalog/Index/Mapping/Attribute.php @@ -4,6 +4,7 @@ use Divante\VsbridgeIndexerCore\Api\MappingInterface; use Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface; +use Divante\VsbridgeIndexerCore\Index\Mapping\GeneralMapping; use Magento\Framework\Event\ManagerInterface as EventManager; /** @@ -17,14 +18,23 @@ class Attribute implements MappingInterface */ private $eventManager; + /** + * @var GeneralMapping + */ + private $generalMapping; + /** * Attribute constructor. * + * @param GeneralMapping $generalMapping * @param EventManager $eventManager */ - public function __construct(EventManager $eventManager) - { + public function __construct( + GeneralMapping $generalMapping, + EventManager $eventManager + ) { $this->eventManager = $eventManager; + $this->generalMapping = $generalMapping; } /** @@ -73,6 +83,7 @@ public function __construct(EventManager $eventManager) */ private $stringProperties = [ 'attribute_code', + 'swatch_input_type', 'attribute_model', 'backend_model', 'backend_table', @@ -113,7 +124,8 @@ public function getMappingProperties() 'properties' => [ 'value' => ['type' => FieldInterface::TYPE_TEXT], 'label' => ['type' => FieldInterface::TYPE_TEXT], - 'sort_order' => ['type' => FieldInterface::TYPE_LONG], + 'sort_order' => ['type' => FieldInterface::TYPE_INTEGER], + 'swatch' => $this->generalMapping->getSwatchProperties(), ] ]; diff --git a/src/module-vsbridge-indexer-catalog/Index/Mapping/Product.php b/src/module-vsbridge-indexer-catalog/Index/Mapping/Product.php index 06f9e2fc..80137436 100644 --- a/src/module-vsbridge-indexer-catalog/Index/Mapping/Product.php +++ b/src/module-vsbridge-indexer-catalog/Index/Mapping/Product.php @@ -46,6 +46,7 @@ class Product extends AbstractMapping implements MappingInterface * @param GeneralMapping $generalMapping * @param ConfigurableAttributes $configurableAttributes * @param AttributeDataProvider $resourceModel + * @param array $staticFieldMapping */ public function __construct( EventManager $eventManager, @@ -210,6 +211,8 @@ private function getConfigurableOptionsMapping(): array 'values' => [ 'properties' => [ 'value_index' => ['type' => FieldInterface::TYPE_KEYWORD], + 'label' => ['type' => FieldInterface::TYPE_TEXT], + 'swatch' => $this->generalMapping->getSwatchProperties(), ], ], ], @@ -282,7 +285,7 @@ private function getCustomOptionsMapping(): array 'price' => ['type' => FieldInterface::TYPE_DOUBLE], 'price_type' => ['type' => FieldInterface::TYPE_TEXT], 'sku' => ['type' => FieldInterface::TYPE_KEYWORD], - 'sort_order' => ['type' => FieldInterface::TYPE_LONG], + 'sort_order' => ['type' => FieldInterface::TYPE_INTEGER], 'title' => ['type' => FieldInterface::TYPE_TEXT], 'type' => ['type' => FieldInterface::TYPE_TEXT], 'values' => [ @@ -291,7 +294,7 @@ private function getCustomOptionsMapping(): array 'price' => ['type' => FieldInterface::TYPE_DOUBLE], 'title' => ['type' => FieldInterface::TYPE_TEXT], 'price_type' => ['type' => FieldInterface::TYPE_TEXT], - 'sort_order' => ['type' => FieldInterface::TYPE_LONG], + 'sort_order' => ['type' => FieldInterface::TYPE_INTEGER], 'option_type_id' => ['type' => FieldInterface::TYPE_INTEGER], ] ] @@ -311,7 +314,7 @@ private function getTierPricesMapping(): array 'value' => ['type' => FieldInterface::TYPE_DOUBLE], 'extension_attributes' => [ 'properties' => [ - 'website_id' => ['type' => FieldInterface::TYPE_INTEGER] + 'website_id' => ['type' => FieldInterface::TYPE_SHORT] ], ], ], diff --git a/src/module-vsbridge-indexer-catalog/Model/Attribute/LoadOptions.php b/src/module-vsbridge-indexer-catalog/Model/Attribute/LoadOptions.php index f7350907..a2850125 100644 --- a/src/module-vsbridge-indexer-catalog/Model/Attribute/LoadOptions.php +++ b/src/module-vsbridge-indexer-catalog/Model/Attribute/LoadOptions.php @@ -12,10 +12,11 @@ namespace Divante\VsbridgeIndexerCatalog\Model\Attribute; use Divante\VsbridgeIndexerCatalog\Model\ResourceModel\Product\AttributeDataProvider; -use Magento\Catalog\Model\ResourceModel\Eav\Attribute; + use Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection as OptionCollection; use Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory; - +use Magento\Eav\Model\Entity\Attribute; +use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource; use Magento\Eav\Model\Entity\Attribute\Source\Table as SourceTable; /** @@ -84,21 +85,19 @@ private function loadOptions(Attribute $attribute): array $key = $attribute->getId() . '_' . $attribute->getStoreId(); if (!isset($this->optionsByAttribute[$key])) { - $source = $attribute->getSource(); - - if (SourceTable::class !== get_class($source) && - $source instanceof \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource - ) { + if ($this->useSourceModel($attribute)) { + $source = $attribute->getSource(); $options = $source->getAllOptions(); } else { - $attributeId = $attribute->getAttributeId(); - $storeId = $attribute->getStoreId(); - - /** @var OptionCollection $options */ - $options = $this->collectionFactory->create(); - $options->setOrder('sort_order', 'asc'); - $options->setAttributeFilter($attributeId)->setStoreFilter($storeId); - $options = $this->toOptionArray($options); + $loadSwatches = $this->isVisualSwatch($attribute); + $optionCollection = $this->getOptionCollection($attribute, $loadSwatches); + $additionalFields = []; + + if ($loadSwatches) { + $additionalFields['swatch'] = 'swatch'; + } + + $options = $this->toOptionArray($optionCollection, $additionalFields); } $this->optionsByAttribute[$key] = $options; @@ -107,13 +106,70 @@ private function loadOptions(Attribute $attribute): array return $this->optionsByAttribute[$key]; } + /** + * @param Attribute $attribute + * + * @return bool + */ + private function useSourceModel(Attribute $attribute) + { + $source = $attribute->getSource(); + + if ($source instanceof AbstractSource && !($source instanceof SourceTable)) { + return true; + } + + return false; + } + + /** + * @param Attribute $attribute + * + * @return OptionCollection + */ + private function getOptionCollection(Attribute $attribute, $loadSwatches) + { + $attributeId = $attribute->getAttributeId(); + $storeId = $attribute->getStoreId(); + + /** @var OptionCollection $options */ + $options = $this->collectionFactory->create(); + $options->setOrder('sort_order', 'asc'); + $options->setAttributeFilter($attributeId) + ->setStoreFilter($storeId); + + if ($loadSwatches) { + $options->getSelect()->joinLeft( + ['swatch_table' => $options->getTable('eav_attribute_option_swatch')], + 'swatch_table.option_id = main_table.option_id AND swatch_table.store_id = 0', + [ + 'swatch_value' => 'value', + 'swatch_type' => 'type', + ] + ); + } + + return $options; + } + + /** + * @param Attribute $attribute + * + * @return bool + */ + private function isVisualSwatch(Attribute $attribute) + { + return \Magento\Swatches\Model\Swatch::SWATCH_INPUT_TYPE_VISUAL === $attribute->getData('swatch_input_type'); + } + /** * @param OptionCollection $collection + * @param array $additional * * @return array */ - private function toOptionArray(OptionCollection $collection): array + private function toOptionArray(OptionCollection $collection, array $additional): array { - return $this->optionCollectionToArray->execute($collection); + return $this->optionCollectionToArray->execute($collection, $additional); } } diff --git a/src/module-vsbridge-indexer-catalog/Model/Attribute/OptionCollectionToArray.php b/src/module-vsbridge-indexer-catalog/Model/Attribute/OptionCollectionToArray.php index 36272f3d..6f3f76c6 100644 --- a/src/module-vsbridge-indexer-catalog/Model/Attribute/OptionCollectionToArray.php +++ b/src/module-vsbridge-indexer-catalog/Model/Attribute/OptionCollectionToArray.php @@ -18,7 +18,6 @@ */ class OptionCollectionToArray { - /** * @param OptionCollection $collection * @param array $additional @@ -46,6 +45,13 @@ public function execute(OptionCollection $collection, array $additional = []): a $value = (string)$value; } + if ('swatch' === $field) { + $value = [ + 'type' => (int)$item->getData('swatch_type'), + 'value' => $item->getData('swatch_value') + ]; + } + $data[$code] = $value; } diff --git a/src/module-vsbridge-indexer-catalog/Model/ConfigurableProcessor/GetConfigurableOptions.php b/src/module-vsbridge-indexer-catalog/Model/ConfigurableProcessor/GetConfigurableOptions.php index c31214cf..65cd9a39 100644 --- a/src/module-vsbridge-indexer-catalog/Model/ConfigurableProcessor/GetConfigurableOptions.php +++ b/src/module-vsbridge-indexer-catalog/Model/ConfigurableProcessor/GetConfigurableOptions.php @@ -10,12 +10,18 @@ use Divante\VsbridgeIndexerCatalog\Model\Attribute\LoadOptionById; use Divante\VsbridgeIndexerCatalog\Model\Attribute\SortValues; +use Divante\VsbridgeIndexerCatalog\Api\Data\CatalogConfigurationInterface; /** * Class GetConfigurableOptions */ class GetConfigurableOptions { + /** + * @var CatalogConfigurationInterface + */ + private $catalogSettings; + /** * @var LoadOptionById */ @@ -28,13 +34,17 @@ class GetConfigurableOptions /** * GetConfigurableOptions constructor. - * - * @param LoadOptionById $loadOptions + * @param LoadOptionById $loadOptionById * @param SortValues $sortValues + * @param CatalogConfigurationInterface $catalogSettings */ - public function __construct(LoadOptionById $loadOptions, SortValues $sortValues) - { - $this->loadOptionById = $loadOptions; + public function __construct( + LoadOptionById $loadOptionById, + SortValues $sortValues, + CatalogConfigurationInterface $catalogSettings + ) { + $this->loadOptionById = $loadOptionById; + $this->catalogSettings = $catalogSettings; $this->sortValues = $sortValues; } @@ -66,6 +76,10 @@ public function execute(string $attributeCode, int $storeId, array $configurable $option = $this->loadOptionById->execute($attributeCode, $value, $storeId); if (!empty($option)) { + if (!$this->catalogSettings->addSwatchesToConfigurableOptions()) { + unset($option['swatch']); + } + $options[] = $option; } } diff --git a/src/module-vsbridge-indexer-catalog/Model/Indexer/DataProvider/Product/ConfigurableData.php b/src/module-vsbridge-indexer-catalog/Model/Indexer/DataProvider/Product/ConfigurableData.php index c9d22614..ca9cd5fb 100644 --- a/src/module-vsbridge-indexer-catalog/Model/Indexer/DataProvider/Product/ConfigurableData.php +++ b/src/module-vsbridge-indexer-catalog/Model/Indexer/DataProvider/Product/ConfigurableData.php @@ -250,10 +250,16 @@ private function applyConfigurableOptions(array $productDTO, $storeId) foreach ($options as $option) { $values[] = (int)$option['value']; - $productAttribute['values'][] = [ + $optionValue = [ 'value_index' => $option['value'], 'label' => $option['label'], ]; + + if (isset($option['swatch'])) { + $optionValue['swatch'] = $option['swatch']; + } + + $productAttribute['values'][] = $optionValue; } $productDTO['configurable_options'][] = $productAttribute; diff --git a/src/module-vsbridge-indexer-catalog/Model/ResourceModel/Product/AttributeDataProvider.php b/src/module-vsbridge-indexer-catalog/Model/ResourceModel/Product/AttributeDataProvider.php index 42c5de17..9b8940af 100644 --- a/src/module-vsbridge-indexer-catalog/Model/ResourceModel/Product/AttributeDataProvider.php +++ b/src/module-vsbridge-indexer-catalog/Model/ResourceModel/Product/AttributeDataProvider.php @@ -14,6 +14,7 @@ use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection; use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory; use Magento\Catalog\Model\ResourceModel\Eav\Attribute; +use Magento\Framework\Serialize\Serializer\Json; /** * Products Attribute provider @@ -27,6 +28,11 @@ class AttributeDataProvider extends AbstractEavAttributes */ private $attributeCollectionFactory; + /** + * @var Json + */ + private $serializer; + /** * Product attributes by id * @@ -43,17 +49,20 @@ class AttributeDataProvider extends AbstractEavAttributes /** * AttributeDataProvider constructor. * + * @param Json $serializer * @param AttributeCollectionFactory $attributeCollectionFactory * @param ResourceConnection $resourceConnection * @param MetadataPool $metadataPool * @param string $entityType */ public function __construct( + Json $serializer, AttributeCollectionFactory $attributeCollectionFactory, ResourceConnection $resourceConnection, MetadataPool $metadataPool, $entityType = \Magento\Catalog\Api\Data\ProductInterface::class ) { + $this->serializer = $serializer; $this->attributeCollectionFactory = $attributeCollectionFactory; parent::__construct($resourceConnection, $metadataPool, $entityType); @@ -112,6 +121,8 @@ public function initAttributes() $attributeCollection = $this->getAttributeCollection(); foreach ($attributeCollection as $attribute) { + $this->prepareAttribute($attribute); + $this->attributesById[$attribute->getId()] = $attribute; $this->attributeCodeToId[$attribute->getAttributeCode()] = $attribute->getId(); } @@ -120,6 +131,26 @@ public function initAttributes() return $this->attributesById; } + /** + * @param Attribute $attribute + * + * @return Attribute + */ + public function prepareAttribute(Attribute $attribute) + { + $additionalData = (string)$attribute->getData('additional_data'); + + if (!empty($additionalData)) { + $additionalData = $this->serializer->unserialize($additionalData); + + if (isset($additionalData['swatch_input_type'])) { + $attribute->setData('swatch_input_type', $additionalData['swatch_input_type']); + } + } + + return $attribute; + } + /** * @return Collection */ diff --git a/src/module-vsbridge-indexer-catalog/Model/Settings.php b/src/module-vsbridge-indexer-catalog/Model/Settings.php index 12d63e2b..c2fa692e 100644 --- a/src/module-vsbridge-indexer-catalog/Model/Settings.php +++ b/src/module-vsbridge-indexer-catalog/Model/Settings.php @@ -75,6 +75,14 @@ public function syncTierPrices() return (bool) $this->getConfigParam('sync_tier_prices'); } + /** + * @return bool + */ + public function addSwatchesToConfigurableOptions() + { + return (bool) $this->getConfigParam('add_swatches_to_configurable_options'); + } + /** * @inheritdoc */ diff --git a/src/module-vsbridge-indexer-catalog/etc/adminhtml/system.xml b/src/module-vsbridge-indexer-catalog/etc/adminhtml/system.xml index 9338d465..736d54a3 100644 --- a/src/module-vsbridge-indexer-catalog/etc/adminhtml/system.xml +++ b/src/module-vsbridge-indexer-catalog/etc/adminhtml/system.xml @@ -42,6 +42,10 @@ Magento\Config\Model\Config\Source\Yesno + + + Magento\Config\Model\Config\Source\Yesno + diff --git a/src/module-vsbridge-indexer-catalog/etc/config.xml b/src/module-vsbridge-indexer-catalog/etc/config.xml index e9d196e4..debb79d9 100644 --- a/src/module-vsbridge-indexer-catalog/etc/config.xml +++ b/src/module-vsbridge-indexer-catalog/etc/config.xml @@ -14,6 +14,7 @@ 0 0 0 + 0 diff --git a/src/module-vsbridge-indexer-core/Console/Command/SingleEntityIndexCommand.php b/src/module-vsbridge-indexer-core/Console/Command/SingleEntityIndexCommand.php new file mode 100644 index 00000000..8bf76586 --- /dev/null +++ b/src/module-vsbridge-indexer-core/Console/Command/SingleEntityIndexCommand.php @@ -0,0 +1,179 @@ + + * @copyright 2019 Divante Sp. z o.o. + * @license See LICENSE_DIVANTE.txt for license details. + */ + +namespace Divante\VsbridgeIndexerCore\Console\Command; + +use Divante\VsbridgeIndexerCore\Indexer\StoreManager; +use Magento\Framework\App\ObjectManagerFactory; +use Magento\Framework\Indexer\IndexerInterface; +use Magento\Indexer\Console\Command\AbstractIndexerCommand; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Magento\Store\Model\StoreManagerInterface as StoreManagerInterface; +use Symfony\Component\Console\Input\InputArgument; + +/** + * Class SingleEntityIndexCommand + */ +class SingleEntityIndexCommand extends AbstractIndexerCommand +{ + const INPUT_STORE = 'store'; + + const INPUT_INDEXER_CODE = 'index'; + + const INPUT_ENTITY_ID = 'id'; + + /** + * @var StoreManager + */ + private $indexerStoreManager; + + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * @var array + */ + private $excludeIndices = []; + + /** + * RebuildEsIndexCommand constructor. + * + * @param ObjectManagerFactory $objectManagerFactory + * @param array $excludeIndices + */ + public function __construct( + ObjectManagerFactory $objectManagerFactory, + array $excludeIndices = [] + ) { + $this->excludeIndices = $excludeIndices; + parent::__construct($objectManagerFactory); + } + + /** + * @inheritdoc + */ + protected function configure() + { + $this->setName('vsbridge:index') + ->setDescription( + 'Update single entity in ES (product, category, attribute, etc..). Useful tool for testing new data.' + ); + + $this->setDefinition($this->getInputList()); + + parent::configure(); + } + + /** + * Get list of options and arguments for the command + * + * @return array + */ + private function getInputList() + { + return [ + new InputArgument( + self::INPUT_INDEXER_CODE, + InputArgument::REQUIRED , + 'Indexer code' + ), + new InputArgument( + self::INPUT_STORE, + InputArgument::REQUIRED , + 'Store ID or Store Code' + ), + new InputArgument( + self::INPUT_ENTITY_ID, + InputArgument::REQUIRED , + 'Entity id' + ), + ]; + } + + /** + * @inheritdoc + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->initObjectManager(); + $output->setDecorated(true); + + $storeId = $input->getArgument(self::INPUT_STORE); + $index = $input->getArgument(self::INPUT_INDEXER_CODE); + $id = $input->getArgument(self::INPUT_ENTITY_ID); + + $store = $this->getStoreManager()->getStore($storeId); + $this->getIndexerStoreManager()->setLoadedStores([$store]); + $indexer = $this->getIndex($index); + + if ($indexer) { + $message = "\nIndex: " . $indexer->getTitle() . + "\nStore: " . $store->getName() . + "\nID: " . $id; + $output->writeln("Indexing... $message"); + $indexer->reindexRow($id); + } else { + $output->writeln("Index with code: $index hasn't been found. "); + } + } + + /** + * @return IndexerInterface + */ + private function getIndex($code) + { + /** @var IndexerInterface[] */ + $indexers = $this->getAllIndexers(); + $vsbridgeIndexers = []; + + foreach ($indexers as $indexer) { + $indexId = $indexer->getId(); + + if ($code === $indexId) { + return $indexer; + } + } + + return null; + } + + /** + * @return StoreManagerInterface + */ + private function getStoreManager() + { + if (null === $this->storeManager) { + $this->storeManager = $this->getObjectManager()->get(StoreManagerInterface::class); + } + + return $this->storeManager; + } + + /** + * @return StoreManager + */ + private function getIndexerStoreManager() + { + if (null === $this->indexerStoreManager) { + $this->indexerStoreManager = $this->getObjectManager()->get(StoreManager::class); + } + + return $this->indexerStoreManager; + } + + /** + * Initiliaze object manager + */ + private function initObjectManager() + { + $this->getObjectManager(); + } +} diff --git a/src/module-vsbridge-indexer-core/Index/Mapping/GeneralMapping.php b/src/module-vsbridge-indexer-core/Index/Mapping/GeneralMapping.php index 8b34db79..2ae87340 100644 --- a/src/module-vsbridge-indexer-core/Index/Mapping/GeneralMapping.php +++ b/src/module-vsbridge-indexer-core/Index/Mapping/GeneralMapping.php @@ -40,6 +40,19 @@ public function getCommonProperties() return $this->commonProperties; } + /** + * @return array + */ + public function getSwatchProperties(): array + { + return [ + 'properties' => [ + 'value' => ['type' => FieldInterface::TYPE_TEXT], + 'type' => ['type' => FieldInterface::TYPE_SHORT], // to make it compatible with other fields + ] + ]; + } + /** * @return array */ diff --git a/src/module-vsbridge-indexer-core/etc/di.xml b/src/module-vsbridge-indexer-core/etc/di.xml index 8f3dd332..c6850c0a 100644 --- a/src/module-vsbridge-indexer-core/etc/di.xml +++ b/src/module-vsbridge-indexer-core/etc/di.xml @@ -63,6 +63,7 @@ + Divante\VsbridgeIndexerCore\Console\Command\SingleEntityIndexCommand Divante\VsbridgeIndexerCore\Console\Command\RebuildEsIndexCommand