Skip to content

Commit d5cf0c3

Browse files
author
Alexander Akimov
authored
Merge pull request magento#1519 from magento-mpi/MPI-PR-2.2.1
[MPI] 2.2.1 Bug fixes
2 parents 304c734 + bd02ed0 commit d5cf0c3

File tree

11 files changed

+339
-86
lines changed

11 files changed

+339
-86
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ define([
6161
},
6262

6363
/**
64-
* @returns {Bool}
64+
* @returns {Boolean}
6565
*/
6666
isVaultEnabled: function () {
6767
return this.vaultEnabler.isVaultEnabled();
@@ -144,10 +144,19 @@ define([
144144
},
145145

146146
/**
147-
* Trigger order placing
147+
* Returns state of place order button
148+
* @returns {Boolean}
149+
*/
150+
isButtonActive: function () {
151+
return this.isActive() && this.isPlaceOrderActionAllowed();
152+
},
153+
154+
/**
155+
* Triggers order placing
148156
*/
149157
placeOrderClick: function () {
150158
if (this.validateCardType()) {
159+
this.isPlaceOrderActionAllowed(false);
151160
$(this.getSelector('submit')).trigger('click');
152161
}
153162
},

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@
141141
data-bind="
142142
click: placeOrderClick,
143143
attr: {title: $t('Place Order')},
144-
css: {disabled: !isPlaceOrderActionAllowed()},
145-
enable: isActive()
144+
enable: isButtonActive()
146145
"
147146
disabled>
148147
<span data-bind="i18n: 'Place Order'"></span>

app/code/Magento/Catalog/Cron/DeleteOutdatedPriceValues.php

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
/**
1515
* Cron operation is responsible for deleting all product prices on WEBSITE level
16-
* in case 'Catalog Price Scope' configuratoin parameter is set to GLOBAL.
16+
* in case 'Catalog Price Scope' configuration parameter is set to GLOBAL.
1717
*/
1818
class DeleteOutdatedPriceValues
1919
{
@@ -48,27 +48,46 @@ public function __construct(
4848
}
4949

5050
/**
51-
* Delete all price values for non-admin stores if PRICE_SCOPE is global
51+
* Delete all price values for non-admin stores if PRICE_SCOPE is set to global.
5252
*
5353
* @return void
5454
*/
5555
public function execute()
5656
{
57-
$priceScope = $this->scopeConfig->getValue(Store::XML_PATH_PRICE_SCOPE);
58-
if ($priceScope == Store::PRICE_SCOPE_GLOBAL) {
59-
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $priceAttribute */
60-
$priceAttribute = $this->attributeRepository
61-
->get(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE);
62-
$connection = $this->resource->getConnection();
63-
$conditions = [
64-
$connection->quoteInto('attribute_id = ?', $priceAttribute->getId()),
65-
$connection->quoteInto('store_id != ?', Store::DEFAULT_STORE_ID),
66-
];
57+
if ($this->isPriceScopeSetToGlobal() === false) {
58+
return;
59+
}
60+
61+
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $priceAttribute */
62+
$priceAttribute = $this->attributeRepository
63+
->get(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE);
64+
$connection = $this->resource->getConnection();
65+
$conditions = [
66+
$connection->quoteInto('attribute_id = ?', $priceAttribute->getId()),
67+
$connection->quoteInto('store_id != ?', Store::DEFAULT_STORE_ID),
68+
];
6769

68-
$connection->delete(
69-
$priceAttribute->getBackend()->getTable(),
70-
$conditions
71-
);
70+
$connection->delete(
71+
$priceAttribute->getBackend()->getTable(),
72+
$conditions
73+
);
74+
}
75+
76+
/**
77+
* Checks if price scope config option explicitly equal to global value.
78+
*
79+
* Such strict comparision is required to prevent price deleting when
80+
* price scope config option is null for some reason.
81+
*
82+
* @return bool
83+
*/
84+
private function isPriceScopeSetToGlobal()
85+
{
86+
$priceScope = $this->scopeConfig->getValue(Store::XML_PATH_PRICE_SCOPE);
87+
if ($priceScope === null) {
88+
return false;
7289
}
90+
91+
return (int)$priceScope === Store::PRICE_SCOPE_GLOBAL;
7392
}
7493
}

app/code/Magento/Customer/Model/Plugin/CustomerNotification.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Framework\App\Area;
1313
use Magento\Framework\App\RequestInterface;
1414
use Magento\Framework\App\State;
15+
use Magento\Framework\Exception\NoSuchEntityException;
16+
use Psr\Log\LoggerInterface;
1517

1618
class CustomerNotification
1719
{
@@ -35,24 +37,32 @@ class CustomerNotification
3537
*/
3638
private $state;
3739

40+
/**
41+
* @var LoggerInterface
42+
*/
43+
private $logger;
44+
3845
/**
3946
* Initialize dependencies.
4047
*
4148
* @param Session $session
4249
* @param NotificationStorage $notificationStorage
4350
* @param State $state
4451
* @param CustomerRepositoryInterface $customerRepository
52+
* @param LoggerInterface $logger
4553
*/
4654
public function __construct(
4755
Session $session,
4856
NotificationStorage $notificationStorage,
4957
State $state,
50-
CustomerRepositoryInterface $customerRepository
58+
CustomerRepositoryInterface $customerRepository,
59+
LoggerInterface $logger
5160
) {
5261
$this->session = $session;
5362
$this->notificationStorage = $notificationStorage;
5463
$this->state = $state;
5564
$this->customerRepository = $customerRepository;
65+
$this->logger = $logger;
5666
}
5767

5868
/**
@@ -63,17 +73,23 @@ public function __construct(
6373
*/
6474
public function beforeDispatch(AbstractAction $subject, RequestInterface $request)
6575
{
76+
$customerId = $this->session->getCustomerId();
77+
6678
if ($this->state->getAreaCode() == Area::AREA_FRONTEND && $request->isPost()
6779
&& $this->notificationStorage->isExists(
6880
NotificationStorage::UPDATE_CUSTOMER_SESSION,
69-
$this->session->getCustomerId()
81+
$customerId
7082
)
7183
) {
72-
$customer = $this->customerRepository->getById($this->session->getCustomerId());
73-
$this->session->setCustomerData($customer);
74-
$this->session->setCustomerGroupId($customer->getGroupId());
75-
$this->session->regenerateId();
76-
$this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customer->getId());
84+
try {
85+
$customer = $this->customerRepository->getById($customerId);
86+
$this->session->setCustomerData($customer);
87+
$this->session->setCustomerGroupId($customer->getGroupId());
88+
$this->session->regenerateId();
89+
$this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customerId);
90+
} catch (NoSuchEntityException $e) {
91+
$this->logger->error($e);
92+
}
7793
}
7894
}
7995
}

app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Customer\Model\ResourceModel;
88

99
use Magento\Customer\Api\CustomerMetadataInterface;
10+
use Magento\Customer\Model\Customer\NotificationStorage;
1011
use Magento\Framework\Api\DataObjectHelper;
1112
use Magento\Framework\Api\ImageProcessorInterface;
1213
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
@@ -88,6 +89,11 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte
8889
*/
8990
private $collectionProcessor;
9091

92+
/**
93+
* @var NotificationStorage
94+
*/
95+
private $notificationStorage;
96+
9197
/**
9298
* @param \Magento\Customer\Model\CustomerFactory $customerFactory
9399
* @param \Magento\Customer\Model\Data\CustomerSecureFactory $customerSecureFactory
@@ -103,6 +109,7 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte
103109
* @param ImageProcessorInterface $imageProcessor
104110
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
105111
* @param CollectionProcessorInterface $collectionProcessor
112+
* @param NotificationStorage $notificationStorage
106113
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
107114
*/
108115
public function __construct(
@@ -119,7 +126,8 @@ public function __construct(
119126
DataObjectHelper $dataObjectHelper,
120127
ImageProcessorInterface $imageProcessor,
121128
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
122-
CollectionProcessorInterface $collectionProcessor = null
129+
CollectionProcessorInterface $collectionProcessor,
130+
NotificationStorage $notificationStorage
123131
) {
124132
$this->customerFactory = $customerFactory;
125133
$this->customerSecureFactory = $customerSecureFactory;
@@ -134,7 +142,8 @@ public function __construct(
134142
$this->dataObjectHelper = $dataObjectHelper;
135143
$this->imageProcessor = $imageProcessor;
136144
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
137-
$this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor();
145+
$this->collectionProcessor = $collectionProcessor;
146+
$this->notificationStorage = $notificationStorage;
138147
}
139148

140149
/**
@@ -345,6 +354,8 @@ public function deleteById($customerId)
345354
$customerModel = $this->customerRegistry->retrieve($customerId);
346355
$customerModel->delete();
347356
$this->customerRegistry->remove($customerId);
357+
$this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customerId);
358+
348359
return true;
349360
}
350361

@@ -370,20 +381,4 @@ protected function addFilterGroupToCollection(
370381
$collection->addFieldToFilter($fields);
371382
}
372383
}
373-
374-
/**
375-
* Retrieve collection processor
376-
*
377-
* @deprecated 100.2.0
378-
* @return CollectionProcessorInterface
379-
*/
380-
private function getCollectionProcessor()
381-
{
382-
if (!$this->collectionProcessor) {
383-
$this->collectionProcessor = \Magento\Framework\App\ObjectManager::getInstance()->get(
384-
'Magento\Eav\Model\Api\SearchCriteria\CollectionProcessor'
385-
);
386-
}
387-
return $this->collectionProcessor;
388-
}
389384
}

0 commit comments

Comments
 (0)