Smile-SA / elasticsuite

Smile ElasticSuite - Magento 2 merchandising and search engine built on ElasticSearch
https://elasticsuite.io
Open Software License 3.0
761 stars 341 forks source link

Pagebuilder product widget category filter not working with anchored parent categories #2958

Closed chrey closed 1 year ago

chrey commented 1 year ago

When creating a CMS block with a PageBuilder Product carousel, I don't have any products displayed if I select a parent category. Same behaviour if :

It works fine if I use a child category that has products directly assigned. All my categories have is_anchor = 1 in database

Preconditions

Magento Version : Adobe commerce 2.4.6 + B2B shared catalog activated ElasticSuite Version : 2.11.1.1 Environment : Production mode

Third party modules : "akeneo/magento2-connector-enterprise": "^103.4", "amasty/mega-menu": "^2.4", "amasty/mega-menu-page-builder": "^1.0", "amasty/module-hide-price": "^1.6", "amasty/module-request-a-quote-pro-subscription-package": "^1.0", "cweagans/composer-patches": "^1.7", "dompdf/dompdf": "^2.0", "magento/composer-dependency-version-audit-plugin": "~0.1", "magento/composer-root-update-plugin": "~2.0", "magento/extension-b2b": "^1.3", "magento/product-enterprise-edition": "2.4.6", "mageplaza/magento-2-french-language-pack": "^1.0", "markshust/magento2-module-disabletwofactorauth": "^2.0", "nesbot/carbon": "^2.66", "owebia/magento2-module-advanced-shipping": "^2.8", "smile/elasticsuite": "~2.11.0", "smile/module-cron": "^5.0", "smile/module-custom-entity": "^1.3", "smile/module-custom-entity-product-link": "^1.3", "smile/module-elasticsuite-quick-order": "^2.11", "smile/module-elasticsuite-shared-catalog": "~2.11", "smile/module-patch": "^1.0", "smile/module-reconfigure": "^5.0", "stripe/module-payments": "^3.4"

Steps to reproduce

  1. Create a CMS block in backend
  2. Use pagebuilder to edit the block, add a row and a Product widget inside
  3. Select Carousel + Category + take a category in the list that has subcategories and no products directly assigned
  4. Validate the widget

Expected result

  1. Products of subcategories should be displayed in carousel

Actual result

No products displayed, empty block

unnamed

Other comment :

It works on another project having more or less the same modules stack on Magento 2.4.3-93 + Elasticsuite 2.10.4

vahonc commented 1 year ago

Hello @chrey,

Are the categories from your screenshots real or virtual (based on some rules)?

Have you compared the assigned relations of the products in both your environment?

Also, please provide an extract of the queries that are being sent to ES when you validate the widget. You can get it from the system.log file if you activate the Debug mode of Elasticsuite in: Stores -> Configuration -> Elasticsuite -> Base settings -> Elasticsearch Client -> Enable Debug Mode.

BR, Vadym

vimart-smile commented 1 year ago

Hi @vahonc. @chrey ask me to check your previous comment.

Logs part from system.log file after enabling debug mode.

This part contains the next steps:

  1. Open the page
  2. Open the page builder editor
  3. Add Row element
  4. Add Products block element
  5. Config block (select category from the second level). The product count, on the counter, was updated.
  6. Save

Logs:

