0

I'm working on a module where I need to save the records based on the scope of website and store. For that I need to have the select box as its in the system->configuration.

website configuration scope - magento

How can I get that select box in my form and save the website/store value in database so that it can be displayed in the specific store/website? Any suggestions on it?

Now I'm trying it breaking into two fields -> website and store. Now, how can I change the options in store based on the website selected?

2

Finally, I'd written my own code for this.

    $scope = array('default' => 'default');
    foreach (Mage::app()->getWebsites() as $website) {
        $scope['website_' . $website->getCode()] = $website->getName();
        foreach ($website->getGroups() as $group) {
            $stores = array();
            foreach ($group->getStores() as $store) {
                $stores[] = array(
                    'label' => $store->getName(),
                    'value' => 'store_' . $store->getCode()
                );
            }
            $scope[] = array(
                'label' => $website->getName(),
                'value' => $stores
            );
        }
    }
    $fieldset->addField('website', 'select', array(
        'label' => Mage::helper('designer')->__('Website'),
        'name' => 'website',
        'values' => $scope
    ));

Thanks to this post by Marius

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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