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

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

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?