[2023-06-05T12:59:42.099482+00:00] report.INFO: Request Success: {"method":"HEAD","uri":"http://localhost:9200/magento2_fr_catalog_product","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.001769} []
[2023-06-05T12:59:42.101683+00:00] report.INFO: curl -XHEAD 'http://localhost:9200/magento2_fr_catalog_product?pretty=true' [] []
[2023-06-05T12:59:42.450515+00:00] report.INFO: Request Success: {"method":"HEAD","uri":"http://localhost:9200/magento2_fr_catalog_product","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.001452} []
[2023-06-05T12:59:42.451688+00:00] report.INFO: curl -XHEAD 'http://localhost:9200/magento2_fr_catalog_product?pretty=true' [] []
[2023-06-05T12:59:44.438597+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_all/_stats","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.003145} []
[2023-06-05T12:59:44.439763+00:00] report.INFO: curl -XGET 'http://localhost:9200/_all/_stats?pretty=true' [] []
[2023-06-05T12:59:44.467017+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_alias","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.000845} []
[2023-06-05T12:59:44.468094+00:00] report.INFO: curl -XGET 'http://localhost:9200/_alias?pretty=true' [] []
[2023-06-05T12:59:51.044674+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_all/_stats","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.002853} []
[2023-06-05T12:59:51.045925+00:00] report.INFO: curl -XGET 'http://localhost:9200/_all/_stats?pretty=true' [] []
[2023-06-05T12:59:51.074472+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_alias","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.000997} []
[2023-06-05T12:59:51.075591+00:00] report.INFO: curl -XGET 'http://localhost:9200/_alias?pretty=true' [] []
[2023-06-05T12:59:54.180476+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_all/_stats","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.002906} []
[2023-06-05T12:59:54.181702+00:00] report.INFO: curl -XGET 'http://localhost:9200/_all/_stats?pretty=true' [] []
[2023-06-05T12:59:54.209388+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_alias","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.000833} []
[2023-06-05T12:59:54.210503+00:00] report.INFO: curl -XGET 'http://localhost:9200/_alias?pretty=true' [] []
[2023-06-05T12:59:55.607587+00:00] report.INFO: Request Success: {"method":"HEAD","uri":"http://localhost:9200/magento2_fr_catalog_product","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.001436} []
[2023-06-05T12:59:55.608816+00:00] report.INFO: curl -XHEAD 'http://localhost:9200/magento2_fr_catalog_product?pretty=true' [] []
[2023-06-05T12:59:57.584179+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_all/_stats","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.003495} []
[2023-06-05T12:59:57.585498+00:00] report.INFO: curl -XGET 'http://localhost:9200/_all/_stats?pretty=true' [] []
[2023-06-05T12:59:57.614357+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_alias","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.000884} []
[2023-06-05T12:59:57.615466+00:00] report.INFO: curl -XGET 'http://localhost:9200/_alias?pretty=true' [] []
[2023-06-05T12:59:58.341047+00:00] report.INFO: Request Success: {"method":"HEAD","uri":"http://localhost:9200/magento2_fr_catalog_product","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.001397} []
[2023-06-05T12:59:58.342307+00:00] report.INFO: curl -XHEAD 'http://localhost:9200/magento2_fr_catalog_product?pretty=true' [] []
[2023-06-05T12:59:58.380353+00:00] report.INFO: Request Success: {"method":"POST","uri":"http://localhost:9200/magento2_fr_catalog_product/_search","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.003681} []
[2023-06-05T12:59:58.381571+00:00] report.INFO: curl -XPOST 'http://localhost:9200/magento2_fr_catalog_product/_search?pretty=true' -d '{"size":0,"query":{"constant_score":{"filter":{"bool":{"must":[{"bool":{"must":[],"must_not":[],"should":[],"boost":1}},{"term":{"stock.is_in_stock":{"value":true,"boost":1}}},{"terms":{"visibility":[2,4],"boost":1}},{"terms":{"visibility":[2,4],"boost":1}},{"nested":{"path":"category","score_mode":"none","query":{"terms":{"category.category_id":["5"],"boost":1}},"boost":1}}],"must_not":[],"should":[],"boost":1}},"boost":1}},"aggregations":{"attribute_set_id":{"terms":{"field":"attribute_set_id","size":10000,"order":{"_count":"desc"}}},"indexed_attributes":{"terms":{"field":"indexed_attributes","size":10000,"order":{"_count":"desc"}}}},"track_total_hits":true}' [] []
[2023-06-05T12:59:58.389108+00:00] report.INFO: Request Success: {"method":"POST","uri":"http://localhost:9200/magento2_fr_catalog_product/_search","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.004128} []
[2023-06-05T12:59:58.390303+00:00] report.INFO: curl -XPOST 'http://localhost:9200/magento2_fr_catalog_product/_search?pretty=true' -d '{"size":"5","sort":[{"category.position":{"order":"ASC","missing":"_last","unmapped_type":"keyword","nested":{"path":"category","filter":{"terms":{"category.category_id":["5"],"boost":1}}},"mode":"min"}},{"_score":{"order":"desc"}},{"entity_id":{"order":"desc","missing":"_first","unmapped_type":"keyword"}}],"from":0,"query":{"constant_score":{"filter":{"bool":{"must":[{"bool":{"must":[],"must_not":[],"should":[],"boost":1}},{"term":{"stock.is_in_stock":{"value":true,"boost":1}}},{"terms":{"visibility":[2,4],"boost":1}},{"terms":{"visibility":[2,4],"boost":1}},{"nested":{"path":"category","score_mode":"none","query":{"terms":{"category.category_id":["5"],"boost":1}},"boost":1}}],"must_not":[],"should":[],"boost":1}},"boost":1}},"aggregations":{"attribute_set_id":{"terms":{"field":"attribute_set_id","size":10000,"order":{"_count":"desc"}}},"indexed_attributes":{"terms":{"field":"indexed_attributes","size":10000,"order":{"_count":"desc"}}}},"track_total_hits":0}' [] []
[2023-06-05T12:59:59.671887+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_all/_stats","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.003378} []
[2023-06-05T12:59:59.673230+00:00] report.INFO: curl -XGET 'http://localhost:9200/_all/_stats?pretty=true' [] []
[2023-06-05T12:59:59.701927+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_alias","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.001028} []
[2023-06-05T12:59:59.703041+00:00] report.INFO: curl -XGET 'http://localhost:9200/_alias?pretty=true' [] []
[2023-06-05T13:00:43.301997+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_all/_stats","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.003763} []
[2023-06-05T13:00:43.303266+00:00] report.INFO: curl -XGET 'http://localhost:9200/_all/_stats?pretty=true' [] []
[2023-06-05T13:00:43.331582+00:00] report.INFO: Request Success: {"method":"GET","uri":"http://localhost:9200/_alias","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.15.0-1031-gcp; PHP 8.1.17)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.17,t=7.17.1,a=0,cu=7.81.0"]},"HTTP code":200,"duration":0.000968} []
[2023-06-05T13:00:43.332723+00:00] report.INFO: curl -XGET 'http://localhost:9200/_alias?pretty=true' [] []

Kind regards.

vahonc commented 1 year ago

Hello @chrey,

Unfortunately, I was not able to reproduce this issue on fresh Magento 2.4.6 + B2B extensions and ElasticSuite 2.11.1.1 versions.

Here're some screenshots: Screenshot from 2023-06-06 16-23-05

Screenshot from 2023-06-06 16-23-24

Screenshot from 2023-06-06 16-23-44

So as you can see I created a new category with subcategories at different levels and created two products with assign directly to the Cat A and Cat A1. No matter which level of the category I select (Cat A, Cat A1, or even Test cat's) during the configuration of my CMS block in Page Builder I see the same result, it shows me two products, as I expected.

I checked provided queries that are being sent to ES when you validate the widget and it looks correct. Also, from a conversation with Victor I know that you have synchronization with Akeneo, and sometimes during reindex process one index, namely catalog_category_product is failed with an error. In fact, ElasticSuite takes info about products directly from this index. so if something is wrong with these data it could be a reason of your issue. Maybe I should pay more attention to this.

BR, Vadym

romainruaud commented 1 year ago

Hi @chrey

I close this issue since we were not able to reproduce it.

Please try to solve it internally for your project.

If in the end it's really an Elasticsuite issue, feel free to open another issue.

Regards