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?

  • Means You want to set current product name in cms block, and that cms block call in all product page – Murtuza Zabuawala Dec 27 '16 at 9:52
  • yes, exactly... – Miuzik Dec 27 '16 at 10:20
  • check my answer and let me know – Murtuza Zabuawala Dec 27 '16 at 11:53
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, privacy policy and cookie policy

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