Skip to main content

About Profiles

Profiles are the core mechanism for managing data synchronization between Magento 2 and FreeAgent. They provide a flexible, configurable way to automate bidirectional data exchange with minimal manual effort.

What Are Profiles?

A Profile is a configured synchronization task that defines:

  • What data to synchronize (contacts, invoices, credit memos)
  • Which direction to sync (export to FreeAgent, import from FreeAgent, or collect data)
  • How to process the data (batch size, retry logic, transformations)
  • When to run (manual execution, scheduled cron, or event-triggered)

Think of profiles as "sync jobs" that handle specific data transfer operations between your Magento store and FreeAgent accounting system.

How Profiles Work

Data Flow

┌─────────────┐         ┌─────────────┐         ┌─────────────┐
│ │ Export │ │ Import │ │
│ Magento │────────>│ Profile │────────>│ FreeAgent │
│ │ │ │ │ │
│ │<────────│ (Sync) │<────────│ │
│ │ Import │ │ Export │ │
└─────────────┘ └─────────────┘ └─────────────┘

Three-Phase Workflow

Each entity sync follows a three-phase workflow:

  1. Collect - Fetch data from the FreeAgent API and store locally for processing
  2. Export - Generate payloads from Magento data and send to FreeAgent API
  3. Import - Process collected FreeAgent data and update Magento entities

Execution Flow

  1. Trigger: Profile execution starts (manual, cron, or CLI)
  2. Collect: Retrieve data from source system via API
  3. Generate: Create API payloads with correct format and mappings
  4. Process: Transfer data to destination system
  5. Post-Process: Update local entities, manage queue, log results
  6. History: Record execution details, errors, and metrics

Profile Lifecycle

[Created] → [Configured] → [Active] → [Running] → [Completed]
↓ ↓
[Disabled] [Failed]
  • Created: Profile exists but not configured
  • Configured: Settings defined, ready for execution
  • Active: Enabled and available for scheduled execution
  • Running: Currently processing data
  • Completed: Execution finished successfully
  • Disabled: Temporarily deactivated
  • Failed: Execution encountered fatal error

Profile Types

Magento FreeAgent Integration includes the following profile types:

Contact Profiles

Profile TypeDirectionPurpose
Contact ExportMagento → FreeAgentExport Magento customers as FreeAgent contacts
Contact ImportFreeAgent → MagentoImport FreeAgent contacts to Magento
Contact CollectFreeAgent → LocalFetch contact data from FreeAgent for processing

Use Cases:

  • Sync customer accounts to FreeAgent contacts
  • Create contacts for guest checkout customers
  • Keep address and company details synchronized
  • Map customer groups to FreeAgent categories

Invoice Profiles

Profile TypeDirectionPurpose
Invoice ExportMagento → FreeAgentExport Magento orders as FreeAgent invoices
Invoice ImportFreeAgent → MagentoImport invoice status updates from FreeAgent
Invoice CollectFreeAgent → LocalFetch invoice data from FreeAgent for processing

Use Cases:

  • Automatically create invoices in FreeAgent for new orders
  • Sync invoice status back to Magento
  • Handle shipping charges and discount line items
  • Trigger invoice emails from FreeAgent

Credit Memo Profiles

Profile TypeDirectionPurpose
Credit Memo ExportMagento → FreeAgentExport Magento credit memos as FreeAgent credit notes
Credit Memo ImportFreeAgent → MagentoImport credit memo status from FreeAgent
Credit Memo CollectFreeAgent → LocalFetch credit memo data from FreeAgent

Use Cases:

  • Create credit notes in FreeAgent for Magento refunds
  • Maintain accurate financial records across platforms
  • Handle partial refunds and shipping refunds

Profile Architecture

Components

Each profile consists of several key components:

1. Profile Entity

The main profile record stored in byte8_profile_entity:

  • Profile ID: Unique identifier
  • Name: Human-readable profile name
  • Type ID: Profile type identifier (e.g., freeagent_invoice_export)
  • Status: Current status (enabled/disabled)
  • Created At / Updated At: Timestamps

2. Configuration

Profile-specific settings stored in byte8_profile_config:

  • Client Connection: FreeAgent API credentials
  • Schedule Settings: Cron expression, batch size
  • Processing Options: Retry logic, queue behavior
  • Entity Settings: Type-specific configuration

3. Schedule

Automated execution settings stored in byte8_profile_schedule:

  • Cron Expression: When to run (e.g., */15 * * * * for every 15 minutes)
  • Status: Schedule active/inactive
  • Type ID: Associated profile type

4. History

Execution tracking stored in byte8_profile_history:

  • Status: Success/failure
  • Type ID: Profile type that was executed
  • Message: Execution log messages
  • Created At: Execution timestamp

5. Queue

Entity processing queue stored in byte8_profile_queue:

  • Subject Entity ID: The entity being processed
  • Subject Type ID: Entity type identifier
  • Status: Queue status (pending, processing, success, error)
  • Metadata: Additional processing data (JSON)

Data Storage

Profiles and entity data are stored in these database tables:

TablePurpose
byte8_profile_entityMain profile records
byte8_profile_configProfile configuration
byte8_profile_scheduleCron schedule settings
byte8_profile_historyExecution history
byte8_profile_queueAsync queue messages
freeagent_contact_entityContact sync tracking
freeagent_invoice_entityInvoice sync tracking
freeagent_creditmemo_entityCredit memo sync tracking

Profile Features

Flexible Scheduling

Manual Execution:

  • Run on-demand from admin panel
  • Execute via CLI commands
  • Trigger from custom code

Cron Scheduling:

  • Standard cron expressions
  • Configurable per profile
  • Independent scheduling for each entity type

Processing Pipeline

Each export service uses a multi-stage processor pipeline:

Generator (sortOrder: 10-30)
→ Processor (sortOrder: 40-50)
→ PostProcessor (sortOrder: 100)

Generators create the API payload data Processors send data to the FreeAgent API PostProcessors handle response data, queue cleanup, and logging

Error Handling

Retry Logic:

  • Configurable retry attempts per profile
  • Automatic retry on transient failures
  • Maximum retry limit to prevent infinite loops

Error Logging:

  • Detailed error messages in profile history
  • Per-entity log files for debugging
  • Email notifications for critical errors

Partial Processing:

  • Continue processing on item-level failures
  • Individual entity status tracking
  • Queue-based recovery for failed items

Performance Optimization

Batch Processing:

  • Configurable batch sizes per profile
  • Process multiple records per execution
  • Memory-efficient chunked operations

Queue Processing:

  • Asynchronous entity processing
  • Background workers via Magento message queue
  • Non-blocking operations

Profile Uniqueness

One Profile Per Type

Profiles are unique by type. You can only have ONE profile of each type in the system.

For example, you cannot create two "Invoice Export" profiles. If you need different scenarios, use:

  • Filters to control which data is processed
  • Configuration options to customize behavior
  • CLI parameters for ad-hoc variations

Profile Management

Admin Interface

Access profiles via: Byte8 > FreeAgent > Profiles

Available Actions:

  • View: See profile details and status
  • Edit: Modify configuration
  • Execute: Run manually
  • Schedule: Configure cron
  • Disable: Temporarily deactivate
  • View History: See execution logs

Command Line Interface (CLI)

Profiles can be managed via CLI:

# Export profile configuration
bin/magento profile:config:export

# Import profile configuration
bin/magento profile:config:import

# Purge profile data
bin/magento profile:data:purge

# Run entity-specific sync
bin/magento fa_contact:export
bin/magento fa_invoice:export
bin/magento fa_creditmemo:export

Best Practices

Profile Configuration

  1. Start Simple: Begin with basic configuration, add complexity gradually
  2. Test Thoroughly: Use sandbox mode and dry-run before enabling production sync
  3. Monitor Execution: Review history and logs regularly
  4. Version Control: Export configurations for backup

Scheduling

  1. Avoid Peak Times: Schedule resource-intensive profiles during off-peak hours
  2. Stagger Executions: Don't run all profiles simultaneously
  3. Monitor Performance: Track execution times and adjust schedules
  4. Set Realistic Intervals: Balance data freshness with system load

Data Integrity

  1. Use Filters: Process only necessary data
  2. Monitor Errors: Review error logs regularly
  3. Test with Sandbox: Always test changes in sandbox first
  4. Backup Before Changes: Export profile config before major changes

Next Steps

  1. Contact Export - Configure contact synchronization
  2. Invoice Export - Set up invoice processing
  3. Credit Memo Export - Configure credit memo sync
  4. CLI Commands - Full CLI reference