-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f1099e
commit 4afc05f
Showing
5 changed files
with
286 additions
and
223 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
app/code/Magento/Customer/Model/Plugin/UpdateCustomerId.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,49 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\Customer\Model\Plugin; | ||
|
||
use Magento\Framework\Webapi\Rest\Request as RestRequest; | ||
use Magento\Customer\Api\Data\CustomerInterface; | ||
use Magento\Customer\Api\CustomerRepositoryInterface; | ||
|
||
/** | ||
* Update customer id from request param | ||
*/ | ||
class UpdateCustomerId | ||
{ | ||
/** | ||
* @var RestRequest $request | ||
*/ | ||
private $request; | ||
|
||
/** | ||
* @param RestRequest $request | ||
*/ | ||
public function __construct(RestRequest $request) | ||
{ | ||
$this->request = $request; | ||
} | ||
|
||
/** | ||
* Update customer id from request if exist | ||
* | ||
* @param CustomerRepositoryInterface $customerRepository | ||
* @param CustomerInterface $customer | ||
* @return void | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function beforeSave(CustomerRepositoryInterface $customerRepository, CustomerInterface $customer): void | ||
{ | ||
$cartId = $this->request->getParam('customerId'); | ||
|
||
if ($cartId) { | ||
$customer->setId($cartId); | ||
} | ||
} | ||
} |
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.