From f978bf03cd8d0067ad12674e317d2ae15ce3af75 Mon Sep 17 00:00:00 2001 From: IrinaZhadzinets Date: Fri, 15 Jul 2022 17:48:10 +0300 Subject: [PATCH] scandipwa/scandipwa#4903 - Aff filter for url and parent title fields --- src/Block/Adminhtml/Item/Grid.php | 7 ++++--- src/Helper/Adminhtml/Data.php | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Block/Adminhtml/Item/Grid.php b/src/Block/Adminhtml/Item/Grid.php index d7f2537..4a60c12 100644 --- a/src/Block/Adminhtml/Item/Grid.php +++ b/src/Block/Adminhtml/Item/Grid.php @@ -100,11 +100,12 @@ protected function _prepareColumns() 'parent_title', [ 'header' => __('Parent Item'), - 'type' => 'text', + 'type' => 'options', 'index' => 'parent_title', 'escape' => true, 'renderer' => '\ScandiPWA\MenuOrganizer\Block\Adminhtml\Item\Renderer\Parentitem', - 'filter' => false + 'options' => $this->_menumanagerHelper->getAvailableParentTitles(), + 'filter_index' => 'main_table.parent_id', ] ); @@ -115,7 +116,7 @@ protected function _prepareColumns() 'type' => 'text', 'index' => 'url', 'escape' => true, - 'filter' => false, + 'filter_index' => 'main_table.url', 'sortable' => false, ] ); diff --git a/src/Helper/Adminhtml/Data.php b/src/Helper/Adminhtml/Data.php index c91509b..47434f3 100644 --- a/src/Helper/Adminhtml/Data.php +++ b/src/Helper/Adminhtml/Data.php @@ -286,6 +286,19 @@ public function getUrlTypes() ]; } + public function getAvailableParentTitles() + { + $item = $this->initItem(); + $menuId = $this->_getRequest()->getParam('menu_id', null); + + $result = $item->getCollection() + ->addMenuFilter($menuId) + ->excludeCurrentItem($item->getId()) + ->toItemOptionArray(); + + return [null => 'All'] + $result; + } + /** * Load Menu from request *