Skip to content

Commit 1f39f24

Browse files
authored
Merge pull request #762 from abhishek-webkul/gli-1445
Updated: Search Results Page Filters options have been moved to module wkhotelfilterblock
2 parents c3f5371 + dbaf23c commit 1f39f24

File tree

4 files changed

+118
-32
lines changed

4 files changed

+118
-32
lines changed

controllers/admin/AdminPPreferencesController.php

-23
Original file line numberDiff line numberDiff line change
@@ -400,29 +400,6 @@ public function __construct()
400400
// 'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();advancedStockManagementActivationAuthorization();</script>',
401401
// 'submit' => array('title' => $this->l('Save'))
402402
// ),
403-
'fo_search_filters' => array(
404-
'title' => $this->l('Search Results Page Filters'),
405-
'icon' => 'icon-search',
406-
'fields' => array(
407-
'SHOW_AMENITIES_FILTER' => array(
408-
'title' => $this->l('Show Amenities filter'),
409-
'hint' => $this->l('Enable to display Amenities filter.'),
410-
'validation' => 'isBool',
411-
'cast' => 'intval',
412-
'required' => false,
413-
'type' => 'bool',
414-
),
415-
'SHOW_PRICE_FILTER' => array(
416-
'title' => $this->l('Show Price filter'),
417-
'hint' => $this->l('Enable to display Price filter.'),
418-
'validation' => 'isBool',
419-
'cast' => 'intval',
420-
'required' => false,
421-
'type' => 'bool',
422-
),
423-
),
424-
'submit' => array('title' => $this->l('Save'))
425-
),
426403
);
427404
}
428405

install/data/theme.sql

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ SET NAMES 'utf8';
33
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_CONDITIONS';
44
UPDATE `PREFIX_configuration` SET value = '12' WHERE name = 'PS_PRODUCTS_PER_PAGE';
55
UPDATE `PREFIX_configuration` SET value = '9' WHERE name = 'PS_HOTEL_IMAGES_PER_PAGE';
6-
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_AMENITIES_FILTER';
7-
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_PRICE_FILTER';
86
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_PRODUCTS_ORDER_WAY';
97
UPDATE `PREFIX_configuration` SET value = '4' WHERE name = 'PS_PRODUCTS_ORDER_BY';
108
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DISPLAY_QTIES';

install/data/xml/configuration.xml

-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@
6262
<configuration id="PS_HOTEL_IMAGES_PER_PAGE" name="PS_HOTEL_IMAGES_PER_PAGE">
6363
<value>9</value>
6464
</configuration>
65-
<configuration id="SHOW_AMENITIES_FILTER" name="SHOW_AMENITIES_FILTER">
66-
<value>1</value>
67-
</configuration>
68-
<configuration id="SHOW_PRICE_FILTER" name="SHOW_PRICE_FILTER">
69-
<value>1</value>
70-
</configuration>
7165
<configuration id="PS_PURCHASE_MINIMUM" name="PS_PURCHASE_MINIMUM">
7266
<value>0</value>
7367
</configuration>

modules/wkhotelfilterblock/wkhotelfilterblock.php

+118-1
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,117 @@ public function __construct()
4242
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
4343
}
4444

45+
public function getContent()
46+
{
47+
$this->html = '';
48+
if (Tools::isSubmit('btnConfigSubmit')) {
49+
$this->postProcess();
50+
} else {
51+
$this->html .= '<br />';
52+
}
53+
54+
$this->html .= $this->renderForm();
55+
56+
return $this->html;
57+
}
58+
59+
public function renderForm()
60+
{
61+
$fields_form = array();
62+
$fields_form['form'] = array(
63+
'legend' => array(
64+
'icon' => 'icon-cog',
65+
'title' => $this->l('Search Results Page Filters'),
66+
),
67+
'input' => array(
68+
array(
69+
'type' => 'switch',
70+
'label' => $this->l('Show Amenities filter'),
71+
'name' => 'SHOW_AMENITIES_FILTER',
72+
'is_bool' => true,
73+
'values' => array(
74+
array(
75+
'id' => 'active_on',
76+
'value' => 1,
77+
),
78+
array(
79+
'id' => 'active_off',
80+
'value' => 0,
81+
),
82+
),
83+
'hint' => $this->l('Enable to display Amenities filter.'),
84+
),
85+
array(
86+
'type' => 'switch',
87+
'label' => $this->l('Show Price filter'),
88+
'name' => 'SHOW_PRICE_FILTER',
89+
'is_bool' => true,
90+
'values' => array(
91+
array(
92+
'id' => 'active_on',
93+
'value' => 1,
94+
),
95+
array(
96+
'id' => 'active_off',
97+
'value' => 0,
98+
),
99+
),
100+
'hint' => $this->l('Enable to display Price filter.'),
101+
),
102+
),
103+
'submit' => array(
104+
'title' => $this->l('Save'),
105+
'name' => 'submit_conf_filter',
106+
),
107+
);
108+
109+
$helper = new HelperForm();
110+
$helper->show_toolbar = false;
111+
$helper->table = $this->table;
112+
$lang = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
113+
$helper->default_form_language = $lang->id;
114+
$this->fields_form = array();
115+
$helper->identifier = $this->identifier;
116+
$helper->submit_action = 'btnConfigSubmit';
117+
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).
118+
'&configure='.$this->name.'&module_name='.$this->name;
119+
$helper->token = Tools::getAdminTokenLite('AdminModules');
120+
121+
$helper->tpl_vars = array(
122+
'fields_value' => $this->getConfigFieldsValues(),
123+
'languages' => $this->context->controller->getLanguages(),
124+
'id_language' => $this->context->language->id,
125+
);
126+
127+
return $helper->generateForm(array($fields_form));
128+
}
129+
130+
public function postProcess()
131+
{
132+
if (Tools::isSubmit('btnConfigSubmit')) {
133+
Configuration::updateValue(
134+
'SHOW_AMENITIES_FILTER',
135+
Tools::getValue('SHOW_AMENITIES_FILTER')
136+
);
137+
Configuration::updateValue('SHOW_PRICE_FILTER', Tools::getValue('SHOW_PRICE_FILTER'));
138+
139+
// redirect after saving the configuration
140+
Tools::redirectAdmin(
141+
$this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&tab_module='.$this->tab.
142+
'&module_name='.$this->name.'&conf=4'
143+
);
144+
}
145+
}
146+
45147
public function install()
46148
{
47149
if (!parent::install()
48150
|| !$this->registerHook('header')
49151
|| !$this->registerHook('addOtherModuleSetting')
50-
|| !$this->registerHook('displayLeftColumn')) {
152+
|| !$this->registerHook('displayLeftColumn')
153+
|| !Configuration::updateValue('SHOW_AMENITIES_FILTER', 1)
154+
|| !Configuration::updateValue('SHOW_PRICE_FILTER', 1)
155+
) {
51156
return false;
52157
}
53158

@@ -155,4 +260,16 @@ public function getConfigFieldsValues()
155260
'SHOW_PRICE_FILTER' => Configuration::get('SHOW_PRICE_FILTER'),
156261
);
157262
}
263+
264+
public function uninstall()
265+
{
266+
if (!parent::uninstall()
267+
|| !Configuration::deleteByName('SHOW_AMENITIES_FILTER')
268+
|| !Configuration::deleteByName('SHOW_PRICE_FILTER')
269+
) {
270+
return false;
271+
}
272+
273+
return true;
274+
}
158275
}

0 commit comments

Comments
 (0)