diff --git a/app/code/Magento/InventoryInStorePickup/Model/PickupLocation/Mapper/CreateFromSource.php b/app/code/Magento/InventoryInStorePickup/Model/PickupLocation/Mapper/CreateFromSource.php index 90a8a8af6706..2f91f5395ec1 100644 --- a/app/code/Magento/InventoryInStorePickup/Model/PickupLocation/Mapper/CreateFromSource.php +++ b/app/code/Magento/InventoryInStorePickup/Model/PickupLocation/Mapper/CreateFromSource.php @@ -67,7 +67,7 @@ public function execute(SourceInterface $source, array $map, array $preProcessor private function preProcessData(SourceInterface $source, array $data, array $preProcessors) { foreach ($preProcessors as $field => $processor) { - if (isset($data[$field])) { + if (array_key_exists($field, $data)) { $data[$field] = $processor->process($source, $data[$field]); } } diff --git a/app/code/Magento/InventoryInStorePickup/Model/PickupLocation/Mapper/PreProcessor/FrontendName.php b/app/code/Magento/InventoryInStorePickup/Model/PickupLocation/Mapper/PreProcessor/FrontendName.php new file mode 100644 index 000000000000..a4f1b8bc436c --- /dev/null +++ b/app/code/Magento/InventoryInStorePickup/Model/PickupLocation/Mapper/PreProcessor/FrontendName.php @@ -0,0 +1,33 @@ +getName(); + } + + return $value; + } +} diff --git a/app/code/Magento/InventoryInStorePickup/Plugin/InventoryApi/SourceValidatorChain/SetFrontendName.php b/app/code/Magento/InventoryInStorePickup/Plugin/InventoryApi/SourceValidatorChain/SetFrontendName.php deleted file mode 100644 index 2a11e5ac3c6a..000000000000 --- a/app/code/Magento/InventoryInStorePickup/Plugin/InventoryApi/SourceValidatorChain/SetFrontendName.php +++ /dev/null @@ -1,40 +0,0 @@ -getExtensionAttributes() === null) { - return; - } - - $frontendName = trim($source->getExtensionAttributes()->getFrontendName() ?? ''); - - if ($frontendName === '') { - $source->getExtensionAttributes()->setFrontendName($source->getName()); - if ($source instanceof DataObject) { - $source->setData('frontend_name', $source->getExtensionAttributes()->getFrontendName()); - } - } - } -} diff --git a/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupLocation/MapperTest.php b/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupLocation/MapperTest.php index ec353dd5179a..0481a4076523 100644 --- a/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupLocation/MapperTest.php +++ b/app/code/Magento/InventoryInStorePickup/Test/Integration/PickupLocation/MapperTest.php @@ -120,6 +120,22 @@ public function testMapPickupLocation() $this->assertInstanceOf(PickupLocationExtensionInterface::class, $pickupLocation->getExtensionAttributes()); } + /** + * @magentoDataFixture ../../../../app/code/Magento/InventoryInStorePickup/Test/_files/pickup_location.php + * @throws + */ + public function testEmptyFrontendName() + { + $source = $this->sourceRepository->get($this->sourceCode); + $source->getExtensionAttributes()->setFrontendName(null); + + /** @var Mapper $mapper */ + $mapper = $this->objectManager->create(Mapper::class); + + $pickupLocation = $mapper->map($source); + $this->assertEquals($source->getName(), $pickupLocation->getName()); + } + /** * @return array */ diff --git a/app/code/Magento/InventoryInStorePickup/etc/di.xml b/app/code/Magento/InventoryInStorePickup/etc/di.xml index 63a9bb91cb68..b8abb4c70197 100644 --- a/app/code/Magento/InventoryInStorePickup/etc/di.xml +++ b/app/code/Magento/InventoryInStorePickup/etc/di.xml @@ -38,12 +38,11 @@ name description + + Magento\InventoryInStorePickup\Model\PickupLocation\Mapper\PreProcessor\FrontendName + - - -