@@ -18,6 +18,11 @@ class Update extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
18
18
*/
19
19
private $ _cache ;
20
20
21
+ /**
22
+ * @var array
23
+ */
24
+ private $ layoutUpdateCache ;
25
+
21
26
/**
22
27
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
23
28
* @param \Magento\Framework\Cache\FrontendInterface $cache
@@ -55,14 +60,17 @@ public function fetchUpdatesByHandle(
55
60
\Magento \Framework \View \Design \ThemeInterface $ theme ,
56
61
\Magento \Framework \App \ScopeInterface $ store
57
62
) {
58
- $ bind = ['layout_update_handle ' => $ handle , 'theme_id ' => $ theme ->getId (), 'store_id ' => $ store ->getId ()];
59
- $ result = '' ;
60
- $ connection = $ this ->getConnection ();
61
- if ($ connection ) {
62
- $ select = $ this ->_getFetchUpdatesByHandleSelect ();
63
- $ result = join ('' , $ connection ->fetchCol ($ select , $ bind ));
63
+ $ bind = ['theme_id ' => $ theme ->getId (), 'store_id ' => $ store ->getId ()];
64
+ $ cacheKey = implode ('- ' , $ bind );
65
+ if (!isset ($ this ->layoutUpdateCache [$ cacheKey ])) {
66
+ foreach ($ this ->getConnection ()->fetchAll ($ this ->_getFetchUpdatesByHandleSelect (), $ bind ) as $ layout ) {
67
+ if (!isset ($ this ->layoutUpdateCache [$ cacheKey ][$ layout ['handle ' ]])) {
68
+ $ this ->layoutUpdateCache [$ cacheKey ][$ layout ['handle ' ]] = '' ;
69
+ }
70
+ $ this ->layoutUpdateCache [$ cacheKey ][$ layout ['handle ' ]] .= $ layout ['xml ' ];
71
+ }
64
72
}
65
- return $ result ;
73
+ return isset ( $ this -> layoutUpdateCache [ $ cacheKey ][ $ handle ]) ? $ this -> layoutUpdateCache [ $ cacheKey ][ $ handle ] : '' ;
66
74
}
67
75
68
76
/**
@@ -79,7 +87,7 @@ protected function _getFetchUpdatesByHandleSelect($loadAllUpdates = false)
79
87
80
88
$ select = $ this ->getConnection ()->select ()->from (
81
89
['layout_update ' => $ this ->getMainTable ()],
82
- ['xml ' ]
90
+ ['xml ' , ' handle ' ]
83
91
)->join (
84
92
['link ' => $ this ->getTable ('layout_link ' )],
85
93
'link.layout_update_id=layout_update.layout_update_id ' ,
@@ -88,8 +96,6 @@ protected function _getFetchUpdatesByHandleSelect($loadAllUpdates = false)
88
96
'link.store_id IN (0, :store_id) '
89
97
)->where (
90
98
'link.theme_id = :theme_id '
91
- )->where (
92
- 'layout_update.handle = :layout_update_handle '
93
99
)->order (
94
100
'layout_update.sort_order ' . \Magento \Framework \DB \Select::SQL_ASC
95
101
);
0 commit comments