Magento Version: (Enterprise)

Background / Problem

Using the following as a guide, I successfully created a module that adds custom form fields (fb_og_image and fb_og_video) to CMS pages (revisions on) and adds columns to two database tables (cms_page and enterprise_cms_page_revision).

In the module's Observer, I successfully added the two fields.

public function cmsFields(Varien_Event_Observer $observer)
        // per https://www.atwix.com/magento/adding-custom-attribute-to-a-cms-page/
        // get CMS model with data
        $model = Mage::registry('cms_page');

        // get form instance
        $form = $observer->getForm();

        // apply new fields to 'Meta Data' CMS tab
        $fieldset = $form->getElement('meta_fieldset');

        // create new custom fields `fb_og_image` and `fb_og_video`
        $fieldset->addField('fb_og_image', 'text', array(
            'name'     => 'fb_og_image',
            'label'    => Mage::helper('cms')->__('Facebook Image (og:image)'),
            'title'    => Mage::helper('cms')->__('Facebook Image (og:image)'),
            'disabled' => false
        $fieldset->addField('fb_og_video', 'text', array(
            'name'     => 'fb_og_video',
            'label'    => Mage::helper('cms')->__('Facebook Video (og:video)'),
            'title'    => Mage::helper('cms')->__('Facebook Video (og:video)'),
            'disabled' => false

I also updated $_revisionControlledAttributes to make sure revision happens on those two fields.

class ST_Social_Model_Config extends Enterprise_Cms_Model_Config
    protected $_revisionControlledAttributes = array_merge(
        array('fb_og_image', 'fb_og_video'),
        $this->_revisionControlledAttributes  // parent attributes

When entering values in the two fields, they persist on save/publish. However, this is where the strangeness happens. Here are the relevant queries in the database:

mysql> select page_id, identifier, update_time, is_active, published_revision_id, under_version_control, fb_og_image, fb_og_video from cms_page where identifier = 'our-vision';
| page_id | identifier | update_time         | is_active | published_revision_id | under_version_control | fb_og_image | fb_og_video |
|      13 | our-vision | 2017-03-03 16:40:54 |         1 |                  3483 |                     1 | NULL        | NULL        |
1 row in set (0.01 sec)

mysql> select revision_id, version_id, page_id, revision_number, fb_og_image, fb_og_video from enterprise_cms_page_revision where revision_id = 3483;
| revision_id | version_id | page_id | revision_number | fb_og_image  | fb_og_video  |
|        3483 |         12 |      13 |              15 | imagecmstest | videocmstest |
1 row in set (0.01 sec)

Notice that the two custom field values are set in the enterprise_cms_page_revision database table. However, the two custom field values are missing the same data in the cms_page database table.

When I use var_dump('<pre>', Mage::getSingleton('cms/page')); die; in my Block, the custom fields are pulling from the cms_page database table (which do not have the necessary data).

Questions (finally!)

  1. How do I make sure to get the data from the latest revision (found in the enterprise_cms_page_revision table)? Should I use a different singleton or a different class/method altogether?
  2. Is there a reason that the custom cms_page database table columns don't get set as they do in the enterprise_cms_page_revision?

Please don't tell me to ask Magento for support. I have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.