Step 4: Defining the Mappings Between Internal and External Entities
For each pair of an internal entity and an external entity that should be synchronized, you must create a mapping class. For details about the mapping class, see Mapping Classes.
Defining the Mappings Between Internal and External Entities
- In the Visual Studio project of the extension library, in the connector class,
define the
TYPE
andNAME
constants in it, as shown in the following code. You will need these constants in the mapping classes.namespace WooCommerceTest { public class WooCommerceConnector { public const string TYPE = "WCC"; public const string NAME = "WooCommerce"; ... } }
- For each pair of an internal entity and an external entity that should be
synchronized, in the Visual Studio project of the extension library, create a
mapping class that derives from
PX.Commerce.Core.MappedEntity<ExternType, LocalType>.
The following example shows the implementation of the
MappedCustomer
class.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) { } } }
- Build the project.