Skip to content
4 changes: 3 additions & 1 deletion src/DataProvider/CustomerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#[Package('fundamentals@after-sales')]
class CustomerProvider extends DemoDataProvider
{
public const CUSTOMER_ID = '6c97534c2c0747f39e8751e43cb2b013';

private Connection $connection;

/**
Expand Down Expand Up @@ -56,7 +58,7 @@ public function getPayload(): array

return [
[
'id' => '6c97534c2c0747f39e8751e43cb2b013',
'id' => self::CUSTOMER_ID,
'defaultPaymentMethodId' => $paymentMethodId,
'salutationId' => $salutationId,
'salesChannelId' => $salesChannelId,
Expand Down
15 changes: 15 additions & 0 deletions src/DataProvider/ProductProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Shopware\Core\Defaults;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Uuid\Uuid;
use Swag\PlatformDemoData\Resources\helper\DbHelper;
use Swag\PlatformDemoData\Resources\helper\ProductReviewHelper;
use Swag\PlatformDemoData\Resources\helper\TranslationHelper;

#[Package('fundamentals@after-sales')]
Expand All @@ -25,10 +27,16 @@ class ProductProvider extends DemoDataProvider

private TranslationHelper $translationHelper;

private DbHelper $dbHelper;

private ProductReviewHelper $productReviewHelper;

public function __construct(Connection $connection)
{
$this->connection = $connection;
$this->translationHelper = new TranslationHelper($connection);
$this->dbHelper = new DbHelper($connection);
$this->productReviewHelper = new ProductReviewHelper();
}

public function getAction(): string
Expand Down Expand Up @@ -56,6 +64,7 @@ public function getPayload(): array
{
$taxId = $this->getTaxId();
$storefrontSalesChannel = $this->getStorefrontSalesChannel();
$enLanguageId = $this->dbHelper->getLanguageId('en-GB');

return [
[
Expand Down Expand Up @@ -142,6 +151,7 @@ public function getPayload(): array
'visibility' => ProductVisibilityDefinition::VISIBILITY_ALL,
],
],
'productReviews' => $this->productReviewHelper->createReviews($storefrontSalesChannel, $enLanguageId),
],
[
'id' => '1901dc5e888f4b1ea4168c2c5f005540',
Expand Down Expand Up @@ -207,6 +217,7 @@ public function getPayload(): array
'id' => '77421c4f75af40c8a57657cdc2ad49a2',
],
],
'productReviews' => $this->productReviewHelper->createReviews($storefrontSalesChannel, $enLanguageId),
],
[
'id' => '2a88d9b59d474c7e869d8071649be43c',
Expand Down Expand Up @@ -279,6 +290,7 @@ public function getPayload(): array
'id' => 'dc6f98beeca44852beb078a9e8e21e7d',
],
],
'productReviews' => $this->productReviewHelper->createReviews($storefrontSalesChannel, $enLanguageId),
],
[
'id' => '3ac014f329884b57a2cce5a29f34779c',
Expand Down Expand Up @@ -341,6 +353,7 @@ public function getPayload(): array
'id' => 'c53fa30db00e4a84b4516f6b07c02e8d',
],
],
'productReviews' => $this->productReviewHelper->createReviews($storefrontSalesChannel, $enLanguageId),
],
[
'id' => '43a23e0c03bf4ceabc6055a2185faa87',
Expand Down Expand Up @@ -500,6 +513,7 @@ public function getPayload(): array
],
],
],
'productReviews' => $this->productReviewHelper->createReviews($storefrontSalesChannel, $enLanguageId),
],
[
'id' => 'c7bca22753c84d08b6178a50052b4146',
Expand Down Expand Up @@ -625,6 +639,7 @@ public function getPayload(): array
],
],
],
'productReviews' => $this->productReviewHelper->createReviews($storefrontSalesChannel, $enLanguageId),
],
];
}
Expand Down
174 changes: 174 additions & 0 deletions src/Resources/helper/ProductReviewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?php

declare(strict_types=1);
/*
* (c) shopware AG <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Swag\PlatformDemoData\Resources\helper;

use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Uuid\Uuid;
use Swag\PlatformDemoData\DataProvider\CustomerProvider;

#[Package('fundamentals@after-sales')]
class ProductReviewHelper
{
public function createReviews(string $salesChannelId, string $languageId): array
{
return [
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Very good',
'content' => 'Excellent product! The quality is top notch, everything works perfectly and exceeds my expectations. I definitely recommend buying it.',
'points' => 5.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Outstanding Quality',
'content' => 'Top product! High-quality build, easy to use, and fast delivery. I would buy it again anytime',
'points' => 5.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Exceeded Expectations',
'content' => 'Absolutely delighted. Exactly as described, even better than expected.',
'points' => 5.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Perfect Choice',
'content' => 'Perfect! Exactly what I was looking for. Works flawlessly.',
'points' => 5.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Good',
'content' => 'Very good product with minor flaws. Overall, I am satisfied; it offers good value for money.',
'points' => 4.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Very Solid Product',
'content' => 'Overall a very good product. Minor flaws, but nothing serious.',
'points' => 4.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Great Value for Money',
'content' => 'Solid product with good value for money. I would recommend it.',
'points' => 4.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Satisfactory',
'content' => 'The product is fine, serves its purpose, but there is nothing special about it. Acceptable for the price.',
'points' => 3.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Does the Job',
'content' => 'Okay for everyday use. Does its job, but there are definitely better alternatives.',
'points' => 3.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Average Experience',
'content' => 'Average. Neither particularly good nor particularly bad.',
'points' => 3.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Poor',
'content' => 'Unfortunately disappointing. The quality is mediocre and there were several problems during use.',
'points' => 2.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Disappointing Durability',
'content' => 'Unfortunately not very durable. Problems appeared after a short time.',
'points' => 2.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Good Idea, Weak Execution',
'content' => 'The idea is good, but the execution is lacking.',
'points' => 2.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Very poor',
'content' => 'Absolutely not recommended. The product is defective, does not work as described and appears to be cheaply made.',
'points' => 1.0,
'status' => true,
],
[
'id' => Uuid::randomHex(),
'salesChannelId' => $salesChannelId,
'customerId' => CustomerProvider::CUSTOMER_ID,
'languageId' => $languageId,
'title' => 'Not Worth It',
'content' => 'Very disappointing. Poor quality and not functional upon delivery.',
'points' => 1.0,
'status' => true,
],
];
}
}