implement seach on category loop.
This commit is contained in:
@@ -18,6 +18,7 @@ use Thelia\Core\Template\Element\LoopResult;
|
|||||||
use Thelia\Core\Template\Element\LoopResultRow;
|
use Thelia\Core\Template\Element\LoopResultRow;
|
||||||
|
|
||||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||||
|
use Thelia\Core\Template\Element\SearchLoopInterface;
|
||||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ use Thelia\Model\ProductQuery;
|
|||||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||||
*/
|
*/
|
||||||
class Category extends BaseI18nLoop implements PropelSearchLoopInterface
|
class Category extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLoopInterface
|
||||||
{
|
{
|
||||||
protected $timestampable = true;
|
protected $timestampable = true;
|
||||||
protected $versionable = true;
|
protected $versionable = true;
|
||||||
@@ -83,6 +84,23 @@ class Category extends BaseI18nLoop implements PropelSearchLoopInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array of available field to search in
|
||||||
|
*/
|
||||||
|
public function getSearchIn()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"title"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doSearch(&$search, $searchTerm, $searchIn, $searchCriteria)
|
||||||
|
{
|
||||||
|
$search->_and();
|
||||||
|
|
||||||
|
$search->where("CASE WHEN NOT ISNULL(`requested_locale_i18n`.ID) THEN `requested_locale_i18n`.`TITLE` ELSE `default_locale_i18n`.`TITLE` END ".$searchCriteria." ?", $searchTerm, \PDO::PARAM_STR);
|
||||||
|
}
|
||||||
|
|
||||||
public function buildModelCriteria()
|
public function buildModelCriteria()
|
||||||
{
|
{
|
||||||
$search = CategoryQuery::create();
|
$search = CategoryQuery::create();
|
||||||
|
|||||||
@@ -170,6 +170,44 @@
|
|||||||
</div>
|
</div>
|
||||||
{* end order search *}
|
{* end order search *}
|
||||||
|
|
||||||
|
{* category search *}
|
||||||
|
<div class="general-block-decorator">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-condensed table-left-aligned">
|
||||||
|
<caption class="clearfix">
|
||||||
|
{intl l='Category'}
|
||||||
|
</caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{intl l="ID"}</th>
|
||||||
|
<th></th>
|
||||||
|
<th>{intl l="Category title"}</th>
|
||||||
|
|
||||||
|
<th class="actions">{intl l="Actions"}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{loop type="category" name="category-search" visible="*" search_mode="sentence" search_term=trim($smarty.get.search_term) search_in="title"}
|
||||||
|
<tr>
|
||||||
|
<td>{$ID}</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="object-title"><a href="{url path="/admin/categories/update" category_id={$ID}}">{$TITLE}</a></td>
|
||||||
|
<td class="actions">
|
||||||
|
<div class="btn-group">
|
||||||
|
{loop type="auth" name="can_change" role="ADMIN" resource="admin.category" access="UPDATE"}
|
||||||
|
<a class="btn btn-default btn-xs" title="{intl l='Edit this product'}" href="{url path="/admin/categories/update" category_id={$ID}}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||||
|
{/loop}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/loop}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{* end category search *}
|
||||||
|
|
||||||
{* product search *}
|
{* product search *}
|
||||||
<div class="general-block-decorator">
|
<div class="general-block-decorator">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
|
|||||||
Reference in New Issue
Block a user