File tree 4 files changed +17
-18
lines changed
MediaContentCatalog/Observer 4 files changed +17
-18
lines changed Original file line number Diff line number Diff line change 17
17
use Magento \MediaContentApi \Api \ExtractAssetsFromContentInterface ;
18
18
19
19
/**
20
- * Observe the catalog_category_delete event and deletes relation between category content and media asset.
20
+ * Observe the catalog_category_delete_after event and deletes relation between category content and media asset.
21
21
*/
22
22
class CategoryDelete implements ObserverInterface
23
23
{
@@ -88,16 +88,16 @@ public function __construct(
88
88
*/
89
89
public function execute (Observer $ observer ): void
90
90
{
91
- $ model = $ observer ->getEvent ()->getData ('category ' );
91
+ $ category = $ observer ->getEvent ()->getData ('category ' );
92
92
$ contentAssetLinks = [];
93
93
94
- if ($ model instanceof CatalogCategory) {
94
+ if ($ category instanceof CatalogCategory) {
95
95
foreach ($ this ->fields as $ field ) {
96
96
$ contentIdentity = $ this ->contentIdentityFactory ->create (
97
97
[
98
98
self ::TYPE => self ::CONTENT_TYPE ,
99
99
self ::FIELD => $ field ,
100
- self ::ENTITY_ID => (string ) $ model ->getEntityId (),
100
+ self ::ENTITY_ID => (string ) $ category ->getEntityId (),
101
101
]
102
102
);
103
103
$ content = implode (PHP_EOL , $ this ->getContent ->execute ($ contentIdentity ));
Original file line number Diff line number Diff line change @@ -88,20 +88,20 @@ public function __construct(
88
88
*/
89
89
public function execute (Observer $ observer ): void
90
90
{
91
- $ model = $ observer ->getEvent ()->getData ('product ' );
91
+ $ product = $ observer ->getEvent ()->getData ('product ' );
92
92
$ contentAssetLinks = [];
93
93
94
- if ($ model instanceof CatalogProduct) {
94
+ if ($ product instanceof CatalogProduct) {
95
95
foreach ($ this ->fields as $ field ) {
96
96
$ contentIdentity = $ this ->contentIdentityFactory ->create (
97
97
[
98
98
self ::TYPE => self ::CONTENT_TYPE ,
99
99
self ::FIELD => $ field ,
100
- self ::ENTITY_ID => (string ) $ model ->getEntityId (),
100
+ self ::ENTITY_ID => (string ) $ product ->getEntityId (),
101
101
]
102
102
);
103
- $ content = implode (PHP_EOL , $ this ->getContent ->execute ($ contentIdentity ));
104
- $ assets = $ this ->extractAssetsFromContent ->execute ($ content );
103
+ $ productContent = implode (PHP_EOL , $ this ->getContent ->execute ($ contentIdentity ));
104
+ $ assets = $ this ->extractAssetsFromContent ->execute ($ productContent );
105
105
106
106
foreach ($ assets as $ asset ) {
107
107
$ contentAssetLinks [] = $ this ->contentAssetLinkFactory ->create (
Original file line number Diff line number Diff line change @@ -88,20 +88,19 @@ public function __construct(
88
88
*/
89
89
public function execute (Observer $ observer ): void
90
90
{
91
- $ model = $ observer ->getEvent ()->getData ('object ' );
91
+ $ block = $ observer ->getEvent ()->getData ('object ' );
92
92
$ contentAssetLinks = [];
93
93
94
- if ($ model instanceof CmsBlock) {
94
+ if ($ block instanceof CmsBlock) {
95
95
foreach ($ this ->fields as $ field ) {
96
96
$ contentIdentity = $ this ->contentIdentityFactory ->create (
97
97
[
98
98
self ::TYPE => self ::CONTENT_TYPE ,
99
99
self ::FIELD => $ field ,
100
- self ::ENTITY_ID => (string ) $ model ->getId (),
100
+ self ::ENTITY_ID => (string ) $ block ->getId (),
101
101
]
102
102
);
103
-
104
- $ assets = $ this ->extractAssetsFromContent ->execute ((string ) $ model ->getData ($ field ));
103
+ $ assets = $ this ->extractAssetsFromContent ->execute ((string ) $ block ->getData ($ field ));
105
104
106
105
foreach ($ assets as $ asset ) {
107
106
$ contentAssetLinks [] = $ this ->contentAssetLinkFactory ->create (
Original file line number Diff line number Diff line change @@ -88,20 +88,20 @@ public function __construct(
88
88
*/
89
89
public function execute (Observer $ observer ): void
90
90
{
91
- $ model = $ observer ->getEvent ()->getData ('object ' );
91
+ $ page = $ observer ->getEvent ()->getData ('object ' );
92
92
$ contentAssetLinks = [];
93
93
94
- if ($ model instanceof CmsPage) {
94
+ if ($ page instanceof CmsPage) {
95
95
foreach ($ this ->fields as $ field ) {
96
96
$ contentIdentity = $ this ->contentIdentityFactory ->create (
97
97
[
98
98
self ::TYPE => self ::CONTENT_TYPE ,
99
99
self ::FIELD => $ field ,
100
- self ::ENTITY_ID => (string ) $ model ->getId (),
100
+ self ::ENTITY_ID => (string ) $ page ->getId (),
101
101
]
102
102
);
103
103
104
- $ assets = $ this ->extractAssetsFromContent ->execute ((string ) $ model ->getData ($ field ));
104
+ $ assets = $ this ->extractAssetsFromContent ->execute ((string ) $ page ->getData ($ field ));
105
105
106
106
foreach ($ assets as $ asset ) {
107
107
$ contentAssetLinks [] = $ this ->contentAssetLinkFactory ->create (
You can’t perform that action at this time.
0 commit comments