Skip to main content

OCI Response Generator

The OciConnectorResponseGenerator produces an OciFormData structure from the cart. This is rendered as an HTML form in the storefront template and submitted to the procurement system's hook URL on transfer.


buildForm()

public function buildForm(
Cart $cart,
OciSystemEntity $system,
ConnectorSession $session,
SalesChannelContext $context
): OciFormData

Process:

  1. For each cart line item → find the matching LineItemContextResolver
  2. For each OCI field with target LINE_ITEM: resolve value via fallback chain + apply filters
  3. Optionally: append a shipping line item (when attachShipping is enabled and deliveries exist)
  4. Fire OciResponseGenerationEventOciFormData can be modified before return

OciFormData structure

OciFormData
├── hookUrl (string) – return URL of the procurement system
└── lineItems[] (list)
└── OciLineItemData
└── fields[]
└── OciFieldData
├── name (string) – e.g. "NEW_ITEM-DESCRIPTION[1]"
├── value (string) – resolved value
└── type (OciFieldType: standard|long)

Field name convention

OCI field names follow this pattern:

Standard fields:

NEW_ITEM-{FIELDNAME_UPPERCASE}[{INDEX}]

Long-text fields (OciFieldType::LONG):

NEW_ITEM-{FIELDNAME_UPPERCASE}[{INDEX}]:132[]

The :132[] suffix is the OCI 5.0 long text marker for fields that exceed the standard character limit.

Examples:

  • NEW_ITEM-DESCRIPTION[1] (standard)
  • NEW_ITEM-MATNR[1] (standard)
  • NEW_ITEM-LONGTEXT[1]:132[] (long text)

The index ([1], [2], …) corresponds to the position of the line item in the cart.


Field targets

Each OCI field has a configured target:

TargetEnumDescription
line_itemOciFieldTarget::LINE_ITEMField belongs to a cart line item
shipping_itemOciFieldTarget::SHIPPING_ITEMField for the shipping position (only when attachShipping is enabled)

The shipping position is appended as a standalone OCI item at the end of the line items.


Value filters

After fallback resolution, optional filters can be applied to the value:

FilterConfig keysDescription
Substringsubstr.start, substr.endTrims the string to the defined range
Number formatnumber_format, decimalsFormats the value as a decimal number with the defined decimal places (dot as separator, no thousands separator)
Dividedivine.valueDivides the numeric value by the given divisor

OciResponseGenerationEvent

Just before returning the OciFormData, the generator fires:

EventEvent nameWhat can be changed?
OciResponseGenerationEventagiqon_connector.oci.response.generationComplete OciFormData (add, modify, or remove line items)

Example:

use AgiqonConnector\Connector\System\OCI\Event\OciResponseGenerationEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

#[AsEventListener(event: OciResponseGenerationEvent::EVENT_NAME)]
final class MyOciResponseListener
{
public function __invoke(OciResponseGenerationEvent $event): void
{
$formData = $event->getFormData();

// Custom logic: e.g. modify line items
// $event->setFormData($modifiedFormData);
}
}