Skip to content

Commit 3d6eaf4

Browse files
author
Aasim Goriya
committed
Meta title issue fixed for product page
1 parent 0a834cc commit 3d6eaf4

File tree

1 file changed

+18
-1
lines changed
  • app/code/Magento/Catalog/Helper/Product

1 file changed

+18
-1
lines changed

app/code/Magento/Catalog/Helper/Product/View.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ private function preparePageMetadata(ResultPage $resultPage, $product)
118118
$pageConfig = $resultPage->getConfig();
119119

120120
$metaTitle = $product->getMetaTitle();
121-
$pageConfig->setMetaTitle($metaTitle);
121+
$productMetaTitle = $metaTitle ? $this->addConfigValues($metaTitle) : null;
122+
$pageConfig->setMetaTitle($productMetaTitle);
122123
$pageConfig->getTitle()->set($metaTitle ?: $product->getName());
123124

124125
$keyword = $product->getMetaKeyword();
@@ -294,4 +295,20 @@ public function prepareAndRender(ResultPage $resultPage, $productId, $controller
294295
$this->preparePageMetadata($resultPage, $product);
295296
return $this;
296297
}
298+
299+
/**
300+
* @param string $title
301+
* @return string
302+
*/
303+
private function addConfigValues($title)
304+
{
305+
$preparedTitle = $this->scopeConfig->getValue(
306+
'design/head/title_prefix',
307+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
308+
) . ' ' . $title . ' ' . $this->scopeConfig->getValue(
309+
'design/head/title_suffix',
310+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
311+
);
312+
return trim($preparedTitle);
313+
}
297314
}

0 commit comments

Comments
 (0)