Skip to content
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

magento/magento2#24730: Fix Frontend Invoice PDF configured Logo image #30632

Merged
merged 10 commits into from
Nov 13, 2020

Conversation

mozok
Copy link
Contributor

@mozok mozok commented Oct 23, 2020

Description (*)

According to #24730 Admin Configuration Stores -> Configuration -> Sales -> Sales ->'Invoice and Packaging Slip Design' -> 'Logo for HTML Print View' does not affect on logo on frontend invoice print page.

sales_order_printinvoice page use general theme class/template for Logo generation - app/code/Magento/Theme/Block/Html/Header/Logo.php

In Block 'logo_src' argument is checked, before logo path is generated, so I use it as extension point to insert logo configuration on print invoice page.
Changes affects only frontend sales order print invoice page through layout file. Similar approach can be used to change other print pages, like sales_order_print.

Related Pull Requests

no

Fixed Issues (if relevant)

  1. Fixes Invoice PDF on frontend does not use configured logo image #24730

Manual testing scenarios (*)

  1. Create Order from storefront.
  2. Create Invoice from admin.
  3. On storefront go to Customer Account > My Orders > View Order
  4. Select Invoices Tab.
  5. Select Print Invoice. By Default Logo is Luma.
  6. In Admin Configuration go to Sales -> Sales ->'Invoice and Packaging Slip Design' -> 'Logo for HTML Print View' and upload custom image
  7. Clear cache.
  8. In customer account repeat steps 3-5. The Logo now should be your custom image.

Questions or comments

no

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 23, 2020

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

@mozok
Copy link
Contributor Author

mozok commented Oct 23, 2020

@magento give me test instance

@magento-deployment-service
Copy link

Hi @mozok. Thank you for your request. I'm working on Magento instance for you.

@Stepa4man Stepa4man self-requested a review October 23, 2020 20:19
@Stepa4man Stepa4man self-assigned this Oct 23, 2020
@magento-deployment-service
Copy link

@sidolov sidolov added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Oct 23, 2020
Copy link
Contributor

@Stepa4man Stepa4man left a comment

Choose a reason for hiding this comment

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

Hi @mozok
Thanks for your contribution

Please take a look at my comments and consider covering your functionality by tests. (I think integration test is the best fit here)

<referenceContainer name="header-wrapper">
<referenceBlock name="logo">
<arguments>
<argument name="logo_src" xsi:type="helper" helper="Magento\Sales\Helper\Invoice\Logo::getLogoFile"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change xsi:type, I believe it should be "object" instead of "helper"
Also for block it's better to use ViewModel

Copy link
Contributor Author

@mozok mozok Oct 24, 2020

Choose a reason for hiding this comment

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

Here I rely on check in original Block class
\Magento\Theme\Block\Html\Header\Logo

public function getLogoSrc()
{
    if (empty($this->_data['logo_src'])) {
        $this->_data['logo_src'] = $this->_getLogoUrl();
    }
    return $this->_data['logo_src'];
}

So I want to inject result of my service class execution into 'logo_src' argument just in one layout.
I assume, that give me opportunity to change logo for one layout, and not modify original template/block class.

app/code/Magento/Sales/Helper/Invoice/Logo.php Outdated Show resolved Hide resolved
app/code/Magento/Sales/Helper/Invoice/Logo.php Outdated Show resolved Hide resolved
app/code/Magento/Sales/Helper/Invoice/Logo.php Outdated Show resolved Hide resolved
app/code/Magento/Sales/Helper/Invoice/Logo.php Outdated Show resolved Hide resolved
app/code/Magento/Sales/Helper/Invoice/Logo.php Outdated Show resolved Hide resolved
app/code/Magento/Sales/Helper/Invoice/Logo.php Outdated Show resolved Hide resolved
app/code/Magento/Sales/Helper/Invoice/Logo.php Outdated Show resolved Hide resolved
app/code/Magento/Sales/Helper/Invoice/Logo.php Outdated Show resolved Hide resolved
app/code/Magento/Sales/Helper/Invoice/Logo.php Outdated Show resolved Hide resolved
@ghost ghost moved this from Pending Review to Changes Requested in Pull Requests Dashboard Oct 23, 2020
Move Custom Logo file getter to separate service class
simplify execute method
@ghost ghost assigned mozok Oct 24, 2020
@mozok
Copy link
Contributor Author

mozok commented Oct 24, 2020

@magento run all tests

@mozok
Copy link
Contributor Author

mozok commented Oct 24, 2020

@magento run Integration Tests

@mozok
Copy link
Contributor Author

mozok commented Oct 24, 2020

@magento run Functional Tests EE

1 similar comment
@mozok
Copy link
Contributor Author

mozok commented Oct 24, 2020

@magento run Functional Tests EE

@mozok
Copy link
Contributor Author

mozok commented Oct 25, 2020

@magento run Functional Tests EE

This test is failing on different 'flaky' tests (

@ghost ghost removed this from Pending Review in Pull Requests Dashboard Oct 27, 2020
@engcom-Bravo engcom-Bravo self-assigned this Oct 28, 2020
@engcom-Bravo engcom-Bravo moved this from Ready for Testing to Testing in Progress in High Priority Pull Requests Dashboard Oct 28, 2020
@engcom-Bravo
Copy link
Contributor

engcom-Bravo commented Oct 28, 2020

✔️ QA Passed

Manual testing scenario

  1. Go to Storefront and Log In as Customer
  2. Place an order
  3. From Admin, Submit Invoice for the previously created order
  4. Go to Customer Account - My Orders, and View the previously created order
  5. Switch to Invoice tab, click Print Invoice
  6. Observe the Logo in the printed file. Default Luma logo is displayed
    default_logo
  7. From Admin, go to Stores - Configuration - Sales - Sales - 'Invoice and Packaging Slip Design' - 'Logo for HTML Print View' and Upload a custom image
  8. Save config and clear Magento cache
  9. Go to Storefront and Log in with the same Customer
  10. Go to Customer Account - My Orders, and View the previously created order
  11. Switch to Invoice tab, click Print Invoice
  12. Observe the Logo in the printed file.

Before applying changes provided in the PR, the logo was the same Default Luma
before

Afters switching to the PR, the logo in the printed file has changed to the custom uploaded logo
after

@engcom-Bravo engcom-Bravo moved this from Testing in Progress to Merge in Progress in High Priority Pull Requests Dashboard Oct 28, 2020
@ghost ghost moved this from Merge in Progress to Ready for Testing in High Priority Pull Requests Dashboard Nov 2, 2020
@engcom-Bravo
Copy link
Contributor

✔️ QA Passed

The result is the same as in the comment above

@engcom-Bravo engcom-Bravo moved this from Ready for Testing to Testing in Progress in High Priority Pull Requests Dashboard Nov 2, 2020
@engcom-Bravo engcom-Bravo moved this from Testing in Progress to Merge in Progress in High Priority Pull Requests Dashboard Nov 2, 2020
@gabrieldagama
Copy link
Contributor

@magento run all tests

@mozok
Copy link
Contributor Author

mozok commented Nov 9, 2020

again error in "flaky" test)
@magento run Functional Tests B2B

@m2-assistant
Copy link

m2-assistant bot commented Nov 13, 2020

Hi @mozok, 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.

@sidolov sidolov moved this from Merge in Progress to Recently Merged in High Priority Pull Requests Dashboard Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Component: Sales Event: MageCONF CD 2020 Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invoice PDF on frontend does not use configured logo image
7 participants