PHPackages                             renttek/magento2-search-criteria-processor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. renttek/magento2-search-criteria-processor

ActiveLibrary

renttek/magento2-search-criteria-processor
==========================================

Generic processor for Magento 2 SearchCriteria

2.1.0(4y ago)33.3k1[1 issues](https://github.com/renttek/magento2-search-criteria-processor/issues)proprietaryPHPPHP &gt;=7.4

Since Apr 15Pushed 4y ago2 watchersCompare

[ Source](https://github.com/renttek/magento2-search-criteria-processor)[ Packagist](https://packagist.org/packages/renttek/magento2-search-criteria-processor)[ RSS](/packages/renttek-magento2-search-criteria-processor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (9)Used By (0)

SearchCriteriaProcessor for Magento 2
=====================================

[](#searchcriteriaprocessor-for-magento-2)

Helper library for processing search M2 SearchCriteria in custom repositories/queries.

[![Latest Stable Version](https://camo.githubusercontent.com/399a2593439a89184751356b64fd126d56ac11706d9c70109b827a9b8aa8febf/68747470733a2f2f706f7365722e707567782e6f72672f72656e7474656b2f6d6167656e746f322d7365617263682d63726974657269612d70726f636573736f722f76657273696f6e)](https://packagist.org/packages/renttek/magento2-search-criteria-processor)

License: MIT

Why?
----

[](#why)

"But why? You can always use the default magento models &amp; collections, yada yada" Yeah, I know, but I don't really like them, as they are really bloated (my opinion)

Features
--------

[](#features)

This library contains processor classes which will add the following things to queries:

- Filtering (Filters &amp; FilterGroups)
- Sorting
- Pagination
- Automatic joins\*

(\*kind of)

Basics
------

[](#basics)

This library brings a set of Processor, which add conditions, limits etc. to an `Magento\Framework\DB\Select` instance. Every Processor implements `Renttek\SearchCriteriaProcessor\ProcessorInterface`.

There are the following implementations of `Renttek\SearchCriteriaProcessor\ProcessorInterface` are provided:

ClassDescriptionFilterProcessorApplies Filters &amp; FilterGroups as Where-StatementsSortOrderProcessorApplies 1 or multiple SortOrders as OrderBy-ClausesLimitProcessorApplies PageSize &amp; CurrentPage as Limit-Offset-ClausesJoinProcessorAdds Joins to the query based on used Tables/FieldsChainProcessorTakes multiple processors and applies allDefaultSearchCriteriaProcessorApplies the default Filter-, SortOrder- &amp; LimitProcessor, Also Accepts Joins(Every Processor is in the `Renttek\SearchCriteriaProcessor\` namespace)

The except for the JoinProcessor all processors should be are pretty simple and self-explanatory.

### JoinProcessor

[](#joinprocessor)

The JoinProcessor extracts used tables from the `Magento\Framework\DB\Select` and adds the joins to the query.

To achieve this, the JoinProcessor takes 2 parameters:

1. A FieldExtractor (`Renttek\SearchCriteriaProcessor\FieldExtractor\FieldExtractorInterface`)
2. A list of Joins (`Renttek\SearchCriteriaProcessor\Join\JoinInterface`)

When processing the SearchCriteria, the processor runs the field extractor to get a list of used tables and fields. This list is then matched the list of Joins to find an instance which supports the given table. The Join itself is then added by the Join-Instance. If no matching Join is found, an `\RuntimeException` is thrown.

List of provided FieldExtractors:

ClassDescriptionFilterFieldExtractorExtracts fields &amp; tables from Filter &amp; FilterGroupsSortOrderFieldExtractorExtracts fields &amp; tables from SortOrderChainFieldExtractorTakes multiple extractors and applies allDefaultFieldExtractorApples the default Filter- &amp; Sortorder-Extractors(Every Processor is in the `Renttek\SearchCriteriaProcessor\FieldExtractor` namespace)

List of provided Joins:

ClassDescriptionLeftJoinAdds an Left-Join to the Select(Every Join is in the `Renttek\SearchCriteriaProcessor\Join` namespace)

Usage
-----

[](#usage)

In the most simple cases, the DefaultSearchCriteria is all that is needed:

```
class Bar
{
    // ...
    /** @var DefaultSearchCriteriaProcessor */
    private $searchCriteriaProcessor;

    public function getList(SearchCriteriaInterface $searchCriteria)
    {
        $select = $this->getBaseSelect();
        $select = $this->searchCriteriaProcessor->process($select, $searchCriteria);

        return $this->fetchResult($select);
    }
    // ...
}
```

If you want to customize the behaviour, simply implement a custom Processor using the ProcessorInterface.

### Joins

[](#joins)

To enable automatic Joins you have to use the JoinProcessor (directly or indirectly using the Default- or ChainProcessor) and provide it with a FieldExtractor (e.g. `Renttek\SearchCriteriaProcessor\FieldExtractor\DefaultFieldExtractor`) and a list of of Join-Instances. This Library currently only provides a LeftJoin class.

The LeftJoin takes 3 parameters:

1. Name of the field in the main-table to join by
2. Name of the foreign table to join
3. Name of the field in the foreign-table to join by

Installation
------------

[](#installation)

Via composer:

```
composer require renttek/magento2-search-criteria-processor
```

Contributing
------------

[](#contributing)

You want to improve this library, report or even fix a bug? Awesome! Please, do it :)

You got questions? You can reach me here:

- Twitter: [@Renttek92](https://twitter.com/Renttek92)
- E-Mail:

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~78 days

Total

8

Last Release

1670d ago

Major Versions

1.0.1 → 2.0.02020-11-16

PHP version history (2 changes)1.0.0PHP ~7.1.0|~7.2.0|~7.3.0

2.0.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/91426e74250adada5b0db6113d4c4c7b10cfcbffc6532c79092089051b399ffd?d=identicon)[renttek](/maintainers/renttek)

---

Top Contributors

[![renttek](https://avatars.githubusercontent.com/u/1931090?v=4)](https://github.com/renttek "renttek (14 commits)")

---

Tags

librarymagento2searchcriteria

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/renttek-magento2-search-criteria-processor/health.svg)

```
[![Health](https://phpackages.com/badges/renttek-magento2-search-criteria-processor/health.svg)](https://phpackages.com/packages/renttek-magento2-search-criteria-processor)
```

###  Alternatives

[fastly/magento2

Fastly CDN Module for Magento 2.4.x

1564.2M1](/packages/fastly-magento2)[mage-os/module-automatic-translation

Automatic AI content translation for Mage-OS.

277.1k](/packages/mage-os-module-automatic-translation)[zepgram/module-rest

Technical module to industrialize API REST call with dependency injection pattern using Guzzle library

1326.2k](/packages/zepgram-module-rest)[graycore/magento2-graphql-introspection-cache

1015.2k](/packages/graycore-magento2-graphql-introspection-cache)[mage-os/mageos-common-async-events

Send REST requests to external endpoints asynchronously. This module implements the most common events like order creation and customer change.

147.7k2](/packages/mage-os-mageos-common-async-events)[mage-os/module-inventory-reservations-grid

Add a grid with the list of inventory reservations.

126.8k](/packages/mage-os-module-inventory-reservations-grid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
