Jump to content

Retrieve configuration values in module


Vkt0r S.

Recommended Posts

Hello,
 
I have developed a new module in which I can see all the products in Homepage with pagination and I have coded the settings for the Admin-Panel in the following way :

 

public function displayForm() {
        // Get default language
        $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');

        // Init Fields form array
        $fields_form[0]['form'] = array(
            'legend' => array(
                'title' => $this->l('Settings'),
            ),
            'input' => array(
                array(
                    'type' => 'radio',
                    'label' => $this->l('Sort'),
                    'name' => 'FULL_PRODUCTS_SORT',
                    'values' => array(
                        array(
                            'id' => 'name',
                            'value' => 1,
                            'label' => $this->l('By name')
                        ),
                        array(
                            'id' => 'adddate',
                            'value' => 0,
                            'label' => $this->l('By add date')
                        ),
                        array(
                            'id' => 'price',
                            'value' => 2,
                            'label' => $this->l('By price')
                        ),
                        array(
                            'id' => 'modified_date',
                            'value' => 3,
                            'label' => $this->l('By modified date')
                        ),
                        array(
                            'id' => 'manufacturer',
                            'value' => 4,
                            'label' => $this->l('By manufacturer')
                        ),
                        array(
                            'id' => 'quantity',
                            'value' => 5,
                            'label' => $this->l('By quantity')
                        ),
                        array(
                            'id' => 'manufacturer',
                            'value' => 6,
                            'label' => $this->l('By reference')
                        ),
                    )
                ),
                array(
                    'type' => 'radio',
                    'label' => $this->l('Sort order'),
                    'name' => 'FULL_PRODUCTS_SORT_WAY',
                    'values' => array(
                        array(
                            'id' => 'name',
                            'value' => 1,
                            'label' => $this->l('Descending')
                        ),
                        array(
                            'id' => 'position',
                            'value' => 0,
                            'label' => $this->l('Ascending')
                        ),
                    )
                ),
            ),
            'submit' => array(
                'title' => $this->l('Save'),
                'class' => 'button'
            )
        );

        $helper = new HelperForm();

        // Module, token and currentIndex
        $helper->module = $this;
        $helper->name_controller = $this->name;
        $helper->token = Tools::getAdminTokenLite('AdminModules');
        $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;

        // Language
        $helper->default_form_language = $default_lang;
        $helper->allow_employee_form_lang = $default_lang;

        // Title and toolbar
        $helper->title = $this->displayName;
        $helper->show_toolbar = true;        // false -> remove toolbar
        $helper->toolbar_scroll = true;      // yes - > Toolbar is always visible on the top of the screen.
        $helper->submit_action = 'submit' . $this->name;
        $helper->toolbar_btn = array(
            'save' =>
            array(
                'desc' => $this->l('Save'),
                'href' => AdminController::$currentIndex . '&configure=' . $this->name . '&save' . $this->name .
                '&token=' . Tools::getAdminTokenLite('AdminModules'),
            ),
            'back' => array(
                'href' => AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminModules'),
                'desc' => $this->l('Back to list')
            )
        );


        // Load current value
        $helper->fields_value['FULLPRODUCTS_NAME'] = Configuration::get('FULLPRODUCTS_NAME');

        return $helper->generateForm($fields_form);
    }

In the settings page in the module everything look greats!!!

 

What I need is retrieve the values chosen by the user in the Admin-Panel to set the order of the products in the pagination accord to the values putted by the user in the settings.

 

Any help is appreciated.

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...