magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Broken CMS block preview when using identifier in pagebuilder #35070

Open jeremycharron opened 2 years ago

jeremycharron commented 2 years ago

Summary

When adding a CMS block in a CMS page using the block identifier instead of the block ID, pagebuilder displays following error : "Block with ID: [block identifier] doesn't exist." instead of showing preview of the CMS block.

The block renders properly on front-end. There is no way to add a block with his identifier directly from pagebuilder. This issue would only happen if a developer executes a data patch that generates CMS content or directly edit the content in the database.

Preconditions (*)

  1. Occurs on Magento 2.4.X (tested on 2.4.3-p1)
  2. Tested both on local and Cloud environments

Steps to reproduce (*)

  1. Create a CMS Block with any content
  2. Create a CMS Page and add previously created CMS Block in the page with the PageBuilder Block component
  3. Open cms_page table
  4. Find the created page
  5. Replace block_id value with the block identifier in the content cell. Example for a block with identifier contact-us-banner : <div data-content-type="block" data-appearance="default" data-element="main">{{widget type="Magento\Cms\Block\Widget\Block" template="widget/static_block/default.phtml" block_id="contact-us-banner" type_name="CMS Static Block"}}</div>
  6. Apply changes
  7. Refresh pagebuilder page to see error

block-identifier

Expected result (*)

  1. The pagebuilder should be able to display a preview of the block content

Ability to load block by identifier was added back in 2017 https://github.com/magento/magento2/issues/10414

From what I'm seeing in the following file, getBlockId function should handle non-numeric IDs (identifiers) : https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Cms/Model/ResourceModel/Block.php

Actual result (*)

  1. An error is displayed in the pagebuilder : "Block with ID: [block identifier] doesn't exist.", even though the block exists and is rendered on the front-end. image

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 2 years ago

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

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.


: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] commented 2 years ago

Hi @engcom-Delta. 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:

engcom-Delta commented 2 years ago

Hi @jeremycharron , Thank your for reporting an issue . Kindly elaborate more on step#5 .How can we test it please? Added the label 'Needs update'.

jeremycharron commented 2 years ago

Hi @jeremycharron , Thank your for reporting an issue . Kindly elaborate more on step#5 .How can we test it please? Added the label 'Needs update'.

Hi @engcom-Delta ,

If step 1 to 4 are done, you should have a new row in the cms_page table for your created page. image

You need to edit the value in the content cell. Let's say the content looks like this : <div data-content-type="block" data-appearance="default" data-element="main">{{widget type="Magento\Cms\Block\Widget\Block" template="widget/static_block/default.phtml" block_id="20" type_name="CMS Static Block"}}</div>

You need to change the block_id parameter to the identifier of your block, which you can find in cms_block table : <div data-content-type="block" data-appearance="default" data-element="main">{{widget type="Magento\Cms\Block\Widget\Block" template="widget/static_block/default.phtml" block_id="contact-us-banner" type_name="CMS Static Block"}}</div>

image

Then save the content in the database and refresh pagebuilder to see error described in my initial post. Let me know if you need any other info

Thank you!

engcom-Delta commented 2 years ago

Hi @jeremycharron , Thank you for your quick reply. We tried to reproduce the issue on Magento 2.4-develop branch but the issue is not reproducible.

Steps performed:

  1. Create a CMS Block with any content 35070

  2. Create a CMS Page and add previously created CMS Block in the page. 35070 TWO

  3. Open cms_page table 4 .Find the created page

  4. Replace block_id value with the block identifier in the content cell. 35070three

  5. Apply changes

  6. Refresh pagebuilder page to see error

Result: The pagebuilder should be able to display a preview of the block content 35070 res

Please let me know if this is exactly what your issue was or if there is some more configuration required from my end. Will update accordingly.

thanks

jeremycharron commented 2 years ago

Hello @engcom-Delta

I was not specific enough : You need to use the Pagebuilder Block Content component.

The legacy Static Block Widget doesn't have a preview, this one is working fine.

I will update the steps to reproduce. Thanks!

cms-block

After changing to block identifier : after

engcom-Delta commented 2 years ago

Hi @jeremycharron ,

We tried to reproduce the issue with the above mentioned step but not able to reprouce it, as shown in the screenshot screen123

can you plz tell us the use case of Replace block_id value with the block identifier in the content cell.

jeremycharron commented 2 years ago

Hello @engcom-Delta ,

I'm not sure to understand the screenshot you sent. It looks like a text component. Try removing everything and put a block component directly at the root of pagebuilder. An empty block component should look like this : image

The content of the page in the database should be very similar to this: <div data-content-type="block" data-appearance="default" data-element="main">{{widget type="Magento\Cms\Block\Widget\Block" template="widget/static_block/default.phtml" block_id="20" type_name="CMS Static Block"}}</div>

Then change the block id to the block identifier.

The use case is for data installation scripts. Let's say you need to create a data patch that generates a CMS page containing specific CMS blocks, you need the use the identifier as a unique key. The feature already works, it's only the preview in the pagebuilder that is broken.

engcom-Delta commented 2 years ago

Hi @jeremycharron , We tried to reproduce the issue on Magento 2.4 Develop but we could not reproduce the issue . Hence , It would be great help if you can make a video for reproducing it.

Test results :

Screenshot 2022-04-08 at 3 24 56 PM Screenshot 2022-04-08 at 3 34 32 PM Screenshot 2022-04-08 at 3 51 04 PM
jeremycharron commented 2 years ago

Hello @engcom-Delta ,

Here's a video with steps to reproduce. Thank you. block-identifier

engcom-Delta commented 2 years ago

Hi @jeremycharron , Thank you for providing the recorded video . After following the steps found that issue is reproducible on Magento 2.4 Develop. After updating the block id ,cms page is showing "Block-With ID test-block does not exist". Hence issue is confirming. Screenshots for reference.

Screenshot 2022-04-12 at 6 47 44 PM Screenshot 2022-04-12 at 6 48 53 PM Screenshot 2022-04-12 at 6 49 03 PM Screenshot 2022-04-12 at 6 50 40 PM Screenshot 2022-04-12 at 6 51 22 PM Screenshot 2022-04-12 at 6 51 50 PM
github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-2838 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-Delta. Thank you for verifying the issue.
Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

rvr-robert commented 2 years ago

@magento I am working on this

m2-assistant[bot] commented 2 years ago

Hi @rvr-robert! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

rvr-robert commented 2 years ago

@magento add to contributors team

m2-assistant[bot] commented 2 years ago

Hi @rvr-robert! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

rvr-robert commented 2 years ago

@magento I am working on this

chazzs commented 1 year ago

Are there any plans to build another page builder entity that DOES use the identifier to embed a block? How would one go about extending this entity to use the identifier rater than the hard block_id?

I am trying to modify it now but am getting stuck where the dialog closes and hands over the ID to the preview. I can't seem to locate how to pass back the identifier and not the block_id for the template substitution.