$isCategoryPage = $block->getRequest()->getFullActionName() === 'catalog_category_view';
if ($isCategoryPage) {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$currentCategory = $objectManager->get(\Magento\Framework\Registry::class)->registry('current_category');
if ($currentCategory) {
$catName = trim((string)$currentCategory->getName());
$titleHtml = $catName;
$parentCategory = $currentCategory->getParentCategory();
if ($parentCategory && $parentCategory->getId() > 2) {
$parentName = trim((string)$parentCategory->getName());
$genericNames = ['rings', 'pendants', 'earrings', 'bracelets', 'necklaces', 'bands', 'chains'];
if (in_array(strtolower($catName), $genericNames)) {
$prefix = str_ireplace('Diamonds', 'Diamond', $parentName);
$prefix = str_ireplace('™', '', $prefix);
$titleHtml = $prefix . ' ' . $catName;
}
}
$titleHtml = ucfirst(strtolower($titleHtml));
$titleHtml = preg_replace('/\bargyle\b/i', 'Argyle', $titleHtml);
$titleHtml = preg_replace('/\bsouth\b/i', 'South', $titleHtml);
}
}
?>
Sale