-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP - product load optimization. * Implemented processor in the different space
- Loading branch information
1 parent
625ae54
commit f5b47f5
Showing
4 changed files
with
88 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
57 changes: 57 additions & 0 deletions
57
src/Model/Resolver/Products/CollectionPostProcessor/ReviewSummary.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,57 @@ | ||
<?php | ||
/** | ||
* ScandiPWA - Progressive Web App for Magento | ||
* | ||
* Copyright © Scandiweb, Inc. All rights reserved. | ||
* See LICENSE for license details. | ||
* | ||
* @license OSL-3.0 (Open Software License ('OSL') v. 3.0) | ||
* @package scandipwa/reviews-graphql | ||
* @link https://github.com/scandipwa/reviews-graphql | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ScandiPWA\ReviewsGraphQl\Model\Resolver\Products\CollectionPostProcessor; | ||
|
||
use Magento\Catalog\Model\ResourceModel\Product\Collection; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Review\Model\ResourceModel\Review\Product\Collection as ProductCollection; | ||
use Magento\Review\Model\Review; | ||
use ScandiPWA\Performance\Api\ProductsCollectionPostProcessorInterface; | ||
|
||
class ReviewSummary implements ProductsCollectionPostProcessorInterface | ||
{ | ||
const REVIEW_SUMMARY = 'review_summary'; | ||
|
||
/** | ||
* @var Review | ||
*/ | ||
protected $review; | ||
|
||
/** | ||
* AttributeProcessor constructor. | ||
* @param Review $review | ||
*/ | ||
public function __construct( | ||
Review $review | ||
) { | ||
$this->review = $review; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function process( | ||
Collection $collection, | ||
array $attributeNames | ||
): Collection { | ||
if (in_array(self::REVIEW_SUMMARY, $attributeNames)) { | ||
/** @var $collection ProductCollection */ | ||
$this->review->appendSummary($collection); | ||
} | ||
|
||
return $collection; | ||
} | ||
} |
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,22 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* ScandiPWA - Progressive Web App for Magento | ||
* | ||
* Copyright © Scandiweb, Inc. All rights reserved. | ||
* See LICENSE for license details. | ||
* | ||
* @license OSL-3.0 (Open Software License ("OSL") v. 3.0) | ||
* @package scandipwa/reviews-graphql | ||
* @link https://github.com/scandipwa/reviews-graphql | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="ScandiPWA\Performance\Model\Resolver\Products\CollectionPostProcessor"> | ||
<arguments> | ||
<argument name="processors" xsi:type="array"> | ||
<item name="review_summary" xsi:type="object">ScandiPWA\ReviewsGraphQl\Model\Resolver\Products\CollectionPostProcessor\ReviewSummary</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |