Skip to content

Commit 866bceb

Browse files
committed
fixed issue with socialMarkup fallback process
1 parent c8687a6 commit 866bceb

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Model/Resolver/Category/SocialMarkup.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ public function resolve(
102102
// add url
103103
$this->setUrl($this->retrieveUrl($category->getId(), CategoryUrlRewriteGenerator::ENTITY_TYPE, $store->getId()));
104104
// add title
105-
$this->setTitle($category->getMetaTitle() ?? $category->getName());
105+
$this->setTitle(!empty($category->getMetaTitle()) ?
106+
$category->getMetaTitle() : $category->getName());
106107
// add description
107-
$this->setDescription($category->getMetaDescription() ?? $category->getDescription());
108+
$this->setDescription(!empty($category->getMetaDescription()) ?
109+
$category->getMetaDescription() : $category->getDescription());
108110
// add image, if any
109111
$this->setImage($this->retrieveImage($category->getId(), $store));
110112

@@ -129,14 +131,14 @@ public function retrieveImage($categoryId, $store) {
129131
$category = $categoryRepository->get($categoryId, $storeId);
130132

131133
$imageUrl = $category->getImage();
132-
if (isset($imageUrl) and !empty($imageUrl)) {
134+
if (!empty($imageUrl)) {
133135
$imageUrl = UrlHelper::pinchUrl($store->getBaseUrl(), $imageUrl);
134136
} else {
135137
$imageUrl = $this->socialMarkupHelper->getImagePlaceholder(
136138
CategoryUrlRewriteGenerator::ENTITY_TYPE,
137139
$storeId
138140
);
139-
if (isset($imageUrl) and !empty($imageUrl)) {
141+
if (!empty($imageUrl)) {
140142
// return placeholder
141143
$imageUrl = UrlHelper::pinchUrl(
142144
$store->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . self::PLACEHOLDER_FOLDER,

Model/Resolver/CmsPage/SocialMarkup.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ public function resolve(
9797
// add url
9898
$this->setUrl($this->retrieveUrl($value[PageInterface::IDENTIFIER], CmsPageUrlRewriteGenerator::ENTITY_TYPE, $store->getId()));
9999
// add title
100-
// TODO: fix why if not meta title is set, it returns nothing
101-
$this->setTitle($value['meta_title'] ?? $page->getTitle());
100+
$this->setTitle(!empty($value['meta_title']) ?
101+
$value['meta_title'] : $page->getTitle());
102102
// add description
103-
$this->setDescription($value['meta_description'] ?? $page->getContentHeading());
103+
$this->setDescription(!empty($value['meta_description']) ?
104+
$value['meta_description'] : $page->getContentHeading());
104105
// add image, if any
105106
$this->setImage($this->retrieveImage($page, $store));
106107

@@ -126,7 +127,7 @@ public function retrieveImage($page, $store) {
126127
CmsPageUrlRewriteGenerator::ENTITY_TYPE,
127128
$storeId
128129
);
129-
if (isset($imageUrl) and !empty($imageUrl)) {
130+
if (!empty($imageUrl)) {
130131
// return placeholder
131132
$imageUrl = UrlHelper::pinchUrl($storeUrl . self::PLACEHOLDER_FOLDER, $imageUrl);
132133
}

Model/Resolver/Product/SocialMarkup.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ public function resolve(
102102
// add url
103103
$this->setUrl($this->retrieveUrl($product->getId(), ProductUrlRewriteGenerator::ENTITY_TYPE, $store->getId()));
104104
// add title
105-
$this->setTitle($product->getMetaTitle() ?? $product->getName());
105+
$this->setTitle(!empty($product->getMetaTitle()) ?
106+
$product->getMetaTitle() : $product->getName());
106107
// add description
107-
$this->setDescription($product->getMetaDescription() ?? $product->getDescription());
108+
$this->setDescription(!empty($product->getMetaDescription()) ?
109+
$product->getMetaDescription() : $product->getDescription());
108110
// add image, if any
109111
$this->setImage($this->retrieveImage($product->getId(), $store));
110112

@@ -130,14 +132,14 @@ public function retrieveImage($productId, $store) {
130132
$product = $productFactory->getById($productId);
131133

132134
$imageUrl = $product->getImage();
133-
if (isset($imageUrl) and !empty($imageUrl)) {
135+
if (!empty($imageUrl)) {
134136
$imageUrl = UrlHelper::pinchUrl($storeUrl . 'catalog/product', $imageUrl);
135137
} else {
136138
$imageUrl = $this->socialMarkupHelper->getImagePlaceholder(
137139
ProductUrlRewriteGenerator::ENTITY_TYPE,
138140
$storeId
139141
);
140-
if (isset($imageUrl) and !empty($imageUrl)) {
142+
if (!empty($imageUrl)) {
141143
// return placeholder
142144
$imageUrl = UrlHelper::pinchUrl($storeUrl . self::PLACEHOLDER_FOLDER, $imageUrl);
143145
}

0 commit comments

Comments
 (0)