This is a module for integration with the Bloomreach service.
- Magento 2.3, 2.4
- PHP 7.3, 7.4, 8.1, 8.2
- composer config repositories.bloomreach git https://github.com/exponea/bloomreach-magento2-integration.git
- composer require bloomreach/bloomreach-engagement-connector-magento
Check to see if your Magento instance has an app/code directory structure. If not, create it manually.
- Then create 2 more directories with this path:
Bloomreach/EngagementConnector
. The final path should look like:app/code/Bloomreach/EngagementConnector
- Extract the downloaded zip folder and move the content of the extracted folder to this path:
app/code/Bloomreach/EngagementConnector
- bin/magento maintenance:enable
- bin/magento module:enable Bloomreach_EngagementConnector
- bin/magento deploy:mode:set production
- bin/magento cache:clean
- bin/magento maintenance:disable
- bin/magento module:enable Bloomreach_EngagementConnector
- bin/magento setup:upgrade
- bin/magento cache:clean
bloomreach_export_queue
- contains a queue of prepared data waiting to be exported.bloomreach_export_entity
- contains the identifiers of the entities to be added to the export queue.bloomreach_initial_export_status
- stores the initial export data (Current export status, export progress, export errors)
bloomreach_add_to_export_queue
- prepares the entities that are waiting to be exported and adds them to the export queue.bloomreach_run_export
- exports data from the export queue to the Bloomreach service.bloomreach_clean_export_queue
- cleans export queue data from database.bloomreach_clean_csv
- cleans csv export files.bloomreach_export_queue_error_notification
- sends export error notifications.
- Responsible class:
Bloomreach\EngagementConnector\Console\Command\AddToExportQueue
- The command:
bin/magento bloomreach:add-to-export-queue
- Responsible class:
Bloomreach\EngagementConnector\Console\Command\StartExport
. The command:
bin/magento bloomreach:export-start --import_id="*********" --csv_file_path="*****" --test_connection="1"
Using the options, you can run the export from a specific csv file.
Where:
- import_id - ID of necessary import, can be taken from the Bloomreach
- csv_file_path - path of the CSV file
-
- test_connection - set "1" to run a test connection (not required)
- Responsible class:
Bloomreach\EngagementConnector\Console\Command\CleanCsvFilesCommand
- The command:
bin/magento bloomreach:clean-csv-files
- Responsible class:
Bloomreach\EngagementConnector\Console\Command\CleanExportQueueCommand
- The command:
bin/magento bloomreach:clean-export-queue
If the module was installed through composer, it can be uninstalled using the magento uninstall command:
bin/magento module:uninstall Bloomreach_EngagementConnector
If the module was installed manually, then you need to do the following steps to completely remove all data:
- bin/magento maintenance:enable
- bin/magento module:disable Bloomreach_EngagementConnector
- delete
MAGENTO_ROOT/app/code/Bloomreach/EngagementConnector
folder; - delete
MAGENTO_ROOT/var/bloomreach
folder; - delete
bloomreach_export_queue
,bloomreach_export_entity
,bloomreach_initial_export_status
tables from database; - delete system configs
WHERE path LIKE 'bloomreach_engagement%'
- bin/magento setup:upgrade
- bin/magento deploy:mode:set production
- bin/magento cache:clean
- bin/magento maintenance:disable
- bin/magento module:disable Bloomreach_EngagementConnector
- delete
MAGENTO_ROOT/app/code/Bloomreach/EngagementConnector
folder; - delete
MAGENTO_ROOT/var/bloomreach
folder; - delete
bloomreach_export_queue
,bloomreach_export_entity
,bloomreach_initial_export_status
tables from database; - delete system configs
WHERE path LIKE 'bloomreach_engagement%'
- bin/magento setup:upgrade
- bin/magento cache:clean
MAGENTO_ROOT/var/log/bloomreach/engagement_connector.log
- contains errors informationMAGENTO_ROOT/var/log/bloomreach/debug.log
- contains debugging information
- Value: 1
- Label: DISABLED
- Initial Export has the DISABLED status if a certain feed is disabled in the system configuration.
- Value: 2
- Label: NOT READY
- Initial Export has the NOT READY status if a certain feed is enabled in the system configuration and import_id setting is not specified.
- Value: 3
- Label: READY
- Initial Export has the READY status if a certain feed is enabled in the system configuration and import_id setting is specified and export has not started yet.
- Value: 4
- Label: SCHEDULED
- Initial Export has the SCHEDULED status if a certain feed is enabled in the system configuration and import_id setting is specified and Start action was triggered.
- Value: 5
- Label: PROCESSING
- Initial Export has the PROCESSING status if a certain feed is enabled in the system configuration and import_id setting is specified and export has started.
- Value: 6
- Label: ERROR
- Initial Export has the ERROR status if a certain feed is enabled in the system configuration and import_id setting is specified and export has finished with errors.
- Value: 7
- Label: SUCCESS
- Initial Export has the SUCCESS status if a certain feed is enabled in the system configuration and import_id setting is specified and export has finished successfully.
- Value: 1
- Label: PENDING
- Queue Item has the PENDING status if an item has not sent yet.
- Value: 2
- Label: IN PROGRESS
- Queue Item has the IN PROGRESS status if sending is in progress.
- Value: 3
- Label: ERROR
- Queue Item has the ERROR status f an error occurred while sending.
- Value: 4
- Label: COMPLETE
- Queue Item has the COMPLETE status if an item was sent successfully.
Bloomreach\EngagementConnector\Model\DataMapping\DataMapperResolver
- responsible for map Magento entity data to the Bloomreach data. ReturnsMagento\Framework\DataObject
;
bloomreach_entity_mapping.xml
- allows you to configure field mapping
entity_type
- entity type to map;bloomreach_code
- the name of the key on the Bloomreach side;field
- field to map withbloomreach_code
.
- Add entity configuration to the
bloomreach_entity_mapping.xml
.
<entity_type entity="custom_entity">
<bloomreach_code code="entity_id">
<field code="entity_id" />
</bloomreach_code>
<bloomreach_code code="created_at">
<field code="created_at" />
</bloomreach_code>
<bloomreach_code code="updated_at">
<field code="updated_at" />
</bloomreach_code>
</entity_type>
- Create a class that implements
Bloomreach\EngagementConnector\Model\DataMapping\DataMapper\DataMapperInterface
- Pass your Mapper to the
Bloomreach\EngagementConnector\Model\DataMapping\DataMapperFactory
viadi.xml
<type name="Bloomreach\EngagementConnector\Model\DataMapping\DataMapperFactory">
<arguments>
<argument name="dataMappers" xsi:type="array">
<item name="custom_entity" xsi:type="string">
Vendor\Name\Model\DataMapping\DataMapper\Custom
</item>
</argument>
</arguments>
</type>
Optional. If you want to use a separate renderer for the field you need:
- Create a class that implements
Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\RenderInterface
- Pass your Renderer to the
Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRendererResolver
viadi.xml
and specify the entity type and field code:
<type name="Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRendererResolver">
<arguments>
<argument name="fieldValueRenderers" xsi:type="array">
<item name="custom_entity" xsi:type="array">
<item name="entity_id" xsi:type="object">
Vendor\Name\Model\DataMapping\FieldValueRenderer\CustomRenderer\EntityIdRenderer
</item>
</item>
</argument>
</arguments>
</type>
- Use
Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRendererResolver
in the mapper class to get field value.
- Create a class that implements
Bloomreach\EngagementConnector\Model\DataMapping\DataMapper\DataMapperInterface
- Pass your Mapper to the
Bloomreach\EngagementConnector\Model\DataMapping\DataMapper\ProductMapperResolver
viadi.xml
and specifyproductTypeId
as the name of the argument
<type name="Bloomreach\EngagementConnector\Model\DataMapping\DataMapper\ProductMapperResolver">
<arguments>
<argument name="dataMappers" xsi:type="array">
<item name="configurable" xsi:type="object">
Vendor\Name\Model\DataMapping\DataMapper\Product\Configurable
</item>
</argument>
</arguments>
</type>
- Create a class that implements
Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\RenderInterface
- Pass your Renderer to the
Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRendererResolver
viadi.xml
and specify theentity_type
andfield
code as name of items:
<type name="Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRendererResolver">
<arguments>
<argument name="fieldValueRenderers" xsi:type="array">
<item name="catalog_product" xsi:type="array">
<item name="custom_field" xsi:type="object">
Vendor\Name\Model\DataMapping\FieldValueRenderer\Product\CustomRenderer
</item>
</item>
</argument>
</arguments>
</type>
- Create a class that implements
Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\RenderInterface
- Pass your Renderer to the
Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\Product\ProductTypeRendererResolver
viadi.xml
and specify theproductTypeId
andfield
code as name of items:
<type name="Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\Product\ProductTypeRendererResolver">
<arguments>
<argument name="fieldValueRenderers" xsi:type="array">
<item name="simple" xsi:type="array">
<item name="entity_id" xsi:type="object">
Vendor\Name\Model\DataMapping\FieldValueRenderer\Product\Simple\EntityIdRenderer
</item>
</item>
</argument>
</arguments>
</type>
- Create a class that implements
Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\RenderInterface
- Pass your Renderer to the
Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRendererResolver
viadi.xml
and specify theentity_type
andfield
code as name of items:
<type name="Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRendererResolver">
<arguments>
<argument name="fieldValueRenderers" xsi:type="array">
<item name="catalog_product" xsi:type="array">
<item name="entity_id" xsi:type="object">
Vendor\Name\Model\DataMapping\FieldValueRenderer\Product\\EntityIdRenderer
</item>
</item>
</argument>
</arguments>
</type>
- Create
bloomreach_entity_mapping.xml
in file in your module. - Add a new
bloomreach_code
node toentity_type
that you want to extend
<entity_type entity="catalog_product">
<bloomreach_code code="custom_code">
<field code="custom_field" />
</bloomreach_code>
</entity_type>
- Create
bloomreach_entity_mapping.xml
in file in your module. - Add
disabled
equaltrue
tobloomreach_code
that you want to exclude from mapping
<entity_type entity="catalog_product">
<bloomreach_code code="entity_id" disabled="true" />
</entity_type>
- Create
bloomreach_entity_mapping.xml
in file in your module. - Add a
field
node tobloomreach_code
node that you want to change
<entity_type entity="catalog_product">
<bloomreach_code code="title">
<field code="custom_field" />
</bloomreach_code>
</entity_type>
Bloomreach\EngagementConnector\Model\Export\QueueProcessor
- obtains the entities that need to be exported, prepares them and adds them to the export queue.Bloomreach\EngagementConnector\Model\Export\ExportProcessor
- obtaining data from export queue and send them to the Bloomreach service.Bloomreach\EngagementConnector\Model\Export\File\DirectoryProvider
- allows to create and retrieve a directory where the export file should be placed.Bloomreach\EngagementConnector\Model\Export\Transporter\TransporterResolver
- sends data to a specific endpoint, for a specific entity type, to the Bloomreach.
- Pass directory name to the
Bloomreach\EngagementConnector\Model\Export\File\DirectoryProvider
viadi.xml
and specify theentity_type
as name of items:
<type name="Bloomreach\EngagementConnector\Model\Export\File\DirectoryProvider">
<arguments>
<argument name="entityDirectories" xsi:type="array">
<item name="catalog_product" xsi:type="string">catalog_product</item>
</argument>
</arguments>
</type>
- Add your entity type to the Entity Provider:
<type name="Bloomreach\EngagementConnector\Model\DataProvider\EntityType">
<arguments>
<argument name="entityTypes" xsi:type="array">
<item name="catalog_product" xsi:type="string">Product Feed</item>
</argument>
</arguments>
</type>
- Create Data Mapping for the new entity.
- Optional If you add an event to the export, you will need to add register fields by which Bloomreach recognizes which customer this event belongs to.
- Add
customer_id
andemail_id
fields to the mapping configuration.
<entity_type entity="purchase">
<bloomreach_code code="email_id">
<field code="customer_email"/>
</bloomreach_code>
<bloomreach_code code="customer_id">
<field code="customer_id"/>
</bloomreach_code>
</entity_type>
- Make sure your entity contains these fields. (If not, implement them using the DataMapper approach).
- Use
Bloomreach\EngagementConnector\Model\DataMapping\DataMapper\RegisteredMapper
in yourDataMapper
to map registered fields.
- Pass collection class to the
Bloomreach\EngagementConnector\Model\Export\Entity\CollectionFactory
viadi.xml
:
<type name="Bloomreach\EngagementConnector\Model\Export\Entity\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="catalog_product" xsi:type="string">
Magento\Catalog\Model\ResourceModel\Product\Collection
</item>
</argument>
</arguments>
</type>
- Add you entity type to the
Bloomreach\EngagementConnector\Model\InitialExport\Action\Configure\Import\Request\BuilderComposite
viadi.xml
and specify needed request builder:
<type name="Bloomreach\EngagementConnector\Model\InitialExport\Action\Configure\Import\Request\BuilderComposite">
<arguments>
<argument name="builderPool" xsi:type="array">
<item name="catalog_product" xsi:type="string">Bloomreach\EngagementConnector\Model\InitialExport\Action\Configure\Import\Request\Entity\Catalog</item>
</argument>
</arguments>
</type>
- Create a system config
feed_enable
, - Create a system config for
import_id
, - Optional Create a system config for
catalog_id
if your entity is a catalog, - Pass your configs to the
ConfigPathGetter
class viadi.xml
:
<type name="Bloomreach\EngagementConnector\System\ConfigPathGetter">
<arguments>
<argument name="configPool" xsi:type="array">
<item name="catalog_product" xsi:type="array">
<item name="feed_enabled" xsi:type="string">bloomreach_engagement/catalog_product_feed/enabled</item>
<item name="import_id" xsi:type="string">bloomreach_engagement/catalog_product_feed/import_id</item>
<item name="catalog_id" xsi:type="string">bloomreach_engagement/catalog_product_feed/catalog_id</item>
</item>
</argument>
</arguments>
</type>
- Create class that implements
Bloomreach\EngagementConnector\Model\Export\Transporter\TransporterInterface
. - Pass your transporter class to the
Bloomreach\EngagementConnector\Model\Export\Transporter\TransporterResolver
viadi.xml
and specify theentity_type
andapi_type
as name of items:
<type name="Bloomreach\EngagementConnector\Model\Export\Transporter\TransporterResolver">
<arguments>
<argument name="transporters" xsi:type="array">
<item name="csv_export" xsi:type="array">
<item name="default" xsi:type="object">
Bloomreach\EngagementConnector\Model\Export\Transporter\InitialExport\DefaultTransporter
</item>
</item>
</argument>
</arguments>
</type>
- Create a data mapper for your entity type.
- Use a
Bloomreach\EngagementConnector\Model\Export\Queue\AddEventToExportQueue
class to add you event to export queue. - Optional If you want to use a separate API to send data to the Bloomreach, you can implement other transporter. Pass your transporter class to the
Bloomreach\EngagementConnector\Model\Export\Transporter\TransporterResolver
viadi.xml
and specify theentity_type
andapi_type
as name of items:
<type name="Bloomreach\EngagementConnector\Model\Export\Transporter\TransporterResolver">
<arguments>
<argument name="transporters" xsi:type="array">
<item name="event" xsi:type="array">
<item name="custom_entity" xsi:type="object">
Bloomreach\EngagementConnector\Model\Export\Transporter\Event\CustomEntityTransporter
</item>
</item>
</argument>
</arguments>
</type>
- Optional If you want to send event using batch api endpoint, pass entity type to
Bloomreach\EngagementConnector\Model\Export\Queue\Batch\CommandNameGetter
:
<type name="Bloomreach\EngagementConnector\Model\Export\Queue\Batch\CommandNameGetter">
<arguments>
<argument name="commandNamePool" xsi:type="array">
<item name="event" xsi:type="array">
<item name="purchase" xsi:type="string">customers/events</item>
<item name="purchase_item" xsi:type="string">customers/events</item>
</item>
</argument>
</arguments>
</type>
{
"eventName": "view_item",
"eventBody": {
"sku": "WS02",
"price": "120.00"
}
}
- Prepare event object:
{
"eventName": "view_item",
"eventBody": {
"sku": "WS02",
"price": "120.00"
}
}
- Use
Bloomreach_EngagementConnector/js/tracking/event-sender
component to send an event.
- Create a class that implements
\Bloomreach\EngagementConnector\Model\Tracking\Event\EventsInterface
and\Magento\Framework\View\Element\Block\ArgumentInterface
interfaces. - Create child block for
bloomreach.engagement.connector.tracking
in the layout. - Use
Bloomreach\EngagementConnector\Block\Tracking\Event
class for event block. - Pass your event class to event block via arguments with name
events
. - Use
Bloomreach_EngagementConnector::tracking/event/default.phtml
template for send event
<referenceBlock name="bloomreach.engagement.connector.tracking">
<block class="Bloomreach\EngagementConnector\Block\Tracking\Event"
name="bloomreach.engagement.connector.custom.event.tracking"
after="-"
template="Bloomreach_EngagementConnector::tracking/event/default.phtml">
<arguments>
<argument name="events" xsi:type="object">
Bloomreach\EngagementConnector\Model\Tracking\Event\ProductPage\ViewItem
</argument>
</arguments>
</block>
</referenceBlock>
- Create a class that implements
\Bloomreach\EngagementConnector\Model\Tracking\Event\EventsInterface
interface. - Pass your class to the
Bloomreach\EngagementConnector\Model\Tracking\Event\Cart\CartUpdateEventsCollector
class viadi.xml
:
<type name="Bloomreach\EngagementConnector\Model\Tracking\Event\Cart\CartUpdateEventsCollector">
<arguments>
<argument name="eventsList" xsi:type="array">
<item name="cart_update" xsi:type="object">Bloomreach\EngagementConnector\Model\Tracking\Event\Cart\CartUpdate</item>
</argument>
</arguments>
</type>