-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added product id to filters, fixed current_category issue. Added opti…
…on to load category by id.
- Loading branch information
1 parent
7fdb02f
commit 83d9ace
Showing
5 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
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
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
42 changes: 42 additions & 0 deletions
42
.../Resolver/Products/SearchCriteria/CollectionProcessor/FilterProcessor/ProductIdFilter.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,42 @@ | ||
<?php | ||
/** | ||
* ScandiPWA_CatalogGraphQl | ||
* | ||
* @category ScandiPWA | ||
* @package ScandiPWA_CatalogGraphQl | ||
* @author Viktors Pliska <[email protected]> | ||
* @copyright Copyright (c) 2018 Scandiweb, Ltd (https://scandiweb.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ScandiPWA\CatalogGraphQl\Model\Resolver\Products\SearchCriteria\CollectionProcessor\FilterProcessor; | ||
|
||
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor\CustomFilterInterface; | ||
use Magento\Framework\Data\Collection\AbstractDb; | ||
use Magento\Framework\Api\Filter; | ||
|
||
/** | ||
* Product filter allows to filter products collection using custom defined filters from search criteria. | ||
*/ | ||
class ProductIdFilter implements CustomFilterInterface | ||
{ | ||
/** | ||
* @param Filter $filter | ||
* @param AbstractDb $collection | ||
* @return bool | ||
*/ | ||
public function apply(Filter $filter, AbstractDb $collection) | ||
{ | ||
$attributeValue = $filter->getValue(); | ||
$conditionType = $filter->getConditionType(); | ||
|
||
$collection->getSelect() | ||
->where($collection->getConnection()->prepareSqlCondition( | ||
'e.entity_id', | ||
[$conditionType => $attributeValue] | ||
)); | ||
|
||
return true; | ||
} | ||
} |
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
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