-
Notifications
You must be signed in to change notification settings - Fork 9.4k
[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
base: 2.4-develop
Are you sure you want to change the base?
Conversation
Hi @huykon. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
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. 🕙 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 |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
@magento run all tests |
@magento run all tests |
@magento run Static Tests |
@magento run WebAPI Tests |
@magento run WebAPI Tests |
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 |
@rogyar That's right. I am facing with problem when create test case on specific store id. Please help |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
@magento run WebAPI Tests |
@magento run WebAPI Tests |
@magento run all tests |
@rogyar can you check what problem with my PR? |
@@ -204,7 +281,7 @@ public function testProductReviewRatings() | |||
*/ | |||
public function testCustomerReviewsAddedToProduct() | |||
{ | |||
$query = <<<QUERY | |||
$query = <<<QUERY |
There was a problem hiding this comment.
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.
@magento run all tests |
Hi @huykon. Please, check my comment regarding the deprecated methods. https://github.com/magento/magento2/pull/30338/files#r507725363 Thank you |
@rogyar which method was deprecated? |
Hi @huykon. The Thanks |
@rogyar Thank you. So which method can I use to replace |
Hi @huykon. Please, use a resource model or repository instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ | ||
$secondStoreId | ||
] | ||
)->save(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ | ||
$secondStoreId | ||
] | ||
)->save(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
)->save(); | |
); | |
$reviewResourceModel->save($review); | |
There was a problem hiding this comment.
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.
dev/tests/integration/testsuite/Magento/Review/_files/different_reviews_different_stores.php
Outdated
Show resolved
Hide resolved
@magento run all tests |
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. |
Hi @huykon |
Description (*)
Get product reviews will filter by Store Id
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Store=store_code
Questions or comments
Contribution checklist (*)