Can't add a custom field resolver for ElasticSearch #39895
Labels
Issue: ready for confirmation
Reported on 2.4.5-p12
Indicates original Magento version for the Issue report.
Triage: Dev.Experience
Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Preconditions and environment
Trying to add a custom data to the products index, but the custom field resolver is placed after the default one in the
$items
property of the\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CompositeResolver
, making it unusable.Steps to reproduce
Magento_CatalogSearch
andMagento_Elasticsearch
(module.xml
)etc/di.xml
file that adds a new product data (example below) and set thesortOrder
before thedefault
resolver:\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface
to get the field name in the Provider (example below):Expected result
\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CompositeResolver::getFieldName
uses thecustomPrice
field name resolverVendor\Module\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CustomPrice
is used when called by the Provider.Actual result
Additional information
I also noticed thanks to xDebug that we enter the
\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CompositeResolver::__construct
5 times, the sort order is correct for each times except for the second entry.Finally, I tried to declare the field name resolver in evey
di.xml
declarations for modules elasticsaerch, elasticsearch5, elasticsearch6 and elasticsearch7 (see below) but it still doesn't work.Related to #32742 but this doesn't seem to work as expected.
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: