Comments + Order Management feature integration

Edit on GitHub

This document describes how to integrate the Comments + Order Management feature into a Spryker project.

Install feature core

Follow the steps below to install the Comments + Order Management feature core.

Prerequisites

To start feature integration, integrate the required features

NAME VERSION INSTALLATION GUIDES
Comments 202204.0 Comments feature integration
Order Management 202204.0 Order Management feature integration

1) Install the required modules using Composer

Install the required modules:

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

Make sure that the following modules were 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 that 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.