Skip to content

Commit

Permalink
[API][Product] fixes to taxon filter
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKasp committed Apr 16, 2021
1 parent 889f37d commit 886d9d2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Api/Shop/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function iOpenProductPage(ProductInterface $product): void
public function iBrowseProductsFromTaxon(TaxonInterface $taxon): void
{
$this->client->index();
$this->client->addFilter('productTaxons', $this->iriConverter->getIriFromItem($taxon));
$this->client->addFilter('taxon', $this->iriConverter->getIriFromItem($taxon));
$this->client->filter();
}

Expand Down
19 changes: 0 additions & 19 deletions src/Sylius/Behat/Service/Context/ChannelContext.php

This file was deleted.

24 changes: 11 additions & 13 deletions src/Sylius/Bundle/ApiBundle/Filter/TaxonFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(ManagerRegistry $managerRegistry, IriConverterInterf

public function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null)
{
if ($property !== 'productTaxons') {
if ($property !== 'taxon') {
return;
}

Expand All @@ -59,18 +59,16 @@ public function filterProperty(string $property, $value, QueryBuilder $queryBuil

public function getDescription(string $resourceClass): array
{
$description = [];
$description["productTaxons"] =
[
'type' => 'string',
'required' => false,
'property' => null,
'swagger' => [
'name' =>'Product taxon filter',
'description' => 'Get a collection of product with chosen taxon'
]
return [
'taxon' => [
'type' => 'string',
'required' => false,
'property' => null,
'swagger' => [
'name' =>'Product taxon filter',
'description' => 'Get a collection of product with chosen taxon',
],
],
];

return $description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function it_adds_taxon_filter_if_property_is_product_taxon(
;

$this->filterProperty(
'productTaxons',
'taxon',
'api/taxon',
$queryBuilder,
$queryNameGenerator,
Expand Down

0 comments on commit 886d9d2

Please sign in to comment.