0

I am a database guy and I am asked to find how to remove breadcrumb category text from product title in the products detail page of a Magento 2 website.

I don't know where the files reside to modify this behavior, I think the ultimo theme is being used.

Any help would be appreciated to remove the category suffix from product title

Thanks in advance!

t n

  • 1
    this is not the default behavior. someone actually put effort into displaying this. Can you ask a person that worked on this project previously? – Philipp Sander Jan 13 at 16:25
  • that person is gone. This has something to do with breadcrumbs, this only shows when breadcrumbs are there – Sharoz Khalid Jan 13 at 17:04
0

hey below file is responsible to show title :

/app/design/frontend/Custom/Theme/Magento_Theme/templates/html/title.phtml (Overide this file in your theme)

please check this file in your theme (replace Custom/Theme with your theme name)

else we can achieve this by overide the Block Magento\Theme\Block\Html\Title

Create a module :

/app/code/Custom/module/etc/di.xml

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Theme\Block\Html\Title" type="Custom\Module\Block\Html\Title" /> </config>

/app/code/Custom/Module/Block/Html/Title.php

<?php
namespace Custom\Module\Block\Html;

use Magento\Framework\View\Element\Template;

class Title extends Template
{

    protected $pageTitle;

    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
        \Magento\Framework\Registry $registry
    )
    {
        parent::__construct($context);
        $this->registry = $registry;    
    }

    public function getCurrentProduct()
    {      
        if($this->registry->registry('current_product')) {
            return $this->registry->registry('current_product');
        }
        return false;        
    }
}

/app/design/frontend/Custom/Theme/Magento_Theme/templates/html/title.phtml

<?php
$prodcut = $block->getCurrentProduct();
$cssClass = $block->getCssClass() ? ' ' . $block->getCssClass() : '';
$title = '';
if (trim($block->getPageHeading())) {
    if($prodcut){ 
    $title = '<span class="base" data-ui-id="page-title-wrapper" ' .  $block->getAddBaseAttribute() . '>'
        . 'SOMETEXT '.$block->escapeHtml($block->getPageHeading()) . '</span>';
    }else{
    $title = '<span class="base" data-ui-id="page-title-wrapper" ' .  $block->getAddBaseAttribute() . '>'
        . $block->escapeHtml($block->getPageHeading()) . '</span>';
    }
}
?>
<?php if ($title): ?>
<div class="page-title-wrapper<?= /* @escapeNotVerified */ $cssClass ?>">
    <h1 class="page-title"
        <?php if ($block->getId()): ?> id="<?= /* @escapeNotVerified */ $block->getId() ?>" <?php endif; ?>
        <?php if ($block->getAddBaseAttributeAria()): ?>
            aria-labelledby="<?= /* @escapeNotVerified */ $block->getAddBaseAttributeAria() ?>"
        <?php endif; ?>>
        <?= /* @escapeNotVerified */ $title ?>
    </h1>
    <?= $block->getChildHtml() ?>
</div>
<?php endif; ?>

With $product variable we can add condition to check product page.

| improve this answer | |
  • Thanks for quick response, i could only find gtm_body.phtml and gtm_head.phtml under /srv/public_html/app/design/frontend/Bixlers/enhanced/Magento_Theme/templates/html – Sharoz Khalid Jan 13 at 16:42
  • ans updated please review – Saif Ali Rehman Jan 13 at 16:48
  • can u connect on linkedIn ? i have sent a connection request – Sharoz Khalid Jan 13 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.