I have simple question about custom layout update. I would like to add static block on product page using Product custom layout update but it doesn't work for me.

I've tried to use this code:

<reference name="product.info">
   <block type="cms/block" name="slider" as="slider" before="-">
      <action method="setBlockId">

2 Answers 2


Well it's because by default the template does not render all its child blocks.

To fix that you need to edit the app/design/frontend/<your_package>/<your_theme>/template/catalog/product/view.phtml file and add the following line where you want your custom block to be displayed:

<?php echo $this->getChildHtml('slider') ?>
  • okay, understood. But, do we have some other way for it? because I would like to use 5-6 different static blocks for different products? How can I show block without getChildHtml?
    – Oleg
    Jun 2, 2016 at 8:44
  • @Oleg Unfortunately that's the only way I'm aware of. Jun 2, 2016 at 8:57
  • 1
    thank you. In this case I guess I have to play with attributes
    – Oleg
    Jun 2, 2016 at 8:58
  • 2
    @Oleg What you can do, is call getChildHtml() without parameters, it will render all children Jun 3, 2016 at 6:29
  • @fschmengler I wanted to post that as well but I ended up not doing it in case other modules were adding blocks to this block and the corresponding getChildHtml('blockname') was not here ;) Jun 3, 2016 at 6:31

Other way that you can try is as below :

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('your_static_block_id')->toHtml(); ?>

Place this code directly in your phtml file where you want to show the static block on the frontend.
If you want different blocks for different products, you can create the static blocks based on the sku.
Suppose there are two products Product A with sku SA and Product B with sku SB, now create two static blocks with ids SA and SB respectively now call them on the catalog/product/view.phtml in your theme using below code.

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId($_product->getSku())->toHtml(); ?>

Other way that you can try is add update handle, you can refer the https://stackoverflow.com/questions/4735522/magento-template-based-on-attribute-set

  • no, it's not what i asked. I need to show different static blocks for different products
    – Oleg
    Jun 2, 2016 at 8:57
  • You can create the static blocks based on the product sku and on the product template file you can pass the sku as the dynamic variable as the block id, if you are creating different blocks for different products. Jun 2, 2016 at 9:01

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.