Skip to content

Commit a4dd35a

Browse files
authored
Merge pull request #248 from BitBagCommerce/op-303-api-support
OP-303: Change DataProvider priority
2 parents 78fbc07 + f876703 commit a4dd35a

File tree

5 files changed

+4
-11
lines changed

5 files changed

+4
-11
lines changed

src/Api/Resolver/FacetsResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function resolve(array $data): array
4747
return [];
4848
}
4949

50-
return $adapter->getAggregations();
50+
return array_filter($adapter->getAggregations(), function ($facet) {
51+
return [] !== $facet['buckets'] ?? [];
52+
});
5153
}
5254
}

src/Resources/config/services/api/data_provider.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<argument type="service" id="bitbag_sylius_elasticsearch_plugin.api.request_data_handler" />
77
<argument type="service" id="bitbag_sylius_elasticsearch_plugin.finder.search_products" />
88
<argument type="service" id="bitbag_sylius_elasticsearch_plugin.api.resolver.facets" />
9-
<tag name="api_platform.collection_data_provider" />
9+
<tag name="api_platform.collection_data_provider" priority="10" />
1010
</service>
1111
</services>
1212
</container>

tests/PHPUnit/Integration/Api/Responses/Expected/test_it_finds_products_by_name.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
}
2323
],
2424
"facets": {
25-
"price": {
26-
"buckets": []
27-
},
2825
"taxon": {
2926
"doc_count_error_upper_bound": 0,
3027
"sum_other_doc_count": 0,

tests/PHPUnit/Integration/Api/Responses/Expected/test_it_finds_products_by_name_and_facets.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
}
3333
]
3434
},
35-
"price": {
36-
"buckets": []
37-
},
3835
"taxon": {
3936
"doc_count_error_upper_bound": 0,
4037
"sum_other_doc_count": 0,

tests/PHPUnit/Integration/Api/Responses/Expected/test_it_finds_products_by_name_and_multiple_facets.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@
6060
}
6161
]
6262
},
63-
"price": {
64-
"buckets": []
65-
},
6663
"taxon": {
6764
"doc_count_error_upper_bound": 0,
6865
"sum_other_doc_count": 0,

0 commit comments

Comments
 (0)