$orderItem->order_id = $orderId;
$orderItem->external_item_id = $order['number'];
$orderItem->offer_name = $item['name'];
- $orderItem->offer_id = $item['name'];
+ $orderItem->offer_id = self::extractArticleCode($item['name']) ?? $item['name'];
$orderItem->price = $item['price'];
$orderItem->count = $item['count'];
$orderItem->buyer_price = $item['price'];
}
}
}
-
+ public static function extractArticleCode($productName)
+ {
+ if (preg_match('/\(([^()]+)\)\s*$/u', $productName, $matches)) {
+ return $matches[1];
+ }
+ return null;
+ }
}