Open ericmorand opened 4 years ago
Hi @ericmorand. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue: @magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel.
: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, please join the Community Contributions Triage session to discuss the appropriate ticket.
:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
I confirm that a plugin solves the issue:
<?php
namespace {Vendor}\{Module}\Plugin\Framework\View\Model\Layout;
use Magento\Framework\View\DesignInterface;
class Merge
{
/** @var DesignInterface */
protected $_design;
public function __construct(DesignInterface $design)
{
$this->_design = $design;
}
public function afterGetTheme(\Magento\Framework\View\Model\Layout\Merge $subject) {
return $this->_design->getDesignTheme();
}
}
Hi This class seem only have responsible to merge all xml files across code base (themes, magento core modules, 3rd-party modules) follow order in app/etc/config.php base xml will always load first then follow by specific area (frontend, adminhtml) then follow modules . Current theme active will have load priority at last, parent will load first
It is also responsible to load handle updates stored in database - for example widgets set in the back office, through this function:
public function getDbUpdateString($handle)
{
return null;
}
This function is intercepted by a plugin (Magento\Widget\Model\ResourceModel\Layout\Plugin
) to actually retrieve the widget updates from the database.
The issue here is that at that point, the theme has already been loaded by the Merge
singleton , and thus when the updates are fetched from the database, they are fetched using the id of the theme that was loaded at construct time - i.e. the default theme of the website. Even if the theme is changed later, the DB updates for that theme won't be grabbed.
You end up with the following situation:
It is expected since when Merge
singleton is created, it is created with the default theme of your website. The Catalog controller later set the custom theme of the Product 123456 but the theme used by Merge
singleton to fetch the database updates will always be the default theme.
It's what my plugin above fixes. But it should be fixed in the core code base.
Widget dynamic type such as (list, link..) only visible after clean cache. If after setup widget we don't clear cache widget will never show. Widget type block will show without need clean cache Test in Open source 2.4.0 similar your case. But no use any customises (clean setup) No varnish setup only default magento cache
Interesting use case! So in your specific case widget will not show ? have try clear cache ? @ericmorand
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:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If 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.
[ ] 2. 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.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- 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!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Maybe we should target on widget plugin ? Obviously that widget should get current theme instead singleton instance CC: @ihor-sviziev maybe he know this
Hi @ericmorand thank you for your report.
If set Schedule Design Update->New Theme=Magento Luma
for product and Design Package/Theme=Magento Luma
for widget withType=Catalog Product List, widget is correctly displayed on product page
Could you clarify how you set specific theme for the Product ?
@engcom-Delta Have you check the test case specific product set for schedule update theme luma and widget set for all product display at blank theme for example.? Expected result widget should not visible when we visit product
This issue may can reproducible in latest codebase
@mrtuvn Thank you for verifying the issue.
Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:
"Reproduced on "
label(s) to this ticket based on verification resultOnce all required information is added, please add label "Issue: Confirmed"
again.
Thanks!
@mrtuvn Thank you for verifying the issue.
Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:
"Reproduced on "
label(s) to this ticket based on verification resultOnce all required information is added, please add label "Issue: Confirmed"
again.
Thanks!
@m2-community-project[bot] Thank you for verifying the issue.
Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:
"Reproduced on "
label(s) to this ticket based on verification resultOnce all required information is added, please add label "Issue: Confirmed"
again.
Thanks!
:white_check_mark: Confirmed by @mrtuvn
Thank you for verifying the issue. Based on the provided information internal tickets MC-42043
were created
Issue Available: @mrtuvn, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Reproducible case with luma theme setup with default sampledata
Pre-config Setup theme config default for store => luma theme
Product named "Joust Duffle Bag" 1.Go to admin -> Change Schedule Design Update : New theme: Choose blank theme 2.Create widget show products list type for blank theme and display only in product detail for "Joust Duffle Bag" 2.1 Type: Catalog Products List 2.2 Design Package/Theme: Blank theme 2.3 Assign to Store Views: All Store Views 2.4 Layout Updates: All product types Specific Products: choose "Joust Duffle Bag" Contianer: Main Container Bottom Widget options: Choose default to make sure all critieria meet and valid widget to show
Actual Widget not show (because magento still get theme luma default from initialized, Actually in the update layout theme applied use should be blank) Theme blank applied (Correct display)
Expected Widget should show and Theme blank applied (Correct display)
cc: @engcom-Delta @engcom-Oscar
Seem issue fixed in this commit https://github.com/magento/magento2/commit/76ff97efcc6352019f3775e2e7f62260fb8b0679#diff-d036d544db88cf91738bb3b56dbe89e156d4043e4cb7062af1eda9d20911d672R196 (lastest recently merged 2.4-develop) Can you verify it again ? @ericmorand Not sure this fix satisfied you or not (for your specific case)
Hi @engcom-Echo. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Hi @engcom-Echo can you help re-verify this case ?
based on update from 2.4-develop as i mentioned previously above message
@ericmorand can you re-verify your use cases one more time ? At latest 2.4-develop branch. Or add new test case that you believe can reproduce problem
Preconditions (*)
Magento 2.3.5
Steps to reproduce (*)
Expected result (*)
The specific theme is used and the widget is displayed.
Actual result (*)
The specific theme is used but the widget is not displayed.
Explanation
\Magento\Framework\View\Model\Layout\Merge
stores the theme at construct time.This creates a major issue with the rendering process, when one of the actor wants to change the theme - like for example the Magento_Catalog module. Since the theme is stored at construct time, would it be changed later, the
Merge
instance would always use the former theme stored at construct time to fetch layout updates.The most spectacuar issues it creates is when trying to assign widgets for catalog layout handles (like catalog_product_view). Since the
Merge
instance always uses the default theme to fetch the layout updates, it never gets the chance to fetch the ones that are assigned to the widget if the theme of the product is not set to the default theme of the website. The only way for the widget to get grabbed is for it to be assigned to the default theme of the website, whatever the custom theme applied to the products.Fortunately it should be easy to write a plugin that intercepts
getTheme
from theMerge
instance to return the current theme instead of the one set at construct time.Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.