Smile-SA/elasticsuite

Backend categories. Products preview not working

webcreative24 opened this issue · 12 comments

Hello. I have a multi-store setup with two stores and two store views. Each store has its own root category:

En store -> Root category: Default category. This one is set as the default store for the instance.
Am store -> Root category: Default am.
I've imported 1,000 products for each store. When I navigate to categories and switch to the En store, I am able to visually sort products. However, when I switch to the Am store, I see this message:
Your product selection is empty for the selected Store View. If you are running a multi-store setup, please check this manual page for more information.

I tried to debug the issue and found that in the En category, the AJAX request (https://magento.loc/admin/virtualcategory/category_virtual/preview/ajax/1/store/1/key/bcdb....) returned an array of products, but the Am store returned an empty result:
{"products":[],"size":56}

There are no virtual categories or custom settings on ElasticSuite.

Can you please help me identify where to debug this issue, or have you faced something similar before?

Preconditions

Magento Version: 2.4.6-p4
ElasticSuite Version: 2.11.7
ElasticSearch Version: 7.17.9
Environment: Developer or Production
Categores structure:
image
En store switch:
image

Am store swtich:
image

Hello @webcreative24,

At the moment it is difficult to say exactly what is wrong, but maybe something is wrong with your import or his configurations, maybe during the import the products were not correctly assigned to the categories belonging to your second store (Armenian).

Take a look at these screenshots:

ScreenShot Tool -20240624163909

ScreenShot Tool -20240624163714

Check some products that belong to another store and ensure everything is configured correctly.

BR,
Vadym

@vahonc I'll check. thanks, but we have only one website and two store views

ssx commented

@vahonc: Also having the same issue on 2.4.7-p1 as well. First store, lists and sorts fine. Second store doesn't.

Hello @ssx,

Are you also sure that all your products are correctly assigned to the corresponding stores/store views?

What about your multi-configuration? Have you also one website and two stores/store views?

Guys, you could try to enable Debug mode in ElasticSuite and send a query to us when browse your categories preview.

BR,
Vadym

ssx commented

Hi @vadym, I'll try to get that over to you shortly.

In our case: two sites, one with 3 store/store views, one with 2 store/store views.

Hello, a patch for that bug (ElasticSuite v2.10.21)

--- ./vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Model/Preview.php.orig	    2024-05-02 15:52:52.000000000 +0200
+++ ./vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Model/Preview.php          2024-06-18 17:32:02.148590600 +0200
@@ -121,7 +121,7 @@
         $directionFallback = $sortBy !== 'position' ? Collection::SORT_ORDER_ASC : Collection::SORT_ORDER_DESC;
 
         $collection->setOrder($sortBy, $this->request->getParam('sort_direction', $directionFallback));
-        $collection->addPriceData(self::DEFAULT_CUSTOMER_GROUP_ID, $this->category->getStoreId());
+        $collection->addPriceData(self::DEFAULT_CUSTOMER_GROUP_ID, $this->category->getStore()->getWebsiteId());
 
         return $collection;
     }

$collection->addPriceData(self::DEFAULT_CUSTOMER_GROUP_ID, $this->category->getStore()->getWebsiteId());

Thanks!

ssx commented

I can confirm that patch has sorted it for us.

@ssx yes, for us too. but we lost the previous sorted positions

Hello @webcreative24

Could you clarify your last comment ?
Which sorted positions did you lose ?
Are those the positions manually set at the "default store view" level ?
Or positions you intended to import through the product import ?

Regards,

ssx commented

@rbayet the patch fixed products displaying for us. I'm not sure about ordering as I don't know what order they were in beforehand.

@vahonc please include @Jerome-Garbocom's patch into a PR