I have CMS static block and I must show in this block individual product name.
When I am going to product page I want show name this product in a static block.
How to do this?
-
Means You want to set current product name in cms block, and that cms block call in all product pageMurtuza Zabuawala– Murtuza Zabuawala ♦2016年12月27日 09:52:53 +00:00Commented Dec 27, 2016 at 9:52
-
yes, exactly...Miuzik– Miuzik2016年12月27日 10:20:15 +00:00Commented Dec 27, 2016 at 10:20
-
check my answer and let me knowMurtuza Zabuawala– Murtuza Zabuawala ♦2016年12月27日 11:53:04 +00:00Commented Dec 27, 2016 at 11:53
2 Answers 2
in your cms block add below code
{{block type='core/template' template='YourtemplatePath/yourTemplate.phtml'}}
And in your folder create file
yourMagentoRoot/app/design/frontend/YourPackage/YourTheme/template/YourtemplatePath/yourTemplate.phtml
and add below code in yourTemplate.phtml file
<?php
echo Mage::registry('current_product')->getName();
?>
I can't find a way to directly inject a variable to the CMS,
but you could for instance insert a custom variable to the block like {{product_name}} , then get the block in product page:
$html = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('block_id')->toHtml();
and then inject your product name:
echo str_replace("{{product_name}}",$product->getName(),$html);