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

List Preview and Sorting - Manual Sort via Drag and Drop Not Working #3440

Open
marijak opened this issue Nov 12, 2024 · 20 comments
Open

List Preview and Sorting - Manual Sort via Drag and Drop Not Working #3440

marijak opened this issue Nov 12, 2024 · 20 comments
Assignees

Comments

@marijak
Copy link

marijak commented Nov 12, 2024

After our upgrade to Magento 2.4.6, this functionality stopped working. Previously, we were using version 2.10.15. Now, we have version 2.11.7.1, and I checked the latest version, which is 2.11.9.2 but issue is persisting here too tested locally.

Preconditions

Magento Version : 2.4.6-p7 (CE)
ElasticSuite Version : 2.11.7.1
Production

Steps to reproduce

  1. Upgrade Magento to version 2.4.6-p7
  2. Navigate to the backend and try to use the drag-and-drop feature for manual sorting
  3. Attempt to use the manual sorting options below the items

Expected result

  1. The drag-and-drop functionality should be available to reorder items.
  2. The manual sorting option should be visible below the items for easy management.

Actual result

  1. The drag-and-drop feature for manual sorting with 3dots is missing from the backend.
  2. The manual sorting options below the items are also unavailable.

sortOrder

@Bashev
Copy link
Contributor

Bashev commented Nov 12, 2024

Manual sorting works only when sorting is ... "position".

@marijak
Copy link
Author

marijak commented Nov 12, 2024

