1

i am trying to add a static block of text to the short description of the product page. i have tried the short code and a couple of other methods. i am able to get the static block to work on a regular cms page but when i try to add it to the short description area it doesn't work.

i have tried the following but not sure i have the right reference name for the short description, product.info might be for a different section then the short description.

enter image description here

3

What you have tried is using layout XML and it does not look like it's really related to the short description. The code would add the static block as child block to "product.info", so dependent on the theme probably on the top of the content. If this is what you want, you can add this code to the "Custom Layout Update" attribute:

screenshot

If that works for you, stop reading now. Otherwise, see below for a solution to actually add static blocks within the short description:

General answer

The product attributes are not parsed by the template processor that is used on CMS pages and in emails. But you can change this with a small custom module that uses the catalog_product_controller_view event where you can modifiy the product attributes before they are displayed.

Observer code

I assume you know how to create a module and register an observer. If not, there are plenty tutorials.

class IntegerNet_WidgetsEverywhere_Model_Observer
{
    /**
     * Apply CMS filter on wysiwyg product attributes to parse widgets
     *
     * @event catalog_controller_product_view
     * @param Varien_Event_Observer $observer
     */
    public function filterProductWysiwygAttributes(Varien_Event_Observer $observer)
    {
        $product = $observer->getProduct();
        $attributeCodes = ['description', 'short_description'];
        foreach ($attributeCodes as $_code) {
            $unfilteredAttributeValue = $product->getData($_code);
            if (!empty($unfilteredAttributeValue)) {
                $filteredAttributevalue = $this->_getTemplateProcessor()->filter($unfilteredAttributeValue);
                $product->setData($_code, $filteredAttributevalue);
            }
        }
    }

    /**
     * @return Varien_Filter_Template
     */
    protected function _getTemplateProcessor()
    {
        return Mage::helper('cms')->getPageTemplateProcessor();
    }
}

This processes the attributes 'description' and 'short_description' with the template processor and thus replaces the {{block}} directive with the actual block.

It is a simplified version of the observer in my "WidgetsEverywhere" module. Check https://github.com/integer-net/ to see if I already open sourced it.

CMS Syntax

This is how you use the CMS syntax to insert the block:

{{block type="cms/block" name="rt_sale" block_id="rt_sale"}}
  • the 1st example i have used on CMS pages to add content to the LEFT nav with success. When i plug that code in the products, custom layout update field it doesn't work. However I wonder if i just need to change the Reference name. I am a bit unclear on what reference names are but assumed like on my CMS pages where I was able to Reference: left to plug something into the left nav that Reference: product.info maybe was the name of the Short Description. Is there a way to find out the Reference name for "Short description" section on the product page? – David Billinghurst Nov 29 '15 at 21:20
  • and... I do not know how to ..."I assume you know how to create a module and register an observer. If not, there are plenty tutorials." so i may be in over my head :) – David Billinghurst Nov 29 '15 at 21:21
1

Hey i used a different method that gave me the result i wanted. i created a widget for PROMO CODE SALE NOTICE see image below, then i attached the static block to the widget

This gave me the ability to choose a list of products to apply this "SALE ALERT" text to and the option of "product extra info" plugged the static block in the short description.

enter image description here

enter image description here

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.