diff --git a/Rakefile b/Rakefile index a460dc57fe8..2a0316d84ca 100644 --- a/Rakefile +++ b/Rakefile @@ -50,6 +50,8 @@ commonOptions = { /gcc.gnu.org\/[\.\w\-\/\?]+/, /github.com\/[\.\w\-\/\?]+/, /www.collect.ai\/[\.\w\-\/\?]+/, + /twitter.com\/[\.\w\-\/\?]+/, + /www.blackfire.io\/[\.\w\-\/\?]+/, /www.optimise-it.de\/[\.\w\-\/\?]+/ ], diff --git a/_includes/pbc/all/install-features/202304.0/install-the-service-points-feature.md b/_includes/pbc/all/install-features/202304.0/install-the-service-points-feature.md index db0f11254fc..f0dcf2e0074 100644 --- a/_includes/pbc/all/install-features/202304.0/install-the-service-points-feature.md +++ b/_includes/pbc/all/install-features/202304.0/install-the-service-points-feature.md @@ -1,3 +1,6 @@ + + + This document describes how to integrate the Service Points feature into a Spryker project. ## Install feature core @@ -7,7 +10,7 @@ To start feature integration, integrate the required features: ### Prerequisites -To start feature integration, overview and install the necessary features: +To start feature integration, integrate the required features: | NAME | VERSION | INTEGRATION GUIDE | |--------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------| @@ -28,12 +31,48 @@ Make sure that the following modules have been installed: | ServicePoint | vendor/spryker/service-point | | ServicePointDataImport | vendor/spryker/service-point-data-import | | ServicePointsBackendApi | vendor/spryker/service-points-backend-api | +| ServicePointSearch | vendor/spryker/service-point-search | {% endinfo_block %} ## 2) Set up database schema and transfer objects -Apply database changes and generate transfer changes: +1. Adjust the schema definition so entity changes trigger events. + +| AFFECTED ENTITY | TRIGGERED EVENTS | +|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------| +| spy_service_point | Entity.spy_service_point.create
Entity.spy_service_point.update
Entity.spy_service_point.delete | +| spy_service_point_address | Entity.spy_service_point_address.create
Entity.spy_service_point_address.update
Entity.spy_service_point_address.delete | +| spy_service_point_store | Entity.spy_service_point_store.create
Entity.spy_service_point_store.update
Entity.spy_service_point_store.delete | + +**src/Pyz/Zed/ServicePoint/Persistence/Propel/Schema/spy_service_point.schema.xml** + +```xml + + + + + + + +
+ + + + + +
+ + + + + +
+ +
+``` + +2. Apply database changes and generate transfer changes: ```bash console transfer:generate @@ -51,65 +90,63 @@ Make sure that the following changes have been applied in the database: | spy_service_point | table | created | | spy_service_point_store | table | created | | spy_service_point_address | table | created | +| spy_service_point_search | table | created | | spy_region.uuid | column | created | -{% endinfo_block %} - -{% info_block warningBox "Verification" %} - Make sure that propel entities have been generated successfully by checking their existence. Also, make generated entity classes extending respective Spryker core classes. -| CLASS NAMESPACE | EXTENDS | -|---------------------------------------------------------------|----------------------------------------------------------------------------------| -| \Orm\Zed\ServicePoint\Persistence\SpyServicePoint | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePoint | -| \Orm\Zed\ServicePoint\Persistence\SpyServicePointQuery | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointQuery | -| \Orm\Zed\ServicePoint\Persistence\SpyServicePointAddress | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointAddress | -| \Orm\Zed\ServicePoint\Persistence\SpyServicePointAddressQuery | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointAddressQuery | -| \Orm\Zed\ServicePoint\Persistence\SpyServicePointStore | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointStore | -| \Orm\Zed\ServicePoint\Persistence\SpyServicePointStoreQuery | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointStoreQuery | - -{% endinfo_block %} - -{% info_block warningBox "Verification" %} +| CLASS NAMESPACE | EXTENDS | +|--------------------------------------------------------------------|---------------------------------------------------------------------------------------| +| \Orm\Zed\ServicePoint\Persistence\SpyServicePoint | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePoint | +| \Orm\Zed\ServicePoint\Persistence\SpyServicePointQuery | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointQuery | +| \Orm\Zed\ServicePoint\Persistence\SpyServicePointAddress | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointAddress | +| \Orm\Zed\ServicePoint\Persistence\SpyServicePointAddressQuery | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointAddressQuery | +| \Orm\Zed\ServicePoint\Persistence\SpyServicePointStore | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointStore | +| \Orm\Zed\ServicePoint\Persistence\SpyServicePointStoreQuery | \Spryker\Zed\ServicePoint\Persistence\Propel\AbstractSpyServicePointStoreQuery | +| \Orm\Zed\ServicePointSearch\Persistence\SpyServicePointSearch | \Spryker\Zed\ServicePointSearch\Persistence\Propel\AbstractSpyServicePointSearch | +| \Orm\Zed\ServicePointSearch\Persistence\SpyServicePointSearchQuery | \Spryker\Zed\ServicePointSearch\Persistence\Propel\AbstractSpyServicePointSearchQuery | Make sure that the following changes have been applied in transfer objects: -| TRANSFER | TYPE | EVENT | PATH | -|---------------------------------------|-------|---------|------------------------------------------------------------------| -| ServicePoint | class | created | src/Generated/Shared/Transfer/ServicePoint | -| ServicePointCollection | class | created | src/Generated/Shared/Transfer/ServicePointCollection | -| ServicePointCollectionRequest | class | created | src/Generated/Shared/Transfer/ServicePointCollectionRequest | -| ServicePointCollectionResponse | class | created | src/Generated/Shared/Transfer/ServicePointCollectionResponse | -| ServicePointCriteria | class | created | src/Generated/Shared/Transfer/ServicePointCriteria | -| ServicePointConditions | class | created | src/Generated/Shared/Transfer/ServicePointConditions | -| ApiServicePointsAttributes | class | created | src/Generated/Shared/Transfer/ApiServicePointsAttributes | -| ApiServicePointAddressesAttributes | class | created | src/Generated/Shared/Transfer/ApiServicePointAddressesAttributes | -| StoreRelation | class | created | src/Generated/Shared/Transfer/StoreRelation | -| Store | class | created | Generated/Shared/Transfer/Store | -| Error | class | created | Generated/Shared/Transfer/Error | -| Sort | class | created | Generated/Shared/Transfer/Sort | -| Pagination | class | created | Generated/Shared/Transfer/Pagination | -| ErrorCollection | class | created | Generated/Shared/Transfer/ErrorCollection | -| DataImporterConfiguration | class | created | Generated/Shared/Transfer/DataImporterConfiguration | -| DataImporterReport | class | created | Generated/Shared/Transfer/DataImporterReport | -| CountryCriteria | class | created | Generated/Shared/Transfer/CountryCriteria | -| CountryConditions | class | created | Generated/Shared/Transfer/CountryConditions | -| Country | class | created | Generated/Shared/Transfer/Country | -| CountryCollection | class | created | Generated/Shared/Transfer/CountryCollection | -| Region | class | created | Generated/Shared/Transfer/Region | -| ServicePointAddressCollection | class | created | Generated/Shared/Transfer/ServicePointAddressCollection | -| ServicePointAddressCollectionRequest | class | created | Generated/Shared/Transfer/ServicePointAddressCollectionRequest | -| ServicePointAddressCollectionResponse | class | created | Generated/Shared/Transfer/ServicePointAddressCollectionResponse | -| ServicePointAddressCriteria | class | created | Generated/Shared/Transfer/ServicePointAddressCriteria | -| ServicePointAddressConditions | class | created | Generated/Shared/Transfer/ServicePointAddressConditions | -| ServicePointAddress | class | created | Generated/Shared/Transfer/ServicePointAddress | -| GlueRelationship | class | created | Generated/Shared/Transfer/GlueRelationship | +| TRANSFER | TYPE | EVENT | PATH | +|----------------------------------------|-------|---------|------------------------------------------------------------------| +| ServicePoint | class | created | src/Generated/Shared/Transfer/ServicePoint | +| ServicePointCollection | class | created | src/Generated/Shared/Transfer/ServicePointCollection | +| ServicePointCollectionRequest | class | created | src/Generated/Shared/Transfer/ServicePointCollectionRequest | +| ServicePointCollectionResponse | class | created | src/Generated/Shared/Transfer/ServicePointCollectionResponse | +| ServicePointCriteria | class | created | src/Generated/Shared/Transfer/ServicePointCriteria | +| ServicePointConditions | class | created | src/Generated/Shared/Transfer/ServicePointConditions | +| ApiServicePointsAttributes | class | created | src/Generated/Shared/Transfer/ApiServicePointsAttributes | +| ApiServicePointAddressesAttributes | class | created | src/Generated/Shared/Transfer/ApiServicePointAddressesAttributes | +| StoreRelation | class | created | src/Generated/Shared/Transfer/StoreRelation | +| Store | class | created | Generated/Shared/Transfer/Store | +| Error | class | created | Generated/Shared/Transfer/Error | +| Sort | class | created | Generated/Shared/Transfer/Sort | +| Pagination | class | created | Generated/Shared/Transfer/Pagination | +| ErrorCollection | class | created | Generated/Shared/Transfer/ErrorCollection | +| DataImporterConfiguration | class | created | Generated/Shared/Transfer/DataImporterConfiguration | +| DataImporterReport | class | created | Generated/Shared/Transfer/DataImporterReport | +| CountryCriteria | class | created | Generated/Shared/Transfer/CountryCriteria | +| CountryConditions | class | created | Generated/Shared/Transfer/CountryConditions | +| Country | class | created | Generated/Shared/Transfer/Country | +| CountryCollection | class | created | Generated/Shared/Transfer/CountryCollection | +| Region | class | created | Generated/Shared/Transfer/Region | +| ServicePointAddressCollection | class | created | Generated/Shared/Transfer/ServicePointAddressCollection | +| ServicePointAddressCollectionRequest | class | created | Generated/Shared/Transfer/ServicePointAddressCollectionRequest | +| ServicePointAddressCollectionResponse | class | created | Generated/Shared/Transfer/ServicePointAddressCollectionResponse | +| ServicePointAddressCriteria | class | created | Generated/Shared/Transfer/ServicePointAddressCriteria | +| ServicePointAddressConditions | class | created | Generated/Shared/Transfer/ServicePointAddressConditions | +| ServicePointAddress | class | created | Generated/Shared/Transfer/ServicePointAddress | +| GlueRelationship | class | created | Generated/Shared/Transfer/GlueRelationship | +| ServicePointSearchCollection | class | created | Generated/Shared/Transfer/ServicePointSearchCollection | +| ServicePointSearch | class | created | Generated/Shared/Transfer/ServicePointSearch | +| ServicePointSearchRequest | class | created | Generated/Shared/Transfer/ServicePointSearchRequest | {% endinfo_block %} ### 3) Set up configuration -1. To make the `service-points` and `service-point-addresses` resources protected, adjust the protected paths configuration: +To make the `service-points` and `service-point-addresses` resources protected, adjust the protected paths configuration: **src/Pyz/Shared/GlueBackendApiApplicationAuthorizationConnector/GlueBackendApiApplicationAuthorizationConnectorConfig.php** @@ -187,7 +224,7 @@ sp2,,DE,Julie-Wolfthorn-Straße,1,,Berlin,10115 | city | mandatory | string | Berlin | City | | zip_code | mandatory | string | 10115 | Zip code | -2. Enable data imports at your configuration file, e.g.: +2. Enable data imports at your configuration file—for example: **data/import/local/full_EU.yml** @@ -332,6 +369,316 @@ service_point.validation.service_point_uuid_is_not_unique,Ein Service Point mit console data:import glossary ``` +### 5) Configure export to Elasticsearch + +1. In `SearchElasticsearchConfig`, adjust Elasicsearch config: + +**src/Pyz/Shared/SearchElasticsearch/SearchElasticsearchConfig.php** + +```php + + */ + protected function getQueueConfiguration(): array + { + return [ + ServicePointSearchConfig::QUEUE_NAME_SYNC_SEARCH_SERVICE_POINT, + ]; + } +} +``` + +4. Register the new queue message processor: + +**src/Pyz/Zed/Queue/QueueDependencyProvider.php** + +```php + + */ + protected function getProcessorMessagePlugins(Container $container): array + { + return [ + ServicePointSearchConfig::QUEUE_NAME_SYNC_SEARCH_SERVICE_POINT => new SynchronizationSearchQueueMessageProcessorPlugin(), + ]; + } +} +``` + +5. Configure the synchronization pool: + +**src/Pyz/Zed/ServicePointSearch/ServicePointSearchConfig.php** + +```php + + */ + protected function getSynchronizationDataPlugins(): array + { + return [ + new ServicePointSynchronizationDataBulkRepositoryPlugin(), + ]; + } +} +``` + +**src/Pyz/Zed/Publisher/PublisherDependencyProvider.php** + +```php + + */ + protected function getPublisherTriggerPlugins(): array + { + return [ + new ServicePointPublisherTriggerPlugin(), + ]; + } +} +``` + +#### Register publisher plugins + +| PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE | +|-----------------------------------------|-----------------------------------------------------|---------------|-----------------------------------------------------------------------------------| +| ServicePointWritePublisherPlugin | Listens for events and publishes respective data. | None | Spryker\Zed\ServicePointSearch\Communication\Plugin\Publisher\ServicePoint | +| ServicePointDeletePublisherPlugin | Listens for events and unpublishes respective data. | None | Spryker\Zed\ServicePointSearch\Communication\Plugin\Publisher\ServicePoint | +| ServicePointAddressWritePublisherPlugin | Listens for events and publishes respective data. | None | Spryker\Zed\ServicePointSearch\Communication\Plugin\Publisher\ServicePointAddress | +| ServicePointStoreWritePublisherPlugin | Listens for events and publishes respective data. | None | Spryker\Zed\ServicePointSearch\Communication\Plugin\Publisher\ServicePointStore | + +**src/Pyz/Zed/Publisher/PublisherDependencyProvider.php** + +```php + + */ + protected function getPublisherPlugins(): array + { + return [ + new ServicePointWritePublisherPlugin(), + new ServicePointDeletePublisherPlugin(), + new ServicePointAddressWritePublisherPlugin(), + new ServicePointStoreWritePublisherPlugin(), + ]; + } +} +``` + +#### Register query expander and result formatter plugins + +| PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE | +|------------------------------------------------|-----------------------------------------------|---------------|------------------------------------------------------------------------| +| ServicePointSearchResultFormatterPlugin | Maps raw Elasticsearch results to a transfer. | None | Spryker\Client\ServicePointSearch\Plugin\Elasticsearch\ResultFormatter | +| SortedServicePointSearchQueryExpanderPlugin | Adds sorting to a search query. | None | Spryker\Client\ServicePointSearch\Plugin\Elasticsearch\Query | +| PaginatedServicePointSearchQueryExpanderPlugin | Adds pagination to a search query. | None | Spryker\Client\ServicePointSearch\Plugin\Elasticsearch\Query | +| StoreServicePointSearchQueryExpanderPlugin | Adds filtering by locale to a search query. | None | Spryker\Client\ServicePointSearch\Plugin\Elasticsearch\Query | + +**src/Pyz/Client/ServicePointSearch/ServicePointSearchDependencyProvider.php** + +```php + + */ + protected function getServicePointSearchResultFormatterPlugins(): array + { + return [ + new ServicePointSearchResultFormatterPlugin(), + ]; + } + + /** + * @return list<\Spryker\Client\SearchExtension\Dependency\Plugin\QueryExpanderPluginInterface> + */ + protected function getServicePointSearchQueryExpanderPlugins(): array + { + return [ + new StoreServicePointSearchQueryExpanderPlugin(), + new SortedServicePointSearchQueryExpanderPlugin(), + new PaginatedServicePointSearchQueryExpanderPlugin(), + ]; + } +} +``` + +{% info_block warningBox "Verification" %} + +1. Fill the `spy_service_point` table with some data and run `console publish:trigger-events -r service_point`. +2. Make sure that the `spy_service_point_search` table is filled with respective data per store. +3. Check Elasticearch documents and make sure data is structured in the following format: + +```yaml +{ + "store":"DE", + "type":"service_point", + "search-result-data":{ + "idServicePoint":123, + "uuid":"40320bdf-c2af-4dd8-8d09-4550ece4287d", + "name":"Service Point Name #1", + "key":"service-point-name-1", + "address":{ + "idServicePointAddress":44, + "uuid":"2f02b327-0165-46ea-88df-0190d9a1c242", + "address1":"Seeburger Str.", + "address2":"270", + "address3":"Block B", + "city":"Berlin", + "zipCode":"10115", + "country":{ + "iso2Code":"DE", + "name":"Germany" + }, + "region":{ + "name":"Saxony" + } + } + }, + "full-text-boosted":[ + "Service Point Name #1" + ], + "full-text":[ + "Service Point Name #1", + "Seeburger Str. 270 Block B", + "Berlin", + "10115", + "Germany", + "Saxony" + ], + "suggestion-terms":[ + "Service Point Name #1" + ], + "completion-terms":[ + "Service Point Name #1" + ], + "string-sort":{ + "city":"Berlin" + } +} +``` + +4. In the `spy_service_point_search` table, change some records and run `console sync:data service_point`. +5. Make sure that your changes have been synced to the respective Elasticsearch document. + +{% endinfo_block %} + ### 6) Set up behavior 1. To enable the Backend API, register the plugins: @@ -409,67 +756,71 @@ class GlueBackendApiApplicationGlueJsonApiConventionConnectorDependencyProvider {% info_block warningBox "Verification" %} -1. Make sure that you can send the following requests: - - * `POST https://glue-backend.mysprykershop.com/service-points` - ```json - { - "data": { - "type": "service-points", - "attributes": { - "name": "Some Service Point", - "key": "ssp", - "isActive": "true", - "stores": ["DE", "AT"] - } - } - } - ``` - * `PATCH https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}` - ```json - { - "data": { - "type": "service-points", - "attributes": { - "name": "Another Name" - } +Make sure that you can send the following requests: + +* `POST https://glue-backend.mysprykershop.com/service-points` + ```json + { + "data": { + "type": "service-points", + "attributes": { + "name": "Some Service Point", + "key": "ssp", + "isActive": "true", + "stores": ["DE", "AT"] } } - ``` - * `GET https://glue-backend.mysprykershop.com/service-points/` - * `GET https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}` - * `POST https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}/service-point-addresses` - ```json - { - "data": { - "type": "service-point-address", - "attributes": { - "address1": "address1", - "address2": "address2", - "address3": "address3", - "city": "city", - "zipCode": "10115", - "countryIso2Code": "DE" - } + } + ``` + +* `PATCH https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}` + ```json + { + "data": { + "type": "service-points", + "attributes": { + "name": "Another Name" } } - ``` - * `PATCH https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}/service-point-addresses/{{service-point-address-uuid}}` - ```json - { - "data": { - "type": "service-point-address", - "attributes": { - "address1": "another address1", - "address2": "another address2", - "address3": "another address3", - "city": "another city", - "zipCode": "20115", - "countryIso2Code": "AT" - } - } - } - ``` - * `GET https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}/service-point-addresses` + } + ``` + +* `GET https://glue-backend.mysprykershop.com/service-points/` +* `GET https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}` +* `POST https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}/service-point-addresses` + ```json + { + "data": { + "type": "service-point-address", + "attributes": { + "address1": "address1", + "address2": "address2", + "address3": "address3", + "city": "city", + "zipCode": "10115", + "countryIso2Code": "DE" + } + } + } + ``` + +* `PATCH https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}/service-point-addresses/{{service-point-address-uuid}}` + ```json + { + "data": { + "type": "service-point-address", + "attributes": { + "address1": "another address1", + "address2": "another address2", + "address3": "another address3", + "city": "another city", + "zipCode": "20115", + "countryIso2Code": "AT" + } + } + } + ``` + +* `GET https://glue-backend.mysprykershop.com/service-points/{{service-point-uuid}}/service-point-addresses` {% endinfo_block %} diff --git a/docs/scos/dev/feature-integration-guides/202304.0/install-the-service-points-feature.md b/docs/scos/dev/feature-integration-guides/202304.0/install-the-service-points-feature.md index f157e4a3d34..5305e7876ac 100644 --- a/docs/scos/dev/feature-integration-guides/202304.0/install-the-service-points-feature.md +++ b/docs/scos/dev/feature-integration-guides/202304.0/install-the-service-points-feature.md @@ -1,7 +1,7 @@ --- title: Install the Service Points feature description: Learn how to integrate the Service Points feature into your project -last_updated: May 02, 2023 +last_updated: May 10, 2023 template: feature-integration-guide-template ---