Smile-SA / elasticsuite

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

Clicking on show more button gives 0 items #3442

Open ioweb-gr opened 3 days ago

ioweb-gr commented 3 days ago

Similar to issue #2998 I'm also getting an empty array for the items. After debugging I see in function \Smile\ElasticsuiteCatalog\Model\Attribute\LayeredNavAttributesProvider::isLayeredNavAttribute it returns always false. The problem comes from \Smile\ElasticsuiteCatalog\Model\Attribute\LayeredNavAttributesProvider::getList function which checks the property $this->attributes which is an empty array not yet populated.

So I'm assuming there's some sort of initialization that's failing in my case.

If you could provide some insight as to how and when the attributes property is initialized with data, I could dig further

I also don't see anything in di.xml that could have added values to the array or anything that's invoked before it's injected.

Preconditions

Magento Version :2.4.4

ElasticSuite Version : 2.10.23.2

Environment : Developer

Third party modules :

``` List of enabled modules: Amasty_Base Amasty_Geoip Amasty_Conditions Amasty_CommonRules Amasty_CronScheduleList Amasty_CustomFormsLite Amasty_Customform Amasty_Gdpr Amasty_GdprCookie PayPal_Braintree Amasty_GoogleAddressAutocomplete Amasty_ImageOptimizer Amasty_ImageOptimizerUi Amasty_InvisibleCaptcha Amasty_LazyLoad Amasty_LazyLoadUi Amasty_Mage24Fix Amasty_Mostviewed Amasty_PageSpeedOptimizer Amasty_PageSpeedTools Amasty_Payrestriction Amasty_ProductAttachment Apptrian_FacebookCatalog Apptrian_FacebookPixel Apptrian_TikTokPixelApi Bss_FreeShippingBar Bss_SizeChart Codazon_AjaxCartPro Codazon_Core Codazon_ImproveBundle Codazon_Lookbookpro Codazon_MegaMenu Codazon_PageBuilder Codazon_ProductFilter Codazon_ProductLabel Codazon_QuickShop Codazon_SalesPro Codazon_ShippingCostCalculator Codazon_Slideshow Codazon_ThemeOptions Codazon_Utility Ebizmarts_MailChimp Esat_Esatisfaction Harrigo_EverCrumbs Ho_Templatehints Ioweb_AmastyGdprAddon Ioweb_Base Ioweb_CategoryProductColumns Ioweb_Checkout Ioweb_ConfigurableDynamicAttributes Ioweb_ConfigurableFullPrice Ioweb_CronMemory Ioweb_Customizer Ioweb_EnablePdf Ioweb_FacebookCatalogOverride Ioweb_FixStockStatusIssue35494 Ioweb_GoogleRemarketing Ioweb_Html5 Ioweb_Invoicefields Ioweb_MariaDbHotfix Ioweb_MassImageUploader Ioweb_PiraeusBank Ioweb_SkroutzFeedVariations Ioweb_Skroutzfeed Ioweb_Softone Ioweb_Toolbox Ioweb_Wcag Ioweb_Widgets MageVision_GreekRegions Magefan_Community Magefan_Blog Magefan_WysiwygAdvanced Mageplaza_Core Mageplaza_Smtp Mageplaza_SocialLogin Nwdthemes_Base Nwdthemes_Revslider Amasty_Checkout PayPal_BraintreeGraphQl Smile_ElasticsuiteAdminNotification Smile_ElasticsuiteCore Smile_ElasticsuiteCatalog Smile_ElasticsuiteCatalogGraphQl Smile_ElasticsuiteCatalogRule Smile_ElasticsuiteCatalogOptimizer Smile_ElasticsuiteTracker Smile_ElasticsuiteThesaurus Smile_ElasticsuiteSwatches Smile_ElasticsuiteIndices Smile_ElasticsuiteAnalytics Smile_ElasticsuiteVirtualCategory Swissup_Core Swissup_SearchMysqlLegacy Temando_ShippingRemover Ves_All Ves_BaseWidget Ves_PageBuilder Ves_Setup Wyomind_Framework Wyomind_DataFeedManager List of disabled modules: Amasty_ShopbyBase Amasty_Shopby Amasty_ShopbyBrand Amasty_ShopbyPage Amasty_ShopbySeo Codazon_AjaxLayeredNav Codazon_AjaxLayeredNavPro Codazon_GoogleAmpManager Codazon_Shopbybrandpro MageWorx_SearchSuiteAutocomplete Veriteworks_CookieFix ```

