Magento 2 Seo title product override not workingPre populate description meta dataMagento2 - Remove Meta Keywords from all pagesrewrite block not working againBlock override in Magento2 not workingHow to override _registerJsPrice($price) function in Configurable.php Block in Magento2?Override protected function of block class in Magento 2.1.7Magento 2: Adding a new function to MagentoCatalogBlockProductViewAfter return parent::_prepareCollection() store filter not working in product collectionHow to rename the product detail tab title, and display as the last tab?Override __construct MagentoCatalogModelProduct

What happens if you do emergency landing on a US base in middle of the ocean?

Chopin: marche funèbre bar 15 impossible place

Movie where a boy is transported into the future by an alien spaceship

Why use water tanks from a retired Space Shuttle?

Did Darth Vader wear the same suit for 20+ years?

Why don't B747s start takeoffs with full throttle?

Will TSA allow me to carry a Continuous Positive Airway Pressure (CPAP) device?

Unorthodox way of solving Einstein field equations

How can I add depth to my story or how do I determine if my story already has depth?

Concise way to draw this pyramid

Could a guilty Boris Johnson be used to cancel Brexit?

Initialize an array of doubles at compile time

Responsibility for visa checking

Can The Malloreon be read without first reading The Belgariad?

Pros and cons of writing a book review?

How to decline physical affection from a child whose parents are pressuring them?

Is there a rule that prohibits us from using 2 possessives in a row?

Does any lore text explain why the planes of Acheron, Gehenna, and Carceri are the alignment they are?

Have powerful mythological heroes ever run away or been deeply afraid?

Computing the differentials in the Adams spectral sequence

What does it mean by "d-ism of Leibniz" and "dotage of Newton" in simple English?

Metal bar on DMM PCB

You've spoiled/damaged the card

Is it possible for people to live in the eye of a permanent hypercane?



Magento 2 Seo title product override not working


Pre populate description meta dataMagento2 - Remove Meta Keywords from all pagesrewrite block not working againBlock override in Magento2 not workingHow to override _registerJsPrice($price) function in Configurable.php Block in Magento2?Override protected function of block class in Magento 2.1.7Magento 2: Adding a new function to MagentoCatalogBlockProductViewAfter return parent::_prepareCollection() store filter not working in product collectionHow to rename the product detail tab title, and display as the last tab?Override __construct MagentoCatalogModelProduct






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I overrided the MagentoCatalogBlockProductView.php adding this code



protected function _prepareLayout()

parent::_prepareLayout();
$this->pageConfig->getTitle()->set($title . '- suffix');

return $this;



And added the
<preference for="MagentoCatalogBlockProductView" type="IndetachCatalogBlockProductView" />



But it's not working....










share|improve this question
























  • run di:compil command

    – magefms
    May 25 at 12:27











  • I did it, but the seo title is still the same on the product page...

    – xdev
    May 25 at 13:18


















1















I overrided the MagentoCatalogBlockProductView.php adding this code



protected function _prepareLayout()

parent::_prepareLayout();
$this->pageConfig->getTitle()->set($title . '- suffix');

return $this;



And added the
<preference for="MagentoCatalogBlockProductView" type="IndetachCatalogBlockProductView" />



But it's not working....










share|improve this question
























  • run di:compil command

    – magefms
    May 25 at 12:27











  • I did it, but the seo title is still the same on the product page...

    – xdev
    May 25 at 13:18














1












1








1








I overrided the MagentoCatalogBlockProductView.php adding this code



protected function _prepareLayout()

parent::_prepareLayout();
$this->pageConfig->getTitle()->set($title . '- suffix');

return $this;



And added the
<preference for="MagentoCatalogBlockProductView" type="IndetachCatalogBlockProductView" />



But it's not working....










share|improve this question
















I overrided the MagentoCatalogBlockProductView.php adding this code



protected function _prepareLayout()

parent::_prepareLayout();
$this->pageConfig->getTitle()->set($title . '- suffix');

return $this;



And added the
<preference for="MagentoCatalogBlockProductView" type="IndetachCatalogBlockProductView" />



But it's not working....







magento2 overrides seo title






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 26 at 5:36









Muhammad Anas

1,2233526




1,2233526










asked May 25 at 12:11









xdevxdev

717




