While developing an extension recently I came across the need to add the ability to allow changes on a store view level.
To start off with I wanted to make sure this functioned the same as the built store view selection, to make it easy on the end user (take a look at how store view is handled with CMS Page creation to see what I’m referring to). However, by default Magento keeps its store view information in seperate tables (ie CMS_PAGE_STORE), which wasn’t ideal for this scenerio. The solution I came up with involves using one field ‘store_id’ in your modules table to save the Store ID’s as comma seperated values.
In your module’s adminhtml edit/create form (<Namespace>_<Module>_Block_Adminhtml_<Model>_Edit_Tab_Form add the following in the _prepareForm function where you would like the store selection to show up:
(This adds the store view multiselect to your form if you have multiple stores setup, if not it adds a hidden field with the current stores id taking into consideration the posibility of more stores being added in the future.)
Next in your module’s Controller file(<Namespace>_<Module>_Adminhtml_Controller) add the following to your saveAction: