-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2267 from magento-engcom/MSI-2182-Source-Entity-e…
…xpansion-with-Pickup-Location-attributes Msi 2182 source entity expansion with pickup location attributes
- Loading branch information
Showing
21 changed files
with
448 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
InventoryInStorePickup/Model/PickupLocation/Mapper/PreProcessor/FrontendName.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryInStorePickup\Model\PickupLocation\Mapper\PreProcessor; | ||
|
||
use Magento\InventoryApi\Api\Data\SourceInterface; | ||
use Magento\InventoryInStorePickupApi\Model\Mapper\PreProcessorInterface; | ||
|
||
class FrontendName implements PreProcessorInterface | ||
{ | ||
|
||
/** | ||
* Process Source Field before pass it to Pickup Location | ||
* | ||
* @param SourceInterface $source | ||
* @param string $value Frontend Name Extension Attribute value | ||
* | ||
* @return string | ||
*/ | ||
public function process(SourceInterface $source, $value): string | ||
{ | ||
if (empty($value)) { | ||
$value = $source->getName(); | ||
} | ||
|
||
return $value; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
InventoryInStorePickup/Model/Source/InitPickupLocationExtensionAttributes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryInStorePickup\Model\Source; | ||
|
||
use Magento\Framework\Api\ExtensionAttributesFactory; | ||
use Magento\Framework\DataObject; | ||
use Magento\InventoryApi\Api\Data\SourceInterface; | ||
use Magento\InventoryInStorePickupApi\Api\Data\PickupLocationInterface; | ||
|
||
/** | ||
* Set store-pickup related source extension attributes | ||
*/ | ||
class InitPickupLocationExtensionAttributes | ||
{ | ||
/** | ||
* @var ExtensionAttributesFactory | ||
*/ | ||
private $extensionAttributesFactory; | ||
|
||
/** | ||
* @param ExtensionAttributesFactory $extensionAttributesFactory | ||
*/ | ||
public function __construct(ExtensionAttributesFactory $extensionAttributesFactory) | ||
{ | ||
$this->extensionAttributesFactory = $extensionAttributesFactory; | ||
} | ||
/** | ||
* @param SourceInterface $source | ||
*/ | ||
public function execute(SourceInterface $source): void | ||
{ | ||
if (!$source instanceof DataObject) { | ||
return; | ||
} | ||
$pickupAvailable = $source->getData(PickupLocationInterface::IS_PICKUP_LOCATION_ACTIVE); | ||
$frontendName = $source->getData(PickupLocationInterface::FRONTEND_NAME); | ||
$frontendDescription = $source->getData(PickupLocationInterface::FRONTEND_DESCRIPTION); | ||
|
||
$extensionAttributes = $source->getExtensionAttributes(); | ||
|
||
if ($extensionAttributes === null) { | ||
$extensionAttributes = $this->extensionAttributesFactory->create(SourceInterface::class); | ||
/** @noinspection PhpParamsInspection */ | ||
$source->setExtensionAttributes($extensionAttributes); | ||
} | ||
|
||
$extensionAttributes | ||
->setIsPickupLocationActive((bool)$pickupAvailable) | ||
->setFrontendName($frontendName) | ||
->setFrontendDescription($frontendDescription); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.