Skip to content

Commit

Permalink
Merge pull request #762 from abhishek-webkul/gli-1445
Browse files Browse the repository at this point in the history
Updated: Search Results Page Filters options have been moved to module wkhotelfilterblock
  • Loading branch information
rohit053 authored Mar 15, 2024
2 parents c3f5371 + dbaf23c commit 1f39f24
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 32 deletions.
23 changes: 0 additions & 23 deletions controllers/admin/AdminPPreferencesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,29 +400,6 @@ public function __construct()
// 'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();advancedStockManagementActivationAuthorization();</script>',
// 'submit' => array('title' => $this->l('Save'))
// ),
'fo_search_filters' => array(
'title' => $this->l('Search Results Page Filters'),
'icon' => 'icon-search',
'fields' => array(
'SHOW_AMENITIES_FILTER' => array(
'title' => $this->l('Show Amenities filter'),
'hint' => $this->l('Enable to display Amenities filter.'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
),
'SHOW_PRICE_FILTER' => array(
'title' => $this->l('Show Price filter'),
'hint' => $this->l('Enable to display Price filter.'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
),
),
'submit' => array('title' => $this->l('Save'))
),
);
}

Expand Down
2 changes: 0 additions & 2 deletions install/data/theme.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ SET NAMES 'utf8';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_CONDITIONS';
UPDATE `PREFIX_configuration` SET value = '12' WHERE name = 'PS_PRODUCTS_PER_PAGE';
UPDATE `PREFIX_configuration` SET value = '9' WHERE name = 'PS_HOTEL_IMAGES_PER_PAGE';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_AMENITIES_FILTER';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_PRICE_FILTER';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_PRODUCTS_ORDER_WAY';
UPDATE `PREFIX_configuration` SET value = '4' WHERE name = 'PS_PRODUCTS_ORDER_BY';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DISPLAY_QTIES';
Expand Down
6 changes: 0 additions & 6 deletions install/data/xml/configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@
<configuration id="PS_HOTEL_IMAGES_PER_PAGE" name="PS_HOTEL_IMAGES_PER_PAGE">
<value>9</value>
</configuration>
<configuration id="SHOW_AMENITIES_FILTER" name="SHOW_AMENITIES_FILTER">
<value>1</value>
</configuration>
<configuration id="SHOW_PRICE_FILTER" name="SHOW_PRICE_FILTER">
<value>1</value>
</configuration>
<configuration id="PS_PURCHASE_MINIMUM" name="PS_PURCHASE_MINIMUM">
<value>0</value>
</configuration>
Expand Down
119 changes: 118 additions & 1 deletion modules/wkhotelfilterblock/wkhotelfilterblock.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,117 @@ public function __construct()
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
}

public function getContent()
{
$this->html = '';
if (Tools::isSubmit('btnConfigSubmit')) {
$this->postProcess();
} else {
$this->html .= '<br />';
}

$this->html .= $this->renderForm();

return $this->html;
}

public function renderForm()
{
$fields_form = array();
$fields_form['form'] = array(
'legend' => array(
'icon' => 'icon-cog',
'title' => $this->l('Search Results Page Filters'),
),
'input' => array(
array(
'type' => 'switch',
'label' => $this->l('Show Amenities filter'),
'name' => 'SHOW_AMENITIES_FILTER',
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
),
array(
'id' => 'active_off',
'value' => 0,
),
),
'hint' => $this->l('Enable to display Amenities filter.'),
),
array(
'type' => 'switch',
'label' => $this->l('Show Price filter'),
'name' => 'SHOW_PRICE_FILTER',
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
),
array(
'id' => 'active_off',
'value' => 0,
),
),
'hint' => $this->l('Enable to display Price filter.'),
),
),
'submit' => array(
'title' => $this->l('Save'),
'name' => 'submit_conf_filter',
),
);

$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$this->fields_form = array();
$helper->identifier = $this->identifier;
$helper->submit_action = 'btnConfigSubmit';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).
'&configure='.$this->name.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');

$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id,
);

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

public function postProcess()
{
if (Tools::isSubmit('btnConfigSubmit')) {
Configuration::updateValue(
'SHOW_AMENITIES_FILTER',
Tools::getValue('SHOW_AMENITIES_FILTER')
);
Configuration::updateValue('SHOW_PRICE_FILTER', Tools::getValue('SHOW_PRICE_FILTER'));

// redirect after saving the configuration
Tools::redirectAdmin(
$this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&tab_module='.$this->tab.
'&module_name='.$this->name.'&conf=4'
);
}
}

public function install()
{
if (!parent::install()
|| !$this->registerHook('header')
|| !$this->registerHook('addOtherModuleSetting')
|| !$this->registerHook('displayLeftColumn')) {
|| !$this->registerHook('displayLeftColumn')
|| !Configuration::updateValue('SHOW_AMENITIES_FILTER', 1)
|| !Configuration::updateValue('SHOW_PRICE_FILTER', 1)
) {
return false;
}

Expand Down Expand Up @@ -155,4 +260,16 @@ public function getConfigFieldsValues()
'SHOW_PRICE_FILTER' => Configuration::get('SHOW_PRICE_FILTER'),
);
}

public function uninstall()
{
if (!parent::uninstall()
|| !Configuration::deleteByName('SHOW_AMENITIES_FILTER')
|| !Configuration::deleteByName('SHOW_PRICE_FILTER')
) {
return false;
}

return true;
}
}

0 comments on commit 1f39f24

Please sign in to comment.