Skip to content

Commit

Permalink
Fixed filter counts in combination with sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Dec 1, 2019
1 parent c73448e commit 4d777fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,20 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], &$expir
* @category User
*/
$limit = $config->get( 'client/html/catalog/count/limit', 10000 );

$startid = $view->config( 'client/html/catalog/filter/tree/startid' );
$level = $view->config( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE );
$sort = $view->param( 'f_sort', $config->get( 'client/html/catalog/lists/sort', 'relevance' ) );

$cntl = \Aimeos\Controller\Frontend::create( $context, 'product' )
->sort( $sort ) // prioritize user sorting over the sorting through category
->category( $view->param( 'f_catid', $startid ), 'default', $level )
->supplier( $view->param( 'f_supid', [] ) )
->allof( $view->param( 'f_attrid', [] ) )
->oneOf( $view->param( 'f_optid', [] ) )
->oneOf( $view->param( 'f_oneid', [] ) )
->text( $view->param( 'f_search' ) )
->slice( 0, $limit )->sort();
->slice( 0, $limit );

$view->attributeCountList = $cntl->aggregate( 'index.attribute.id' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,20 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], &$expir
* @category User
*/
$limit = $config->get( 'client/html/catalog/count/limit', 10000 );

$startid = $view->config( 'client/html/catalog/filter/tree/startid' );
$level = $view->config( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE );
$sort = $view->param( 'f_sort', $config->get( 'client/html/catalog/lists/sort', 'relevance' ) );

$cntl = \Aimeos\Controller\Frontend::create( $context, 'product' )
->sort( $sort ) // prioritize user sorting over the sorting through category
->category( $view->param( 'f_catid', $startid ), 'default', $level )
->supplier( $view->param( 'f_supid', [] ) )
->allof( $view->param( 'f_attrid', [] ) )
->oneOf( $view->param( 'f_optid', [] ) )
->oneOf( $view->param( 'f_oneid', [] ) )
->text( $view->param( 'f_search' ) )
->slice( 0, $limit )->sort();
->slice( 0, $limit );

$view->supplierCountList = $cntl->aggregate( 'index.supplier.id' );
}
Expand Down
4 changes: 3 additions & 1 deletion client/html/src/Client/Html/Catalog/Count/Tree/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], &$expir
$limit = $config->get( 'client/html/catalog/count/limit', 10000 );
$startid = $view->config( 'client/html/catalog/filter/tree/startid' );
$level = $view->config( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST );
$sort = $view->param( 'f_sort', $config->get( 'client/html/catalog/lists/sort', 'relevance' ) );

$cntl = \Aimeos\Controller\Frontend::create( $context, 'catalog' )->root( $startid );
$root = $cntl->getTree( \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE );
Expand All @@ -241,13 +242,14 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], &$expir

$tree = $cntl->getTree();
$cntl = \Aimeos\Controller\Frontend::create( $context, 'product' )
->sort( $sort ) // prioritize user sorting over the sorting through category
->category( array_keys( $tree->toList() ) )
->supplier( $view->param( 'f_supid', [] ) )
->allof( $view->param( 'f_attrid', [] ) )
->oneOf( $view->param( 'f_optid', [] ) )
->oneOf( $view->param( 'f_oneid', [] ) )
->text( $view->param( 'f_search' ) )
->slice( 0, $limit )->sort();
->slice( 0, $limit );

$view->treeCountList = $cntl->aggregate( 'index.catalog.id' );

Expand Down

0 comments on commit 4d777fc

Please sign in to comment.