cancel
Showing results for 
Search instead for 
Did you mean: 

How cms_page select data from core_store?

How cms_page select data from core_store?

In admin panel on the CMS-Pages I see all available pages assign to websites with it names, but I can't understand how they select it from core_store.

There is, in core Cms module, Page model (with Resource and Collection) where selected data from cms_page table, but I can't find in which point cms_page joined with core_store, speaking MySQL language.

5 REPLIES

Re: How cms_page select data from core_store?

There are 2 tables for COmmunity Edition for CMS Pages: cms_page and cms_page_store and the second one have relation to the store.

 

Thanks

Re: How cms_page select data from core_store?

I understand but I can't understand how happend that in result we recieve such result. I don't see joining this tables and fetching data from them.

 

Should be something like this

 

select * from cms_page join cms_page_store 

 

with some parameters. 

 

But there is some magic in this case.

Re: How cms_page select data from core_store?

Not really sure what exactly you want to know. The link between cms_page and cms_page_store tables is implemented in

1. Page resource model (Mage_Cms_Model_Resource_Page) in methods _beforeDelete, _afterSave, _getLoadSelect and few others.

2. Page collection (Mage_Cms_Model_Resource_Page_Collection) in method _afterLoad

 

When you visit CMS-Pages in admin, page grid loads page collection together with store IDs where this page is assigned to. And then this grid asks Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Store to render HTML for column "Store" for each row. As you can see in its method render, it calls Mage_Adminhtml_Model_System_Store::getStoresStructure() method to get information about stores by their IDs.

 

So in the case of CMS-Pages page there is no SQL join between cms_page and core_store tables in the PHP code, it is all being selected separately during rendering. Which actually often causes errors when people delete the store which has at least one assigned page and then are unable to edit this page because of the fatal error.


ET Web Solutions
extensions, custom work, support

Re: How cms_page select data from core_store?

Thanks.

 

So if I want implements this on my page, I should inherit some Models or something else?

Re: How cms_page select data from core_store?

It depends on where you want to use this information. If you have a grid and want to add a column with stores, you can use

 

if (!Mage::app()->isSingleStoreMode()) {
    $this->addColumn('store_id', array(
        'header'        => Mage::helper('cms')->__('Store View'),
        'index'         => 'store_id',
        'type'          => 'store',
        'store_all'     => true,
        'store_view'    => true,
        'sortable'      => false,
    ));
}

 

But if you need to use that somewhere else, then it really depends on the task. The question is too abstract. Unless you describe your situation in more detail, I won't be able to help you.


ET Web Solutions
extensions, custom work, support