-
Notifications
You must be signed in to change notification settings - Fork 9.4k
#26121 - special price & tier price are coming in base currency #28890
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
#26121 - special price & tier price are coming in base currency #28890
Conversation
Collect store specific value for store specific currecny when querying products special_price and price_tiers
Hi @pmarjan. 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. |
@magento run all tests |
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.
Can you please update or add test automated tests to cover these changes.
* @param array|null $value | ||
* @param array|null $args | ||
* @return mixed|Value | ||
* @throws \Exception |
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.
This should not throw \Exception. Resolvers should only throw graphql specific exceptions
* @param array|null $args | ||
* @return mixed|Value | ||
* @throws \Exception | ||
*/public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) |
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.
look like the comment closing tag is on same line as function
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.
static tests fail, some params are not used
class SpecialPrice implements ResolverInterface | ||
{ | ||
/** | ||
* Fetches the data from persistence models and format it according to the GraphQL schema. |
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.
Fetch the data (Imperative, Fetches would be descriptive)
/** | ||
* Fetches the data from persistence models and format it according to the GraphQL schema. | ||
* | ||
* @param \Magento\Framework\GraphQl\Config\Element\Field $field |
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.
move FQDN to use statement
* @param array|null $args | ||
* @return mixed|Value | ||
* @throws \Exception | ||
*/public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) |
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.
static tests fail, some params are not used
Adjust to take customer group (via setting customerGroupId) into consideration.
@magento run all tests |
Edits, Support by api-functional tests, Address static tests
@magento run all tests |
Address static tests - session 2
@magento run all tests |
*/ | ||
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) | ||
{ | ||
/** @var \Magento\Catalog\Model\Product $product */ |
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.
use product interface
Refactor to pass new optional parameter to @api class constructor
@magento run all tests |
Refactor TierPriceBuilder
Revert Pricing Price TierPrice
@magento run all tests |
Adjust unit and integration tests
@magento run all tests |
@cpartica @danielrenaud |
Move price transform to PriceTiers
@magento run all tests |
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.
Functionality looks good, just some cleanup comments for the tests
*/ | ||
public function testAllGroups() | ||
{ | ||
/** @var string $productSku */ |
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.
/** @var string $productSku */ |
Remove all unnecessary @var annotations
$response = $this->graphQlQuery($query); | ||
|
||
$itemTiers = $response['products']['items'][0]['price_tiers']; | ||
$this->assertEquals(5, sizeof($itemTiers)); |
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.
You can use assertCount()
* @param string $password | ||
* @return array | ||
*/ | ||
private function getHeaderAuthorization(string $username, string $password): array |
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 use \Magento\GraphQl\GetCustomerAuthenticationHeader instead
$productRepository = $this->objectManager->get(ProductRepositoryInterface::class); | ||
/** @var Product $product */ | ||
$product = $productRepository->get($productSku, false, null, true); | ||
$tierPriceData =[ |
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.
data changes should be done in fixtures
); | ||
|
||
$itemTiers = $response['products']['items'][0]['price_tiers']; | ||
$this->assertEquals(3, sizeof($itemTiers)); |
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.
use assertCount()
* @param array $tiers | ||
* @return float | ||
*/ | ||
private function getValueForQuantity(float $quantity, array $tiers) |
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 add short description for utility methods
{ | ||
return <<<QUERY | ||
{ | ||
products(search: "{$productSku}") { |
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 might be safer to use "filter sku equals" to make sure you get an exact match
*/ | ||
public function testSpecialPrice() | ||
{ | ||
/** @var string $productSku */ |
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.
/** @var string $productSku */ |
|
||
$response = $this->graphQlQuery($query); | ||
|
||
/** @var float $specialPrice */ |
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.
/** @var float $specialPrice */ |
{ | ||
/** @var string $productSku */ | ||
$productSku = 'simple'; | ||
/** @var string $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.
/** @var string $query */ |
Adjustments to api-functional test
Adjustments to api-functional test
Adjustments to api-functional test
@magento run all tests |
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.
Nice work!
Hi @pmarjan, thank you for your contribution! |
Collect store specific value for store specific currecny when querying products special_price and price_tiers
Description (*)
Solves for #26121
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)