Skip to content

Magento 2 Data Store Sync

BerezinLiz edited this page May 23, 2022 · 5 revisions

Overview

If you are using Gigya's Data Store (DS), synchronization between Magento and the Data Store is available through an optional, separate module that can be installed on top of the main Gigya Extension for Magento.

The DS Sync module pulls data from Gigya's Data Store and maps it into the user account database in Magento.

Customers who only use Gigya's account storage, and do not use the Gigya Data Store service, do not have to install this additional module.

Installation and Implementation

To implement DC sync, follow these steps:

1.Download and save DS Sync   2.Map fields   3.Select Method   4.Enable Module

1. Download and Save DS Sync

  1. Download the DS module for Magento 2.1 here.

  2. In the Magento root folder, create the following folder structure (the "app" directory should already exist): app/code/Gigya/GigyaDS.

  3. Unzip the module into this directory.

2. Map Fields

Map the fields whose data you wish to sync between the Data Store and Magento. This mapping will apply on the front-end, in the following scenarios:

  • New user registers

  • Existing user logs in

  • User edits their profile

Each field mapping definition is a single JSON object, and includes the following parameters:

Required Key Description
cmsName Name of the field in Magento (case sensitive). If you are mapping custom EAV attributes (e.g. attributes added by installing additional modules), these attributes must be prefixed by "custom_". For example: "cmsName": "custom_pet_name"
cmsType The field data type in Magento - int (short/long), string (varchar(X)), date, Boolean.
  gigyaName Field in Gigya DS in the following format: ds.. , where ds is fixed, and the type (table) and field name should be specified (case sensitive).
gigyaType The field data type in Gigya (e.g., string).
custom An array in which to specify the Data Store oid parameter.

Example: The following file maps the ds.test.data field from Gigya DS to a field called custom2 in Magento:

    [
        {
            "cmsName": "custom_pet_nickname",
            "cmsType": "string",
            "gigyaName": "ds.pets.nickname",
            "gigyaType": "string",
            "custom": {
                "old": "gigya_pets"
            }
        },
        {
            "cmsName": "custom_pet_animaltype",
            "cmsType": "string",
            "gigyaName": "ds.pets.animalType",
            "gigyaType": "string",
            "custom": {
                "old": "gigya_pets"
            }
        }
    ]

Reference the JSON File

Once your file is saved, reference it in the Data Store module.

  1. In Magento, navigate to Stores > Configuration > Gigya Identity Management > Data Store.

  2. Specify the full path and file name of the DS field mapping JSON file.

  3. Click Save Config.

Use Hook to Transform DS Data

In some cases, you may want to map fields between Gigya and Magento that have different types, or that have different logic. For example, a field that is an integer in Magento, while the corresponding Gigya field is a string. In these cases, the module provides you with a hook for data transformation.

Hook: gigya_client_gigya_ds_data_alter

Fired on Magento to Gigya synchronization

Parameters:

  • "gigya_user" : the Gigya user object

  • "customer" : an empty Magento Customer model

3. Select Method

In Magento, navigate to Stores > Configuration > Gigya Identity Management > Data Store to define the data extraction method, whether Get or Search.

  • When passing a single OID, use get.

  • When using multiple OIDs, use search.

4. Enable the Module

On the server, run the following command:

    bin/magento module:enable Gigya_GigyaDS