717












  • run di:compil command

    – magefms
    May 25 at 12:27











  • I did it, but the seo title is still the same on the product page...

    – xdev
    May 25 at 13:18


















  • run di:compil command

    – magefms
    May 25 at 12:27











  • I did it, but the seo title is still the same on the product page...

    – xdev
    May 25 at 13:18

















run di:compil command

– magefms
May 25 at 12:27





run di:compil command

– magefms
May 25 at 12:27













I did it, but the seo title is still the same on the product page...

– xdev
May 25 at 13:18






I did it, but the seo title is still the same on the product page...

– xdev
May 25 at 13:18











1 Answer
1






active

oldest

votes


















0














You may try to use plug in for MagentoCatalogHelperProductView as describe below to override Product View Page SEO title.



I assume you are using a custom module named "Company_MyModule".



step 1:



Create di.xml under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/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">
<type name="MagentoCatalogHelperProductView">
<plugin name="CompanyModuleProductViewHelperData" type="CompanyMyModulePluginProductPlugin" sortOrder="10"/>
</type>
</config>


step 2:



Create ProductPlugin.php under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/ProductPlugin.php



<?php

namespace CompanyMyModulePlugin;

use MagentoCatalogHelperProductView as ProductViewHelper;
use MagentoCatalogModelProduct;
use MagentoFrameworkDataObject;
use MagentoFrameworkViewResultPage as ResultPage;
use MagentoFrameworkViewResultPage;

class ProductPlugin



public function beforeInitProductLayout(
ProductViewHelper $subject,
$resultPage,
$product,
$params
)


if ($resultPage instanceof ResultPage )
$resultPage->getConfig()->getTitle()->set('YOUR PRODUCT SEO TITLE');

return [
$resultPage,
$product,
$params
];






Step 3: Run DI compile



php bin/magento setup:di:compile


enter image description here






share|improve this answer

























  • I tried it out, the product still appears, but the seo title and the page title now is "404 error", the method to override is "preparePageMetadata" but there's no way to do that cause it's private....

    – xdev
    May 25 at 22:52












  • Please try to override initProductLayout ( not preparePageMetadata) of the class MagentoCatalogHelperProductView (as per my answer). I successfully override SEO Title by using before Plugin for public method initProductLayout. Thank you

    – Pritam Info 24
    May 26 at 10:05











  • Is your magento version 2.3? I can't override it, I did it but when I get to the product page, the product is going to load but the seo title and the page title show 404 error

    – xdev
    May 26 at 10:28












  • No. My Magento version is not 2.3 but I can test the code in M 2.3 and let to know.

    – Pritam Info 24
    May 26 at 10:35











  • My bad, it doesn't show the 404 error but the seo title still not changing...

    – xdev
    May 26 at 11:11











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276098%2fmagento-2-seo-title-product-override-not-working%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You may try to use plug in for MagentoCatalogHelperProductView as describe below to override Product View Page SEO title.



I assume you are using a custom module named "Company_MyModule".



step 1:



Create di.xml under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/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">
<type name="MagentoCatalogHelperProductView">
<plugin name="CompanyModuleProductViewHelperData" type="CompanyMyModulePluginProductPlugin" sortOrder="10"/>
</type>
</config>


step 2:



Create ProductPlugin.php under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/ProductPlugin.php



<?php

namespace CompanyMyModulePlugin;

use MagentoCatalogHelperProductView as ProductViewHelper;
use MagentoCatalogModelProduct;
use MagentoFrameworkDataObject;
use MagentoFrameworkViewResultPage as ResultPage;
use MagentoFrameworkViewResultPage;

class ProductPlugin



public function beforeInitProductLayout(
ProductViewHelper $subject,
$resultPage,
$product,
$params
)


if ($resultPage instanceof ResultPage )
$resultPage->getConfig()->getTitle()->set('YOUR PRODUCT SEO TITLE');

return [
$resultPage,
$product,
$params
];






Step 3: Run DI compile



php bin/magento setup:di:compile


enter image description here






