Comments + Order Management feature integration
Edit on GitHub
You are browsing a previous version of the document. The latest version is 202212.0.
Install Feature Core
Prerequisites
To start feature integration, overview and install the necessary features:
Name | Version |
---|---|
Comment | 201907.0 |
Order Management | 201907.0 |
1) Install the required modules using Composer
Run the following command(s) to 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:
Configuration | 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
Run the following commands to 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.
Thank you!
For submitting the form