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

Missing addOptionsData in filter options #729

Closed
Leone opened this issue Feb 6, 2018 · 2 comments
Closed

Missing addOptionsData in filter options #729

Leone opened this issue Feb 6, 2018 · 2 comments
Labels

Comments

@Leone
Copy link
Contributor

Leone commented Feb 6, 2018

When you change option label in the filter attribute in the admin panel, filter navigation on the frontend disappears.

Preconditions

Magento Version : 2.1.10 CE

ElasticSuite Version : 2.3.0, but does not matter

Environment : does not matter

Third party modules : does not matter

Steps to reproduce

  1. edit attribute in the admin panel
  2. change label in some option
  3. save changes

Expected result

  1. Filters should be still visible on the frontend.

Actual result

Filter nav (the whole block) on the frontend disappears.
We found in logs:

main.CRITICAL: Notice: Undefined index: adminSortIndex in /*/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/Layer/Filter/Attribute.php on line 277 [] []

The problem is that script doesn't set key adminSortIndex to all items in array $items and a few lines below the script tries to sort these array using this key.

Possible solution

In class Smile\ElasticsuiteCatalog\Model\Layer\Filter\Attribute, method addOptionsData(),
change this:

usort($items, function ($item1, $item2) {
    return $item1['adminSortIndex'] <= $item2['adminSortIndex'] ? -1 : 1;
});

to this:

usort($items, function ($item1, $item2) {
    // check if key adminSortIndex exists
    if(!isset($item1['adminSortIndex']) or !isset($item2['adminSortIndex'])){
        return 0;
    }
    return $item1['adminSortIndex'] <= $item2['adminSortIndex'] ? -1 : 1;
});
@afoucret
Copy link
Contributor

Hi @Leone

I will try to look at your PR quickly now.

@afoucret afoucret added the bug label Feb 12, 2018
@afoucret
Copy link
Contributor

PR have been merged and will be part of the next maintenance release (2.5.1).

Thx for contributing.

@afoucret afoucret modified the milestone: 2.5 Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants