-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Nosto/ADS-4289_implement_more_sorting_options
ADS-4289 Support more sorting options
- Loading branch information
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/Search/Request/Handler/SortHandlers/CustomFieldSortingHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nosto\NostoIntegration\Search\Request\Handler\SortHandlers; | ||
|
||
use Nosto\NostoIntegration\Search\Request\SearchRequest; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting; | ||
|
||
class CustomFieldSortingHandler implements SortingHandlerInterface | ||
{ | ||
public function supportsSorting(FieldSorting $fieldSorting): bool | ||
{ | ||
return str_starts_with($fieldSorting->getField(), 'customFields'); | ||
} | ||
|
||
public function generateSorting(FieldSorting $fieldSorting, SearchRequest $searchNavigationRequest): void | ||
{ | ||
$searchNavigationRequest->setSort($fieldSorting->getField(), $fieldSorting->getDirection()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Search/Request/Handler/SortHandlers/ProductNumberSortingHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nosto\NostoIntegration\Search\Request\Handler\SortHandlers; | ||
|
||
use Nosto\NostoIntegration\Search\Request\SearchRequest; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting; | ||
|
||
class ProductNumberSortingHandler implements SortingHandlerInterface | ||
{ | ||
public function supportsSorting(FieldSorting $fieldSorting): bool | ||
{ | ||
return $fieldSorting->getField() === 'product.productNumber'; | ||
} | ||
|
||
public function generateSorting(FieldSorting $fieldSorting, SearchRequest $searchNavigationRequest): void | ||
{ | ||
$searchNavigationRequest->setSort('customFields.productNumber', $fieldSorting->getDirection()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Search/Request/Handler/SortHandlers/RatingSortingHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nosto\NostoIntegration\Search\Request\Handler\SortHandlers; | ||
|
||
use Nosto\NostoIntegration\Search\Request\SearchRequest; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting; | ||
|
||
class RatingSortingHandler implements SortingHandlerInterface | ||
{ | ||
public function supportsSorting(FieldSorting $fieldSorting): bool | ||
{ | ||
return $fieldSorting->getField() === 'product.ratingAverage'; | ||
} | ||
|
||
public function generateSorting(FieldSorting $fieldSorting, SearchRequest $searchNavigationRequest): void | ||
{ | ||
$searchNavigationRequest->setSort('ratingValue', $fieldSorting->getDirection()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Search/Request/Handler/SortHandlers/StockSortingHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nosto\NostoIntegration\Search\Request\Handler\SortHandlers; | ||
|
||
use Nosto\NostoIntegration\Search\Request\SearchRequest; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting; | ||
|
||
class StockSortingHandler implements SortingHandlerInterface | ||
{ | ||
public function supportsSorting(FieldSorting $fieldSorting): bool | ||
{ | ||
return $fieldSorting->getField() === 'product.stock'; | ||
} | ||
|
||
public function generateSorting(FieldSorting $fieldSorting, SearchRequest $searchNavigationRequest): void | ||
{ | ||
$searchNavigationRequest->setSort('inventoryLevel', $fieldSorting->getDirection()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters