18
18
use Magento \Framework \Serialize \Serializer \Json ;
19
19
use Magento \UrlRewrite \Controller \Adminhtml \Url \Rewrite ;
20
20
use Magento \UrlRewrite \Model \ResourceModel \UrlRewriteCollection ;
21
+ use Magento \UrlRewrite \Service \V1 \Data \UrlRewrite as UrlRewriteService ;
21
22
22
23
/**
23
24
* UrlRewrite model class
@@ -140,9 +141,9 @@ public function setMetadata($metadata)
140
141
*
141
142
* @param string $path
142
143
* @param int $storeId
143
- * @return UrlRewrite |null
144
+ * @return UrlRewriteService |null
144
145
*/
145
- private function getFinalTargetUrlRewrite (string $ path , int $ storeId ): ?UrlRewrite
146
+ private function getFinalTargetUrlRewrite (string $ path , int $ storeId ): ?UrlRewriteService
146
147
{
147
148
$ urlRewriteTarget = $ this ->urlFinder ->findOneByData (
148
149
[
@@ -166,7 +167,7 @@ private function getFinalTargetUrlRewrite(string $path, int $storeId): ?UrlRewri
166
167
/**
167
168
* Clean the cache for entities affected by current rewrite
168
169
*/
169
- private function cleanEntitiesCache ()
170
+ public function cleanEntitiesCache ()
170
171
{
171
172
if (!$ this ->isEmpty ()) {
172
173
if ($ this ->getEntityType () === Rewrite::ENTITY_TYPE_CUSTOM ) {
@@ -215,7 +216,7 @@ private function cleanCacheForEntity(string $entityType, int $entityId)
215
216
*/
216
217
public function afterDelete ()
217
218
{
218
- $ this ->cleanEntitiesCache ( );
219
+ $ this ->_getResource ()-> addCommitCallback ([ $ this , ' cleanEntitiesCache ' ] );
219
220
return parent ::afterDelete ();
220
221
}
221
222
@@ -224,7 +225,7 @@ public function afterDelete()
224
225
*/
225
226
public function afterSave ()
226
227
{
227
- $ this ->cleanEntitiesCache ( );
228
+ $ this ->_getResource ()-> addCommitCallback ([ $ this , ' cleanEntitiesCache ' ] );
228
229
return parent ::afterSave ();
229
230
}
230
231
}
0 commit comments