Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

I have a scenario where i need to be able to select magento stores like this from the system configuration section . Store view

Thanks in advance for any kind of help.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

This goes in the system.xml under the fields tag.

<field_name_here translate="title" module="[module]">
    <label>Label goes here</label>
    <frontend_type>multiselect</frontend_type>
    <source_model>[module]/store</source_model>
    <sort_order>10</sort_order> <!-- feel free to change this value -->
    <show_in_default>1</show_in_default><!-- can be 0 or 1 -->
    <show_in_website>0</show_in_website><!-- can be 0 or 1 -->
    <show_in_store>0</show_in_store><!-- can be 0 or 1 -->
</field_name_here>

Then create the source model.
For that you need a class inside your module.

app/code/[codebool]/[Namespace]/[Module]/Model/Store.php with this code:

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

Replace in the code above the values between [] with the appropriate values and you are done.

share|improve this answer
    
Thanks a lot, it works like a charm. Thanks again. –  Saddam Aug 25 at 8:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.