1

I'm looking to have dynamic text that changes based on the store view and the product for seo reason. Below i've used a simple exemple of a dynamic country name :

1 - On the attribut configuration page :

  • Create text attribut called "seo-word-country".

side attribut

2 - On the product configuration page :

  • On store-view "Belgium", i add the word "Belgium" in the attribut text field.
  • On store-view "Germany" this would be "Germany"...etc

side product

  • In the short description i add the following text : This product can be shipped to your country "widget-seo-word-country" !.

side description

3 - On the front-end product page :

  • The client and Google crawlers sees the following text on the belgium site : this product can be shipped to your country Belgium !

side frontend

The idear is to have only one default text in short and long description tab which changes on the front-end based on the store-view and the product page.

Big thanks in advance for your help.

Regards, Marc

1 Answer 1

0

Here alternative solution for this

  Add desciption in admin like below format

 

"This clamp has an exterior size {} for clamping on the tube"

{} will replace in frontend.

 //Get product desciption in frontend 
  $description =  $_product->getDescription();


  //Get product attribute in frontend
  $size_clamp = $_product->getResource()->getAttribute('size_clamp')->getFrontend()->getValue($_product);
  // Assume it will retrun 27mm

  $updatedDesciption = str_replace('{}', $size_clamp, $description);
  echo  $updatedDesciption
// output   This clamp has an exterior size 27mm for clamping on the tube
 
2
  • Hi mp raj, thank you for your return. That is a great solution, it's like a variable ? Can just echo the "size-clamp" attribut and then in the text have {size-clamp} ? Or do i need to echo the entire text ?
    – Marcwales
    Commented Aug 8, 2023 at 15:11
  • "size-clamp" will replace the {} then echo the description text.
    – MP Raj
    Commented Aug 9, 2023 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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