Skip to content

Commit 71a6a0c

Browse files
author
Tobias Merkl
committed
module configuration for all searchable fields
1 parent c621546 commit 71a6a0c

5 files changed

Lines changed: 80 additions & 13 deletions

File tree

Application/views/admin/de/oxcom_adminsearch_lang.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
'OXCOM_ADMINSEARCH_MODULE_ACTIVE' => 'aktiv',
2727
'OXCOM_ADMINSEARCH_MODULE_INACTIVE' => 'inaktiv',
2828
'SHOP_MODULE_GROUP_oxcom_adminsearch_main' => 'Allg. Einstellungen',
29+
'SHOP_MODULE_GROUP_oxcom_adminsearch_fields' => 'Durchsuchbare Felder',
2930
'SHOP_MODULE_blOxComAdminSearchShowArticles' => 'Artikel durchsuchen',
3031
'SHOP_MODULE_blOxComAdminSearchShowCategories' => 'Kategorien durchsuchen',
3132
'SHOP_MODULE_blOxComAdminSearchShowCmsPages' => 'CMS-Seiten durchsuchen',
@@ -35,4 +36,12 @@
3536
'SHOP_MODULE_blOxComAdminSearchShowVendors' => 'Lieferanten durchsuchen',
3637
'SHOP_MODULE_blOxComAdminSearchShowManufacturers' => 'Hersteller durchsuchen',
3738
'SHOP_MODULE_blOxComAdminSearchShowModules' => 'Module durchsuchen',
39+
'SHOP_MODULE_aOxComAdminSearchArticleFields' => 'Artikel-Felder',
40+
'SHOP_MODULE_aOxComAdminSearchCategoryFields' => 'Kategorie-Felder',
41+
'SHOP_MODULE_aOxComAdminSearchCmsPageFields' => 'CMS-Seiten-Felder',
42+
'SHOP_MODULE_aOxComAdminSearchOrderFields' => 'Bestellungs-Felder',
43+
'SHOP_MODULE_aOxComAdminSearchUserFields' => 'Benutzer-Felder',
44+
'SHOP_MODULE_aOxComAdminSearchCompanyFields' => 'Firmen-Felder',
45+
'SHOP_MODULE_aOxComAdminSearchVendorFields' => 'Lieferanten-Felder',
46+
'SHOP_MODULE_aOxComAdminSearchManufacturerFields' => 'Hersteller-Felder',
3847
];

Application/views/admin/en/oxcom_adminsearch_lang.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
'OXCOM_ADMINSEARCH_MODULE_ACTIVE' => 'active',
2727
'OXCOM_ADMINSEARCH_MODULE_INACTIVE' => 'inactive',
2828
'SHOP_MODULE_GROUP_oxcom_adminsearch_main' => 'General settings',
29+
'SHOP_MODULE_GROUP_oxcom_adminsearch_fields' => 'Searchable fields',
2930
'SHOP_MODULE_blOxComAdminSearchShowArticles' => 'Search articles',
3031
'SHOP_MODULE_blOxComAdminSearchShowCategories' => 'Search categories',
3132
'SHOP_MODULE_blOxComAdminSearchShowCmsPages' => 'Search CMS pages',
@@ -35,4 +36,12 @@
3536
'SHOP_MODULE_blOxComAdminSearchShowVendors' => 'Search vendors',
3637
'SHOP_MODULE_blOxComAdminSearchShowManufacturers' => 'Search manufacturers',
3738
'SHOP_MODULE_blOxComAdminSearchShowModules' => 'Search modules',
39+
'SHOP_MODULE_aOxComAdminSearchArticleFields' => 'Article fields',
40+
'SHOP_MODULE_aOxComAdminSearchCategoryFields' => 'Category fields',
41+
'SHOP_MODULE_aOxComAdminSearchCmsPageFields' => 'CMS page fields',
42+
'SHOP_MODULE_aOxComAdminSearchOrderFields' => 'Order fields',
43+
'SHOP_MODULE_aOxComAdminSearchUserFields' => 'User fields',
44+
'SHOP_MODULE_aOxComAdminSearchCompanyFields' => 'Company fields',
45+
'SHOP_MODULE_aOxComAdminSearchVendorFields' => 'Vendor fields',
46+
'SHOP_MODULE_aOxComAdminSearchManufacturerFields' => 'Manufacturer fields',
3847
];

