Cms page (or static block) inside product description
-
16-10-2019 - |
Question
I need to add some static content inside the product description.
I have a store where I bulk add all my products via CSV import and many of them share common HTML code in the description field, for example, the model description.
Let's say that I have 500 products model XYZ and the XYZ description is
<h1>XYZ</h1>
<p>The next generation of XY<p>
is there a way to create this as a cms page (or static block) and insert it in the description of the products?
I could have it done editing the layout of the product page, but I want it in the description so I can easily sync it with eBay and other markets.
Thank you
Solution
Although I don't recommend it because this may lead to performance issues (more time needed for processing the product description), I wrote a tutorial on how to do this. You can find it here.
It worked for me for products and categories without a problem.
The main idea is to process the product description (or any other attribute) just like the content of a CMS page or a CMS block is processed before returning the content. I mean It should be able to support directives like {{block type="..."}}
, {{store url=""}}
, {{skin}}
and others.
OTHER TIPS
From any CMS field in Magento you should be able to refer to a static block - you can even refer to it programmatically:
Adding Static and non-static blocks directly to templates:
<?php echo $this->getLayout()
->createBlock('cms/block')
->setBlockId('your_block_id')->toHtml(); ?>
Short code inside another block or cms page :
{{block type="cms/block" block_id="your_block_id"}}
Some more reading:
http://bradfrostweb.com/blog/web/magento-static-blocks/
Source: https://stackoverflow.com/questions/8007555/how-to-add-a-cms-static-block-to-all-pages-in-magento