Merchant Product Restrictions feature integration
Edit on GitHubInstall Feature Core
Prerequisites
To start feature integration, overview and install the necessary features:
Name | Version |
---|---|
Product Lists | 2018.11.0 |
1) Install the required modules using Composer
Run the following command(s) to install the required modules:
composer require spryker-feature/merchant-product-restrictions:"^2018.11.0" --update-with-dependencies
Verification
Make sure that the following modules were installed:Module | Expected Directory |
---|---|
`MerchantRelationshipProductList` | `vendor/spryker/merchant-relationship-product-list` |
`MerchantRelationshipProductListDataImport` | `vendor/spryker/merchant-relationship-product-list-data-import` |
`MerchantRelationshipProductListGui` | `vendor/spryker/merchant-relationship-product-list-gui` |
2) Set up Database Schema
Run the following commands to apply database changes, as well as generate entity and transfer changes:
console transfer:generate
console propel:install
console transfer:generate
Verification
Make sure that the following changes have been applied by checking your database:Database entity | Type | Event |
---|---|---|
spy_product_list.fk_merchant_relationship | column | created |
3) Import Data
Import Merchant Relationship to Product Lists
Prepare your data according to your requirements using our demo data:
merchant_relation_key,product_list_key
mr-008,pl-001
mr-008,pl-002
mr-008,pl-003
mr-009,pl-004
mr-010,pl-005
mr-011,pl-006
mr-011,pl-007
mr-011,pl-00
Column | Is obligatory? | Data type | Data example | Data explanation |
---|---|---|---|---|
merchant_relation_key |
mandatory | string | mr-008 | Identifier of merchant relations. The merchant relations must exist already. |
product_list_key |
mandatory | string | pl-001 | Identifier of product lists. The product lists must exist already. |
Register the following plugin to enable data import: |
Plugin | Specification | Prerequisites | Namespace |
---|---|---|---|
MerchantRelationshipProductListDataImportPlugin |
Imports basic product list data into the database. |
|
Spryker\Zed\MerchantRelationshipProductListDataImport\Communication\Plugin |
src/Pyz/Zed/DataImport/DataImportDependencyProvider.php
<?php
namespace Pyz\Zed\DataImport;
use Spryker\Zed\DataImport\DataImportDependencyProvider as SprykerDataImportDependencyProvider;
use Spryker\Zed\MerchantRelationshipProductListDataImport\Communication\Plugin\MerchantRelationshipProductListDataImportPlugin;
class DataImportDependencyProvider extends SprykerDataImportDependencyProvider
{
/**
* @return array
*/
protected function getDataImporterPlugins(): array
{
return [
new MerchantRelationshipProductListDataImportPlugin(),
];
}
}
Run the following console command to import data:
console data:import merchant-relationship-product-list
Verification
Make sure that the configured data are added to the `spy_product_list` table in the database.
4) Set up Behaviour
Activate the following plugins:
Plugin | Specification | Prerequisites | Namespace |
---|---|---|---|
ProductListCustomerTransferExpanderPlugin |
|
None | Spryker\Zed\MerchantRelationshipProductList\Communication\Plugin\Customer |
MerchantRelationshipProductListOwnerTypeFormExpanderPlugin |
|
None | Spryker\Zed\MerchantRelationshipProductListGui\Communication\Plugin\ProductListGuiExtension |
MerchantRelationshipTableExpanderPlugin |
Provides table header, config and data extensions for product lists with merchant relationship owner type. | None | Spryker\Zed\MerchantRelationshipProductListGui\Communication\Plugin\ProductListGuiExtension |
src/Pyz/Zed/Customer/CustomerDependencyProvider.php
<?php
namespace Pyz\Zed\Customer;
use Spryker\Zed\Customer\CustomerDependencyProvider as SprykerCustomerDependencyProvider;
use Spryker\Zed\MerchantRelationshipProductList\Communication\Plugin\Customer\ProductListCustomerTransferExpanderPlugin;
class CustomerDependencyProvider extends SprykerCustomerDependencyProvider
{
/**
* @return \Spryker\Zed\Customer\Dependency\Plugin\CustomerTransferExpanderPluginInterface[]
*/
protected function getCustomerTransferExpanderPlugins()
{
return [
new ProductListCustomerTransferExpanderPlugin(),
];
}
}
src/Pyz/Zed/ProductListGui/ProductListGuiDependencyProvider.php
<?php
namespace Pyz\Zed\ProductListGui;
use Spryker\Zed\MerchantRelationshipProductListGui\Communication\Plugin\ProductListGuiExtension\MerchantRelationshipProductListOwnerTypeFormExpanderPlugin;
use Spryker\Zed\MerchantRelationshipProductListGui\Communication\Plugin\ProductListGuiExtension\MerchantRelationshipTableExpanderPlugin;
use Spryker\Zed\ProductListGui\ProductListGuiDependencyProvider as SprykerProductListGuiDependencyProvider;
class ProductListGuiDependencyProvider extends SprykerProductListGuiDependencyProvider
{
/**
* @return \Spryker\Zed\ProductListGuiExtension\Dependency\Plugin\ProductListOwnerTypeFormExpanderPluginInterface[]
*/
protected function getProductListOwnerTypeFormExpanderPlugins(): array
{
return [
new MerchantRelationshipProductListOwnerTypeFormExpanderPlugin(),
];
}
/**
* @return \Spryker\Zed\ProductListGuiExtension\Dependency\Plugin\ProductListTableConfigExpanderPluginInterface[]
*/
protected function getProductListTableConfigExpanderPlugins(): array
{
return [
new MerchantRelationshipTableExpanderPlugin(),
];
}
/**
* @return \Spryker\Zed\ProductListGuiExtension\Dependency\Plugin\ProductListTableDataExpanderPluginInterface[]
*/
protected function getProductListTableDataExpanderPlugins(): array
{
return [
new MerchantRelationshipTableExpanderPlugin(),
];
}
/**
* @return \Spryker\Zed\ProductListGuiExtension\Dependency\Plugin\ProductListTableDataExpanderPluginInterface[]
*/
protected function getProductListTableHeaderExpanderPlugins(): array
{
return [
new MerchantRelationshipTableExpanderPlugin(),
];
}
}
Verification
Make sure that when creating or editing a product list in Zed, you can select the merchant relationship as an owner type and see the selected value in the list of product lists.Also make sure that when a customer (with an assigned merchant relationship that has assigned product lists
Thank you!
For submitting the form