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 OciResponseGenerationEvent → OciFormData 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
System price digitsprice_digitsFormats the value with the decimals configured on the system. cXML only — the OCI field dialog never writes this key.

Filters are applied in this order: substr → number_format → divine → price_digits. Because price_digits runs last it overrides a previously applied number_format; the administration therefore prevents both from being active at the same time.


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);
}
}