Skip to content

Commit 834f1af

Browse files
authored
Merge pull request #4184 from magento-mpi/PR-2019-05-07
[mpi] MAGETWO-98462: Shopping cart does not show all four digits of quantity
2 parents 0b2fcf1 + 935b45a commit 834f1af

File tree

9 files changed

+92
-45
lines changed

9 files changed

+92
-45
lines changed

app/code/Magento/Catalog/Block/Product/View.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ public function getAddToCartUrl($product, $additional = [])
169169
}
170170

171171
/**
172-
* Get JSON encoded configuration array which can be used for JS dynamic
173-
* price calculation depending on product options
172+
* Get JSON encoded configuration which can be used for JS dynamic price calculation depending on product options
174173
*
175174
* @return string
176175
*/
@@ -254,6 +253,7 @@ public function hasRequiredOptions()
254253
* instantly.
255254
*
256255
* @return bool
256+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
257257
*/
258258
public function isStartCustomization()
259259
{
@@ -262,6 +262,7 @@ public function isStartCustomization()
262262

263263
/**
264264
* Get default qty - either as preconfigured, or as 1.
265+
*
265266
* Also restricts it by minimal qty.
266267
*
267268
* @param null|\Magento\Catalog\Model\Product $product
@@ -323,10 +324,7 @@ public function getQuantityValidators()
323324
public function getIdentities()
324325
{
325326
$identities = $this->getProduct()->getIdentities();
326-
$category = $this->_coreRegistry->registry('current_category');
327-
if ($category) {
328-
$identities[] = Category::CACHE_TAG . '_' . $category->getId();
329-
}
327+
330328
return $identities;
331329
}
332330

app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,18 @@ public function testGetIdentities()
6767
{
6868
$productTags = ['cat_p_1'];
6969
$product = $this->createMock(\Magento\Catalog\Model\Product::class);
70-
$category = $this->createMock(\Magento\Catalog\Model\Category::class);
7170

7271
$product->expects($this->once())
7372
->method('getIdentities')
7473
->will($this->returnValue($productTags));
75-
$category->expects($this->once())
76-
->method('getId')
77-
->will($this->returnValue(1));
7874
$this->registryMock->expects($this->any())
7975
->method('registry')
8076
->will($this->returnValueMap(
8177
[
8278
['product', $product],
83-
['current_category', $category],
8479
]
8580
)
8681
);
87-
$this->assertEquals(['cat_p_1', 'cat_c_1'], $this->view->getIdentities());
82+
$this->assertEquals($productTags, $this->view->getIdentities());
8883
}
8984
}

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ private function getAuthentication()
475475
}
476476

477477
/**
478-
* {@inheritdoc}
478+
* @inheritdoc
479479
*/
480480
public function resendConfirmation($email, $websiteId = null, $redirectUrl = '')
481481
{
@@ -498,7 +498,7 @@ public function resendConfirmation($email, $websiteId = null, $redirectUrl = '')
498498
}
499499

500500
/**
501-
* {@inheritdoc}
501+
* @inheritdoc
502502
*/
503503
public function activate($email, $confirmationKey)
504504
{
@@ -507,7 +507,7 @@ public function activate($email, $confirmationKey)
507507
}
508508

509509
/**
510-
* {@inheritdoc}
510+
* @inheritdoc
511511
*/
512512
public function activateById($customerId, $confirmationKey)
513513
{
@@ -547,7 +547,7 @@ private function activateCustomer($customer, $confirmationKey)
547547
}
548548

549549
/**
550-
* {@inheritdoc}
550+
* @inheritdoc
551551
*/
552552
public function authenticate($username, $password)
553553
{
@@ -582,7 +582,7 @@ public function authenticate($username, $password)
582582
}
583583

584584
/**
585-
* {@inheritdoc}
585+
* @inheritdoc
586586
*/
587587
public function validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken)
588588
{
@@ -591,7 +591,7 @@ public function validateResetPasswordLinkToken($customerId, $resetPasswordLinkTo
591591
}
592592

593593
/**
594-
* {@inheritdoc}
594+
* @inheritdoc
595595
*/
596596
public function initiatePasswordReset($email, $template, $websiteId = null)
597597
{
@@ -677,7 +677,7 @@ private function matchCustomerByRpToken(string $rpToken): CustomerInterface
677677
}
678678

679679
/**
680-
* {@inheritdoc}
680+
* @inheritdoc
681681
*/
682682
public function resetPassword($email, $resetToken, $newPassword)
683683
{
@@ -706,7 +706,12 @@ public function resetPassword($email, $resetToken, $newPassword)
706706
$customerSecure->setPasswordHash($this->createPasswordHash($newPassword));
707707
$this->getAuthentication()->unlock($customer->getId());
708708
$this->destroyCustomerSessions($customer->getId());
709-
$this->sessionManager->destroy();
709+
if ($this->sessionManager->isSessionExists() && !headers_sent()) {
710+
//delete old session and move data to the new session
711+
//use this instead of $this->sessionManager->regenerateId because last one doesn't delete old session
712+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
713+
session_regenerate_id(true);
714+
}
710715
$this->customerRepository->save($customer);
711716

712717
return true;
@@ -798,7 +803,7 @@ protected function getMinPasswordLength()
798803
}
799804

800805
/**
801-
* {@inheritdoc}
806+
* @inheritdoc
802807
*/
803808
public function getConfirmationStatus($customerId)
804809
{
@@ -814,7 +819,7 @@ public function getConfirmationStatus($customerId)
814819
}
815820

816821
/**
817-
* {@inheritdoc}
822+
* @inheritdoc
818823
*/
819824
public function createAccount(CustomerInterface $customer, $password = null, $redirectUrl = '', $extensions = [])
820825
{
@@ -835,7 +840,7 @@ public function createAccount(CustomerInterface $customer, $password = null, $re
835840
}
836841

837842
/**
838-
* {@inheritdoc}
843+
* @inheritdoc
839844
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
840845
* @SuppressWarnings(PHPMD.NPathComplexity)
841846
*/
@@ -920,7 +925,7 @@ public function createAccountWithPasswordHash(
920925
}
921926

922927
/**
923-
* {@inheritdoc}
928+
* @inheritdoc
924929
*/
925930
public function getDefaultBillingAddress($customerId)
926931
{
@@ -929,7 +934,7 @@ public function getDefaultBillingAddress($customerId)
929934
}
930935

931936
/**
932-
* {@inheritdoc}
937+
* @inheritdoc
933938
*/
934939
public function getDefaultShippingAddress($customerId)
935940
{
@@ -974,7 +979,7 @@ protected function sendEmailConfirmation(CustomerInterface $customer, $redirectU
974979
}
975980

976981
/**
977-
* {@inheritdoc}
982+
* @inheritdoc
978983
*/
979984
public function changePassword($email, $currentPassword, $newPassword)
980985
{
@@ -987,7 +992,7 @@ public function changePassword($email, $currentPassword, $newPassword)
987992
}
988993

989994
/**
990-
* {@inheritdoc}
995+
* @inheritdoc
991996
*/
992997
public function changePasswordById($customerId, $currentPassword, $newPassword)
993998
{
@@ -1046,6 +1051,8 @@ protected function createPasswordHash($password)
10461051
}
10471052

10481053
/**
1054+
* Get EAV validator
1055+
*
10491056
* @return Backend
10501057
*/
10511058
private function getEavValidator()
@@ -1057,7 +1064,7 @@ private function getEavValidator()
10571064
}
10581065

10591066
/**
1060-
* {@inheritdoc}
1067+
* @inheritdoc
10611068
*/
10621069
public function validate(CustomerInterface $customer)
10631070
{
@@ -1082,7 +1089,7 @@ public function validate(CustomerInterface $customer)
10821089
}
10831090

10841091
/**
1085-
* {@inheritdoc}
1092+
* @inheritdoc
10861093
*/
10871094
public function isEmailAvailable($customerEmail, $websiteId = null)
10881095
{
@@ -1098,7 +1105,7 @@ public function isEmailAvailable($customerEmail, $websiteId = null)
10981105
}
10991106

11001107
/**
1101-
* {@inheritDoc}
1108+
* @inheritdoc
11021109
*/
11031110
public function isCustomerInStore($customerWebsiteId, $storeId)
11041111
{
@@ -1549,6 +1556,7 @@ private function getEmailNotification()
15491556

15501557
/**
15511558
* Destroy all active customer sessions by customer id (current session will not be destroyed).
1559+
*
15521560
* Customer sessions which should be deleted are collecting from the "customer_visitor" table considering
15531561
* configured session lifetime.
15541562
*

app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if ($block->getIsShipping()):
3232
require(["Magento_Sales/order/create/form"], function(){
3333

3434
order.shippingAddressContainer = '<?= /* @escapeNotVerified */ $_fieldsContainerId ?>';
35-
order.setAddresses(<?= /* @escapeNotVerified */ $customerAddressFormatter->getAddressesJson($addressArray) ?>);
35+
order.setAddresses(<?= /* @noEscape */ $block->getAddressCollectionJson() ?>);
3636

3737
});
3838
</script>

app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ define([
4242
this.isOnlyVirtualProduct = false;
4343
this.excludedPaymentMethods = [];
4444
this.summarizePrice = true;
45+
this.selectAddressEvent = false;
4546
this.shippingTemplate = template(shippingTemplate, {
4647
data: {
4748
title: jQuery.mage.__('Shipping Method'),
@@ -169,17 +170,19 @@ define([
169170
},
170171

171172
selectAddress : function(el, container){
173+
172174
id = el.value;
173175
if (id.length == 0) {
174176
id = '0';
175177
}
176-
if(this.addresses[id]){
177-
this.fillAddressFields(container, this.addresses[id]);
178178

179-
}
180-
else{
179+
this.selectAddressEvent = true;
180+
if (this.addresses[id]) {
181+
this.fillAddressFields(container, this.addresses[id]);
182+
} else {
181183
this.fillAddressFields(container, {});
182184
}
185+
this.selectAddressEvent = false;
183186

184187
var data = this.serializeData(container);
185188
data[el.name] = id;
@@ -190,6 +193,7 @@ define([
190193
} else{
191194
this.saveData(data);
192195
}
196+
193197
},
194198

195199
/**
@@ -279,6 +283,10 @@ define([
279283
$('order-' + type + '_address_customer_address_id').value;
280284
}
281285

286+
if (name === 'country_id' && this.selectAddressEvent === false) {
287+
$('order-' + type + '_address_customer_address_id').value = '';
288+
}
289+
282290
this.resetPaymentMethod();
283291

284292
if (data['reset_shipping']) {

app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_cart.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
height: 36px;
220220
margin-top: -7px;
221221
text-align: center;
222-
width: 45px;
222+
width: 60px;
223223
}
224224
}
225225

app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
.item-qty {
353353
margin-right: @indent__s;
354354
text-align: center;
355-
width: 45px;
355+
width: 60px;
356356
}
357357

358358
.update-cart-item {

lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@ public function toNestedArray(
4545
}
4646
$dataObjectArray = $this->dataObjectProcessor->buildOutputDataArray($dataObject, $dataObjectType);
4747
//process custom attributes if present
48+
$dataObjectArray = $this->processCustomAttributes($dataObjectArray, $skipAttributes);
49+
50+
if (!empty($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY])) {
51+
/** @var array $extensionAttributes */
52+
$extensionAttributes = $dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY];
53+
unset($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);
54+
foreach ($extensionAttributes as $attributeKey => $attributeValue) {
55+
if (!in_array($attributeKey, $skipAttributes)) {
56+
$dataObjectArray[$attributeKey] = $attributeValue;
57+
}
58+
}
59+
}
60+
return $dataObjectArray;
61+
}
62+
63+
/**
64+
* Recursive process array to process customer attributes
65+
*
66+
* @param array $dataObjectArray
67+
* @param array $skipAttributes
68+
* @return array
69+
*/
70+
private function processCustomAttributes(array $dataObjectArray, array $skipAttributes): array
71+
{
4872
if (!empty($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY])) {
4973
/** @var AttributeValue[] $customAttributes */
5074
$customAttributes = $dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY];
@@ -56,16 +80,13 @@ public function toNestedArray(
5680
}
5781
}
5882
}
59-
if (!empty($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY])) {
60-
/** @var array $extensionAttributes */
61-
$extensionAttributes = $dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY];
62-
unset($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);
63-
foreach ($extensionAttributes as $attributeKey => $attributeValue) {
64-
if (!in_array($attributeKey, $skipAttributes)) {
65-
$dataObjectArray[$attributeKey] = $attributeValue;
66-
}
83+
84+
foreach ($dataObjectArray as $key => $value) {
85+
if (is_array($value)) {
86+
$dataObjectArray[$key] = $this->processCustomAttributes($value, $skipAttributes);
6787
}
6888
}
89+
6990
return $dataObjectArray;
7091
}
7192

0 commit comments

Comments
 (0)