You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
\Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Preview::canApply has been heavily reworked to address the bug #1418.
Unfortunately, the current code has two new bugs
the preview for Catalog Product Search is broken when apply_to is set to 0 (All search terms)
the preview for Category Product View is broken when apply_to is set to 0 but there are some categories selected (the user selected one or several categories, then changed is mind by switching back the select from Selected categories to All categories
Preconditions
Magento Version : EE 2.3.2
ElasticSuite Version : 2.8-x
Environment : Developer
Third party modules : N/A
Steps to reproduce for Catalog Product Search
On a Luma, disable ALL existing optimizers
Create a new optimizer of constant model, active, available on all 3 request types (Catalog Product Search, Catalog Product Autocomplete, Category Product View)
Input a sensible boost value (for instance 20 %)
In 'Apply to products', add a rule
If ALL of these conditions are TRUE
Attribute Set is Bag
DO NOT SAVE the optimizer yet
In the preview, select Catalog Product Search and type bag inside the Query Text input field
Expected result for Catalog Product Search
Bags products should be boosted while non-bags products (eg Affirm Water Bottle, Rocco Gym Tank, etc) should be "un-boosted"
Actual result for Catalog Product Search
The optimizer is not applied, no product has its score changed
Steps to reproduce for Category Product View
On a Luma, disable ALL existing optimizers
Create a new optimizer of constant model, active, available on all 3 request types (Catalog Product Search, Catalog Product Autocomplete, Category Product View)
Input a sensible boost value (for instance 20 %)
In 'Apply to products', add a rule
If ALL of these conditions are TRUE
Attribute Set is Bag
In the Category Product View fieldset, change "Apply to" to "Selected categories"
In Apply to categories select the "Gear" category, then change back "Apply to" to "All Categories"
DO NOT SAVE the optimizer yet
In the preview, select Category Product View and select the Gear category
Expected result for Category Product View
Bags products should be boosted while non-bags products (eg Set of Sprite Yoga Straps, sport watches, etc) should be "un-boosted"
Actual result for Category Product View
The optimizer is not applied, no product has its score changed
Explanation
The behavior of \Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Preview::canApply with regards to evaluating "canApply" has been reversed :
is initially valued to true or false depending on the fact that the current container is selected in applicable containers
and then if canApply is true potential additional restrictions are pulled from the containers
if on quick_search_container/Catalog Product Search and apply_to is set to 1 (Selected search terms), the preview search term is compared to the selected search terms
if on catalog_view_container/Category Product View and apply_to is set to 1 (Selected categories), the preview category is compared to the selected categories
and then if the current container is selected in applicable containers
if on quick_search_container/Catalog Product Search, canApply can only become true if apply_to is set to 1, it thus can never become true if it is set to 0 (All search terms)
if on catalog_view_container/Category Product View there is a useless checkempty($config['category_ids'] when $config['apply_to'] is set to 0 : if the user switched from All categories to Selected categories, selected one or several categories, then switched back to All categorieswithout saving the Optimizer, the `$config['category_ids'] is not empty but it should not matter
Conclusion
The current code has bugs and is too complex, the refactoring should be undone :
the issue error in optimizer #1418 should be re-fixed while keeping as much as possible the initial boolean evaluation logic (using strict comparison operators is ok if there are no side-effects)
all implicit functional tests cases should work as expected (with regard to before / after saving the Optimizer, having / not having selected search terms/categories)
The text was updated successfully, but these errors were encountered:
\Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Preview::canApply
has been heavily reworked to address the bug #1418.Unfortunately, the current code has two new bugs
Catalog Product Search
is broken when apply_to is set to0
(All search terms)Category Product View
is broken when apply_to is set to0
but there are some categories selected (the user selected one or several categories, then changed is mind by switching back the select fromSelected categories
toAll categories
Preconditions
Magento Version : EE 2.3.2
ElasticSuite Version : 2.8-x
Environment : Developer
Third party modules : N/A
Steps to reproduce for
Catalog Product Search
constant
model, active, available on all 3 request types (Catalog Product Search
,Catalog Product Autocomplete
,Category Product View
)20 %
)Catalog Product Search
and typebag
inside the Query Text input fieldExpected result for
Catalog Product Search
Affirm Water Bottle
,Rocco Gym Tank
, etc) should be "un-boosted"Actual result for
Catalog Product Search
Steps to reproduce for
Category Product View
constant
model, active, available on all 3 request types (Catalog Product Search
,Catalog Product Autocomplete
,Category Product View
)20 %
)Category Product View
fieldset, change "Apply to" to "Selected categories"Apply to categories
select the "Gear" category, then change back "Apply to" to "All Categories"Category Product View
and select theGear
categoryExpected result for
Category Product View
Set of Sprite Yoga Straps
, sport watches, etc) should be "un-boosted"Actual result for
Category Product View
Explanation
The behavior of
\Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Preview::canApply
with regards to evaluating "canApply" has been reversed :true
orfalse
depending on the fact that the current container is selected in applicable containersquick_search_container/Catalog Product Search
andapply_to
is set to1
(Selected search terms), the preview search term is compared to the selected search termscatalog_view_container/Category Product View
andapply_to
is set to1
(Selected categories), the preview category is compared to the selected categoriesfalse
quick_search_container/Catalog Product Search
,canApply
can only becometrue
ifapply_to
is set to1
, it thus can never becometrue
if it is set to0
(All search terms
)catalog_view_container/Category Product View
there is a useless checkempty($config['category_ids']
when $config['apply_to'] is set to 0 : if the user switched fromAll categories
toSelected categories
, selected one or several categories, then switched back toAll categories
without saving the Optimizer, the `$config['category_ids'] is not empty but it should not matterConclusion
The current code has bugs and is too complex, the refactoring should be undone :
\Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Preview::canApply
should be reverted back to its 41c11b7648455deed8034b09cf3c10b3b2529eb8 versionThe text was updated successfully, but these errors were encountered: