Mapping Classes

For each pair of an internal entity and an external entity that should be synchronized, you implement a mapping class, which defines the correspondence between the properties of the internal and external entities.

Base Class and Interfaces

You derive a mapping class from the PX.Commerce.Core.MappedEntity<ExternType, LocalType> base class, which implements the following interfaces:

The MappedEntity<ExternType, LocalType> class provides the default implementation of these interfaces. The class also provides the default constructors from which you can derive the constructors of the mapping classes. These constructors use as input parameters a string identifier of the mapped entities, which is exactly two characters long, and a string identifier of the connector, which is defined in the ConnectorType property of the connector class.

Example

An example of the implementation of a mapping class is shown in the following code.

Tip: You can see this code on GitHub.
using System;
using PX.Commerce.Core;
using PX.Commerce.Core.API;

namespace WooCommerceTest
{
    public class MappedCustomer : MappedEntity<CustomerData, Customer>
    {
        public const string TYPE = BCEntitiesAttribute.Customer;

        public MappedCustomer()
            : base(WooCommerceConnector.TYPE, TYPE)
        { }
        public MappedCustomer(Customer entity, Guid? id, DateTime? timestamp)
            : base(WooCommerceConnector.TYPE, TYPE, entity, id, timestamp) { }
        public MappedCustomer(CustomerData entity, string id, DateTime? timestamp)
            : base(WooCommerceConnector.TYPE, TYPE, entity, id, id, timestamp) { }
    }
}