share|improve this answer

























  • I tried it out, the product still appears, but the seo title and the page title now is "404 error", the method to override is "preparePageMetadata" but there's no way to do that cause it's private....

    – xdev
    May 25 at 22:52












  • Please try to override initProductLayout ( not preparePageMetadata) of the class MagentoCatalogHelperProductView (as per my answer). I successfully override SEO Title by using before Plugin for public method initProductLayout. Thank you

    – Pritam Info 24
    May 26 at 10:05











  • Is your magento version 2.3? I can't override it, I did it but when I get to the product page, the product is going to load but the seo title and the page title show 404 error

    – xdev
    May 26 at 10:28












  • No. My Magento version is not 2.3 but I can test the code in M 2.3 and let to know.

    – Pritam Info 24
    May 26 at 10:35











  • My bad, it doesn't show the 404 error but the seo title still not changing...

    – xdev
    May 26 at 11:11















0














You may try to use plug in for MagentoCatalogHelperProductView as describe below to override Product View Page SEO title.



I assume you are using a custom module named "Company_MyModule".



step 1:



Create di.xml under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/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">
<type name="MagentoCatalogHelperProductView">
<plugin name="CompanyModuleProductViewHelperData" type="CompanyMyModulePluginProductPlugin" sortOrder="10"/>
</type>
</config>


step 2:



Create ProductPlugin.php under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/ProductPlugin.php



<?php

namespace CompanyMyModulePlugin;

use MagentoCatalogHelperProductView as ProductViewHelper;
use MagentoCatalogModelProduct;
use MagentoFrameworkDataObject;
use MagentoFrameworkViewResultPage as ResultPage;
use MagentoFrameworkViewResultPage;

class ProductPlugin



public function beforeInitProductLayout(
ProductViewHelper $subject,
$resultPage,
$product,
$params
)


if ($resultPage instanceof ResultPage )
$resultPage->getConfig()->getTitle()->set('YOUR PRODUCT SEO TITLE');

return [
$resultPage,
$product,
$params
];






Step 3: Run DI compile



php bin/magento setup:di:compile


enter image description here






share|improve this answer

























  • I tried it out, the product still appears, but the seo title and the page title now is "404 error", the method to override is "preparePageMetadata" but there's no way to do that cause it's private....

    – xdev
    May 25 at 22:52












  • Please try to override initProductLayout ( not preparePageMetadata) of the class MagentoCatalogHelperProductView (as per my answer). I successfully override SEO Title by using before Plugin for public method initProductLayout. Thank you

    – Pritam Info 24
    May 26 at 10:05











  • Is your magento version 2.3? I can't override it, I did it but when I get to the product page, the product is going to load but the seo title and the page title show 404 error

    – xdev
    May 26 at 10:28












  • No. My Magento version is not 2.3 but I can test the code in M 2.3 and let to know.

    – Pritam Info 24
    May 26 at 10:35











  • My bad, it doesn't show the 404 error but the seo title still not changing...

    – xdev
    May 26 at 11:11













0












0








0







You may try to use plug in for MagentoCatalogHelperProductView as describe below to override Product View Page SEO title.



I assume you are using a custom module named "Company_MyModule".



step 1:



Create di.xml under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/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">
<type name="MagentoCatalogHelperProductView">
<plugin name="CompanyModuleProductViewHelperData" type="CompanyMyModulePluginProductPlugin" sortOrder="10"/>
</type>
</config>


step 2:



Create ProductPlugin.php under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/ProductPlugin.php



<?php

namespace CompanyMyModulePlugin;

use MagentoCatalogHelperProductView as ProductViewHelper;
use MagentoCatalogModelProduct;
use MagentoFrameworkDataObject;
use MagentoFrameworkViewResultPage as ResultPage;
use MagentoFrameworkViewResultPage;

class ProductPlugin



public function beforeInitProductLayout(
ProductViewHelper $subject,
$resultPage,
$product,
$params
)


if ($resultPage instanceof ResultPage )
$resultPage->getConfig()->getTitle()->set('YOUR PRODUCT SEO TITLE');

return [
$resultPage,
$product,
$params
];






Step 3: Run DI compile



php bin/magento setup:di:compile


enter image description here






share|improve this answer















You may try to use plug in for MagentoCatalogHelperProductView as describe below to override Product View Page SEO title.



I assume you are using a custom module named "Company_MyModule".



step 1:



Create di.xml under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend/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">
<type name="MagentoCatalogHelperProductView">
<plugin name="CompanyModuleProductViewHelperData" type="CompanyMyModulePluginProductPlugin" sortOrder="10"/>
</type>
</config>


step 2:



Create ProductPlugin.php under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/



File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Plugin/ProductPlugin.php



<?php

