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".
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
- In the short description i add the following text : This product can be shipped to your country "widget-seo-word-country" !.
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 !
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
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
-
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– Marcwales2023年08月08日 15:11:34 +00:00Commented Aug 8, 2023 at 15:11
-
"size-clamp" will replace the {} then echo the description text.MP Raj– MP Raj2023年08月09日 04:57:19 +00:00Commented Aug 9, 2023 at 4:57