This commit is contained in:
team 1
2026-05-06 11:19:26 +02:00
parent 433ce2046f
commit 566b7be36f
5 changed files with 142 additions and 0 deletions

View File

@@ -65,6 +65,66 @@ final class ShopwareCriteriaBuilder
);
}
/**
* Builds a narrow, rich-text-free criteria payload for exact article-number lookups.
* Pure product-number searches should not run through Shopware full-text search,
* because broad numeric search can surface unrelated products and trigger JSON
* encoding problems in rich text/custom fields.
*/
public function buildExactProductNumber(string $productNumber, ?int $limit = 5): array
{
$productNumber = trim($productNumber);
$criteria = [
'page' => 1,
'limit' => max(1, $limit),
'total-count-mode' => 0,
'includes' => [
'product' => [
'id',
'name',
'translated.name',
'productNumber',
'available',
'calculatedPrice',
'manufacturer',
],
'product_manufacturer' => [
'name',
],
'calculated_price' => [
'unitPrice',
'totalPrice',
'referencePrice',
'listPrice',
'regulationPrice',
],
],
'associations' => [
'manufacturer' => new \stdClass(),
],
'filter' => [
[
'type' => 'equals',
'field' => 'active',
'value' => true,
],
[
'type' => 'equals',
'field' => 'available',
'value' => true,
],
[
'type' => 'equals',
'field' => 'productNumber',
'value' => $productNumber,
],
],
];
return $criteria;
}
/**
* Builds an ultra-safe Store API payload for the final recovery attempt.
* It keeps only identity, availability and price fields and intentionally