Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move ProductReviewLoader logic to core
- Loading branch information
Showing
27 changed files
with
1,266 additions
and
603 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
33 changes: 33 additions & 0 deletions
33
changelog/_unreleased/2024-04-17-product-review-loader-core.md
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,33 @@ | ||
--- | ||
title: Product review loader core | ||
issue: NEXT-00000 | ||
author: Benjamin Wittwer | ||
author_email: dev@a-k-f.de | ||
author_github: akf-bw | ||
--- | ||
# Core | ||
* Changed `ProductDescriptionReviewsCmsElementResolver` to use the `AbstractProductReviewLoader` and removed the duplicate functions | ||
* Changed `ProductDescriptionReviewsCmsElementResolver` to now execute the Core `ProductReviewsWidgetLoadedHook` hook | ||
* Added `AbstractProductReviewLoader` to allow overwriting product review load logic | ||
* Added `ProductReviewLoader` based on the Storefront `ProductReviewLoader` | ||
* Changed `ProductReviewResult` to include the `totalNativeReviews` field | ||
* Added `ProductReviewsWidgetLoadedHook` based on the Storefront `ProductReviewsWidgetLoadedHook` | ||
* Added `ProductReviewsLoadedEvent` based on the Storefront `ProductReviewsLoadedEvent` | ||
* Added `Migration1711461585AddDefaultSettingConfigValueForReviewListingPerPage` to include the new config option | ||
* Added `core.listing.reviewsPerPage` to config `listing` with default value `10` | ||
* Changed `ProductDescriptionReviewsTypeDataResolverTest` to match Core changes | ||
* Added `ProductReviewLoaderTest` to match core changes | ||
___ | ||
# Storefront | ||
* Changed `CmsController` to use `AbstractProductReviewLoader` | ||
* Changed `ProductController` to use `AbstractProductReviewLoader` | ||
* Changed `ProductReviewLoader` to `@deprecated` and copy logic from Core `ProductReviewLoader` | ||
* Changed `ProductReviewsLoadedEvent` to `@deprecated` | ||
* Changed `ProductReviewsWidgetLoadedHook` to `@deprecated` | ||
* Changed `ReviewLoaderResult` to `@deprecated` | ||
* Changed `review.html.twig` template to include the new `core.listing.reviewsPerPage` to config | ||
* Changed `review.html.twig` template to include missing `nativeReviewsCount` and `foreignReviewsCount` variables | ||
* Changed `review.html.twig` by including additional `component_review_list_action_filters` and `component_review_list_counter` blocks | ||
* Changed `CmsControllerTest` to match Storefront changes | ||
* Changed `ProductControllerTest` to match Storefront changes | ||
* Changed `ProductReviewLoaderTest` to match Storefront changes |
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
15 changes: 15 additions & 0 deletions
15
src/Core/Content/Product/SalesChannel/Review/AbstractProductReviewLoader.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,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Shopware\Core\Content\Product\SalesChannel\Review; | ||
|
||
use Shopware\Core\Framework\Log\Package; | ||
use Shopware\Core\System\SalesChannel\SalesChannelContext; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
#[Package('inventory')] | ||
abstract class AbstractProductReviewLoader | ||
{ | ||
abstract public function getDecorated(): AbstractProductReviewLoader; | ||
|
||
abstract public function load(Request $request, SalesChannelContext $context, string $productId, ?string $parentId = null): ProductReviewResult; | ||
} |
42 changes: 42 additions & 0 deletions
42
src/Core/Content/Product/SalesChannel/Review/Event/ProductReviewsLoadedEvent.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 declare(strict_types=1); | ||
|
||
namespace Shopware\Core\Content\Product\SalesChannel\Review\Event; | ||
|
||
use Shopware\Core\Content\Product\SalesChannel\Review\ProductReviewResult; | ||
use Shopware\Core\Framework\Context; | ||
use Shopware\Core\Framework\Event\NestedEvent; | ||
use Shopware\Core\Framework\Event\ShopwareSalesChannelEvent; | ||
use Shopware\Core\Framework\Log\Package; | ||
use Shopware\Core\System\SalesChannel\SalesChannelContext; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
#[Package('content')] | ||
final class ProductReviewsLoadedEvent extends NestedEvent implements ShopwareSalesChannelEvent | ||
{ | ||
public function __construct( | ||
protected ProductReviewResult $reviews, | ||
protected SalesChannelContext $salesChannelContext, | ||
protected Request $request | ||
) { | ||
} | ||
|
||
public function getReviews(): ProductReviewResult | ||
{ | ||
return $this->reviews; | ||
} | ||
|
||
public function getSalesChannelContext(): SalesChannelContext | ||
{ | ||
return $this->salesChannelContext; | ||
} | ||
|
||
public function getContext(): Context | ||
{ | ||
return $this->salesChannelContext->getContext(); | ||
} | ||
|
||
public function getRequest(): Request | ||
{ | ||
return $this->request; | ||
} | ||
} |
Oops, something went wrong.