Steps to reproduce

  1. I'm not sure how to reproduce this as I've never faced this issue before. It's a standard installation of the elastic suite and I removed all other modules affecting layered navigation or search.

Expected result

  1. Show more yields more options

Actual result

  1. Show more removes everything from the attribute filter

https://github.com/user-attachments/assets/b464a2b7-37e4-4f4b-9590-16d92174ddf5

vahonc commented 1 day ago

@ioweb-gr,

I can try to reproduce this issue, but not sure if I have any luck, cause it looks like this is something specific for your environment.

As for start points for debugging, you can enable logging ES queries in: Stores -> Configuration -> Elasticsuite -> Base settings -> Elasticsearch Client -> Enable Debug Mode and the queries that are being sent to ES when you are browsing categories will be logged into the system.log.

Have you checked errors in Magento logs and in the console of the Dev tools in your browser?

BR, Vadym

ioweb-gr commented 1 day ago

Hi @vahonc I know this won't be easy to troubleshoot however there doesn't seem to be any starting point where I can even begin to check at.

I enabled debug mode

``` [2024-11-18T15:29:36.630884+00:00] main.INFO: Request Success: {"method":"HEAD","uri":"http://localhost:9200/safeblock.yourstaging.eu_gr_catalog_product","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.16.0 (Linux 6.8.0-48-generic; PHP 7.4.33)"],"x-elastic-client-meta":["es=7.16.0,php=7.4.33,t=7.16.0,a=0,cu=8.5.0"]},"HTTP code":200,"duration":0.000946} [] [2024-11-18T15:29:36.631160+00:00] main.INFO: curl -XHEAD 'http://localhost:9200/safeblock.yourstaging.eu_gr_catalog_product?pretty=true' [] [] [2024-11-18T15:29:36.652702+00:00] main.INFO: Request Success: {"method":"GET","uri":"http://localhost/","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.16.0 (Linux 6.8.0-48-generic; PHP 7.4.33)"],"x-elastic-client-meta":["es=7.16.0,php=7.4.33,t=7.16.0,a=0,cu=8.5.0"]},"HTTP code":200,"duration":0.000159} [] [2024-11-18T15:29:36.652919+00:00] main.INFO: curl -XGET 'http://localhost/?pretty=true' [] [] [2024-11-18T15:29:36.653395+00:00] main.INFO: Request Success: {"method":"GET","uri":"http://localhost/","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.16.0 (Linux 6.8.0-48-generic; PHP 7.4.33)"],"x-elastic-client-meta":["es=7.16.0,php=7.4.33,t=7.16.0,a=0,cu=8.5.0"]},"HTTP code":200,"duration":0.000114} [] [2024-11-18T15:29:36.653605+00:00] main.INFO: curl -XGET 'http://localhost/?pretty=true' [] [] [2024-11-18T15:29:36.654991+00:00] main.INFO: Request Success: {"method":"POST","uri":"http://localhost:9200/safeblock.yourstaging.eu_gr_catalog_product/_search","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.16.0 (Linux 6.8.0-48-generic; PHP 7.4.33)"],"x-elastic-client-meta":["es=7.16.0,php=7.4.33,t=7.16.0,a=0,cu=8.5.0"]},"HTTP code":200,"duration":0.000875} [] [2024-11-18T15:29:36.655365+00:00] main.INFO: curl -XPOST 'http://localhost:9200/safeblock.yourstaging.eu_gr_catalog_product/_search?pretty=true' -d '{"size":0,"query":{"constant_score":{"filter":{"bool":{"must":[{"term":{"stock.is_in_stock":{"value":true,"boost":1}}},{"terms":{"visibility":[2,4],"boost":1}},{"nested":{"path":"category","score_mode":"none","query":{"bool":{"must":[{"bool":{"must_not":[{"term":{"category.is_virtual":{"value":true,"boost":1}}}],"boost":1}},{"terms":{"category.category_id":["48"],"boost":1,"_name":"\u039a\u03b1\u03c4\u03b7\u03b3\u03bf\u03c1\u03af\u03b1 \u03b5\u03af\u03bd\u03b1\u03b9 \u03ad\u03bd\u03b1 \u03b1\u03c0\u03cc 48"}}],"must_not":[],"should":[],"boost":1}},"boost":1,"_name":"(1\/2\/48) standard category [\u03a1\u03bf\u03cd\u03c7\u03b1 \u0395\u03c1\u03b3\u03b1\u03c3\u03af\u03b1\u03c2]:48"}},{"bool":{"must_not":[{"nested":{"path":"category","score_mode":"none","query":{"bool":{"must":[{"term":{"category.category_id":{"value":48,"boost":1}}},{"term":{"category.is_blacklisted":{"value":true,"boost":1}}}],"must_not":[],"should":[],"boost":1}},"boost":1}}],"boost":1}},{"terms":{"visibility":[2,4],"boost":1}},{"terms":{"option_text_cat.untouched":["48"],"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}' [] [] [2024-11-18T15:29:36.659246+00:00] main.INFO: Request Success: {"method":"POST","uri":"http://localhost:9200/safeblock.yourstaging.eu_gr_catalog_product/_search","port":"9200","headers":{"Host":["localhost"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.16.0 (Linux 6.8.0-48-generic; PHP 7.4.33)"],"x-elastic-client-meta":["es=7.16.0,php=7.4.33,t=7.16.0,a=0,cu=8.5.0"]},"HTTP code":200,"duration":0.000431} [] [2024-11-18T15:29:36.659470+00:00] main.INFO: curl -XPOST 'http://localhost:9200/safeblock.yourstaging.eu_gr_catalog_product/_search?pretty=true' -d '{"size":0,"query":{"constant_score":{"filter":{"bool":{"must":[{"term":{"stock.is_in_stock":{"value":true,"boost":1}}},{"terms":{"visibility":[2,4],"boost":1}},{"nested":{"path":"category","score_mode":"none","query":{"bool":{"must":[{"bool":{"must_not":[{"term":{"category.is_virtual":{"value":true,"boost":1}}}],"boost":1}},{"terms":{"category.category_id":["48"],"boost":1,"_name":"\u039a\u03b1\u03c4\u03b7\u03b3\u03bf\u03c1\u03af\u03b1 \u03b5\u03af\u03bd\u03b1\u03b9 \u03ad\u03bd\u03b1 \u03b1\u03c0\u03cc 48"}}],"must_not":[],"should":[],"boost":1}},"boost":1,"_name":"(1\/2\/48) standard category [\u03a1\u03bf\u03cd\u03c7\u03b1 \u0395\u03c1\u03b3\u03b1\u03c3\u03af\u03b1\u03c2]:48"}},{"bool":{"must_not":[{"nested":{"path":"category","score_mode":"none","query":{"bool":{"must":[{"term":{"category.category_id":{"value":48,"boost":1}}},{"term":{"category.is_blacklisted":{"value":true,"boost":1}}}],"must_not":[],"should":[],"boost":1}},"boost":1}}],"boost":1}},{"terms":{"visibility":[2,4],"boost":1}},{"terms":{"option_text_cat.untouched":["48"],"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}' [] [] ```

This is what was added in system.log after clicking show more.

Exception log is clean There are no console errors just that the controller returns an empty array.

Could you point me to how the \Smile\ElasticsuiteCatalog\Model\Attribute\LayeredNavAttributesProvider::$attributes property should be populated and when?

By debugging after the controller is invoked, I ended up finding that it all happens because this property is empty. So If I can find where it should be populated perhaps we can nail the culprit.

ioweb-gr commented 1 day ago

Moreover it occurs with all modules disabled and luma active so I don't think it's a conflict this time.