OTC auf Einzelartikel je Produkt begrenzen
This commit is contained in:
1 parent
d5d428e09c
commit
e0cd3a456a
1 file changed
+14
-4
@@ -129,10 +129,20 @@ function sellable_item_exists(PDO $pdo, int $sellableItemId): bool
|
|||||||
function find_sellable_item_for_product(PDO $pdo, int $productId): ?int
|
function find_sellable_item_for_product(PDO $pdo, int $productId): ?int
|
||||||
{
|
{
|
||||||
$stmt = $pdo->prepare(
|
$stmt = $pdo->prepare(
|
||||||
'SELECT sellable_item_id
|
'SELECT sic.sellable_item_id
|
||||||
FROM sellable_item_component
|
FROM sellable_item_component sic
|
||||||
WHERE product_id = :product_id
|
INNER JOIN sellable_item si ON si.id = sic.sellable_item_id
|
||||||
ORDER BY id
|
INNER JOIN product p ON p.id = sic.product_id
|
||||||
|
WHERE sic.product_id = :product_id
|
||||||
|
AND sic.qty_per_item = 1
|
||||||
|
AND si.item_code = p.sku || \'.01\'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM sellable_item_component other_sic
|
||||||
|
WHERE other_sic.sellable_item_id = sic.sellable_item_id
|
||||||
|
AND other_sic.id <> sic.id
|
||||||
|
)
|
||||||
|
ORDER BY sic.id
|
||||||
LIMIT 1'
|
LIMIT 1'
|
||||||
);
|
);
|
||||||
$stmt->execute([':product_id' => $productId]);
|
$stmt->execute([':product_id' => $productId]);
|
||||||
|
|||||||
Reference in new issue
Block a user