6
6
7
7
namespace Magento \Search \Model \ResourceModel ;
8
8
9
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
9
10
use Magento \Framework \DB \Helper \Mysql \Fulltext ;
10
11
use Magento \Framework \Exception \LocalizedException ;
11
12
use Magento \Framework \Model \ResourceModel \Db \AbstractDb ;
13
+ use Magento \Store \Model \ScopeInterface ;
12
14
use Magento \Store \Model \StoreManagerInterface ;
13
15
14
16
/**
@@ -55,12 +57,12 @@ public function loadByPhrase(\Magento\Search\Model\SynonymReader $object, $phras
55
57
$ rows = $ this ->queryByPhrase (strtolower ($ phrase ));
56
58
$ synsPerScope = $ this ->getSynRowsPerScope ($ rows );
57
59
58
- if (!empty ($ synsPerScope [\ Magento \ Store \ Model \ ScopeInterface::SCOPE_STORES ])) {
59
- $ object ->setData ($ synsPerScope [\ Magento \ Store \ Model \ ScopeInterface::SCOPE_STORES ]);
60
- } elseif (!empty ($ synsPerScope [\ Magento \ Store \ Model \ ScopeInterface::SCOPE_WEBSITES ])) {
61
- $ object ->setData ($ synsPerScope [\ Magento \ Store \ Model \ ScopeInterface::SCOPE_WEBSITES ]);
60
+ if (!empty ($ synsPerScope [ScopeInterface::SCOPE_STORES ])) {
61
+ $ object ->setData ($ synsPerScope [ScopeInterface::SCOPE_STORES ]);
62
+ } elseif (!empty ($ synsPerScope [ScopeInterface::SCOPE_WEBSITES ])) {
63
+ $ object ->setData ($ synsPerScope [ScopeInterface::SCOPE_WEBSITES ]);
62
64
} else {
63
- $ object ->setData ($ synsPerScope [\ Magento \ Framework \ App \ Config \ ScopeConfigInterface::SCOPE_TYPE_DEFAULT ]);
65
+ $ object ->setData ($ synsPerScope [ScopeConfigInterface::SCOPE_TYPE_DEFAULT ]);
64
66
}
65
67
$ this ->_afterLoad ($ object );
66
68
return $ this ;
@@ -74,9 +76,15 @@ public function loadByPhrase(\Magento\Search\Model\SynonymReader $object, $phras
74
76
public function getAllSynonyms (): array
75
77
{
76
78
$ connection = $ this ->getConnection ();
77
- $ select = $ connection ->select ()->from ($ this ->getMainTable (), 'synonyms ' );
78
-
79
- return $ connection ->fetchCol ($ select );
79
+ $ query = $ connection ->select ()->from ($ this ->getMainTable ());
80
+ $ rows = $ connection ->fetchAll ($ query );
81
+ $ synonymsPerScope = $ this ->getSynRowsPerScope ($ rows );
82
+
83
+ return array_merge (
84
+ array_column ($ synonymsPerScope [ScopeInterface::SCOPE_STORES ], 'synonyms ' ),
85
+ array_column ($ synonymsPerScope [ScopeInterface::SCOPE_WEBSITES ], 'synonyms ' ),
86
+ array_column ($ synonymsPerScope [ScopeConfigInterface::SCOPE_TYPE_DEFAULT ], 'synonyms ' )
87
+ );
80
88
}
81
89
82
90
/**
@@ -151,9 +159,9 @@ private function getSynRowsPerScope($rows)
151
159
$ synRowsForDefault [] = $ row ;
152
160
}
153
161
}
154
- $ synsPerScope [\ Magento \ Store \ Model \ ScopeInterface::SCOPE_STORES ] = $ synRowsForStoreView ;
155
- $ synsPerScope [\ Magento \ Store \ Model \ ScopeInterface::SCOPE_WEBSITES ] = $ synRowsForWebsite ;
156
- $ synsPerScope [\ Magento \ Framework \ App \ Config \ ScopeConfigInterface::SCOPE_TYPE_DEFAULT ] = $ synRowsForDefault ;
162
+ $ synsPerScope [ScopeInterface::SCOPE_STORES ] = $ synRowsForStoreView ;
163
+ $ synsPerScope [ScopeInterface::SCOPE_WEBSITES ] = $ synRowsForWebsite ;
164
+ $ synsPerScope [ScopeConfigInterface::SCOPE_TYPE_DEFAULT ] = $ synRowsForDefault ;
157
165
return $ synsPerScope ;
158
166
}
159
167
0 commit comments