Jose Eduardo Jose Eduardo - 4 months ago 21
PHP Question

Create Store_view check box on the grid - Magento

I noticed that the Product Catalog, there is an equal housing image to select the store view, it would be very useful in my case, however I do not find how to add this in my GRID.

Store Choose

Could you tell me how to do this?
Thank you

@EDIT
enter image description here

Just trying to be clearer, when used multistore in catalog_product page is shown a drop down box with all the store, I need to do the same, but on a custom page of my module.

Answer Source

From what I understood you want the drop down box to show the list of all stores. Then you need the source model of adminhtml/system_config_source_store

This is what you need and/or what you could do. Create a system.xml in the module you created. Add a field to it something like this.

<store_select translate="label comment">
    <label>Select Store</label>
    <frontend_type>Select</frontend_type>
    <source_model>adminhtml/system_config_source_store</backend_model>
    <sort_order>20</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</store_select>

The other options is to create your own source model

class [Namespace]_[Module]_Model_Store {
   public function toOptionArray() {
       return Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true);
   }
}

And then replace the source model path of the system.xml with the one you just created.

EDIT:

My Github

Checkout the commits with message "091115 : Admin Controller Base". Again this is just the base where you could start. You still need to implement the logic for the select to work.