Closed

Description
This issue is automatically created based on existing pull request: #28147: Introduce separate BlockByIdentifier class to get Layout Block based on CMS Block Identifier
Preconditions: (*)
The existing class is anti-pattern:
- Uses
\Magento\Framework\Model\AbstractModel::load
to load Model - If
block_id
is identifier, thegetIdentities
method returns same identity whatever the Scope is (return [\Magento\Cms\Model\Block::CACHE_TAG . '_' . $this->getBlockId()];
), which is painful when you use the sameidentifier
for multiple per-store CMS blocks.
Why can't we fix the original Block? Some of developers might have used:
<referenceContainer name="page.top">
<block class="Magento\Cms\Block\Block" name="header.info" after="navigation.sections">
<arguments>
<argument name="block_id" xsi:type="string">666</argument>
</arguments>
</block>
</referenceContainer>
That is why we keep old Block backwards-compatible and introducing new one that can be used explicitly:
<referenceContainer name="page.top">
<block class="Magento\Cms\Block\BlockByIdentifier" name="header.info" after="navigation.sections">
<arguments>
<argument name="identifier" xsi:type="string">header-info</argument>
</arguments>
</block>
</referenceContainer>
Related Pull Requests
Fixed Issues (if relevant)
- magento/magento2#<issue_number>: Issue title
Steps to reproduce (*)
Actual Result (*)
Expected Result (*)
- ...
- ...
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)
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.4-develop branchGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentMay be fixed according to the position in the backlog.The issue has been reproduced on latest 2.4-develop branchAffects non-critical data or functionality and does not force users to employ a workaround.
Type
Projects
Status
Done