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 today

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 67% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

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

1618d 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

[yireo/magento2-webp2

Magento 2 module to add WebP support to the Magento frontend

2071.2M6](/packages/yireo-magento2-webp2)[mageworx/module-searchsuiteautocomplete

Search Suite Autocomplete extension by MageWorx for Magento 2

34290.7k1](/packages/mageworx-module-searchsuiteautocomplete)[smile/module-store-delivery

Smile Store Delivery

23344.3k1](/packages/smile-module-store-delivery)[kiwicommerce/module-customer-password

Magento 2 - Customer Password

1355.9k](/packages/kiwicommerce-module-customer-password)[developersalliance/module-table-rates

This module allows administrators to manage and view shipping table rates from the admin UI.

443.0k](/packages/developersalliance-module-table-rates)[magenerds/richsnippet

This module provides rich snippet functionality

1024.8k](/packages/magenerds-richsnippet)

PHPackages © 2026

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