namespace CompanyMyModulePlugin;

use MagentoCatalogHelperProductView as ProductViewHelper;
use MagentoCatalogModelProduct;
use MagentoFrameworkDataObject;
use MagentoFrameworkViewResultPage as ResultPage;
use MagentoFrameworkViewResultPage;

class ProductPlugin



public function beforeInitProductLayout(
ProductViewHelper $subject,
$resultPage,
$product,
$params
)


if ($resultPage instanceof ResultPage )
$resultPage->getConfig()->getTitle()->set('YOUR PRODUCT SEO TITLE');

return [
$resultPage,
$product,
$params
];






Step 3: Run DI compile



php bin/magento setup:di:compile


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited May 26 at 10:05

























answered May 25 at 20:43









Pritam Info 24Pritam Info 24

1,092127




1,092127












  • I tried it out, the product still appears, but the seo title and the page title now is "404 error", the method to override is "preparePageMetadata" but there's no way to do that cause it's private....

    – xdev
    May 25 at 22:52












  • Please try to override initProductLayout ( not preparePageMetadata) of the class MagentoCatalogHelperProductView (as per my answer). I successfully override SEO Title by using before Plugin for public method initProductLayout. Thank you

    – Pritam Info 24
    May 26 at 10:05











  • Is your magento version 2.3? I can't override it, I did it but when I get to the product page, the product is going to load but the seo title and the page title show 404 error

    – xdev
    May 26 at 10:28












  • No. My Magento version is not 2.3 but I can test the code in M 2.3 and let to know.

    – Pritam Info 24
    May 26 at 10:35











  • My bad, it doesn't show the 404 error but the seo title still not changing...

    – xdev
    May 26 at 11:11

















  • I tried it out, the product still appears, but the seo title and the page title now is "404 error", the method to override is "preparePageMetadata" but there's no way to do that cause it's private....

    – xdev
    May 25 at 22:52












  • Please try to override initProductLayout ( not preparePageMetadata) of the class MagentoCatalogHelperProductView (as per my answer). I successfully override SEO Title by using before Plugin for public method initProductLayout. Thank you

    – Pritam Info 24
    May 26 at 10:05











  • Is your magento version 2.3? I can't override it, I did it but when I get to the product page, the product is going to load but the seo title and the page title show 404 error

    – xdev
    May 26 at 10:28












  • No. My Magento version is not 2.3 but I can test the code in M 2.3 and let to know.

    – Pritam Info 24
    May 26 at 10:35











  • My bad, it doesn't show the 404 error but the seo title still not changing...

    – xdev
    May 26 at 11:11
















I tried it out, the product still appears, but the seo title and the page title now is "404 error", the method to override is "preparePageMetadata" but there's no way to do that cause it's private....

– xdev
May 25 at 22:52






I tried it out, the product still appears, but the seo title and the page title now is "404 error", the method to override is "preparePageMetadata" but there's no way to do that cause it's private....

– xdev
May 25 at 22:52














Please try to override initProductLayout ( not preparePageMetadata) of the class MagentoCatalogHelperProductView (as per my answer). I successfully override SEO Title by using before Plugin for public method initProductLayout. Thank you

– Pritam Info 24
May 26 at 10:05





Please try to override initProductLayout ( not preparePageMetadata) of the class MagentoCatalogHelperProductView (as per my answer). I successfully override SEO Title by using before Plugin for public method initProductLayout. Thank you

– Pritam Info 24
May 26 at 10:05













Is your magento version 2.3? I can't override it, I did it but when I get to the product page, the product is going to load but the seo title and the page title show 404 error

– xdev
May 26 at 10:28






Is your magento version 2.3? I can't override it, I did it but when I get to the product page, the product is going to load but the seo title and the page title show 404 error

– xdev
May 26 at 10:28














No. My Magento version is not 2.3 but I can test the code in M 2.3 and let to know.

– Pritam Info 24
May 26 at 10:35





No. My Magento version is not 2.3 but I can test the code in M 2.3 and let to know.

– Pritam Info 24
May 26 at 10:35













My bad, it doesn't show the 404 error but the seo title still not changing...

– xdev
May 26 at 11:11





My bad, it doesn't show the 404 error but the seo title still not changing...

– xdev
May 26 at 11:11

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276098%2fmagento-2-seo-title-product-override-not-working%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form