Skip to content

[GraphQl][GiftMessage] Add functionality for getting message for order item #29417

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

Conversation

Usik2203
Copy link
Contributor

@Usik2203 Usik2203 commented Aug 6, 2020

Description (*)

Now we use customerOrders query for getting GiftMessage of order
Screenshot 2020-08-06 at 11 54 41
But this query is DEPRECATED @deprecated(reason: "Use orders from customer instead")

1.

Using correct query we are getting issue
Screenshot 2020-08-05 at 15 29 13

2.

*Using this query we can't get GiftMessage of order items

{
  customer {
   orders(filter:{number:{eq:"000000234"}}){
    total_count
    items
    {
      id
      number
      status
      order_date
      items {
        product_sku
        gift_message {
          from
          to 
          message
        }
      }
      gift_message {
        from
        to
        message
      }
    }
   }
 }
}

Actual result

This PR fixes first issue and add functionality to get GiftMessage for Order Items
Screenshot 2020-08-06 at 12 03 02

Fixed Issues (if relevant)

  1. Fixes magento/magento2#<issue_number>

Manual testing scenarios (*)

  1. ...
  2. ...

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)

Resolved issues:

  1. resolves [Issue] [GraphQl][GiftMessage] Add functionality for getting message for order item  #29418: [GraphQl][GiftMessage] Add functionality for getting message for order item

@m2-assistant
Copy link

m2-assistant bot commented Aug 6, 2020

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

@magento-engcom-team magento-engcom-team added Component: GiftMessageGraphQl Release Line: 2.4 Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner labels Aug 6, 2020
@Usik2203
Copy link
Contributor Author

Usik2203 commented Aug 6, 2020

@magento create issue

@Usik2203
Copy link
Contributor Author

Usik2203 commented Aug 6, 2020

@magento run all tests

@Usik2203
Copy link
Contributor Author

Usik2203 commented Aug 6, 2020

@magento run all tests

@@ -58,9 +58,11 @@ public function resolve(
if (!isset($value['id'])) {
throw new GraphQlInputException(__('"id" value should be specified'));
}
// phpcs:ignore Magento2.Functions.DiscouragedFunction
$orderId = (int)base64_decode($value['id']) ?: (int)$value['id'];
Copy link
Member

Choose a reason for hiding this comment

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

i think that we must be more careful with values provided from FE.

<?php

declare(strict_types=1);

echo "\nit's wrong (string)`1 hi all!` !== (int)`1`\n";
$a = base64_encode('1 hi all!');
var_dump((int)base64_decode($a));


echo "\nit's wrong (string)`1 hi all!` !== (int)`1`\n";
var_dump((int) '1 hi all!');

https://3v4l.org/dAvUu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @rvitaliy
I am sorry but I am not sure that i understand your remark.
Yes, I understood problem which you provided in example but i can't get how it is related with this case in the code.
Perhaps you could explain your point ?
Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

he means if we trust that $value['id'] is a trusted value
and he explained a way to exploit such a value and how it can be misleading using base64_decode

if you wouldn't add this empty line we would of not seen this :)
we actually have a safer way to do this \Magento\Framework\GraphQl\Query\Uid::decode
you can use it if you want, but it's not really the purpose of this PR

@rogyar rogyar added Award: category of expertise Award: test coverage Auto-Tests: Covered All changes in Pull Request is covered by auto-tests labels Aug 7, 2020
return null;
}

if (!$this->giftMessageHelper->isMessagesAllowed('item', $orderItem)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I just want to double-check we really need this part. If we calling isMessageAllowed with type = "items", the second invocation (with type = "item") will be performed eventually. See the following implementation

if ($this->isMessagesAllowed($_type, $item, $store)) {

Please, correct me if I'm wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @rogyar
isMessageAllowed with type = "item" need for checking isMessageAllowed on product level because we can have situation where GiftMessages are enable in configs but disable for some products
Thanks

@ghost ghost added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Aug 17, 2020
@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-8059 has been created to process this Pull Request

@ishakhsuvarov
Copy link
Contributor

Hi @Usik2203

Is there any chance you could take a look and resolve the merge conflict with the leatest 2.4-develop branch? I have tried getting this processedc and delivered but now I'm getting red builds all over the place.

Thank you

@engcom-Charlie
Copy link
Contributor

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

@magento run Functional Tests B2B, Functional Tests EE, Integration Tests, Static Tests, Unit Tests , WebAPI 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-Charlie
Copy link
Contributor

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

@magento run Functional Tests B2B, Functional Tests EE, Integration Tests, Static 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-Charlie
Copy link
Contributor

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

Hi @ishakhsuvarov,

I have resolved the merge conflicts. Also fixed all the build failures.

The functional b2b failures are not part of this PR, or not even failing because of this PR's changes. Hence moving this PR to Merge in Progress now.

Thank you!

@engcom-Charlie
Copy link
Contributor

@magento run Functional Tests B2B, Unit 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.

magento-devops-reposync-svc pushed a commit that referenced this pull request Sep 20, 2022
[GraphQl][GiftMessage] Add functionality for getting message for order item #29417
@magento-devops-reposync-svc magento-devops-reposync-svc merged commit 2e19e09 into magento:2.4-develop Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: advanced Award: category of expertise Award: test coverage Component: GiftMessageGraphQl Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept Project: GraphQL Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] [GraphQl][GiftMessage] Add functionality for getting message for order item