Skip to content

#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

Merged
merged 12 commits into from
Jul 19, 2020

Conversation

pmarjan
Copy link
Contributor

@pmarjan pmarjan commented Jun 25, 2020

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 (*)

  • 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)

Collect store specific value for store specific currecny when querying products special_price and price_tiers
@m2-assistant
Copy link

m2-assistant bot commented Jun 25, 2020

Hi @pmarjan. 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.

@pmarjan
Copy link
Contributor Author

pmarjan commented Jun 25, 2020

@magento run all tests

Copy link
Contributor

@danielrenaud danielrenaud left a 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
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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

@ghost ghost assigned cpartica Jun 25, 2020
* @param array|null $args
* @return mixed|Value
* @throws \Exception
*/public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
Copy link
Contributor

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.
@pmarjan
Copy link
Contributor Author

pmarjan commented Jun 29, 2020

@magento run all tests

Edits, Support by api-functional tests, Address static tests
@pmarjan
Copy link
Contributor Author

pmarjan commented Jun 30, 2020

@magento run all tests

@pmarjan
Copy link
Contributor Author

pmarjan commented Jun 30, 2020

@magento run all tests

@pmarjan pmarjan requested review from cpartica and danielrenaud July 1, 2020 08:46
*/
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
/** @var \Magento\Catalog\Model\Product $product */
Copy link
Contributor

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
@pmarjan
Copy link
Contributor Author

pmarjan commented Jul 11, 2020

@magento run all tests

@pmarjan
Copy link
Contributor Author

pmarjan commented Jul 12, 2020

@magento run all tests

@pmarjan
Copy link
Contributor Author

pmarjan commented Jul 13, 2020

@magento run all tests

@pmarjan
Copy link
Contributor Author

pmarjan commented Jul 13, 2020

@cpartica @danielrenaud
all remarks are addressed, PR is ready for new re-review

@pmarjan pmarjan requested review from cpartica and danielrenaud July 13, 2020 13:46
@pmarjan
Copy link
Contributor Author

pmarjan commented Jul 16, 2020

@magento run all tests

Copy link
Contributor

@danielrenaud danielrenaud left a 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 */
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
/** @var string $productSku */

Remove all unnecessary @var annotations

$response = $this->graphQlQuery($query);

$itemTiers = $response['products']['items'][0]['price_tiers'];
$this->assertEquals(5, sizeof($itemTiers));
Copy link
Contributor

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
Copy link
Contributor

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 =[
Copy link
Contributor

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));
Copy link
Contributor

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)
Copy link
Contributor

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}") {
Copy link
Contributor

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 */
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
/** @var string $productSku */


$response = $this->graphQlQuery($query);

/** @var float $specialPrice */
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
/** @var float $specialPrice */

{
/** @var string $productSku */
$productSku = 'simple';
/** @var string $query */
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
/** @var string $query */

@pmarjan
Copy link
Contributor Author

pmarjan commented Jul 17, 2020

@magento run all tests

Copy link
Contributor

@danielrenaud danielrenaud left a comment

Choose a reason for hiding this comment

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

Nice work!

@m2-assistant
Copy link

m2-assistant bot commented Jul 19, 2020

Hi @pmarjan, 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
Archived in project
Development

Successfully merging this pull request may close these issues.

special price & tier price are coming in base currency
5 participants