Extend

Export customer upon address change

By default, customers are enqueued (re-enqueued actually) for export upon changing any of their addresses. Depending on your project’s requirements, you may want to export customer data only when certain types of addresses are changed (Magento does not have address types but Dynamics BC has and is extremely picky about these). In order to fit your project’s needs, you can implement the public interface \TechDivision\PacemakerDynamicsBcEntityExportCustomer\Api\Query\MustExportCustomerAfterAddressChangeInterface and set your implementation as the preferred one in your module’s etc/di.xml.

Example

  1. Implement the query interface

    namespace MyVendor\MyModule\Model\Query;
    
       use Magento\Customer\Api\Data\AddressInterface;
       use TechDivision\PacemakerDynamicsBcEntityExportCustomer\Api\Query\MustExportCustomerAfterAddressChangeInterface;
    
       class ExportCustomerOnlyAfterBillingAddressChange implements MustExportCustomerAfterAddressChangeInterface
       {
           public function execute(AddressInterface $address) : bool
           {
               return (bool)$address->isDefaultBilling();
           }
       }
  2. Register your implementation as the preferred implementation in app/code/MyVendor/MyModule/etc/di.xml:

          <preference for="TechDivision\PacemakerDynamicsBcEntityExportCustomer\Api\Query\MustExportCustomerAfterAddressChangeInterface"
                      type="MyVendor\MyModule\Model\Query\ExportCustomerOnlyAfterBillingAddressChange"/>