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

Rework abstract mapper to allow configure static type map in di.xml #125

Merged
merged 1 commit into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ abstract class AbstractMapping
/**
* @var array
*/
private $staticFieldMapping = [
'status' => FieldInterface::TYPE_INTEGER,
'visibility' => FieldInterface::TYPE_INTEGER,
'position' => FieldInterface::TYPE_LONG,
'level' => FieldInterface::TYPE_INTEGER,
'category_ids' => FieldInterface::TYPE_LONG,
'sku' => FieldInterface::TYPE_KEYWORD,
'url_path' => FieldInterface::TYPE_KEYWORD,
'url_key' => FieldInterface::TYPE_KEYWORD,
];
private $staticFieldMapping;

/**
* AbstractMapping constructor.
*
* @param array $staticFieldMapping
*/
public function __construct(array $staticFieldMapping)
{
$this->staticFieldMapping = $staticFieldMapping;
}

/**
* @var array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/
class Category extends AbstractMapping implements MappingInterface
{

/**
* @var array
*/
Expand Down Expand Up @@ -61,17 +60,20 @@ class Category extends AbstractMapping implements MappingInterface
* @param GeneralMapping $generalMapping
* @param CategoryChildAttributes $categoryChildAttributes
* @param AttributeDataProvider $resourceModel
* @param array $staticFieldMapping
*/
public function __construct(
EventManager $eventManager,
GeneralMapping $generalMapping,
CategoryChildAttributes $categoryChildAttributes,
AttributeDataProvider $resourceModel
AttributeDataProvider $resourceModel,
array $staticFieldMapping
) {
$this->eventManager = $eventManager;
$this->generalMapping = $generalMapping;
$this->resourceModel = $resourceModel;
$this->childAttributes = $categoryChildAttributes;
parent::__construct($staticFieldMapping);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/module-vsbridge-indexer-catalog/Index/Mapping/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
class Product extends AbstractMapping implements MappingInterface
{

/**
* @var EventManager
*/
Expand Down Expand Up @@ -52,12 +51,14 @@ public function __construct(
EventManager $eventManager,
GeneralMapping $generalMapping,
ConfigurableAttributes $configurableAttributes,
AttributeDataProvider $resourceModel
AttributeDataProvider $resourceModel,
array $staticFieldMapping
) {
$this->eventManager = $eventManager;
$this->generalMapping = $generalMapping;
$this->resourceModel = $resourceModel;
$this->configurableAttributes = $configurableAttributes;
parent::__construct($staticFieldMapping);
}

/**
Expand Down
14 changes: 14 additions & 0 deletions src/module-vsbridge-indexer-catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,18 @@
<type name="Magento\CatalogInventory\Observer\ReindexQuoteInventoryObserver">
<plugin name="update_product_in_es" type="Divante\VsbridgeIndexerCatalog\Plugin\Indexer\CatalogInventory\ReindexQuoteInventoryObserverPlugin"/>
</type>
<type name="Divante\VsbridgeIndexerCatalog\Index\Mapping\AbstractMapping">
<arguments>
<argument name="staticFieldMapping" xsi:type="array">
<item name="status" xsi:type="const">Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface::TYPE_INTEGER</item>
<item name="visibility" xsi:type="const">Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface::TYPE_INTEGER</item>
<item name="position" xsi:type="const">Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface::TYPE_LONG</item>
<item name="level" xsi:type="const">Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface::TYPE_INTEGER</item>
<item name="category_ids" xsi:type="const">Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface::TYPE_LONG</item>
<item name="sku" xsi:type="const">Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface::TYPE_KEYWORD</item>
<item name="url_path" xsi:type="const">Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface::TYPE_KEYWORD</item>
<item name="url_key" xsi:type="const">Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface::TYPE_KEYWORD</item>
</argument>
</arguments>
</type>
</config>