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

[Backport] Fixed Issue : Search REST API returns wrong total_count #21801

Closed
wants to merge 3 commits into from
Closed

[Backport] Fixed Issue : Search REST API returns wrong total_count #21801

wants to merge 3 commits into from

Conversation

ronak2ram
Copy link
Member

Original Pull Request

#21713

Description (*)

I added function for getting total_count of result item.

Fixed Issues (if relevant)

  1. Search REST API returns wrong total_count #17295: Search REST API returns wrong total_count

Manual testing scenarios (*)

Request :

rest/V1/search?searchCriteria[requestName]=quick_search_container&searchCriteria[filterGroups][0][filters][0][field]=search_term&searchCriteria[filterGroups][0][filters][0][conditionType]=like&searchCriteria[filterGroups][0][filters][0][value]=test&searchCriteria[current_page]=1&searchCriteria[page_size]=2

Response :

{
    "items": [
        {
            "id": 126,
            "custom_attributes": [
                {
                    "attribute_code": "score",
                    "value": "73.7660923004150400"
                }
            ]
        },
        {
            "id": 61,
            "custom_attributes": [
                {
                    "attribute_code": "score",
                    "value": "73.7660923004150400"
                }
            ]
        }
    ],
    "aggregations": {
        "buckets": [
            {
                "name": "category_bucket",
                "values": [
                    {
                        "value": "32",
                        "metrics": [
                            "32",
                            "1"
                        ]
                    }
                ]
            },
            {
                "name": "stock_status_bucket",
                "values": []
            },
            {
                "name": "rating_summary_bucket",
                "values": []
            },
            {
                "name": "am_is_new_bucket",
                "values": []
            },
            {
                "name": "am_on_sale_bucket",
                "values": []
            },
            {
                "name": "color_bucket",
                "values": []
            },
            {
                "name": "sub_category_bucket",
                "values": []
            }
        ],
        "bucket_names": [
            "category_bucket",
            "stock_status_bucket",
            "rating_summary_bucket",
            "am_is_new_bucket",
            "am_on_sale_bucket",
            "color_bucket",
            "sub_category_bucket"
        ]
    },
    "search_criteria": {
        "request_name": "quick_search_container",
        "filter_groups": [
            {
                "filters": [
                    {
                        "field": "search_term",
                        "value": "test",
                        "condition_type": "like"
                    }
                ]
            }
        ],
        "page_size": 2,
        "current_page": 1
    },
    "total_count": 9
}

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @ronak2ram. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.2-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@dmytro-ch
Copy link
Contributor

Hi @ronak2ram,
thank you for your contribution!

There are a couple of errors in unit tests with the current solution.

1) Magento\Framework\Search\Test\Unit\Adapter\Mysql\AdapterTest::testQuery
Exception: Notice: Undefined index: total in /home/travis/build/magento/magento2/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/AdapterTest.php on line 171
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/App/ErrorHandler.php:61
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/AdapterTest.php:171
2) Magento\Framework\Search\Test\Unit\Adapter\Mysql\ResponseFactoryTest::testCreate
Exception: Notice: Undefined index: total in /home/travis/build/magento/magento2/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php on line 69
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/App/ErrorHandler.php:61
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php:69
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/ResponseFactoryTest.php:68
3) Magento\Framework\Search\Test\Unit\SearchResponseBuilderTest::testBuild
TypeError: Return value of Magento\Framework\Search\Response\QueryResponse::getTotal() must be of the type integer, null returned
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/Search/Response/QueryResponse.php:81
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/Search/SearchResponseBuilder.php:54
/home/travis/build/magento/magento2/lib/internal/Magento/Framework/Search/Test/Unit/SearchResponseBuilderTest.php:80

Could you please check these issues?

Thank you!

@ronak2ram
Copy link
Member Author

Hello @dmytro-ch
Thanks for the review of my PR. I updated the test case and resolved Travis error.
Can you please review again.

@ghost
Copy link

ghost commented Mar 18, 2019

@ronak2ram unfortunately, only members of the maintainers team are allowed to remove progress related labels to the pull request

@dmytro-ch
Copy link
Contributor

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @dmytro-ch. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @dmytro-ch, here is your new Magento instance.
Admin access: https://pr-21801.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@magento-engcom-team
Copy link
Contributor

Hi @dmytro-ch, thank you for the review.
ENGCOM-4529 has been created to process this Pull Request

@soleksii
Copy link

✔️ QA Passed

Result:

after

@sidolov
Copy link
Contributor

sidolov commented Mar 20, 2019

@ronak2ram please, apply latest fixes from the original PR: #21713

Copy link
Contributor

@sidolov sidolov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes from the original PR is needed

@ronak2ram
Copy link
Member Author

@sidolov I did all the change from this PR: #21713
Can you please help me to find the remaining changes.

@sidolov
Copy link
Contributor

sidolov commented Apr 4, 2019

Hi @ronak2ram , changeset from the #21713 contains only 2 files, current PR contains 9 files. Please, make changes from the original PR.

@ronak2ram
Copy link
Member Author

ronak2ram commented Apr 4, 2019

Hi @sidolov
I added new files change in this PR because someone added those changes in 2.3-develop(021a953#diff-d3e053570d9a25c8e314852f808fec8a) branch so not need to add in 2.3-develop PR #21713.
But I see in 2.2-develop I do not find this commit 021a953#diff-d3e053570d9a25c8e314852f808fec8a
changes so I added that files and code in current PR which need for the get correct total count.

@sidolov
Copy link
Contributor

sidolov commented Apr 10, 2019

Hi @ronak2ram , unfortunately, such changes are not acceptable for 2.2 release line due to backward compatibility. Probably you may find a different solution for 2.2 without breaking changes.

@ronak2ram
Copy link
Member Author

okay @sidolov, we have to close this PR.

@sidolov
Copy link
Contributor

sidolov commented Apr 10, 2019

@ronak2ram thank you for collaboration!

@sidolov sidolov closed this Apr 10, 2019
@m2-assistant
Copy link

m2-assistant bot commented Apr 10, 2019

Hi @ronak2ram, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants