magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Product Alert Adding custom CMS blocks to mail template

Open leonhelmus opened this issue 2 years ago • 8 comments

Preconditions and environment

  • Magento 2.4.4-p1
  • php 8.1

Steps to reproduce

  1. Go to backend
  2. Create a cms block (Content > Blocks) > Add new Block > Edit with pagebuilder
  3. Add element named a HTML code
<table class="header-tabs" align="center">
                <tbody>
                    <tr>
                        <td class="header-tab webshop">
                            <a href="{{config path="web/secure/base_url"}}"><b>test1</b></a>
                        </td>
                        <td class="header-tab service">
                            <a href="{{config path="web/secure/base_url"}}test2"><b>test2</b></a>
                        </td>
                        <td class="header-tab faq">
                            <a href="{{config path="web/secure/base_url"}}test3"><b>test3</b></a>
                        </td>
                    </tr>
                </tbody>
            </table>
  1. add identifier "custom"
  2. Enable back in stock
  3. Go to marketing > Email templates
  4. Add new template > load template "Stock Alert"
  5. Add this in the content {{block class="Magento\Cms\Block\BlockByIdentifier" area='frontend' identifier="custom"}}
  6. Enable stock alert
  7. Create customer account
  8. subscribe to stock alert for out of stock product.
  9. Make the product back in stock

Expected result

The block "custom" gets rendered as html.

Actual result

The block "custom" gets rendered as text and you see the whole html tags rendered as text.

Additional information

Product alert now uses queues in magento 2.4.4 while before it used crons.

Because it now uses queues it does not have an area, since queue's in most cases use AREA global, because it uses the area global it does not get to use the plugin \Magento\PageBuilder\Plugin\Filter\TemplatePlugin of pagebuilder. This plugin is responsible of making encoded html and decodes it. By adding this patch the problem is resolved.


diff --git a/vendor/magento/module-page-builder/etc/di.xml b/vendor/magento/module-page-builder/etc/di.xml
--- a/vendor/magento/module-page-builder/etc/di.xml	
+++ b/vendor/magento/module-page-builder/etc/di.xml	(date 1663074045963)
@@ -450,4 +450,7 @@
             </argument>
         </arguments>
     </virtualType>
+    <type name="Magento\Framework\Filter\Template">
+        <plugin name="convertBackgroundImages" type="Magento\PageBuilder\Plugin\Filter\TemplatePlugin"/>
+    </type>
 </config>

Release note

No response

Triage and priority

  • [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [X] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

leonhelmus avatar Sep 13 '22 13:09 leonhelmus

Hi @leonhelmus. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] avatar Sep 13 '22 13:09 m2-assistant[bot]

@magento give me 2.4-develop instance

engcom-Dash avatar Sep 20 '22 10:09 engcom-Dash

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

Hi @engcom-Dash, here is your Magento Instance: https://48bfef7cf8b7230a6dc329376a6db94d.instances.magento-community.engineering Admin access: https://48bfef7cf8b7230a6dc329376a6db94d.instances.magento-community.engineering/admin_d807 Login: 4e0fd3ff Password: 3e99ccd018d9

Hi @engcom-Dash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
      DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
    1. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

m2-assistant[bot] avatar Sep 20 '22 11:09 m2-assistant[bot]

Hi @leonhelmus ,

We are trying to reproduce the issue in 2.4-develop branch and 2.4.4 also we are not able to reproduce the issue. we are getting The block "custom" gets rendered as html.

For your reference i attached the screenshots: Screenshot from 2022-09-20 17-33-12 Screenshot from 2022-09-20 17-24-25 Screenshot from 2022-09-20 17-23-19 Screenshot from 2022-09-20 17-22-23

Steps to reproduce:

Go to back-end Create a cms block (Content > Blocks) > Add new Block > Edit with page builder Add element named a HTML coded identifier "custom" Enable back in stock Go to marketing > Email templates Add new template > load template "Stock Alert" Add this in the content which is provided Enable stock alert Create customer account subscribe to stock alert for out of stock product.

Let us know if we are Missing anything!!!

Thnaks!!!!

engcom-Dash avatar Sep 20 '22 12:09 engcom-Dash

@engcom-Dash could it be that the feature environment for the product elart queue has an area, because our queue uses global and that's why that patch is needed.

leonhelmus avatar Sep 20 '22 16:09 leonhelmus

We added the static block in this way {{block or are you using a widget?

leonhelmus avatar Sep 20 '22 16:09 leonhelmus

@magento give me 2.4-develop instance

engcom-Dash avatar Oct 19 '22 12:10 engcom-Dash

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

Hi @engcom-Dash, here is your Magento Instance: https://48bfef7cf8b7230a6dc329376a6db94d.instances.magento-community.engineering Admin access: https://48bfef7cf8b7230a6dc329376a6db94d.instances.magento-community.engineering/admin_80be Login: 4ef7c1b1 Password: 0fdbd3bb12ca

Hi @leonhelmus ,

As per description we are added block...and we are getting the result is "The block "custom" gets rendered as html".

Let us know if we missing anything!!!

Thanks!!!

engcom-Dash avatar Oct 19 '22 13:10 engcom-Dash

Hi @leonhelmus ,

Thanks for your Contribution!

We have noticed that this issue has not been updated for a period of 14 Days.
Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks !!!

engcom-Dash avatar Nov 02 '22 04:11 engcom-Dash