Skip to content

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Jul 17, 2025

Problem

The Magento 2 extension was only importing orders with the "B2C_" prefix, skipping orders from other stores like Amazon orders created by M2E Pro plugin. This resulted in incomplete order history in Clerk.io and incorrect ranking.

Issue: FED-1397 - Importar pedidos de Magento 2 sin prefijo B2C_

Root Cause

The AbstractAction.php was hardcoded to filter orders by store_id, which restricted imports to only the current store scope. For multi-store setups with different order prefixes (B2C_, B2B_, Amazon orders, etc.), this caused orders from other stores to be excluded.

Solution

Added a new configuration option "Import orders from all stores" that allows administrators to choose between:

  • Current Store Only (default/existing behavior)
  • All Stores (new behavior for comprehensive order history)

Changes Made

  1. New Admin Configuration

    • Added "Import orders from all stores" option in Stores > Configuration > Clerk > Synchronization
    • Includes helpful description for when to use this feature
  2. Enhanced Order Controller

    • Override shouldApplyStoreFilter() method to check configuration
    • Add comprehensive logging to track import strategy
    • Maintain backward compatibility with existing single-store behavior
  3. Improved AbstractAction Architecture

    • Added shouldApplyStoreFilter() method that child classes can override
    • Separated store filtering logic from collection preparation
    • Maintains existing behavior for other controllers (Product, Customer, etc.)
  4. Documentation

    • Updated README with configuration instructions
    • Added troubleshooting guidance with logging information

Testing

The solution:

  • ✅ Maintains backward compatibility (default behavior unchanged)
  • ✅ Allows multi-store order import when enabled
  • ✅ Includes comprehensive logging for troubleshooting
  • ✅ Only affects Order controller, not other data synchronization

Configuration Instructions

For the client (La Ciclomoto Imperatore Srl):

  1. Go to Stores > Configuration > Clerk > Synchronization
  2. Set "Import orders from all stores" to Yes
  3. Save configuration
  4. Trigger manual sync or wait for next cron run

This will import orders from all stores including:

  • B2C orders (B2C-200004786)
  • Amazon orders (amIT403-2773820-6141919)
  • Any other marketplace orders created by M2E Pro

Files Modified

  • etc/adminhtml/system.xml - Added new configuration field
  • Model/Config.php - Added configuration constant
  • Controller/AbstractAction.php - Enhanced with configurable store filtering
  • Controller/Order/Index.php - Override store filtering logic with logging
  • README.md - Added documentation for new feature

💻 View my work • 👤 Initiated by @CasperKNAbout Codegen

- Add new configuration option 'Import orders from all stores' in admin panel
- Override store filtering logic in Order controller to support multi-store imports
- Add comprehensive logging to track which import strategy is being used
- Update AbstractAction to allow child classes to control store filtering
- Add documentation for the new multi-store feature

This fixes the issue where only orders with B2C_ prefix were being imported
by allowing orders from all stores to be synchronized to Clerk.io when enabled.

Fixes: FED-1397
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants