dsheiko / magentosearchquerybuilder
Tool to build search criteria query for Magento REST Web API
Installs: 10 740
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=5.6.0
Requires (Dev)
- peridot-php/leo: ^1.6
- peridot-php/peridot: ^1.19
- squizlabs/php_codesniffer: ^3.1
This package is not auto-updated.
Last update: 2024-11-10 05:40:27 UTC
README
Tool to build search criteria query for Magento REST Web API
Installation
Require as a composer dependency:
composer require "dsheiko/magentosearchquerybuilder"
Building query
<?php use Dsheiko\SearchCriteria; $builder = new SearchCriteria(); $builder ->filterGroup([ [ "name", "%25Leggings%25", "like" ], [ "name", "%25Parachute%25", "like" ], ]) ->filterGroup([ [ "price", 30, "lt" ], ]) ->sortOrder( "created_at", "DESC") ->limit(1, 10);
Obtaining query string
<?php $builder->toString();
The result:
"searchCriteria[filter_groups][0][filters][0][field]=name"
. "&searchCriteria[filter_groups][0][filters][0][value]=%25Leggings%25"
. "&searchCriteria[filter_groups][0][filters][0][condition_type]=like"
. "&searchCriteria[filter_groups][0][filters][1][field]=name"
. "&searchCriteria[filter_groups][0][filters][1][value]=%25Parachute%25"
. "&searchCriteria[filter_groups][0][filters][1][condition_type]=like"
. "&searchCriteria[filter_groups][1][filters][1][field]=price"
. "&searchCriteria[filter_groups][1][filters][1][value]=30"
. "&searchCriteria[filter_groups][1][filters][1][condition_type]=lt"
. "&searchCriteria[sort_orders][0][field]=created_at"
. "&searchCriteria[sort_orders][0][direction]=DESC"
. "&searchCriteria[current_page]=1"
. "&searchCriteria[page_size]=10"
Obtaining query array
<?php $builder->toArray();