The document outlines the steps to integrate PrestaShop customer data into OroCRM, including:
1. Creating bundles, entities, and migrations to support the integration
2. Implementing a transport to connect to PrestaShop's API and store connection settings
3. Developing an iterator, converter, and normalizer to retrieve customers and map data between systems
4. Configuring a strategy and processor to import customer data into OroCRM
5. Using workflows to automatically create associated contacts and accounts upon customer import
The presentation concludes by noting potential issues that could arise with large or complex real-world integration projects.
2. Developer Training
Goals
- Overview of OroCRM integration techniques
- Demonstrate implementation of integration
with PrestaShop
- Share best practices
5. Developer Training
Introduction
OroImportExportBundle:
- provides abstraction for processors, converters, normalizers and strategies
OroIntegrationBundle:
- interaction between third party services and the platform
- provides abstraction for integrations, transports and connectors
8. Developer Training
Goals
- Create UI for PrestaShop Integration management
- Create PrestShop Customer entity
- Import Customers from PrestaShop into our custom entity
- Create associated Contacts and Accounts
Integration with PrestaShop
Integration with PrestaShop
9. Developer Training
Step 1: Bundle creation
src/OroTutorial/Bundle/PrestashopBundle
http://www.orocrm.com/documentation/index/current/cookbook/how-to-create-new-bundle
Note: need to set bundle priority > 20 since we depend on Account and
Contact bundles in oro/bundles.yml:
bundles:
- { name: OroTutorialBundlePrestashopBundleOroTutorialPrestashopBundle, priority: 99 }
Integration with PrestaShop
Integration with PrestaShop
10. Developer Training
Step 2: Integration Channel Type
- implements OroBundleIntegrationBundleProviderChannelInterface
- register with oro_integration.channel tag using unique type
Step 3: PrestaShop Customer entity
- extends BasePerson
- should use IntegrationEntityTrait
- should be a configurable entity (defined by annotation:
OroBundleEntityConfigBundleMetadataAnnotationConfig)
- remoteId should be a configurable field (defined by annotation:
OroBundleEntityConfigBundleMetadataAnnotationConfigField)
Integration with PrestaShop
Integration with PrestaShop
11. Developer Training
Integration with PrestaShop
Integration with PrestaShop
Step 4: Implement Transport
Responsibility of transport is communication between connector and channel
1. Implement transport type
- extends OroBundleIntegrationBundleProviderRestTransportAbstractRestTransport
- registered by oro_integration.transport tag with specified type and
channel_type
2. Create form to display on channel configuration page
- PrestaShop API requires API key and connection endpoint
3. Create entity that will store transport settings
- extends OroBundleIntegrationBundleEntityTransport
12. Developer Training
Integration with PrestaShop
Integration with PrestaShop
Step 5: Migrations
- create ot_prestashop_customer table
- add columns to oro_integration_transport to store connection settings
13. Developer Training
Integration with PrestaShop
Integration with PrestaShop
Step 6: Connector
Getting customers from PrestaShop that have been updated after our last sync
- create importexport.yml for suitability
- create batch_jobs.yml
Notes:
- we injected RegistryInterface to be able to retrieve last sync date
- importexport.yml is declared in extension file
14. Developer Training
Integration with PrestaShop
Integration with PrestaShop
Lets check what we have so far
we should be able to configure and create our custom
PrestaShop integration
15. Developer Training
Integration with PrestaShop
Integration with PrestaShop
Step 7: Iterator
- extends OroBundleIntegrationBundleProviderRestClientAbstractRestIterator
- implements methods:
loadPage()
getRowsFromPageData()
getTotalCountFromPageData()
Update RestTransport to use our iterator for retrieving customers from
Prestashop
16. Developer Training
Integration with PrestaShop
Integration with PrestaShop
Step 8: Data Converter
Data converter is responsible for converting header of import data
- basically a map of entity fields between source (PrestaShop) and target
(OroCRM)
- extends OroBundleImportExportBundleConverterAbstractTableDataConverter
- registered by tag oro_integration.connector and injected into processor
17. Developer Training
Integration with PrestaShop
Integration with PrestaShop
Step 9: Data Normalizer/Denormalizer
Required for converting array representation to entity objects and visa versa
- registered by oro_importexport.normalizer tag name
- extends ConfigurableEntityNormalizer from OroIntegrationBundle
(This is why we created our PrestaShop customer as a configurable entity )
- on denormalize() set current integration to PrestaShop customer
- introduced DateTimeNormalizer to take care in date/time format differences
18. Developer Training
Integration with PrestaShop
Integration with PrestaShop
Step 10: Strategy and Processor
Strategy
- extends OroBundleImportExportBundleStrategyImportConfigurableAddOrReplaceStrategy
- customize findExistingEntity() to filter entities by integration channel
- inject logger to show integration process
Processor
- extends OroBundleImportExportBundleProcessorImportProcessor
- no separate classes required for our simple case but we have to configure
processor in imporexport.yml
20. Developer Training
Integration with PrestaShop
Integration with PrestaShop
What about Contacts and Accounts?
Well utilize Workflow bundle and add a process definition into process.
yml that will:
- be triggered upon creation of new PrestaShop customer
- create new Contact associated to PrestaShop customer
- create new Account associated to the new Contact
Note: we need to make sure that job queue daemon is running to execute
our processes
21. Developer Training
Integration with PrestaShop
Integration with PrestaShop
use
oro:process:configuration:load
to load your changes from process.yml