enter image description here

i want to remove the search result commas see the image when magento returns sprite it in the commas and i want to remove this commas. how to achieve this am not sure if it possible with custom module or custom theme please guide me

  • You mean the single quotes around sprite?
    – aravind
    Feb 12 '20 at 9:37
  • vendor/magento/module-catalog-search/Block/Result.php - please check with this file.. line number - 195. Feb 12 '20 at 9:37
  • but how to remove that comma i have already found this file
    – Pramod
    Feb 12 '20 at 9:41
  • yes this is exactly what i want
    – Pramod
    Feb 12 '20 at 10:16

You need to add after Plugin for this method getSearchQueryText in


 public function getSearchQueryText()
        return __("Search results for: '%1'", $this->catalogSearchData->getEscapedQueryText());

to do this you need to add a plugin declaration in your module


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\CatalogSearch\Block\Result">
        <plugin name="search_result_page_title_plugin" type="Vendor\Module\Plugin\Result" sortOrder="1" disabled="false"/>

and create Result Plugin class to remove commas


namespace Vendor\Module\Plugin;
class Result{
    protected $catalogSearchData;
    public function __construct(
        \Magento\CatalogSearch\Helper\Data $catalogSearchData
    ) {
        $this->catalogSearchData = $catalogSearchData;
    public function afterGetSearchQueryText(\Magento\CatalogSearch\Block\Result $subject, $phrase){
        return __("Search results for: %1", $this->catalogSearchData->getEscapedQueryText()); // any text here will replace the original title

That's it.

  • can you explain that result.php more in deatil
    – Pramod
    Feb 12 '20 at 10:10
  • Plugins is intended to override the core function of Magento, you can use before, after and around. so we used after plugin to override the output of the main function and return our desired phrase. you can read more about plugins here devdocs.magento.com/guides/v2.3/extension-dev-guide/…
    – Ahmed Atef
    Feb 12 '20 at 10:12
  • this is not working though
    – Pramod
    Feb 12 '20 at 10:25
  • Sorry, i added the wrong class in di.xml file. please check the edited answer
    – Ahmed Atef
    Feb 12 '20 at 10:43
  • do i have to create block file also
    – Pramod
    Feb 12 '20 at 10:47

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.