Install the Comments + Order Management feature

Edit on GitHub

Install feature core

Prerequisites

Install the required features:

NAME VERSION
Comment 202410.0
Order Management 202410.0

1) Install the required modules

Install the required modules using Composer:

composer require spryker/comment-sales-connector:"^1.0.0" --update-with-dependencies
Verification

Make sure the following modules have been installed:

MODULE EXPECTED DIRECTORY
CommentSalesConnector vendor/spryker/comment-sales-connector

2) Set up configuration

Add the following configuration to your project:

CONFIURATION SPECIFICATION NAMESPACE
SalesConfig::getSalesDetailExternalBlocksUrls() Used to display a block with comments related to the order. Pyz\Zed\Sales

Pyz\Zed\Sales\SalesConfig.php

<?php

namespace Pyz\Zed\Sales;

use Spryker\Zed\Sales\SalesConfig as SprykerSalesConfig;

class SalesConfig extends SprykerSalesConfig
{
	public function getSalesDetailExternalBlocksUrls()
	{
		$projectExternalBlocks = [
			'comment' => '/comment-sales-connector/sales/list',
		];

		$externalBlocks = parent::getSalesDetailExternalBlocksUrls();

		return array_merge($externalBlocks, $projectExternalBlocks);
	}
}
Verification

Make sure that the Order detail page in Zed contains a block with comments.

3) Set up transfer objects

Generate transfer changes:

console transfer:generate
Verification

Make sure the following changes have been applied in transfer objects:

TRANSFER TYPE EVENT PATH
Comment class created src/Generated/Shared/Transfer/Comment
CommentThread class created src/Generated/Shared/Transfer/CommentThread
CommentFilter class created src/Generated/Shared/Transfer/CommentFilter
CommentRequest class created src/Generated/Shared/Transfer/CommentRequest

4) Set up behavior

Register the following plugins:

PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
CommentThreadOrderExpanderPlugin Expands OrderTransfer with CommentThread. None Spryker\Zed\CommentSalesConnector\Communication\Plugin\Sales
CommentThreadAttachedCommentOrderPostSavePlugin Duplicates commentThread from Quote to a new order. None Spryker\Zed\CommentSalesConnector\Communication\Plugin\Sales

Pyz\Zed\Sales\SalesDependencyProvider.php

<?php

namespace Pyz\Zed\Sales;

use Spryker\Zed\CommentSalesConnector\Communication\Plugin\Sales\CommentThreadOrderExpanderPlugin;
use Spryker\Zed\Sales\SalesDependencyProvider as SprykerSalesDependencyProvider;

class SalesDependencyProvider extends SprykerSalesDependencyProvider
{
	/**
	 * @return \Spryker\Zed\SalesExtension\Dependency\Plugin\OrderExpanderPluginInterface[]
	 */
	protected function getOrderHydrationPlugins()
	{
		return [
			new CommentThreadOrderExpanderPlugin(),
		];
	}
}
Verification

Make sure that OrderTransfer::commentThread contains information about comments when you retrieve an order from the database.

Pyz\Zed\Sales\SalesDependencyProvider.php

<?php

namespace Pyz\Zed\Sales;

use Spryker\Zed\CommentSalesConnector\Communication\Plugin\Sales\CommentThreadAttachedCommentOrderPostSavePlugin;
use Spryker\Zed\Sales\SalesDependencyProvider as SprykerSalesDependencyProvider;

class SalesDependencyProvider extends SprykerSalesDependencyProvider
{
	/**
	 * @return \Spryker\Zed\SalesExtension\Dependency\Plugin\OrderPostSavePluginInterface[]
	 */
	protected function getOrderPostSavePlugins()
	{
		return [
			new CommentThreadAttachedCommentOrderPostSavePlugin(),
		];
	}
}
Verification

Make sure that all comments from QoteTransfer::commentThread duplicate to a new order after the successful checkout.