@@ -33,11 +33,19 @@ class Fallback implements PostProcessorInterface
33
33
*/
34
34
private $ resourceConnection ;
35
35
36
+ /**
37
+ * @var array
38
+ */
39
+ private $ storeData = [];
40
+
41
+ /**
42
+ * @var array
43
+ */
44
+ private $ websiteData = [];
36
45
/**
37
46
* @var Store
38
47
*/
39
48
private $ storeResource ;
40
-
41
49
/**
42
50
* @var Website
43
51
*/
@@ -64,6 +72,9 @@ public function __construct(
64
72
*/
65
73
public function process (array $ data )
66
74
{
75
+ $ this ->storeData = $ this ->storeResource ->readAllStores ();
76
+ $ this ->websiteData = $ this ->websiteResource ->readAllWebsites ();
77
+
67
78
$ defaultConfig = isset ($ data ['default ' ]) ? $ data ['default ' ] : [];
68
79
$ result = [
69
80
'default ' => $ defaultConfig ,
@@ -92,8 +103,7 @@ private function prepareWebsitesConfig(
92
103
array $ websitesConfig
93
104
) {
94
105
$ result = [];
95
- /** @var WebsiteInterface $website */
96
- foreach ($ this ->websiteResource ->readAllWebsites () as $ website ) {
106
+ foreach ($ this ->websiteData as $ website ) {
97
107
$ code = $ website ['code ' ];
98
108
$ id = $ website ['website_id ' ];
99
109
$ websiteConfig = isset ($ websitesConfig [$ code ]) ? $ websitesConfig [$ code ] : [];
@@ -118,8 +128,7 @@ private function prepareStoresConfig(
118
128
) {
119
129
$ result = [];
120
130
121
- /** @var StoreInterface $store */
122
- foreach ($ this ->storeResource ->readAllStores () as $ store ) {
131
+ foreach ($ this ->storeData as $ store ) {
123
132
$ code = $ store ['code ' ];
124
133
$ id = $ store ['store_id ' ];
125
134
$ websiteConfig = [];
@@ -142,8 +151,7 @@ private function prepareStoresConfig(
142
151
*/
143
152
private function getWebsiteConfig (array $ websites , $ id )
144
153
{
145
- /** @var WebsiteInterface $website */
146
- foreach ($ this ->websiteResource ->readAllWebsites () as $ website ) {
154
+ foreach ($ this ->websiteData as $ website ) {
147
155
if ($ website ['website_id ' ] == $ id ) {
148
156
$ code = $ website ['website_id ' ];
149
157
return isset ($ websites [$ code ]) ? $ websites [$ code ] : [];
0 commit comments