1

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?

3
  • Means You want to set current product name in cms block, and that cms block call in all product page Commented Dec 27, 2016 at 9:52
  • yes, exactly...
    – Miuzik
    Commented Dec 27, 2016 at 10:20
  • check my answer and let me know Commented Dec 27, 2016 at 11:53

2 Answers 2

1

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();
 ?> 
0

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);

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.