简体   繁体   中英

Get store id for each CMS page in Magento

We're extending a custom extension of ours and in a form in the admin page, we're using the store view selector. Once the store is selected, we need to construct a list of the CMS pages for that store.

In order to filter the list of CMS pages based on the selected store, we're trying to insert some javascript to change the pages dropdown as per the selected store and subsequently we need to know what store id, each page belongs to on a per page basis.

Is there an easy way of achieving this? Can't post anything we've tried already as we've literally not managed to come up with anything that doesn't already require the form to be saved so we can get the selection.

Thanks in advance for any assistance.

Not sure about the Javascript part since I am not sure what have written.

If you want to get the store id for a page - you can grab the page using its ID and check the array of store ids for a match. In the case below, $page['store_id'] is an array and can contain multiple store ids. Hope that helps.

$pageId = 12;
$page = Mage::getModel('cms/page')->load($pageId);
$page_StoreIds = $page['store_id']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM