13
13
use Magento \MediaContentApi \Api \UpdateContentAssetLinksInterface ;
14
14
use Magento \MediaContentApi \Api \Data \ContentIdentityInterfaceFactory ;
15
15
use Magento \MediaContentCatalog \Model \ResourceModel \GetContent ;
16
- use Magento \Framework \EntityManager \MetadataPool ;
17
- use Magento \Catalog \Api \Data \CategoryInterface ;
18
16
19
17
/**
20
18
* Observe the catalog_category_save_after event and run processing relation between category content and media asset.
@@ -26,11 +24,6 @@ class Category implements ObserverInterface
26
24
private const ENTITY_ID = 'entityId ' ;
27
25
private const FIELD = 'field ' ;
28
26
29
- /**
30
- * @var MetadataPool
31
- */
32
- private $ metadataPool ;
33
-
34
27
/**
35
28
* @var UpdateContentAssetLinksInterface
36
29
*/
@@ -61,13 +54,11 @@ public function __construct(
61
54
ContentIdentityInterfaceFactory $ contentIdentityFactory ,
62
55
GetContent $ getContent ,
63
56
UpdateContentAssetLinksInterface $ updateContentAssetLinks ,
64
- MetadataPool $ metadataPool ,
65
57
array $ fields
66
58
) {
67
59
$ this ->contentIdentityFactory = $ contentIdentityFactory ;
68
60
$ this ->getContent = $ getContent ;
69
61
$ this ->updateContentAssetLinks = $ updateContentAssetLinks ;
70
- $ this ->metadataPool = $ metadataPool ;
71
62
$ this ->fields = $ fields ;
72
63
}
73
64
@@ -82,7 +73,6 @@ public function execute(Observer $observer): void
82
73
$ model = $ observer ->getEvent ()->getData ('category ' );
83
74
84
75
if ($ model instanceof CatalogCategory) {
85
- $ id = (int ) $ model ->getData ($ this ->metadataPool ->getMetadata (CategoryInterface::class)->getLinkField ());
86
76
foreach ($ this ->fields as $ field ) {
87
77
if (!$ model ->dataHasChangedFor ($ field )) {
88
78
continue ;
@@ -95,7 +85,7 @@ public function execute(Observer $observer): void
95
85
self ::ENTITY_ID => (string ) $ model ->getId (),
96
86
]
97
87
),
98
- $ this ->getContent ->execute ($ id , $ model ->getAttributes ()[$ field ])
88
+ $ this ->getContent ->execute (( int ) $ model -> getId () , $ model ->getAttributes ()[$ field ])
99
89
);
100
90
}
101
91
}
0 commit comments