-
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.
Fixed price groups, fixed scandipwa/scandipwa#887
- Loading branch information
1 parent
3b38e0d
commit dacf941
Showing
7 changed files
with
81 additions
and
34 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* ScandiPWA_CatalogGraphQl | ||
* | ||
* @category ScandiPWA | ||
* @package ScandiPWA_CatalogGraphQl | ||
* @author Alfreds Genkins <[email protected]> | ||
* @copyright Copyright (c) 2018 Scandiweb, Ltd (https://scandiweb.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ScandiPWA\CatalogGraphQl\Plugin\Resolver; | ||
|
||
use Magento\CatalogGraphQl\Model\Resolver\Products as CoreProducts; | ||
use Magento\Customer\Model\Session; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Query\Resolver\Argument\SearchCriteria\Builder; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
|
||
class Products { | ||
/** @var Builder */ | ||
protected $searchCriteriaBuilder; | ||
|
||
/** @var Session */ | ||
protected $customerSession; | ||
|
||
/** | ||
* Products constructor. | ||
* @param Builder $searchCriteriaBuilder | ||
* @param Session $customerSession | ||
*/ | ||
public function __construct( | ||
Builder $searchCriteriaBuilder, | ||
Session $customerSession | ||
) { | ||
$this->searchCriteriaBuilder = $searchCriteriaBuilder; | ||
$this->customerSession = $customerSession; | ||
} | ||
|
||
public function beforeResolve( | ||
CoreProducts $products, | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
$searchCriteria = $this->searchCriteriaBuilder->build('products', $args); | ||
$context->getExtensionAttributes()->setSearchCriteria($searchCriteria); | ||
|
||
foreach ($searchCriteria->getFilterGroups() as $filterGroup) { | ||
foreach ($filterGroup->getFilters() as $filter) { | ||
if ($filter->getField() === 'customer_group_id') { | ||
$this->customerSession->setCustomerGroupId($filter->getValue()); | ||
} | ||
} | ||
} | ||
|
||
return [ | ||
$field, | ||
$context, | ||
$info, | ||
$value, | ||
$args | ||
]; | ||
} | ||
} |
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