Hi @Bashev, yes, I see in the code of vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Model/Preview.php, but the values I have in the backend are not equal to "position" (I don't have the option with the value "position").

I have the following values in the backend:

Here are the labels and corresponding values:

Relevance - relevance_direction_desc
Position - Ascending - position_direction_asc
Position - Descending - position_direction_desc
Product Name - Ascending - name_direction_asc
Product Name - Descending - name_direction_desc
Price - Ascending - price_direction_asc
....

Question:
So, what do you recommend to resolve this at a global level and ensure that manual sorting will work on the categories in the end? Is this the only file related to it?

We want to have the possibility of manual sorting, regardless of the setting for position.
If we have "reposition by manual" set to yes, we need to reorder only those products manually, no matter the position setting.

What code changes are needed for this? I thought it should be working by default after installing your module?

@vahonc
Copy link
Collaborator

vahonc commented Nov 12, 2024

Hi @marijak,

Could you specify from where came these values for Default Product Listing Sort By dropdown?

Relevance - relevance_direction_desc
Position - Ascending - position_direction_asc
Position - Descending - position_direction_desc
Product Name - Ascending - name_direction_asc
Product Name - Descending - name_direction_desc
Price - Ascending - price_direction_asc

I'm pretty sure that it is not Magento's default staff behavior. Maybe it's because you use a third-party module, cause from out-the-box Magento has only three options in this dropdown:

Screenshot from 2024-11-12 17-20-51

I thought it should be working by default after installing your module?

Of course, it will work if you do not customize the default Magento stuff or install some 3rd party modules that can effect on this.

What was the version of Magento before the update?

BR,
Vadym

@marijak
Copy link
Author

marijak commented Nov 13, 2024

Hi, we are using a third-party extension for these additional options:

https://github.com/magesuite/sorting

@vahonc
Copy link
Collaborator

vahonc commented Nov 13, 2024

@marijak,

Compatibility with third-party modules is outside the scope of our Open Source support policy provided here. There is not much we can do for your issue. You'll have to choose between our module and the second one or add customization by yourself (by coding).

BR,
Vadym

@marijak
Copy link
Author

marijak commented Nov 13, 2024

Ok, I will try now with the third-party module disabled. I am able to manage the sort from the backend, but I don't see the changes on the frontend in my test environment. Do I need to reindex?

On the category list page, I don’t see any change in the sort order; they are as they were before

image

image

image

@vahonc
Copy link
Collaborator

vahonc commented Nov 13, 2024

@marijak

After that, you select Position as the value for Default Product Listing Sort By the Manual Sort option will be visible below the items, and with the drag-and-drop functionality you will be able to reorder items. Don't forget to Save your category. Then of course you need to run reindex.

BR,
Vadym

@marijak
Copy link
Author

marijak commented Nov 13, 2024

Yes, I tried, and I see the module is installed via Composer: creativestyle/magesuite, and elasticsuite Smile is part of it
image

Can you provide me with the steps to install only the Smile Elastic clean installation so I can test the manual sort from the beginning?

@vahonc
Copy link
Collaborator

vahonc commented Nov 13, 2024

@marik,

First of all, you should remove creativestyle/magesuite from your test environment to have ability to clean test the manual sort from the beginning:
$ composer remove creativestyle/magesuite

then you need to install Elasticsuite:
$ composer require smile/elasticsuite ~2.11.0 it will install the latest version of our module.

BR,
Vadym

@marijak
Copy link
Author

marijak commented Nov 14, 2024

do you have a demo version so i can see how it works on clean installation?

@marijak
Copy link
Author

marijak commented Nov 14, 2024

I found this: https://demo.magento-elastic-suite.io/admin but could not find the credentials

@romainruaud
Copy link
Collaborator

Hi @marijak

this is obvious that it's not working anymore because of this : https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-virtual-category/Model/Preview.php#L152

If the sort order is not "position", the drag and drop is disabled.

In magesuite, the sort order can be either "position_direction_asc" or "position_direction_desc" : https://github.com/magesuite/sorting/blob/1.x/Model/Sorting/Options.php

This is, imho, not needed anymore since we allow to manage the sort direction with ElasticSuite now.

I would recommend to remove/disable the magesuite/sorting module because all it does (offering a way to control the position) is already existing in ElasticSuite now.

Regards

@marijak
Copy link
Author

marijak commented Nov 15, 2024

Hi, yes, thank you for your answer and support. I tried disabling it, but then other things stopped working. I cannot disable or uninstall only the magesuite/sorting module because it is part of a package: composer require creativestyle/magesuite.

There are a lot of issues in our system after disabling it, so I am unable to check further.

Anyway, if we want to control this only from Smile Elasticsearch, what changes are necessary? If we remove this code from Preview.php, we can see the control for manual sorting in the backend, but again, no changes are visible after performing actions on the frontend.

I have also opened a ticket with the Magesuite support team, but I'm still waiting for a response.
magesuite/magesuite#126

Do you know where the entire logic for the pre-sort is located and which files are responsible? Is it complex? This will help us understand what we need to do if we want to use this feature in the future.

@romainruaud
Copy link
Collaborator

Anyway, if we want to control this only from Smile Elasticsearch, what changes are necessary? If we remove this code from Preview.php, we can see the control for manual sorting in the backend, but again, no changes are visible after performing actions on the frontend.

Imho you could just create your own di.xml file somewhere and disable all the magesuite/sorting plugins located there :

https://github.com/magesuite/sorting/blob/1.x/etc/di.xml

So your file should look like this :

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <type name="Magento\Catalog\Model\Config\Source\ListSort">
        <plugin name="replace_with_options_containing_sorting_direction" disabled="true"/>
    </type>

    <type name="Magento\Catalog\Model\Category\Attribute\Source\Sortby">
        <plugin name="replace_with_options_containing_sorting_direction" disabled="true"/>
    </type>

    <type name="Magento\Catalog\Model\Category">
        <plugin name="replace_available_sort_by_options" disabled="true"/>
    </type>

    <type name="Magento\Catalog\Block\Product\ProductList\Toolbar">
        <plugin name="replace_available_orders" disabled="true">
    </type>

</config>

@marijak
Copy link
Author

marijak commented Nov 26, 2024

Hi, thanks! After adding this code to the custom module, manual sorting is activated in the backend and works fine. However, on the frontend, the product order doesn't match the backend. I even switched to the Luma theme, set the default sort to "position," and reindexed, but the issue persists.

n the end, we need both functionalities to work together. We’ve also contacted the MageSuite vendor creators, but we haven't received any response yet.

image
image

@romainruaud
Copy link
Collaborator

In your capture it looks like it's applying "position DESC" if I trust the picture of the arrow, is it the case ?

regards

@vahonc
Copy link
Collaborator

vahonc commented Nov 26, 2024

@romainruaud,

Nope, if the arrow is Up it means that Ascending Direction is set, and if the arrow is Down = Descending Direction.

@marijak, are you sure that you Saved your category after manual sorting? Are there no other third-party extensions that could affect that?

BR,
Vadym

@romainruaud
Copy link
Collaborator

OK for the arrow :)

On top of that, maybe you can attach the content of the elasticsearch query which is generated on this page.

You can see it on the system.log file after enabling the debug mode of Elasticsuite in Store>Configuration>ElasticSuite>Base Settings > Debug mode

@marijak
Copy link
Author

marijak commented Nov 26, 2024

On my local environment, the debug log shows the following:
"Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone."

@marijak
Copy link
Author

marijak commented Nov 26, 2024

I also thought that, regardless of ascending or descending order, the products set to manual sort should always appear in this order before all others in the collection. And yes, I am sure I saved the category.

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

4 participants