Company Account feature integration
Edit on GitHubInstall Feature Core
Prerequisites
To start feature integration, review and install the necessary features: |Name|Version| |—|—| |Spryker Core|201903.0|
1) Install the required modules using Composer
Run the following command to install the required modules:
composer require spryker-feature/company-account: "^201903.0" --update-with-dependencies
Module | Expected Directory |
`BusinessOnBehalf` | `vvendor/spryker/business-on-behalf` |
`BusinessOnBehalfDataImport` | `vendor/spryker/business-on-behalf-data-import` |
2) Set up Database Schema and Transfer Objects
Run the following commands to:
- apply database changes
- generate entity and transfer changes
console transfer:generate
console propel:install
console transfer:generate
Database Entity | Type | Event |
`spy_company_user.is_default` | column | created |
Transfer | Type | Event | Path |
`CompanyUser.isDefault` | property | created | >|
`Customer.isOnBehalf` | property | created | `src/Generated/Shared/Transfer/CustomerTransfer` |
3) Import Data
Import Business On Behalf
vendor/spryker/spryker/Bundles/BusinessOnBehalfDataImport/data/import/company_user.csv
customer_reference,company_key,business_unit_key,default
DE--6,BoB-Hotel-Mitte,business-unit-mitte-1,0
DE--6,BoB-Hotel-Mitte,business-unit-mitte-2,0
DE--6,BoB-Hotel-Mitte,business-unit-mitte-3,0
DE--7,BoB-Hotel-Jim,business-unit-jim-1,0
DE--7,BoB-Hotel-Mitte,business-unit-mitte-1,0
DE--7,BoB-Hotel-Kudamm,business-unit-kudamm-1,0
DE--7,spryker_systems,spryker_systems_HQ,0
Column | REQUIRED | Data Type | Data Example | Data Explanation |
---|---|---|---|---|
customer_reference | mandatory | string | DE–6 | The key that will identify the Customer to which the data is added. |
company_key | mandatory | string | BoB-Hotel-Mitte | The key that will identify the Company to which the data is added. |
business_unit_key | mandatory | string | business-unit-mitte-1 | The key that will identify the Company Business Unit to which the data is added. |
default | mandatory | bool integer | 0 | Decides if there will be some pre-selected Company Business Unit for BoB User. |
Register the following plugin to enable data import:
|Plugin|Specification|Prerequisites|Namespace|
|—|—|—|—|
|BusinessOnBehalfCompanyUserDataImportPlugin
|Imports Business on Behalf Company Users.|Assumes that the Customer keys exist in the database.
Assumes that the Company keys exist in the database.
Assumes that the Company Business Unit keys exist in the database.|Spryker\Zed\BusinessOnBehalfDataImport\Communication\Plugin\DataImport
|
src/Pyz/Zed/DataImport/DataImportDependencyProvider.php
<?php
namespace Pyz\Zed\DataImport;
use Spryker\Zed\DataImport\DataImportDependencyProvider as SprykerDataImportDependencyProvider;
use Spryker\Zed\BusinessOnBehalfDataImport\Communication\Plugin\DataImport\BusinessOnBehalfCompanyUserDataImportPlugin;
class DataImportDependencyProvider extends SprykerDataImportDependencyProvider
{
protected function getDataImporterPlugins(): array
{
return [
new BusinessOnBehalfCompanyUserDataImportPlugin(),
];
}
}
Run the following console command to import data:
console data:import company-user-on-behalf
4) Set up Behavior
Enable the following behaviors by registering the plugins:
|Plugin|Specification|Prerequisites|Namespace|
|—|—|—|—|
|DefaultCompanyUserCustomerTransferExpanderPlugin
|Sets default Company User for a Business on Behalf customer if no Company User was selected yet.|None|Spryker\Zed\BusinessOnBehalf\Communication\Plugin\Customer
|
|IsOnBehalfCustomerTransferExpanderPlugin
| Sets CustomerTransfer.IsOnBehalf
property so other features can determine if the selected Company User is a Business on Behalf Company User.|None|Spryker\Zed\BusinessOnBehalf\Communication\Plugin\Customer
|
src/Pyz/Zed/Customer/CustomerDependencyProvider.php
<?php
namespace Pyz\Zed\Customer;
use Spryker\Zed\BusinessOnBehalf\Communication\Plugin\Customer\DefaultCompanyUserCustomerTransferExpanderPlugin;
use Spryker\Zed\BusinessOnBehalf\Communication\Plugin\Customer\IsOnBehalfCustomerTransferExpanderPlugin;
use Spryker\Zed\Customer\CustomerDependencyProvider as SprykerCustomerDependencyProvider;
class CustomerDependencyProvider extends SprykerCustomerDependencyProvider
{
/**
* @return \Spryker\Zed\Customer\Dependency\Plugin\CustomerTransferExpanderPluginInterface[]
*/
protected function getCustomerTransferExpanderPlugins()
{
return [
new IsOnBehalfCustomerTransferExpanderPlugin(),
new DefaultCompanyUserCustomerTransferExpanderPlugin(),
];
}
}
1. Log in with a сustomer who has multiple Company Users and a default one.
2. Check in the session if the default Company User was assigned to the Customer.
3. Check in the session if the IsOnBehalf property is set correctly for the Customer.
Install feature frontend
Prerequisites
Please review and install the necessary features before beginning the integration step. |Name|Version| |—|—| |Spryker Core|201903.0| |Customer Account Management|201903.0| |Company Account|201903.0|
1) Install the required modules using Composer
Run the following command to install the required modules:
composer require spryker-feature/company-account: "^201903.0" --update-with-dependencies
Module | Expected Directory |
`BusinessOnBehalfWidget` | `vendor/spryker-shop/business-on-behalf-widget` |
2) Add Translations
Append glossary according to your configuration:
src/data/import/glossary.csv
business_on_behalf_widget.no_selected_company,No selected company,en_US
business_on_behalf_widget.no_selected_company,Kein Unternehmen ausgewählt,de_DE
business_on_behalf_widget.change_company_user,Change Company User,en_US
business_on_behalf_widget.change_company_user,Firmenbenutzer Profil ändern,de_DE
company_user.business_on_behalf.error.company_not_active,"You can not select this company user, company is not active.",en_US
company_user.business_on_behalf.error.company_not_active,"Sie können diesen Firmennutzer nicht auswählen da die Firma inaktiv ist",de_DE
company_user.business_on_behalf.error.company_user_invalid,"You can not select this company user, it is invalid.",en_US
company_user.business_on_behalf.error.company_user_invalid,"Sie können diesen Firmennutzer nicht auswählen da er ungültig ist",de_DE
Run the following console command to import data:
console data:import glossary
3) Set up Widgets
Register the following plugin to enable widgets:
Plugin | Description | Prerequisites | Namespace |
---|---|---|---|
BusinessOnBehalfStatusWidget |
Displays the selected Company Users and allows for Business on Behalf customers to change it through a link. | None | SprykerShop\Yves\BusinessOnBehalfWidget\Widget |
src/Pyz/Yves/ShopApplication/ShopApplicationDependencyProvider.php
<?php
namespace Pyz\Yves\ShopApplication;
use SprykerShop\Yves\BusinessOnBehalfWidget\Widget\BusinessOnBehalfStatusWidget;
use SprykerShop\Yves\ShopApplication\ShopApplicationDependencyProvider as SprykerShopApplicationDependencyProvider;
class ShopApplicationDependencyProvider extends SprykerShopApplicationDependencyProvider
{
/**
* @return string[]
*/
protected function getGlobalWidgets(): array
{
return [
BusinessOnBehalfStatusWidget::class,
];
}
}
Run the following command to enable Javascript and CSS changes:
console frontend:yves:build
Thank you!
For submitting the form