TS Commerce Developers

Filters API

Current version: v1.1

Get list of filters

GET
/filters/list.json
Get list of filters Request

$storeden = new Storeden\Storeden($config);
$filters_list = $storeden->get('/filters/list.json');
					
Get list of filters Response

[
    {
        "_id": {
            "$id": "57e14a8216f46aba048b457d"
        },
        "key": "colore",
        "values": [
            "rosso",
            "blu",
            "verde"
        ],
        "images": [
            "https://...",
            "https://..."
        ],
        "categories": [
            "120383",
            "130286",
            "113306"
        ],
		"feedActive": true,
        "feedLabel": "color",
        "feedValues": [
            "red",
            "blue",
			"green"
        ],
        "descriptions": [
            "",
            ""
        ]
    },
    ...
]
					

Create filter

Check filters list to check if filter_key already exists to avoid duplicated filters.

POST
/filters/filter.json
filter_key required (string) [a-z] carachters, no whitespace, - and _ allowed
filter_values required (array) couples [index]:[value]
descriptions[filter_value] optional (array) couples [filter_value]:Value description
images[filter_value] optional (array) couples [filter_value]:https://cdn.storeden.net/secache/test-image
filter_label optional (string) Jan 3rd, 2021 Default Store locale filter label
categories[] optional (int) repeatable Sep 10th, 2024 Specify for which categories this filter must be considered active. Passing an empty array make this filter available for all categories
Create filter Request

$storeden = new Storeden\Storeden($config);

$payload = array();
$payload['filter_key'] = 'keyboard-material';
$payload['filter_values'] = [0 => 'rosewood', 1 => 'maple'];
$pyaload['descriptions']['rosewood'] = 'Rosewood material';
$pyaload['descriptions']['maple'] = 'Maple material';
$pyaload['images']['rosewood'] = 'https://cdn.storeden.net/secache/test-image-rosewood';
$pyaload['images']['maple'] = 'https://cdn.storeden.net/secache/test-image-maple';
$pyaload['categories'] = array(234245, 923571, 235234, 342591);

$result = $storeden->post('/filters/filter.json', $payload);
						
Create filter Response

{
    "$id": "5eaa931e16f46a9009def81b"
}
					

Update filter values

Add new valutes for specified filter_key.

PUT
/filters/filter.json
filter_key required (string) [a-z] carachters, no whitespace, - and _ allowed
values[] required (string) THis field can be included more times to add more values
descriptions[filter_value] (array) If not setted, system will use previously added elements couples [filter_value]:Value description
images[filter_value] (array) If not setted, system will use previously added elements couples [filter_value]:https://cdn.storeden.net/secache/test-image
filter_label optional (string) Jan 3rd, 2021 Default Store locale filter label
categories[] optional (int) repeatable Sep 10th, 2024 Specify for which categories this filter must be considered active. Passing an empty array make this filter available for all categories
Update filter values Request

$storeden = new Storeden\Storeden($config);

$payload = array();
$payload['filter_key'] = 'keyboard-material';

$payload['values'] = array();
$payload['values'][] ='plastic';
$payload['values'][] ='aluminium';

$pyaload['descriptions']['rosewood'] = 'Rosewood material';
$pyaload['descriptions']['maple'] = 'Maple material';
$pyaload['images']['rosewood'] = 'https://cdn.storeden.net/secache/test-image-rosewood';
$pyaload['images']['maple'] = 'https://cdn.storeden.net/secache/test-image-maple';

$pyaload['categories'] = array(234245, 923571, 235234, 342591);

$result = $storeden->put('/filters/filter.json', $payload);
						
Update filter values Response

{
    "ok": 1,
    "nModified": 1,
    "n": 1,
    "err": null,
    "errmsg": null,
    "updatedExisting": true
}