Developer Guide

Latest Stable Version License: MIT

Packagist Packagist

GitHub forks GitHub stars GitHub watchers


BACK TO THE MENU


The following documentation explains how to add your own processors to the workflow.

Export Customer Data

The export processor job is to loop through the customer data and export the result as an array type. It implements the following interface:

The processors are registered to the following composite, if you want to register you own implementation, add it to the composite via the di.xml file configuration:

<!-- Export Logged In Customer Management -->
<virtualType name="Opengento\Gdpr\Model\Customer\Export\Processor\CompositeProcessor" type="Opengento\Gdpr\Service\Export\Processor\CompositeProcessor">
    <arguments>
        <argument name="processors" xsi:type="array">
            <item name="customer_data" xsi:type="object">Opengento\Gdpr\Model\Customer\Export\Processor\CustomerDataProcessor</item>
            <item name="customer_address_data" xsi:type="object">Opengento\Gdpr\Model\Customer\Export\Processor\CustomerAddressDataProcessor</item>
            <item name="quote" xsi:type="object">Opengento\Gdpr\Model\Customer\Export\Processor\QuoteDataProcessor</item>
            <item name="order" xsi:type="object">Opengento\Gdpr\Model\Customer\Export\Processor\OrderDataProcessor</item>
            <item name="subscriber" xsi:type="object">Opengento\Gdpr\Model\Customer\Export\Processor\SubscriberDataProcessor</item>
        </argument>
    </arguments>
</virtualType>
<!-- Export Guest Management -->
<virtualType name="Opengento\Gdpr\Model\Order\Export\Processor\CompositeProcessor" type="Opengento\Gdpr\Service\Export\Processor\CompositeProcessor">
    <arguments>
        <argument name="processors" xsi:type="array">
            <item name="quote" xsi:type="object">Opengento\Gdpr\Model\Order\Export\Processor\QuoteDataProcessor</item>
            <item name="order" xsi:type="object">Opengento\Gdpr\Model\Order\Export\Processor\OrderDataProcessor</item>
            <item name="subscriber" xsi:type="object">Opengento\Gdpr\Model\Order\Export\Processor\SubscriberDataProcessor</item>
        </argument>
    </arguments>
</virtualType>

The export renderer job is to export a result into a file. It implements the following interface:

The renderers are registered to the following factory, if you want to register your own implementation, add it to the factory via the di.xml file configuration:

<type name="Opengento\Gdpr\Service\Export\RendererFactory">
    <arguments>
        <argument name="renderers" xsi:type="array">
            <item name="json" xsi:type="string">Opengento\Gdpr\Service\Export\Renderer\JsonRenderer</item>
            <item name="csv" xsi:type="string">Opengento\Gdpr\Service\Export\Renderer\CsvRenderer</item>
            <item name="xml" xsi:type="string">Opengento\Gdpr\Service\Export\Renderer\XmlRenderer</item>
            <item name="html" xsi:type="string">Opengento\Gdpr\Service\Export\Renderer\HtmlRenderer</item>
            <item name="pdf" xsi:type="string">Opengento\Gdpr\Service\Export\Renderer\PdfRenderer</item>
        </argument>
    </arguments>
</type>

When the renderers are registered in the factory, they are available to use on the administrator configuration view.

Important

The newsletter integration in Magento does not follows the Service Contract Pattern applied to the Magento 2 core.
Actually the Subscriber model only exists as its own AbstractModel and has no preference over an API interface.
As the existing model is not final, it can be plugged and an interceptor is create on the compilation.
It has side effect and break the data collector resolver by type hitting.
That’s why the subscriber model is used in composition in our own class and marked as final. All call are delegated to the original subscriber model (with their plugin and preferences).

\Opengento\Gdpr\Model\Newsletter\Subscriber class is the final state of \Magento\Newsletter\Model\Subscriber.