Skip to content

Instantly share code, notes, and snippets.

@nanasess
Last active December 26, 2016 05:59
Show Gist options
  • Save nanasess/30f1e8cf4a5ed08b66da02604d0226ec to your computer and use it in GitHub Desktop.
Save nanasess/30f1e8cf4a5ed08b66da02604d0226ec to your computer and use it in GitHub Desktop.
--- a/src/Eccube/Form/Type/SearchProductType.php
+++ b/src/Eccube/Form/Type/SearchProductType.php
@@ -54,8 +54,8 @@ class SearchProductType extends AbstractType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
- $Categories = $this->app['eccube.repository.category']
- ->getList(null, true);
+ // $Categories = $this->app['eccube.repository.category']
+ // ->getList(null, true);
$builder->add('mode', 'hidden', array(
'data' => 'search',
@@ -63,7 +63,12 @@ class SearchProductType extends AbstractType
$builder->add('category_id', 'entity', array(
'class' => 'Eccube\Entity\Category',
'property' => 'NameWithLevel',
- 'choices' => $Categories,
+ // 'choices' => $Categories,
+ 'query_builder' => function (EntityRepository $er) {
+ return $er
+ ->createQueryBuilder('c')
+ ->orderBy('c.rank', 'DESC');
+ },
'empty_value' => '全ての商品',
'empty_data' => null,
'required' => false,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment