> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Magento 2 Order Restructure

> Configuration-based replacement for the prototype magento2-order-restructure in the Legacy Magento 2 Connector.

## Overview

The **Magento 2 Order Restructure** is a configuration-based transformer that restructures the raw order payload received from Magento 2 into a format suitable for further processing or delivery to a target system. It replaces the prototype-based `magento2-order-restructure` previously used in the Legacy Magento 2 Connector.

<Info>
  This component has been migrated from a prototype-based implementation to a configuration-based setup as part of the Legacy Magento 2 Connector replacement project.
</Info>

## Prototype vs Configuration-based

<Warning>
  This is an important behavioral difference to understand before setting up this component.
</Warning>

|                  | Prototype-based                                               | Configuration-based                                                 |
| ---------------- | ------------------------------------------------------------- | ------------------------------------------------------------------- |
| **Reusability**  | Can be reused across different flows by changing a few fields | Not reusable across different purposes or payloads                  |
| **Flexibility**  | One prototype can serve multiple use cases                    | (Not always) Each use case requires its own dedicated configuration |
| **How to reuse** | Modify fields directly                                        | Duplicate the configuration and adjust as needed                    |

If you need to transform a different payload structure or serve a different use case, you must **duplicate** this transformer and adjust the configuration accordingly. Do not modify an existing configuration as another Route already uses it.

## Type

**Transformer**

## Purpose

This transformer takes the raw order data from Magento 2 and restructures it into a normalized format. This typically includes flattening nested structures, renaming fields, mapping values, and preparing the payload for the target system.

## Configuration

| Parameter          | Description                                 | Required |
| ------------------ | ------------------------------------------- | -------- |
| `state`            | Set the field for state (state/status/both) | Yes      |
| `mutation-storage` | The storage to set the mutation date        | Yes      |
|                    |                                             |          |

## Usage

1. Navigate to **Transformers** in your Alumio environment.
2. Search for or create a new **Magento 2 Order Restructure** transformer.
3. Configure the field mappings and optional parameters as described above.
4. Add this transformer to the relevant route in the transformation step.

## Deprecated VS New

An example of the deprecated configuration:

<Frame>
  <img src="https://mintcdn.com/alumio/i_0oO_KC23VzYTWk/images/image-384-legacy-m2.png?fit=max&auto=format&n=i_0oO_KC23VzYTWk&q=85&s=40adddc0aa76bb0b971ce81081ea24e6" alt="Image" width="709" height="152" data-path="images/image-384-legacy-m2.png" />
</Frame>

An example of the new configuration:

<Frame>
  <img src="https://mintcdn.com/alumio/i_0oO_KC23VzYTWk/images/image-385-legacy-m2.png?fit=max&auto=format&n=i_0oO_KC23VzYTWk&q=85&s=dd2afed42eef297af3e69ac1ddfae8b1" alt="Image" width="1885" height="1007" data-path="images/image-385-legacy-m2.png" />
</Frame>

## Notes

* Replaces the prototype: `magento2-order-restructure`
* Unlike the prototype-based implementation, this configuration-based transformer is **not reusable across different purposes or payloads**. If you need to transform a different payload structure or serve a different use case, you must duplicate this transformer and adjust the configuration accordingly.
* Field mapping should be reviewed carefully to ensure it matches the target system's expected payload structure.
