With latest release, CE 1.8.1 cookie_restriction_notice_block went to before_body_end in layout (/app/design/frontend/base/default/layout/page.xml). But users don’t realize about that notice nor that they are expected to allow cookies.

I used this code to easily unset global_cookie_notice block from before_body_end and set it in after_body_start in layout file local.xml in my theme:

    <reference name="before_body_end">
        <action method="unsetChild"><name>global_cookie_notice</name></action>    

    <reference name="after_body_start">
        <block type="page/html_cookieNotice" name="global_cookie_notice" as ="global_cookie_notice" template="page/html/cookienotice.phtml" before="-" />

However, I can’t figure out how to translate for different store views. Changing text as usual in CMS block in the admin (cookie_restriction_notice_block) for different store views didn't work for me.

How can I translate cookie_restriction_notice_block for different store views?

  • Where is the text located. Is it in cookienotice.phtml or a static block? – Sander Mangel Feb 18 '14 at 21:05
  • Text is in a static block. I created different versions per store view as usual, but text is not translated (the ALLOW button is translated via .csv). I see COOKIE_RESTRICTION_NOTICE_CMS_BLOCK_IDENTIFIER is set in cookie.php, but can't figure out how to make it work – Marc Feb 18 '14 at 22:58

in app/code/core/Mage/Page/Block/Html/CookieNotice.php:

$block = Mage::getModel('cms/block')->load($blockIdentifier, 'identifier');

Before loading the block, you should set Store ID:

$block = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load($blockIdentifier, 'identifier');

You can use your local app/code/local/Mage/Page/Block/Html/CookieNotice.php

| improve this answer | |

This block is installed by the CMS module to the default store scope in app/code/core/Mage/Cms/data/cms_setup/data-upgrade-

$content = "<p>This website requires cookies to provide all of its features. For more " .
    "information on what data is contained in the cookies, please see our " .
    "<a href=\"{{store direct_url=\"privacy-policy-cookie-restriction-mode\"}}\">Privacy Policy page</a>. " .
    "To accept cookies from this site, please click the Allow button below.</p>";

$cmsBlock = array(
    'title'         => 'Cookie restriction notice',
    'identifier'    => 'cookie_restriction_notice_block',
    'content'       => $content,
    'is_active'     => 1,
    'stores'        => 0


The translated versions you are trying to create in the admin will work as long as they are limited to the appropriate store scope.

NB: The parameters of the data load can be debugged in Mage_Cms_Model_Resource_Block::_getLoadSelect().

| improve this answer | |
  • I just tried in a clean CE 1.8.1 install, cookies restriction mode on, added a store view, translated the static block with same identifier and assigned new store view. Then, in frontend switched view and text is not translated. – Marc Feb 18 '14 at 23:53
  • Did you assign the original block to the English store? – benmarks Feb 19 '14 at 0:06
  • In this clean install i have Main Website/Main Website Store/ and two store views for Main Website Store, Default Store View and Castellano (new store view created). In static blocks, I have the default - (Title)Cookie restriction notice, (ID) cookie_restriction_notice, (Store View) Default - and the newly created - (Title)Nota Cookies, (ID) cookie_restriction_notice, (Store View) Castellano. Both are enabled, and switching store view in frontend doesn't help. i never had issues translating static blocks, also older versions worked properly if I am not wrong. – Marc Feb 19 '14 at 9:38
  • Something else is going on, because the CMS blocks are explicitly loaded based on store scope. Can you check in the cms_block_store table for the store_id value of the English version? – benmarks Feb 19 '14 at 13:12
  • thanks for your time. In this fresh install now, block_id is 2 for english version and 3 for Spanish version in cms_block_table and crossing with cms_block_store table, I get block_id 2 (EN) shown in store_id 1 and block_id 3 (ES) shown in store_id 2. – Marc Feb 19 '14 at 16:42

Something else is going on, because the CMS blocks are explicitly loaded based on store scope. Can you check in the cms_block_store table for the store_id value of the English version? – benmarks♦ Feb 19 '14 at 13:12

No, CMS blocks are not loaded explicitly on store scope. The load() methods ends in a fetchRow($select) call, that just returns the first row (see Mage_Core_Model_Resource_Db_Abstract::load()). In this case the block added from install script.

The Mage_Cms_Model_Resource_Block::_getLoadSelect() method needs a store ID set to join cms_block_store table. Without setting store ID $object->getStoreId() is NULL ...

 * Retrieve select object for load object data
 * @param string $field
 * @param mixed $value
 * @param Mage_Cms_Model_Block $object
 * @return Zend_Db_Select
protected function _getLoadSelect($field, $value, $object)
    $select = parent::_getLoadSelect($field, $value, $object);

    if ($object->getStoreId()) {
        $stores = array(
            (int) $object->getStoreId(),

            array('cbs' => $this->getTable('cms/block_store')),
            $this->getMainTable().'.block_id = cbs.block_id',
        )->where('is_active = ?', 1)
        ->where('cbs.store_id in (?) ', $stores)
        ->order('store_id DESC')

    return $select;

... a bug, that still exists :( Think https://magento.stackexchange.com/a/18380/46249 is correct ...

| improve this answer | |

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.