Skip to content

Commit

Permalink
send search-criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardogomez97 committed Oct 29, 2024
1 parent 17f0ef7 commit e33d345
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions Model/CategoryListRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Magento\Catalog\Api\CategoryListInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\Search\FilterGroup;

class CategoryListRepository
{
Expand All @@ -23,17 +23,8 @@ public function __construct(
$this->filterBuilder = $filterBuilder;
}

public function execute()
public function getList(SearchCriteriaInterface $searchCriteria)
{
$entityIdFilter = $this->filterBuilder->setField('entity_id')->setValue(1)->setConditionType('gt')->create();
$parentIdFilter = $this->filterBuilder->setField('parent_id')->setValue(1)->setConditionType('gt')->create();
$isActiveFilter = $this->filterBuilder->setField('is_active')->setValue(1)->setConditionType('eq')->create();

$filterGroup = new FilterGroup();
$filterGroup->setFilters([$entityIdFilter, $parentIdFilter, $isActiveFilter]);

$searchCriteria = $this->searchCriteriaBuilder->setFilterGroups([$filterGroup])->create();

$categories = $this->categoryRepository->getList($searchCriteria)->getItems();

$categoryData = [];
Expand Down

0 comments on commit e33d345

Please sign in to comment.