Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"is_used_for_promo_rules" is not handled in getFieldAnalyzers #3171

Open
mvenghaus opened this issue Feb 6, 2024 · 5 comments
Open

"is_used_for_promo_rules" is not handled in getFieldAnalyzers #3171

mvenghaus opened this issue Feb 6, 2024 · 5 comments
Assignees

Comments

@mvenghaus
Copy link
Contributor

mvenghaus commented Feb 6, 2024

If you want to use a text attribute only in promo rules, not searchable, not filterable, you get the wrong default search analyzer.

https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-core/Index/Mapping/Field.php#L377

Here every text attribute gets the keyword analyzer by default. To filter in promos it should get the untouched analyzer to work like it should. The "is_used_for_promo_rules" is not handled there. If you try to use it without, the checkAnalyzer fails and you get an empty propertyName.

I think s.th. like this could solve this

if ($this->getType() === self::FIELD_TYPE_TEXT) {
if ($this->getType() === self::FIELD_TYPE_TEXT && !$this->IsUsedForPromoRules()) {

Then you get the same analyzer like a filterable field.

Preconditions

Magento Version : 2.4.6

ElasticSuite Version : 2.11.5.1

Environment : Developer

Third party modules : -

Steps to reproduce

Create a text attribute with only "is_used_for_promo_rules" enabled.

..
use Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\CollectionFactory as ProductCollectionFactory;
..

$productCollection = $this->productCollectionFactory->create()
    ->addFieldToFilter('text_attribute', ['eq' => 'value']);
@romainruaud
Copy link
Collaborator

Hi @mvenghaus

Maybe changing this line would be better, no ?

https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-core/Index/Mapping/Field.php#L391

if (empty($analyzers) || $this->isFilterable() || $this->isUsedForPromoRules()) {

I'd prefer to add the untouched when needed, rather than "removing the keyword so that the untouched will be added after". It seems more understandable for me.

Your thoughts ?

@mvenghaus
Copy link
Contributor Author

Hey @romainruaud ,

in my understanding the first analyzer is used as the default analyzer. Would the expected analyzer check fail because the untouched is the second one?

@romainruaud
Copy link
Collaborator

The default analyzer is the one returned by getDefaultAnalyzer, it's not the first one.

Did you give a try to my proposal ? It should work the same way as yours, except that the field would still have the keyword as default, and another untouched analyzer being added.

Regards

Copy link

This issue was waiting update from the author for too long. Without any update, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away! Thanks for your contribution.

@mvenghaus
Copy link
Contributor Author

Hey @romainruaud,

adding an addtional untouched analyzer works. I've created a pull request where this is handled.

#3230

Regards
Marcus

@github-actions github-actions bot reopened this Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants