Presentation title here
Integrate your data into
OroCRM
CSV Import and Export
Sergey Zhuravel
https://github.com/sergeyz
https://twitter.com/sergey_zv
Presentation title here
Outline
1. Import and export - process overview
a. Jobs overview
b. Import schema
c. Export schema
2. Basic B2B Customer import and export
a. Fields configuration
b. Data converter
c. Import/export Strategy
d. Strategy events
e. Import and validation processors
f. Button configuraion reference
g. Export processor
h. Export template processor
3. Import and export customization
a. Data Converter with tags support
b. Tags Normalizer
c. Strategy with tags support
Presentation title here
Jobs overview
Job
Step Step Step Step
Presentation title here
Import Process Schema
Step
Reader
Processor
Writer
DataConverter Serializer Strategy
Import and Export
Presentation title here
Export Process Schema
Step
Reader
Processor
Writer
DataConverterSerializer
Import and Export
Presentation title here
Basic B2B Customer import and
export
• Configurable entity import and export process is
managed by EntityConfigBundle. Field configuration
is avalialable in “importexport” configuration scope.
• Minimum import/export configuration should 4 defined
services (DataConverter, Strategy,
Import/ImportValidation and Export Processors).
• In addition, it is possible to define processor to export
file template for data import
Import and Export
Presentation title here
Fields configuration
header – csv column header configuration,
default values is field label (if other are not
defined)
/**
* @ConfigField(
* defaultValues={
* "importexport"={
* "header"="B2BCustomer name"
* }
* }
* )
*/
protected $name;
Import and Export
Presentation title here
Fields configuration
identity – field is used to search entity by
import strategy
/**
* @ConfigField(
* defaultValues={
* "importexport"={
* "identity"=true
* }
* }
* )
*/
protected $name;
Import and Export
Presentation title here
Fields configuration
order – manages column order
/**
* @ConfigField(
* defaultValues={
* "importexport"={
* "order"=10
* }
* }
* )
*/
protected $name;
Import and Export
Presentation title here
Fields configuration
excluded – allows to exclude field from export
and import process
/**
* @ConfigField(
* defaultValues={
* "importexport"={
* "excluded"=true
* }
* }
* )
*/
protected $name;
Import and Export
Presentation title here
Fields configuration
full – used to manage related entities export and
import.
•true - export and import related entity fields
•false – export and import related entity identity fields only
/**
* @ConfigField(
* defaultValues={
* "importexport"={
* "full"=true
* }
* }
* )
*/
protected $name;
Import and Export
Presentation title here
Fields configuration
Import and Export
Presentation title here
Data Converter
• Data converter is responsible for headers
mapping and converting imported data to
nested representation of entity and its
relations.
• Use customized or
ConfigurableTableDataConverter
orocrm_sales.importexport.data_converter.b2bcustomer:
parent: oro_importexport.data_converter.configurable
Import and Export git checkout tags/step-1
Presentation title here
Strategy
• Strategy responsible for processing import
logic.
• Use customized or
ConfigurableTableDataConverter
orocrm_sales.importexport.strategy.b2bcustomer.add_or_replace:
parent: oro_importexport.strategy.configurable_add_or_replace
Import and Export git checkout tags/step-2
Presentation title here
orocrm_sales.importexport.processor.import.b2bcustomer:
parent: oro_importexport.processor.import_abstract
calls:
- [setDataConverter, [@orocrm_sales.importexport.data_converter.b2bcustomer]]
- [setStrategy, [@orocrm_sales.importexport.strategy.b2bcustomer.add_or_replace]]
tags:
- { name: oro_importexport.processor, type: import, entity: %orocrm_sales.b2bcustomer.entity.class%,
alias: orocrm_sales_b2bcustomer }
- { name: oro_importexport.processor, type: import_validation, entity: %orocrm_sales.b2bcustomer.entity.
class%, alias: orocrm_sales_b2bcustomer }
Import and validation processors definition
example
Import and Export
Presentation title here
Button configuration reference
{% include 'OroImportExportBundle:ImportExport:buttons.html.twig' with {
entity_class: entity_class,
exportProcessor: 'orocrm_sales_b2bcustomer',
exportTemplateProcessor: 'orocrm_sales_b2bcustomer',
importProcessor: 'orocrm_sales_b2bcustomer',
dataGridName: gridName,
importTitle: 'orocrm.sales.b2bcustomer.import'|trans
} %}
return [
'entity_class' => $this->container->getParameter('orocrm_sales.b2bcustomer.entity.class')
];
Import and Export git checkout tags/step-4
Presentation title here
Export processor
Export processor denormalizes objects
and converts plain data using
DataConverter
orocrm_sales.importexport.processor.export.b2bcustomer:
parent: oro_importexport.processor.export_abstract
calls:
- [setDataConverter, [@orocrm_sales.importexport.data_converter.b2bcustomer]]
tags:
- { name: oro_importexport.processor, type: export, entity: %orocrm_sales.b2bcustomer.entity.class%,
alias: orocrm_sales_b2bcustomer }
Import and Export git checkout tags/step-5
Presentation title here
Export template processor
Use registered fixture to export an example file.
parameters:
orocrm_sales.importexport.template_fixture.b2bcustomer.class:
OroCRMBundleSalesBundleImportExportTemplateFixtureB2bCustomerFixture
services:
orocrm_sales.importexport.template_fixture.b2bcustomer:
class: %orocrm_sales.importexport.template_fixture.b2bcustomer.class%
tags:
- { name: oro_importexport.template_fixture }
orocrm_sales.importexport.template_fixture.data_converter.b2bcustomer:
parent: oro_importexport.data_converter.template_fixture.configurable
orocrm_sales.importexport.processor.export_template.b2bcustomer:
parent: oro_importexport.processor.export_abstract
calls:
- [setDataConverter, [@orocrm_sales.importexport.template_fixture.data_converter.b2bcustomer]]
tags:
- { name: oro_importexport.processor, type: export_template, entity: %orocrm_sales.b2bcustomer.
entity.class%, alias: orocrm_sales_b2bcustomer }
Import and Export git checkout tags/step-6
Presentation title here
Import and export customization
Import and Export
Three steps are required for adding tags to import and
exprort:
1. Create DataConverter with tags to Tags List header
conversion rule and two methods to convert tag names
list
2. Add Normalizer to load tags by their names
3. Add Strategy to save taggins
Presentation title here
Custom Data Converter
use OroBundleImportExportBundleConverterAbstractTableDataConverter;
class B2BCustomerDataConverter extends AbstractTableDataConverter
{
/**
* {@inheritdoc}
*/
protected function getHeaderConversionRules()
{
return [
'ID' => 'id',
'Name' => 'name',
'Channel' => 'channel:name',
];
}
/**
* {@inheritdoc}
*/
protected function getBackendHeader()
{
return ['id', 'name', 'channel'];
}
}
Import and Export git checkout tags/step-7
Presentation title here
Normalizers
• Import and export use extended Serializer Component.
• Serializer converts plain data to entities and back using
normalizers.
• Oro Serialier and Normalizers have additional parameter
“context” to make normalization process more flexible.
orocrm_sales.importexport.normalizer.b2bcustomer:
parent: oro_importexport.serializer.configurable_entity_normalizer
tags:
- { name: oro_importexport.normalizer }
Import and Export git checkout tags/step-8
Presentation title here
Custom Normalizer
use OroBundleImportExportBundleSerializerNormalizerDenormalizerInterface;
use OroBundleImportExportBundleSerializerNormalizerNormalizerInterface;
use OroCRMBundleSalesBundleEntityB2bCustomer;
class B2BCustomerNormalizer implements NormalizerInterface, DenormalizerInterface
{
/**
* {@inheritdoc}
*/
public function denormalize($data, $class, $format = null, array $context = [])
{
return new B2bCustomer();
}
/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = null, array $context = [])
{
return $type === 'OroCRMBundleSalesBundleEntityB2bCustomer';
}
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
{
/** @var B2BCustomer $object */
return ['name' => $object->getName()];
}
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null, array $context = [])
{
return $data instanceof B2bCustomer;
}
}
Import and Export
Presentation title here
Custom Strategy
use OroBundleImportExportBundleStrategyStrategyInterface
use OroCRMBundleSalesBundleEntityB2bCustomer;
class B2BCustomerStrategy extends StrategyInterface
{
/**
* @param B2BCustomer $entity
*
* {@inheritdoc}
*/
public function process($entity)
{
if (!$entity->getDataChannel()) {
return null;
}
return $entity;
}
}
Import and Export git checkout tags/step-9
Presentation title here
Strategy Events
namespace OroBundleImportExportBundleEvent;
use SymfonyComponentEventDispatcherEvent;
class StrategyEvent extends Event
{
const PROCESS_BEFORE = 'oro_importexport.strategy.process_before';
const PROCESS_AFTER = 'oro_importexport.strategy.process_after';
Import and Export
Presentation title here
Batch Job and services customization
● https://github.com/akeneo/BatchBundle
● http://docs.spring.io/spring-batch/reference/html/domain.html
● https://github.com/orocrm/OroCRMMailChimpBundle/tree/master/ImportExport/Step
Batch job events
● https://github.com/akeneo/BatchBundle/blob/master/Event/EventInterface.php
Documentation
● https://github.com/orocrm/documentation/blob/master/book/importexport.rst
● https://github.
com/orocrm/documentation/blob/master/cookbook/how_to_accelerate_import.rst
● https://github.
com/orocrm/platform/blob/master/src/Oro/Bundle/ImportExportBundle/Resources/doc/i
ndex.md
Sources
● https://github.com/sergeyz/crm-b2bcustomer-import
Information
Import and Export
Presentation title here
Q/A
Import and Export

More Related Content

PDF
Adding custom ui controls to your application (1)
PDF
Customizing oro crm webinar
PDF
OroCRM Partner Technical Training: September 2015
PDF
Working with oro crm entities
PDF
Resting with OroCRM Webinar
PPTX
Data Localization and Translation
PPTX
OroCRM Technology Webinar May 28, 2014
PDF
Controllers and context programming
Adding custom ui controls to your application (1)
Customizing oro crm webinar
OroCRM Partner Technical Training: September 2015
Working with oro crm entities
Resting with OroCRM Webinar
Data Localization and Translation
OroCRM Technology Webinar May 28, 2014
Controllers and context programming

What's hot (20)

PPT
ExtJs Basic Part-1
KEY
Php Unit With Zend Framework Zendcon09
PDF
Hidden Docs in Angular
PDF
What You Need To Build Cool Enterprise Applications With JSF
PPTX
Spring jdbc
PDF
Securing JSF Applications Against the OWASP Top Ten
PDF
Web注入+http漏洞等描述
PDF
RichFaces 4: Rich Ajax Components For Your JSF Applications
PPTX
Application package
PDF
Documenting from the Trenches
PDF
Dynamic binding
PDF
Add on packages
PPS
Java rmi example program with code
PDF
.NET Core, ASP.NET Core Course, Session 13
PPTX
Mike Taulty MIX10 Silverlight Frameworks and Patterns
PDF
Java Enterprise Edition
PPT
Java Server Faces (JSF) - advanced
PDF
Unit testing after Zend Framework 1.8
PDF
Alv for web
PPTX
Mike Taulty OData (NxtGen User Group UK)
ExtJs Basic Part-1
Php Unit With Zend Framework Zendcon09
Hidden Docs in Angular
What You Need To Build Cool Enterprise Applications With JSF
Spring jdbc
Securing JSF Applications Against the OWASP Top Ten
Web注入+http漏洞等描述
RichFaces 4: Rich Ajax Components For Your JSF Applications
Application package
Documenting from the Trenches
Dynamic binding
Add on packages
Java rmi example program with code
.NET Core, ASP.NET Core Course, Session 13
Mike Taulty MIX10 Silverlight Frameworks and Patterns
Java Enterprise Edition
Java Server Faces (JSF) - advanced
Unit testing after Zend Framework 1.8
Alv for web
Mike Taulty OData (NxtGen User Group UK)
Ad

More from Oro Inc. (20)

PDF
Jary Carter Presents OroCRM
PDF
Best Practices For Taking Your B2B Company Online
PDF
Oro Revolutionizes B2B Commerce - OroMeetup NL, 2017
PPTX
How to Close More Deals with B2B eCommerce Systems
PPTX
Email is the digital key - dotmailer, Oro MeetUp, Paris
PPTX
B2B, soyez prêts pour la 2ème vague e-commerce - Akeneo, Oro MeetUp, Paris
PPTX
Comment April Moto met en place une relation client multicanal et augmente so...
PPTX
Revolutionizing CRM market & B2B eCommerce - Oro MeetUp in Paris
PPTX
Oro Meetup London - Allies: How can we really turn data into profit?
PPTX
Oro London Meetup - dotmailer: Faster, smarter, better, email marketing
PPTX
Oro Meetup in London - Oro product vision
PPTX
Webinar: “Create the Ultimate Customer Experience with Prestashop + OroCRM”
PDF
11.17.15 Webinar: “Merchants: deliver an outstanding experience to your custo...
PDF
11.10.15 Webinar: “Improving Magento performance with Blackfire.io”
PPTX
"New OroCRM Release Demo: Discover what’s new in the latest release of OroCRM...
PDF
Benefits of OroCRM + Magento Webinar
PDF
Benefits of Magento + OroCRM Webinar
PPTX
OroCRM Multi-Channel Webinar
PDF
Powerful Customer Service with OroCRM + Zendesk
PDF
Integration with presta shop webinar
Jary Carter Presents OroCRM
Best Practices For Taking Your B2B Company Online
Oro Revolutionizes B2B Commerce - OroMeetup NL, 2017
How to Close More Deals with B2B eCommerce Systems
Email is the digital key - dotmailer, Oro MeetUp, Paris
B2B, soyez prêts pour la 2ème vague e-commerce - Akeneo, Oro MeetUp, Paris
Comment April Moto met en place une relation client multicanal et augmente so...
Revolutionizing CRM market & B2B eCommerce - Oro MeetUp in Paris
Oro Meetup London - Allies: How can we really turn data into profit?
Oro London Meetup - dotmailer: Faster, smarter, better, email marketing
Oro Meetup in London - Oro product vision
Webinar: “Create the Ultimate Customer Experience with Prestashop + OroCRM”
11.17.15 Webinar: “Merchants: deliver an outstanding experience to your custo...
11.10.15 Webinar: “Improving Magento performance with Blackfire.io”
"New OroCRM Release Demo: Discover what’s new in the latest release of OroCRM...
Benefits of OroCRM + Magento Webinar
Benefits of Magento + OroCRM Webinar
OroCRM Multi-Channel Webinar
Powerful Customer Service with OroCRM + Zendesk
Integration with presta shop webinar
Ad

Import export.odp

