-
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.
Source Entity expansion with Pickup Location attributes #2182.
Frontend name and frontend description admin UI. Some refactoring.
- Loading branch information
Showing
6 changed files
with
125 additions
and
45 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
InventoryInStorePickup/Model/Source/SetExtensionAttributes.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,55 @@ | ||
<?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 SetExtensionAttributes | ||
{ | ||
/** | ||
* @var ExtensionAttributesFactory | ||
*/ | ||
private $extensionAttributesFactory; | ||
|
||
/** | ||
* @param ExtensionAttributesFactory $extensionAttributesFactory | ||
*/ | ||
public function __construct(ExtensionAttributesFactory $extensionAttributesFactory) | ||
{ | ||
$this->extensionAttributesFactory = $extensionAttributesFactory; | ||
} | ||
/** | ||
* @param SourceInterface|DataObject $source | ||
*/ | ||
public function execute(SourceInterface $source): void | ||
{ | ||
$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
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