需要修改core代码,位置:vendor/magento/framework/View/Model/Layout/Merge.php: _loadFileLayoutUpdatesXml
添加file_put_contents代码行
foreach ($updateFiles as $file) {
// ...
file_put_contents(BP . '/var/log/layout_files.csv', $tagName.','.$handleName.','.$file->getFilename()."\r\n", FILE_APPEND);
}
清除缓存后访问页面,得到数据 var/log/layout_files.csv
每个页面都有handle,例如catalog_product_view代表product detail page,在layout_files.csv查询catalog_product_view,就能知道该页面加载的所有layout xml的位置。