  • 1. Presentation title here Integrate your data into OroCRM CSV Import and Export Sergey Zhuravel https://github.com/sergeyz https://twitter.com/sergey_zv
  • 2. Presentation title here Outline 1. Import and export - process overview a. Jobs overview b. Import schema c. Export schema 2. Basic B2B Customer import and export a. Fields configuration b. Data converter c. Import/export Strategy d. Strategy events e. Import and validation processors f. Button configuraion reference g. Export processor h. Export template processor 3. Import and export customization a. Data Converter with tags support b. Tags Normalizer c. Strategy with tags support
  • 3. Presentation title here Jobs overview Job Step Step Step Step
  • 4. Presentation title here Import Process Schema Step Reader Processor Writer DataConverter Serializer Strategy Import and Export
  • 5. Presentation title here Export Process Schema Step Reader Processor Writer DataConverterSerializer Import and Export
  • 6. Presentation title here Basic B2B Customer import and export • Configurable entity import and export process is managed by EntityConfigBundle. Field configuration is avalialable in “importexport” configuration scope. • Minimum import/export configuration should 4 defined services (DataConverter, Strategy, Import/ImportValidation and Export Processors). • In addition, it is possible to define processor to export file template for data import Import and Export
  • 7. Presentation title here Fields configuration header – csv column header configuration, default values is field label (if other are not defined) /** * @ConfigField( * defaultValues={ * "importexport"={ * "header"="B2BCustomer name" * } * } * ) */ protected $name; Import and Export
  • 8. Presentation title here Fields configuration identity – field is used to search entity by import strategy /** * @ConfigField( * defaultValues={ * "importexport"={ * "identity"=true * } * } * ) */ protected $name; Import and Export
  • 9. Presentation title here Fields configuration order – manages column order /** * @ConfigField( * defaultValues={ * "importexport"={ * "order"=10 * } * } * ) */ protected $name; Import and Export
  • 10. Presentation title here Fields configuration excluded – allows to exclude field from export and import process /** * @ConfigField( * defaultValues={ * "importexport"={ * "excluded"=true * } * } * ) */ protected $name; Import and Export
  • 11. Presentation title here Fields configuration full – used to manage related entities export and import. •true - export and import related entity fields •false – export and import related entity identity fields only /** * @ConfigField( * defaultValues={ * "importexport"={ * "full"=true * } * } * ) */ protected $name; Import and Export
  • 12. Presentation title here Fields configuration Import and Export
  • 13. Presentation title here Data Converter • Data converter is responsible for headers mapping and converting imported data to nested representation of entity and its relations. • Use customized or ConfigurableTableDataConverter orocrm_sales.importexport.data_converter.b2bcustomer: parent: oro_importexport.data_converter.configurable Import and Export git checkout tags/step-1
  • 14. Presentation title here Strategy • Strategy responsible for processing import logic. • Use customized or ConfigurableTableDataConverter orocrm_sales.importexport.strategy.b2bcustomer.add_or_replace: parent: oro_importexport.strategy.configurable_add_or_replace Import and Export git checkout tags/step-2
  • 15. Presentation title here orocrm_sales.importexport.processor.import.b2bcustomer: parent: oro_importexport.processor.import_abstract calls: - [setDataConverter, [@orocrm_sales.importexport.data_converter.b2bcustomer]] - [setStrategy, [@orocrm_sales.importexport.strategy.b2bcustomer.add_or_replace]] tags: - { name: oro_importexport.processor, type: import, entity: %orocrm_sales.b2bcustomer.entity.class%, alias: orocrm_sales_b2bcustomer } - { name: oro_importexport.processor, type: import_validation, entity: %orocrm_sales.b2bcustomer.entity. class%, alias: orocrm_sales_b2bcustomer } Import and validation processors definition example Import and Export
  • 16. Presentation title here Button configuration reference {% include 'OroImportExportBundle:ImportExport:buttons.html.twig' with { entity_class: entity_class, exportProcessor: 'orocrm_sales_b2bcustomer', exportTemplateProcessor: 'orocrm_sales_b2bcustomer', importProcessor: 'orocrm_sales_b2bcustomer', dataGridName: gridName, importTitle: 'orocrm.sales.b2bcustomer.import'|trans } %} return [ 'entity_class' => $this->container->getParameter('orocrm_sales.b2bcustomer.entity.class') ]; Import and Export git checkout tags/step-4
  • 17. Presentation title here Export processor Export processor denormalizes objects and converts plain data using DataConverter orocrm_sales.importexport.processor.export.b2bcustomer: parent: oro_importexport.processor.export_abstract calls: - [setDataConverter, [@orocrm_sales.importexport.data_converter.b2bcustomer]] tags: - { name: oro_importexport.processor, type: export, entity: %orocrm_sales.b2bcustomer.entity.class%, alias: orocrm_sales_b2bcustomer } Import and Export git checkout tags/step-5
  • 18. Presentation title here Export template processor Use registered fixture to export an example file. parameters: orocrm_sales.importexport.template_fixture.b2bcustomer.class: OroCRMBundleSalesBundleImportExportTemplateFixtureB2bCustomerFixture services: orocrm_sales.importexport.template_fixture.b2bcustomer: class: %orocrm_sales.importexport.template_fixture.b2bcustomer.class% tags: - { name: oro_importexport.template_fixture } orocrm_sales.importexport.template_fixture.data_converter.b2bcustomer: parent: oro_importexport.data_converter.template_fixture.configurable orocrm_sales.importexport.processor.export_template.b2bcustomer: parent: oro_importexport.processor.export_abstract calls: - [setDataConverter, [@orocrm_sales.importexport.template_fixture.data_converter.b2bcustomer]] tags: - { name: oro_importexport.processor, type: export_template, entity: %orocrm_sales.b2bcustomer. entity.class%, alias: orocrm_sales_b2bcustomer } Import and Export git checkout tags/step-6
  • 19. Presentation title here Import and export customization Import and Export Three steps are required for adding tags to import and exprort: 1. Create DataConverter with tags to Tags List header conversion rule and two methods to convert tag names list 2. Add Normalizer to load tags by their names 3. Add Strategy to save taggins
  • 20. Presentation title here Custom Data Converter use OroBundleImportExportBundleConverterAbstractTableDataConverter; class B2BCustomerDataConverter extends AbstractTableDataConverter { /** * {@inheritdoc} */ protected function getHeaderConversionRules() { return [ 'ID' => 'id', 'Name' => 'name', 'Channel' => 'channel:name', ]; } /** * {@inheritdoc} */ protected function getBackendHeader() { return ['id', 'name', 'channel']; } } Import and Export git checkout tags/step-7
  • 21. Presentation title here Normalizers • Import and export use extended Serializer Component. • Serializer converts plain data to entities and back using normalizers. • Oro Serialier and Normalizers have additional parameter “context” to make normalization process more flexible. orocrm_sales.importexport.normalizer.b2bcustomer: parent: oro_importexport.serializer.configurable_entity_normalizer tags: - { name: oro_importexport.normalizer } Import and Export git checkout tags/step-8
  • 22. Presentation title here Custom Normalizer use OroBundleImportExportBundleSerializerNormalizerDenormalizerInterface; use OroBundleImportExportBundleSerializerNormalizerNormalizerInterface; use OroCRMBundleSalesBundleEntityB2bCustomer; class B2BCustomerNormalizer implements NormalizerInterface, DenormalizerInterface { /** * {@inheritdoc} */ public function denormalize($data, $class, $format = null, array $context = []) { return new B2bCustomer(); } /** * {@inheritdoc} */ public function supportsDenormalization($data, $type, $format = null, array $context = []) { return $type === 'OroCRMBundleSalesBundleEntityB2bCustomer'; } /** * {@inheritdoc} */ public function normalize($object, $format = null, array $context = []) { /** @var B2BCustomer $object */ return ['name' => $object->getName()]; } /** * {@inheritdoc} */ public function supportsNormalization($data, $format = null, array $context = []) { return $data instanceof B2bCustomer; } } Import and Export
  • 23. Presentation title here Custom Strategy use OroBundleImportExportBundleStrategyStrategyInterface use OroCRMBundleSalesBundleEntityB2bCustomer; class B2BCustomerStrategy extends StrategyInterface { /** * @param B2BCustomer $entity * * {@inheritdoc} */ public function process($entity) { if (!$entity->getDataChannel()) { return null; } return $entity; } } Import and Export git checkout tags/step-9
  • 24. Presentation title here Strategy Events namespace OroBundleImportExportBundleEvent; use SymfonyComponentEventDispatcherEvent; class StrategyEvent extends Event { const PROCESS_BEFORE = 'oro_importexport.strategy.process_before'; const PROCESS_AFTER = 'oro_importexport.strategy.process_after'; Import and Export
  • 25. Presentation title here Batch Job and services customization ● https://github.com/akeneo/BatchBundle ● http://docs.spring.io/spring-batch/reference/html/domain.html ● https://github.com/orocrm/OroCRMMailChimpBundle/tree/master/ImportExport/Step Batch job events ● https://github.com/akeneo/BatchBundle/blob/master/Event/EventInterface.php Documentation ● https://github.com/orocrm/documentation/blob/master/book/importexport.rst ● https://github. com/orocrm/documentation/blob/master/cookbook/how_to_accelerate_import.rst ● https://github. com/orocrm/platform/blob/master/src/Oro/Bundle/ImportExportBundle/Resources/doc/i ndex.md Sources ● https://github.com/sergeyz/crm-b2bcustomer-import Information Import and Export