Skip to content

[GraphQl] Get product reviews will filter by store Id #30338

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

Open
wants to merge 11 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

huykon
Copy link

@huykon huykon commented Oct 5, 2020

Description (*)

Get product reviews will filter by Store Id

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes [GraphQl] Get product reviews is not filter by store Id #30337

Manual testing scenarios (*)

  1. Query get product reviews by push header Store=store_code
  2. Try this query with each storeview then see the result.

Questions or comments

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 are green)

@m2-assistant
Copy link

m2-assistant bot commented Oct 5, 2020

Hi @huykon. 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 give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

Copy link
Contributor

@rogyar rogyar left a comment

Choose a reason for hiding this comment

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

Hi @huykon. Thank you for providing this improvement. According to definition of done , all changes should be covered by autotests.

Please, cover this case with an API-functional test. The test will repeat the "Steps to reproduce" from the original issue.

Thank you.

{
/** @var Collection $reviewsCollection */
$reviewsCollection = $this->collectionFactory->create()
->addStoreFilter($storeId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, fix indentation to match the other lines of code.

@@ -91,12 +92,16 @@ public function resolve(
throw new GraphQlInputException(__('pageSize value must be greater than 0.'));
}

/** @var StoreInterface $store */
$store = $context->getExtensionAttributes()->getStore();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, fix indentation to match the other lines of code.

/** @var Product $product */
$product = $value['model'];
$reviewsCollection = $this->productReviewsDataProvider->getData(
(int) $product->getId(),
$args['currentPage'],
$args['pageSize']
$args['pageSize'],
(int) $store->getId()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, fix indentation to match the other lines of code.

@huykon
Copy link
Author

huykon commented Oct 5, 2020

@magento run all tests

@sidolov sidolov added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S0 A problem that is blocking the ability to work. An immediate fix is needed. labels Oct 5, 2020
@huykon
Copy link
Author

huykon commented Oct 8, 2020

@magento run all tests

@huykon
Copy link
Author

huykon commented Oct 9, 2020

@magento run Static Tests

@huykon
Copy link
Author

huykon commented Oct 9, 2020

@magento run WebAPI Tests

@huykon
Copy link
Author

huykon commented Oct 12, 2020

@magento run WebAPI Tests

@engcom-Charlie engcom-Charlie self-assigned this Oct 13, 2020
@rogyar
Copy link
Contributor

rogyar commented Oct 14, 2020

Hi @huykon. It looks like there's something wrong with inserting review into the database in the fixture. Please, refer to the following logs for more details
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/30338/a30c75791314044d36f1a61f4bede3bf/WebApi/console-error-logs.html

@huykon
Copy link
Author

huykon commented Oct 14, 2020

@rogyar That's right. I am facing with problem when create test case on specific store id. Please help

@engcom-Charlie engcom-Charlie removed their assignment Oct 19, 2020
Copy link
Contributor

@rogyar rogyar left a comment

Choose a reason for hiding this comment

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

Hi @huykon. Please, check my comments below. Hope it will help with the failing tests.

@@ -199,6 +199,63 @@ public function testProductReviewRatings()
self::assertNotEmpty($items[0]['reviews']['items']);
}

/**
* @magentoApiDataFixture Magento/Review/_files/different_reviews_different_stores.php
* @magentoApiDataFixture Magento/Store/_files/second_store.php
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like your first fixture depends on the second one. That's the main reason of the failing tests. Try to change the order of fixtures loading

[
$secondStoreId
]
)->save();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, do not use deprecated methods. Use a resource model for saving the entity instead.

Thanks

Copy link
Author

Choose a reason for hiding this comment

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

@rogyar I have seen some file use that method so I duplicate to this file. Can you tell me which method can I use?

@huykon
Copy link
Author

huykon commented Oct 19, 2020

@magento run WebAPI Tests

@huykon
Copy link
Author

huykon commented Oct 19, 2020

@magento run WebAPI Tests

@huykon
Copy link
Author

huykon commented Oct 20, 2020

@magento run all tests

@huykon
Copy link
Author

huykon commented Oct 20, 2020

@rogyar can you check what problem with my PR?

@@ -204,7 +281,7 @@ public function testProductReviewRatings()
*/
public function testCustomerReviewsAddedToProduct()
{
$query = <<<QUERY
$query = <<<QUERY
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @huykon. Could I ask you to double-check the indentation for all your changes, please? I'm not sure what happened but for some reason, we have unnecessary spaces here and there.

Thanks.

@huykon
Copy link
Author

huykon commented Oct 25, 2020

@magento run all tests

@rogyar
Copy link
Contributor

rogyar commented Oct 28, 2020

Hi @huykon. Please, check my comment regarding the deprecated methods.

https://github.com/magento/magento2/pull/30338/files#r507725363

Thank you

@huykon
Copy link
Author

huykon commented Oct 29, 2020

@rogyar which method was deprecated?

@rogyar
Copy link
Contributor

rogyar commented Nov 2, 2020

Hi @huykon. The ::save method of the AbstractModel is deprecated since Magento 2.1 (

). You use it for saving the review. Please, check my comment above, it highlights the exact place where you use it.

Thanks

@huykon
Copy link
Author

huykon commented Nov 2, 2020

@rogyar Thank you. So which method can I use to replace save method?

@rogyar
Copy link
Contributor

rogyar commented Nov 2, 2020

Hi @huykon. Please, use a resource model or repository instead

Copy link
Author

@huykon huykon left a comment

Choose a reason for hiding this comment

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

Hi @huykon. Please, use a resource model or repository instead

Hi @rogyar , Can you make a snippet help me? I don't know which method replace of?

[
$secondStoreId
]
)->save();
Copy link
Author

Choose a reason for hiding this comment

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

@rogyar I have seen some file use that method so I duplicate to this file. Can you tell me which method can I use?

Copy link
Contributor

@fooman fooman left a comment

Choose a reason for hiding this comment

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

@huykon I believe @rogyar was looking for something like in the suggested code changes.

[
$secondStoreId
]
)->save();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
)->save();
);
$reviewResourceModel->save($review);

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @fooman I am trying your helpful.

@huykon
Copy link
Author

huykon commented May 7, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-November
Copy link
Contributor

engcom-November commented Mar 27, 2023

Hi @huykon
we re-verified the issue on Magento 2.4-develop instance and after internal discussions, it has been concluded that this is expected behavior but not a bug. "productReviewRatingsMetadata" Graphql response behavior is as per Admin configuration but not based on front end ratings added. Stores - Configuration - Attributes - rating - select price and value - Set rating visibility to both stores and save. If the Graphql query is ran even before rating is added, both price and value are retrieved in the response since enabled in Admin configuration. Kindly refer the Magento docs.
Thank you.

@fooman fooman removed their assignment Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ReviewGraphQl Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: review Release Line: 2.4 Severity: S0 A problem that is blocking the ability to work. An immediate fix is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GraphQl] Get product reviews is not filter by store Id
9 participants