From 5bf68632c3222ec02594358f933b4e5ef77c4031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 28 Jan 2023 23:31:06 +0100 Subject: [PATCH] Use MPN instead of part name for auto product URLs if available Implements issue #93 --- src/Entity/Parts/PartTraits/ManufacturerTrait.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Entity/Parts/PartTraits/ManufacturerTrait.php b/src/Entity/Parts/PartTraits/ManufacturerTrait.php index 51a14a37..fc27ac14 100644 --- a/src/Entity/Parts/PartTraits/ManufacturerTrait.php +++ b/src/Entity/Parts/PartTraits/ManufacturerTrait.php @@ -75,7 +75,12 @@ trait ManufacturerTrait } if (null !== $this->getManufacturer()) { - return $this->getManufacturer()->getAutoProductUrl($this->name); + //If possible use the MPN to resolve the auto product URL, otherwise use the parts name + $mpn = $this->getManufacturerProductNumber(); + if (empty($mpn)) { + $mpn = $this->getName(); + } + return $this->getManufacturer()->getAutoProductUrl($mpn); } return ''; // no url is available