Shipment feature integration
Edit on GitHubThe current feature integration guide only adds the following functionalities:
- Shipment Back Office UI;
- Delivery method per store;
- Shipment data import.
Install Feature Core
Prerequisites
To start the feature integration, overview and install the necessary features:
Name | Version |
---|---|
Spryker Core | 202009.0 |
1) Install the required modules using Composer
Run the following command(s) to install the required modules:
composer require spryker-feature/shipment:"202009.0" --update-with-dependencies
Module | Expected Directory |
`ShipmentDataImport` | `vendor/spryker/shipment-data-import` |
`ShipmentGui` | `vendor/spryker/ShipmentGui` |
2) Set up Database Schema and Transfer Objects
Run the following commands to apply database changes and generate entity and transfer changes:
console transfer:generate
console propel:install
console transfer:generate
Database Entity | Type | Event |
`spy_shipment_method_store` | table | created |
Transfer | Type | Event | Path |
`ShipmentTransfer` | class | created | `src/Generated/Shared/Transfer/ShipmentTransfer` |
`StoreTransfer` | class | created | `src/Generated/Shared/Transfer/StoreTransfer` |
`DataImporterConfigurationTransfer` | class | created | `src/Generated/Shared/Transfer/DataImporterConfigurationTransfer` |
`DataImporterReaderConfigurationTransfer` | class | created | `src/Generated/Shared/Transfer/DataImporterReaderConfigurationTransfer` |
`DataImporterReportTransfer` | class | created | `src/Generated/Shared/Transfer/DataImporterReportTransfer` |
`DataImporterReportMessageTransfer` | class | created | `src/Generated/Shared/Transfer/DataImporterReportMessageTransfer` |
`TotalsTransfer` | class | created | `src/Generated/Shared/Transfer/TotalsTransfer` |
3) Import Data
Import Shipment Methods
Prepare your data according to your requirements using our demo data:
vendor/spryker/spryker/Bundles/ShipmentDataImport/data/import
shipment_method_key,store
spryker_dummy_shipment-standard,AT
spryker_dummy_shipment-standard,DE
spryker_dummy_shipment-standard,US
spryker_dummy_shipment-express,AT
spryker_dummy_shipment-express,DE
spryker_dummy_shipment-express,US
spryker_drone_shipment-air_standard,AT
spryker_drone_shipment-air_standard,DE
spryker_drone_shipment-air_standard,US
spryker_drone_shipment-air_sonic,AT
spryker_drone_shipment-air_sonic,DE
spryker_drone_shipment-air_sonic,US
spryker_drone_shipment-air_light,AT
spryker_drone_shipment-air_light,DE
spryker_drone_shipment-air_light,US
spryker_no_shipment,AT
spryker_no_shipment,DE
spryker_no_shipment,US
Column | REQUIRED | Data Type | Data Example | Data Explanation |
---|---|---|---|---|
shipment_method_key |
mandatory | string | spryker_dummy_shipment-standard | Key of an existing shipping method. |
store |
mandatory | string | DE | Name of an existing store. |
Register the following data import plugins:
Plugin | Specification | Prerequisites | Namespace |
---|---|---|---|
ShipmentDataImportPlugin |
Imports shipment method data into the database. | None | \Spryker\Zed\ShipmentDataImport\Communication\Plugin |
ShipmentMethodPriceDataImportPlugin |
Imports shipment method price data into the database. | None | \Spryker\Zed\ShipmentDataImport\Communication\Plugin |
ShipmentMethodStoreDataImportPlugin |
Imports shipment method store data into the database. | None | \Spryker\Zed\ShipmentDataImport\Communication\Plugin |
src/Pyz/Zed/DataImport/DataImportDependencyProvider.php
<?php
namespace Pyz\Zed\DataImport;
use Spryker\Zed\DataImport\DataImportDependencyProvider as SprykerDataImportDependencyProvider;
use Spryker\Zed\ShipmentDataImport\Communication\Plugin\ShipmentDataImportPlugin;
use Spryker\Zed\ShipmentDataImport\Communication\Plugin\ShipmentMethodPriceDataImportPlugin;
use Spryker\Zed\ShipmentDataImport\Communication\Plugin\ShipmentMethodStoreDataImportPlugin;
class DataImportDependencyProvider extends SprykerDataImportDependencyProvider
{
/**
* @return array
*/
protected function getDataImporterPlugins(): array
{
return [
new ShipmentDataImportPlugin(),
new ShipmentMethodPriceDataImportPlugin(),
new ShipmentMethodStoreDataImportPlugin(),
];
}
}
Enable the behaviors by registering the console commands:
src/Pyz/Zed/Console/ConsoleDependencyProvider.php
<?php
namespace Pyz\Zed\Console;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\Console\ConsoleDependencyProvider as SprykerConsoleDependencyProvider;
use Spryker\Zed\DataImport\Communication\Console\DataImportConsole;
use Spryker\Zed\ShipmentDataImport\ShipmentDataImportConfig;
class ConsoleDependencyProvider extends SprykerConsoleDependencyProvider
{
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Symfony\Component\Console\Command\Command[]
*/
protected function getConsoleCommands(Container $container)
{
$commands = [
new DataImportConsole(DataImportConsole::DEFAULT_NAME . ':' . ShipmentDataImportConfig::IMPORT_TYPE_SHIPMENT),
new DataImportConsole(DataImportConsole::DEFAULT_NAME . ':' . ShipmentDataImportConfig::IMPORT_TYPE_SHIPMENT_PRICE),
new DataImportConsole(DataImportConsole::DEFAULT_NAME . ':' . ShipmentDataImportConfig::IMPORT_TYPE_SHIPMENT_METHOD_STORE),
];
return $commands;
}
}
Run the following console command to import data:
console data:import:shipment
console data:import:shipment-price
console data:import:shipment-method-store
4) Set up Behavior
Configure the data import to use your data on the project level.
src/Pyz/Zed/ShipmentDataImport/ShipmentDataImportConfig
<?php
namespace Pyz\Zed\ShipmentDataImport;
use Generated\Shared\Transfer\DataImporterConfigurationTransfer;
use Spryker\Zed\ShipmentDataImport\ShipmentDataImportConfig as SprykerShipmentDataImportConfig;
class ShipmentDataImportConfig extends SprykerShipmentDataImportConfig
{
/**
* @return \Generated\Shared\Transfer\DataImporterConfigurationTransfer
*/
public function getShipmentDataImporterConfiguration(): DataImporterConfigurationTransfer
{
return $this->buildImporterConfiguration('shipment.csv', static::IMPORT_TYPE_SHIPMENT);
}
/**
* @return \Generated\Shared\Transfer\DataImporterConfigurationTransfer
*/
public function getShipmentMethodPriceDataImporterConfiguration(): DataImporterConfigurationTransfer
{
return $this->buildImporterConfiguration('shipment_price.csv', static::IMPORT_TYPE_SHIPMENT_PRICE);
}
}
Configure shipment GUI module with money and store plugins.
Plugin | Specification | Prerequisites | Namespace |
---|---|---|---|
MoneyCollectionFormTypePlugin |
Represents the money collection fields based on stores, currencies, and price types defined in the system. | None | Spryker\Zed\Money\Communication\Plugin\Form |
StoreRelationToggleFormTypePlugin |
Represents a store relation toggle form based on stores registered in the system. | None | Spryker\Zed\Store\Communication\Plugin\Form |
ShipmentTotalCalculatorPlugin |
Calculates shipment total using expenses. | None | Spryker\Zed\Shipment\Communication\Plugin\Calculation |
src/Pyz/Zed/ShipmentGui/ShipmentGuiDependencyProvider.php
<?php
namespace Pyz\Zed\ShipmentGui;
use Spryker\Zed\Kernel\Communication\Form\FormTypeInterface;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\Money\Communication\Plugin\Form\MoneyCollectionFormTypePlugin;
use Spryker\Zed\ShipmentGui\ShipmentGuiDependencyProvider as SprykerShipmentGuiDependencyProvider;
use Spryker\Zed\Store\Communication\Plugin\Form\StoreRelationToggleFormTypePlugin;
class ShipmentGuiDependencyProvider extends SprykerShipmentGuiDependencyProvider
{
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\Kernel\Communication\Form\FormTypeInterface
*/
protected function getMoneyCollectionFormTypePlugin(Container $container): FormTypeInterface
{
return new MoneyCollectionFormTypePlugin();
}
/**
* @return \Spryker\Zed\Kernel\Communication\Form\FormTypeInterface
*/
protected function getStoreRelationFormTypePlugin(): FormTypeInterface
{
return new StoreRelationToggleFormTypePlugin();
}
}
- You can see the list of shipment methods in the **Back Office > Administration > Shipments > Delivery Methods** section.
- You can see information about the shipment method in the **Back Office > Administration > Shipments > Delivery Methods > View** section.
- You can create the shipment method in the **Back Office > Administration > Shipments > Delivery Methods > Create** section.
- You can edit the shipment method in the **Back Office > Administration > Shipments > Delivery Methods > Edit** section.
- You can delete the shipment method in the **Back Office > Administration > Shipments > Delivery Methods > Delete** section.
src/Pyz/Zed/Calculation/CalculationDependencyProvider.php
<?php
namespace Pyz\Zed\Calculation;
use Spryker\Zed\Calculation\CalculationDependencyProvider as SprykerCalculationDependencyProvider;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\Shipment\Communication\Plugin\Calculation\ShipmentTotalCalculatorPlugin;
class CalculationDependencyProvider extends SprykerCalculationDependencyProvider
{
protected function getQuoteCalculatorPluginStack(Container $container)
{
return [
new ShipmentTotalCalculatorPlugin(),
];
}
}
Thank you!
For submitting the form