Controller/Admin/NavigationController.php

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function getOxcomAdminSearchResults()
5555
if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowCmsPages")) {
5656
$aData["cmspages"] = $this->_getOxcomAdminSearchCmsPages();
5757
}
58-
//if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowOrders")) {
59-
$aData["orders"] = $this->_getOxcomAdminSearchOrders();
60-
//}
58+
if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowOrders")) {
59+
$aData["orders"] = $this->_getOxcomAdminSearchOrders();
60+
}
6161
if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowUsers")) {
6262
$aData["users"] = $this->_getOxcomAdminSearchUsers();
6363
}
@@ -98,7 +98,12 @@ public function getOxcomAdminSearchConfigParam($sParam = '')
9898
protected function _getOxcomAdminSearchArticles()
9999
{
100100
$sViewName = $this->_sViewNameGenerator->getViewName("oxarticles");
101-
$sSql = "SELECT oxid, CONCAT_WS(' / ', oxartnum, oxtitle, '', oxvarselect) FROM $sViewName WHERE CONCAT_WS(' / ', oxartnum, oxtitle, oxvarselect) LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
101+
$aFields = $this->getOxcomAdminSearchConfigParam("aOxComAdminSearchArticleFields");
102+
if (!is_array($aFields)) {
103+
$aFields = ['oxartnum', 'oxtitle', 'oxvarselect'];
104+
}
105+
$sFieldsList = implode(', ', $aFields);
106+
$sSql = "SELECT oxid, CONCAT_WS(' / ', $sFieldsList) FROM $sViewName WHERE CONCAT_WS(' / ', $sFieldsList) LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
102107

103108
return $this->_getOxcomAdminSearchData($sSql, 'article');
104109
}
@@ -111,7 +116,12 @@ protected function _getOxcomAdminSearchArticles()
111116
protected function _getOxcomAdminSearchCategories()
112117
{
113118
$sViewName = $this->_sViewNameGenerator->getViewName("oxcategories");
114-
$sSql = "SELECT oxid, oxtitle FROM $sViewName WHERE oxtitle LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
119+
$aFields = $this->getOxcomAdminSearchConfigParam("aOxComAdminSearchCategoryFields");
120+
if (!is_array($aFields)) {
121+
$aFields = ['oxtitle'];
122+
}
123+
$sFieldsList = implode(', ', $aFields);
124+
$sSql = "SELECT oxid, $sFieldsList FROM $sViewName WHERE $sFieldsList LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
115125

116126
return $this->_getOxcomAdminSearchData($sSql, 'category');
117127
}
@@ -124,7 +134,12 @@ protected function _getOxcomAdminSearchCategories()
124134
protected function _getOxcomAdminSearchCmsPages()
125135
{
126136
$sViewName = $this->_sViewNameGenerator->getViewName("oxcontents");
127-
$sSql = "SELECT oxid, oxtitle FROM $sViewName WHERE oxtitle LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
137+
$aFields = $this->getOxcomAdminSearchConfigParam("aOxComAdminSearchCmsPageFields");
138+
if (!is_array($aFields)) {
139+
$aFields = ['oxtitle'];
140+
}
141+
$sFieldsList = implode(', ', $aFields);
142+
$sSql = "SELECT oxid, $sFieldsList FROM $sViewName WHERE $sFieldsList LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
128143

129144
return $this->_getOxcomAdminSearchData($sSql, 'admin_content');
130145
}
@@ -137,7 +152,12 @@ protected function _getOxcomAdminSearchCmsPages()
137152
protected function _getOxcomAdminSearchOrders()
138153
{
139154
$sViewName = $this->_sViewNameGenerator->getViewName("oxorder");
140-
$sSql = "SELECT oxid, CONCAT_WS(' / ', oxordernr, oxbillfname, oxbilllname, oxbillemail, oxtrackcode, oxremark) AS search FROM $sViewName WHERE CONCAT_WS(' / ', oxordernr, oxbillfname, oxbilllname, oxbillemail, oxtrackcode, oxremark) LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
155+
$aFields = $this->getOxcomAdminSearchConfigParam("aOxComAdminSearchOrderFields");
156+
if (!is_array($aFields)) {
157+
$aFields = ['oxordernr', 'oxbillfname', 'oxbilllname', 'oxbillemail', 'oxtrackcode', 'oxremark'];
158+
}
159+
$sFieldsList = implode(', ', $aFields);
160+
$sSql = "SELECT oxid, CONCAT_WS(' / ', $sFieldsList) AS search FROM $sViewName WHERE CONCAT_WS(' / ', $sFieldsList) LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
141161

142162
return $this->_getOxcomAdminSearchData($sSql, 'admin_order');
143163
}
@@ -150,7 +170,12 @@ protected function _getOxcomAdminSearchOrders()
150170
protected function _getOxcomAdminSearchUsers()
151171
{
152172
$sViewName = $this->_sViewNameGenerator->getViewName("oxuser");
153-
$sSql = "SELECT oxid, CONCAT_WS(' / ', oxcustnr, oxfname, oxlname, oxusername, oxzip) FROM $sViewName WHERE CONCAT_WS(' / ', oxcustnr, oxlname, oxfname, oxusername, oxzip) LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
173+
$aFields = $this->getOxcomAdminSearchConfigParam("aOxComAdminSearchUserFields");
174+
if (!is_array($aFields)) {
175+
$aFields = ['oxcustnr', 'oxfname', 'oxlname', 'oxusername', 'oxzip'];
176+
}
177+
$sFieldsList = implode(', ', $aFields);
178+
$sSql = "SELECT oxid, CONCAT_WS(' / ', $sFieldsList) FROM $sViewName WHERE CONCAT_WS(' / ', $sFieldsList) LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
154179

155180
return $this->_getOxcomAdminSearchData($sSql, 'admin_user');
156181
}
@@ -163,7 +188,12 @@ protected function _getOxcomAdminSearchUsers()
163188
protected function _getOxcomAdminSearchCompanies()
164189
{
165190
$sViewName = $this->_sViewNameGenerator->getViewName("oxuser");
166-
$sSql = "SELECT oxid, oxcompany FROM $sViewName WHERE oxcompany LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
191+
$aFields = $this->getOxcomAdminSearchConfigParam("aOxComAdminSearchCompanyFields");
192+
if (!is_array($aFields)) {
193+
$aFields = ['oxcompany'];
194+
}
195+
$sFieldsList = implode(', ', $aFields);
196+
$sSql = "SELECT oxid, $sFieldsList FROM $sViewName WHERE $sFieldsList LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
167197

168198
return $this->_getOxcomAdminSearchData($sSql, 'admin_user');
169199
}
@@ -176,7 +206,12 @@ protected function _getOxcomAdminSearchCompanies()
176206
protected function _getOxcomAdminSearchVendors()
177207
{
178208
$sViewName = $this->_sViewNameGenerator->getViewName("oxvendor");
179-
$sSql = "SELECT oxid, oxtitle FROM $sViewName WHERE oxtitle LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
209+
$aFields = $this->getOxcomAdminSearchConfigParam("aOxComAdminSearchVendorFields");
210+
if (!is_array($aFields)) {
211+
$aFields = ['oxtitle'];
212+
}
213+
$sFieldsList = implode(', ', $aFields);
214+
$sSql = "SELECT oxid, $sFieldsList FROM $sViewName WHERE $sFieldsList LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
180215

181216
return $this->_getOxcomAdminSearchData($sSql, 'vendor');
182217
}
@@ -189,7 +224,12 @@ protected function _getOxcomAdminSearchVendors()
189224
protected function _getOxcomAdminSearchManufacturers()
190225
{
191226
$sViewName = $this->_sViewNameGenerator->getViewName("oxmanufacturers");
192-
$sSql = "SELECT oxid, oxtitle FROM $sViewName WHERE oxtitle LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
227+
$aFields = $this->getOxcomAdminSearchConfigParam("aOxComAdminSearchManufacturerFields");
228+
if (!is_array($aFields)) {
229+
$aFields = ['oxtitle'];
230+
}
231+
$sFieldsList = implode(', ', $aFields);
232+
$sSql = "SELECT oxid, $sFieldsList FROM $sViewName WHERE $sFieldsList LIKE " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote('%' . $this->_sQueryName . '%');
193233

194234
return $this->_getOxcomAdminSearchData($sSql, 'manufacturer');
195235
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ composer require oxid-community/adminsearch
2727

2828
# Changelog
2929

30+
2025-10-24 1.3.0 module configuration for all searchable fields
3031
2022-02-11 1.2.1 fix mysql result if string is too long, set orders always active
3132
2020-02-21 1.2.0 add oxremark to ordersearch
3233
2020-08-25 1.1.1 improve searches, fix ordersearch

metadata.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
'de' => 'Globale Suche im Shop-Admin',
2323
'en' => 'Global search shop admin'
2424
],
25-
'version' => '1.2.1',
25+
'version' => '1.3.0',
2626
'author' => 'OXID Community',
2727
'url' => 'https://github.com/OXIDprojects/adminsearch',
2828
'extend' => [
@@ -35,13 +35,21 @@
3535
],
3636
'settings' => [
3737
['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowArticles', 'type' => 'bool', 'value' => true],
38+
['group' => 'oxcom_adminsearch_main', 'name' => 'aOxComAdminSearchArticleFields', 'type' => 'arr', 'value' => ['oxartnum', 'oxtitle', 'oxvarselect']],
3839
['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowCategories', 'type' => 'bool', 'value' => true],
40+
['group' => 'oxcom_adminsearch_main', 'name' => 'aOxComAdminSearchCategoryFields', 'type' => 'arr', 'value' => ['oxtitle']],
3941
['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowCmsPages', 'type' => 'bool', 'value' => true],
40-
//['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowOrders', 'type' => 'bool', 'value' => true],
42+
['group' => 'oxcom_adminsearch_main', 'name' => 'aOxComAdminSearchCmsPageFields', 'type' => 'arr', 'value' => ['oxtitle']],
43+
['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowOrders', 'type' => 'bool', 'value' => true],
44+
['group' => 'oxcom_adminsearch_main', 'name' => 'aOxComAdminSearchOrderFields', 'type' => 'arr', 'value' => ['oxordernr', 'oxbillfname', 'oxbilllname', 'oxbillemail', 'oxtrackcode', 'oxremark']],
4145
['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowUsers', 'type' => 'bool', 'value' => true],
46+
['group' => 'oxcom_adminsearch_main', 'name' => 'aOxComAdminSearchUserFields', 'type' => 'arr', 'value' => ['oxcustnr', 'oxfname', 'oxlname', 'oxusername', 'oxzip']],
4247
['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowCompanies', 'type' => 'bool', 'value' => true],
48+
['group' => 'oxcom_adminsearch_main', 'name' => 'aOxComAdminSearchCompanyFields', 'type' => 'arr', 'value' => ['oxcompany']],
4349
['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowVendors', 'type' => 'bool', 'value' => true],
50+
['group' => 'oxcom_adminsearch_main', 'name' => 'aOxComAdminSearchVendorFields', 'type' => 'arr', 'value' => ['oxtitle']],
4451
['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowManufacturers', 'type' => 'bool', 'value' => true],
52+
['group' => 'oxcom_adminsearch_main', 'name' => 'aOxComAdminSearchManufacturerFields', 'type' => 'arr', 'value' => ['oxtitle']],
4553
['group' => 'oxcom_adminsearch_main', 'name' => 'blOxComAdminSearchShowModules', 'type' => 'bool', 'value' => true],
4654
],
4755
];

0 commit comments

Comments
 (0)