5

I am using magento 2.3.1.

I am having this strange issue only in admin>customer grid

No matter which column I choose to sort the results are always the same.

It happens only in this grid.

ID sort ascending

ID sort descending

What I tried:

  1. reindex all indexers, several times
  2. checked Redis conf, removed, reinstalled again
  3. Checked Opcache settings, disabled and enabled back
  4. Used nginx standalone, used Nginx as proxy pass with Apache
  5. Reboot server several time
  6. Magento caches are disabled, recleared several times, recopliled and redeploy
  7. Cleared ui_bookmark table

Nothing from these helped. The only thing I noticed is that on local server with apache only it works with no problem.

Also when this started, when I tried to install a new module, although module was istalled fine, upgraded and compiled when I went to admin I couldn't find it anywhere.

Again in local wasn't this problem. I think that these two are related.

UPDATE

After making some operations to server and needed to restart all services like Nginx, php-fpm, Redis, varnish, elastic magento customer grid started to work fine again.

But after working in admin about 2 days again the customer grid isn't sorting.

I am sure that is definitely some cache problem....Something is caching this particular grid....I am using Redis 5. Maybe I switch to 4?

Any help or ideas will be appreciated!

8
  • 1
    What about request in the network tab of your browser? Is data present in response? Apr 14, 2019 at 10:34
  • @Siarhey Uchukhlebau. I see: http://example.com/admin/mui/index/render/key/a70f1877ef4497ab4d91b261bdc84e59fd55cfa9c4477de093b6585044aeda24/?namespace=customer_listing&search=&filters%5Bplaceholder%5D=true&paging%5BpageSize%5D=100&paging%5Bcurrent%5D=1&sorting%5Bfield%5D=entity_id&sorting%5Bdirection%5D=desc&isAjax=true and http://example.com/admin/mui/bookmark/save/key/cebf3f2d676c37e2259d0e4964b2d5daf27620c32e8010e7e255929dd375cb05/?isAjax=true GET and POST. These only the first time I press in column sort....If I press again I get no data in network.
    – G. G.
    Apr 14, 2019 at 10:39
  • 1
    Is a data obtained in first request are the same as a data in the analogical request on the server without that issue? I think if the data from the first request was broken it can broke whole ui-grid. Apr 15, 2019 at 5:07
  • @Siarhey Uchukhlebau data is the same....I haven't figure out why this is happening. I updated my post with new finds....Also as far as I know when Ajax post the request isn't rendering the right results in grid....but in data is fine...I think is some kind of cache....
    – G. G.
    Apr 21, 2019 at 18:49
  • I faced same issue after upgrade from 2.3. I get it resolved by upgrading it again :( No changes to code nothing, Still had old instance where sorting not working. No words for magento :(
    – anonymous
    Apr 24, 2019 at 12:33

1 Answer 1

2

Faced the same problem in Magento 2.2.8.

The problem is that the controller returns the same results, sorted by ID (or not, not sure).

After digging into this I found out that a problem in this file:

vendor/magento/module-customer/Model/GroupManagement.php

Inside getLoggedInGroups method:

$groupNameSortOrder = $this->sortOrderBuilder
            ->setField('customer_group_code')
            ->setAscendingDirection()
            ->create();

Here, the sort is always set to AscendingDirection (setAscendingDirection) and after setting this sorting to search criteria ->addSortOrder($ groupNameSortOrder)

I fixed this temporarily by simply overriding this file and deleting the line with ->addSortOrder($ groupNameSortOrder)

Small guide:

  1. Create new module.

  2. File: app/code/VENDOR/MODULE/etc/adminhtml/di.xml

     <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
         <!-- Customer Admin Grid Sorting fix -->
         <preference for="Magento\Customer\Model\GroupManagement"
                     type="VENDOR\MODULE\Model\Customer\GroupManagement" />
     </config>
    
  3. File: app/code/VENDOR/MODULE/Model/Customer/GroupManagement.php

    filterBuilder ->setField(GroupInterface::ID) ->setConditionType('neq') ->setValue(self::NOT_LOGGED_IN_ID) ->create(); $groupAll[] = $this->filterBuilder ->setField(GroupInterface::ID) ->setConditionType('neq') ->setValue(self::CUST_GROUP_ALL) ->create(); $searchCriteria = $this->searchCriteriaBuilder ->addFilters($notLoggedInFilter) ->addFilters($groupAll) ->create(); return $this->groupRepository->getList($searchCriteria)->getItems(); } }
6
  • Thank you! But it isn't working for me....Tried with module and directly to core file...No luck. @Игорь Колчин are you sure it fixed for you?
    – G. G.
    Apr 24, 2019 at 13:36
  • Yes. Have you tried to run commands from cli: bin/magento setup:upgrade and bin/magento setup:di:compile ? You can check which results returns magento in devtools: prnt.sc/ngc0mw Do both requests return the same data, or they are different and sorted?
    – Igosyee
    Apr 24, 2019 at 15:58
  • I run upgrade and compile....it didn't help...Also in network when I sort I don't have your screen. I only have one ?namespace=customer request. Above I have only ?isAjax=true with empty results. If I refresh the page I get the two requests. Then when try to sort I get again only one request and empty Ajax
    – G. G.
    Apr 24, 2019 at 18:45
  • Try to sort different column. For example sort column with emails twice and check requests
    – Igosyee
    Apr 25, 2019 at 9:34
  • all columns have same result....Nothing is changing....Also I tried to remove some of them...Problem still there
    – G. G.
    Apr 25, 2019 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.