mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-01 21:09:35 +00:00
Allow to read amazon labels for part retrieval and creation
This commit is contained in:
parent
87919eb445
commit
0b9b2cbf58
7 changed files with 103 additions and 9 deletions
|
|
@ -454,4 +454,28 @@ class PartRepository extends NamedDBElementRepository
|
|||
return $qb->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a part based on the provided SPN (Supplier Part Number), with an option for case sensitivity.
|
||||
* If no part is found with the given SPN, null is returned.
|
||||
* @param string $spn
|
||||
* @param bool $caseInsensitive
|
||||
* @return Part|null
|
||||
*/
|
||||
public function getPartBySPN(string $spn, bool $caseInsensitive = true): ?Part
|
||||
{
|
||||
$qb = $this->createQueryBuilder('part');
|
||||
$qb->select('part');
|
||||
|
||||
$qb->leftJoin('part.orderdetails', 'o');
|
||||
|
||||
if ($caseInsensitive) {
|
||||
$qb->where("LOWER(o.supplierpartnr) = LOWER(:spn)");
|
||||
} else {
|
||||
$qb->where("o.supplierpartnr = :spn");
|
||||
}
|
||||
|
||||
$qb->setParameter('spn', $spn);
|
||||
|
||||
return $qb->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue