@@ -40,6 +40,11 @@ class Suffix extends \Magento\Framework\App\Config\Value
40
40
*/
41
41
protected $ resource ;
42
42
43
+ /**
44
+ * @var \Magento\Framework\App\Config\ScopePool
45
+ */
46
+ private $ scopePool ;
47
+
43
48
/**
44
49
* @param \Magento\Framework\Model\Context $context
45
50
* @param \Magento\Framework\Registry $registry
@@ -75,6 +80,22 @@ public function __construct(
75
80
$ this ->resource = $ appResource ;
76
81
}
77
82
83
+ /**
84
+ * Get instance of ScopePool
85
+ *
86
+ * @return \Magento\Framework\App\Config\ScopePool
87
+ * @deprecated
88
+ */
89
+ private function getScopePool ()
90
+ {
91
+ if ($ this ->scopePool === null ) {
92
+ $ this ->scopePool = \Magento \Framework \App \ObjectManager::getInstance ()->get (
93
+ \Magento \Framework \App \Config \ScopePool::class
94
+ );
95
+ }
96
+ return $ this ->scopePool ;
97
+ }
98
+
78
99
/**
79
100
* Check url rewrite suffix - whether we can support it
80
101
*
@@ -103,6 +124,24 @@ public function afterSave()
103
124
return parent ::afterSave ();
104
125
}
105
126
127
+ /**
128
+ * @return $this
129
+ */
130
+ public function afterDeleteCommit ()
131
+ {
132
+ if ($ this ->isValueChanged ()) {
133
+ $ this ->updateSuffixForUrlRewrites ();
134
+ if ($ this ->isCategorySuffixChanged ()) {
135
+ $ this ->cacheTypeList ->invalidate ([
136
+ \Magento \Framework \App \Cache \Type \Block::TYPE_IDENTIFIER ,
137
+ \Magento \Framework \App \Cache \Type \Collection::TYPE_IDENTIFIER
138
+ ]);
139
+ }
140
+ }
141
+
142
+ return parent ::afterDeleteCommit ();
143
+ }
144
+
106
145
/**
107
146
* Check is category suffix changed
108
147
*
@@ -135,7 +174,12 @@ protected function updateSuffixForUrlRewrites()
135
174
}
136
175
$ entities = $ this ->urlFinder ->findAllByData ($ dataFilter );
137
176
$ oldSuffixPattern = '~ ' . preg_quote ($ this ->getOldValue ()) . '$~ ' ;
138
- $ suffix = $ this ->getValue ();
177
+ if ($ this ->getValue () !== null ) {
178
+ $ suffix = $ this ->getValue ();
179
+ } else {
180
+ $ this ->getScopePool ()->clean ();
181
+ $ suffix = $ this ->_config ->getValue ($ this ->getPath ());
182
+ }
139
183
foreach ($ entities as $ urlRewrite ) {
140
184
$ bind = $ urlRewrite ->getIsAutogenerated ()
141
185
? [UrlRewrite::REQUEST_PATH => preg_replace ($ oldSuffixPattern , $ suffix , $ urlRewrite ->getRequestPath ())]
0 commit comments