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?

Chirag Prajapati
2,9522 gold badges20 silver badges44 bronze badges
asked Dec 27, 2016 at 9:47
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... 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();
 ?> 
answered Dec 27, 2016 at 10:28
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);
answered Dec 27, 2016 at 10:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.