diff --git a/Model/Elasticsearch/Adapter/DataMapper/Stock.php b/Model/Elasticsearch/Adapter/DataMapper/Stock.php index 373a93f..2378ce6 100644 --- a/Model/Elasticsearch/Adapter/DataMapper/Stock.php +++ b/Model/Elasticsearch/Adapter/DataMapper/Stock.php @@ -41,7 +41,7 @@ public function __construct( * * @param mixed $entityId * @param mixed $storeId - * @return bool[]|int[] + * @return int[] * @throws NoSuchEntityException */ public function map($entityId, $storeId): array @@ -49,7 +49,7 @@ public function map($entityId, $storeId): array $sku = $this->inventory->getSkuRelation((int)$entityId); if (!$sku) { - return ['out_of_stock_at_last' => true]; + return ['out_of_stock_at_last' => 1]; } $value = $this->inventory->getStockStatus( diff --git a/Plugin/Model/Adapter/AdditionalFieldMapperPlugin.php b/Plugin/Model/Adapter/AdditionalFieldMapperPlugin.php new file mode 100644 index 0000000..7bd07c8 --- /dev/null +++ b/Plugin/Model/Adapter/AdditionalFieldMapperPlugin.php @@ -0,0 +1,45 @@ + 'integer' + ]; + + /** + * Missing mapped attribute code + * + * @param mixed $subject + * @param array $result + * @return array + */ + public function afterGetAllAttributesTypes($subject, array $result): array + { + foreach ($this->allowedFields as $fieldName => $fieldType) { + $result[$fieldName] = ['type' => $fieldType]; + } + + return $result; + } + + /** + * 3rd module Compatibility + * + * @param mixed $subject + * @param array $result + * @return array + */ + public function afterBuildEntityFields($subject, array $result): array + { + return $this->afterGetAllAttributesTypes($subject, $result); + } +} diff --git a/composer.json b/composer.json index 7ecec1a..9fc24c8 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "magento/module-elasticsearch-7": "*" }, "type": "magento2-module", - "version": "1.0.2", + "version": "1.0.3", "authors": [ { "name": "Tuyen Nguyen", diff --git a/etc/di.xml b/etc/di.xml index 0eb8573..7d92d9f 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,5 +1,14 @@ + + + + + + +