Jump to content

sort grid BO Controller by default


Recommended Posts

Hello,

 

I'm working on a new module with a Bo controller on Symfony.

When I call the controller ("configure action"), the query is not sorted by the defaults settings but by the primary key.

ItemFilter.php

AdminItemController.php

ItemQueryBuilder.php

 

Do you know where does come the problem (I have deleted all cache)? 

 

Thanks for your help

 

 

Link to comment
Share on other sites

class AdminItemController extends FrameworkBundleAdminController{

    private $cache;

    private $commandBus;

    public function __construct(CacheProvider $cache, TacticianCommandBusAdapter $commandBus)

    { 

        $this->cache = $cache;

        $this->commandBus = $commandBus;

    }

    public function indexAction(ItemFilter $filters)

    {

      $itemGridFactory = $this->get('amm.menu.grid.item_grid_factory');

      $itemRequestGrid = $itemGridFactory->getGrid($filters);

       return $this->render('@Modules/ammmenu/views/templates/admin/list.html.twig',[

          'itemGrid' => $this->presentGrid($itemRequestGrid)

      ]);

    }

}

use PrestaShop\PrestaShop\Core\Search\Filters;

use Amm\Menu\Grid\Definition\Factory\ItemDefinitionFactory;

 

final class ItemFilter extends Filters

{

    protected $filterId = ItemDefinitionFactory::GRID_ID;

 

    public static function getDefaults()

    {

        $tab=[

            'limit' => 10,

            'offset' => 0,

            'orderBy' => 'position',

            'sortOrder' => 'asc',

            'filters' => [],

        ];

       

        return $tab;

    }

}

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...