Skip to content

Commit 1cd7afb

Browse files
authored
Update ApplySeoMetadata.php
1 parent 63b4ae3 commit 1cd7afb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Observer/ApplySeoMetadata.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,30 @@ public function execute(Observer $observer): void
6969
/** @var CustomEntity|null $entity */
7070
$entity = $this->registry->registry('current_custom_entity');
7171

72-
if (!$entity || !$entity instanceof CustomEntity) {
72+
if (!$entity || !($entity instanceof CustomEntity)) {
7373
return;
7474
}
7575

76-
// Apply meta title
77-
$metaTitle = $entity->getData('meta_title');
76+
// Apply meta title only if explicitly set
77+
$metaTitle = $entity->getMetaTitle();
7878
if (!empty($metaTitle)) {
7979
$this->pageConfig->getTitle()->set($metaTitle);
8080
}
8181

82-
// Apply meta description
83-
$metaDescription = $entity->getData('meta_description');
82+
// Apply meta description only if explicitly set
83+
$metaDescription = $entity->getMetaDescription();
8484
if (!empty($metaDescription)) {
8585
$this->pageConfig->setDescription($metaDescription);
8686
}
8787

88-
// Apply meta keywords
89-
$metaKeywords = $entity->getData('meta_keywords');
88+
// Apply meta keywords only if explicitly set
89+
$metaKeywords = $entity->getMetaKeywords();
9090
if (!empty($metaKeywords)) {
9191
$this->pageConfig->setKeywords($metaKeywords);
9292
}
9393

9494
// Apply meta robots only if explicitly set
95-
$metaRobots = $entity->getData('meta_robots');
95+
$metaRobots = $entity->getMetaRobots();
9696
if (!empty($metaRobots)) {
9797
$this->pageConfig->setRobots($metaRobots);
9898
}

0 commit comments

Comments
 (0)