Skip to content

Commit 3fffab8

Browse files
authored
Merge pull request #6840 from magento-tsg/2.4-develop-pr145
[Arrows] Fixes for 2.4 (pr145) (2.4-develop)
2 parents 2ffcb6f + 8e19d9e commit 3fffab8

File tree

6 files changed

+116
-18
lines changed

6 files changed

+116
-18
lines changed

app/code/Magento/Customer/Api/Data/CustomerInterface.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
namespace Magento\Customer\Api\Data;
77

88
/**
9-
* Customer interface.
9+
* Customer entity interface for API handling.
10+
*
1011
* @api
1112
* @since 100.0.2
1213
*/
@@ -161,7 +162,10 @@ public function setCreatedIn($createdIn);
161162
/**
162163
* Get date of birth
163164
*
164-
* @return string|null
165+
* @return string|null In keeping with current security and privacy best practices, be sure you are aware of any
166+
* potential legal and security risks associated with the storage of customers’ full date of birth
167+
* (month, day, year) along with other personal identifiers (e.g., full name) before collecting or processing
168+
* such data.
165169
*/
166170
public function getDob();
167171

app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,12 @@ protected function getProductInfo(\Magento\Framework\DataObject $buyRequest, $pr
351351
if ($isStrictProcessMode && !$subProduct->getQty() && $subProduct->isSalable()) {
352352
return __('Please specify the quantity of product(s).')->render();
353353
}
354-
$productsInfo[$subProduct->getId()] = $subProduct->isSalable() ? (float)$subProduct->getQty() : 0;
354+
if (isset($buyRequest['qty']) && !isset($buyRequest['super_group'])) {
355+
$subProductQty = (float)$subProduct->getQty() * (float)$buyRequest['qty'];
356+
$productsInfo[$subProduct->getId()] = $subProduct->isSalable() ? $subProductQty : 0;
357+
} else {
358+
$productsInfo[$subProduct->getId()] = $subProduct->isSalable() ? (float)$subProduct->getQty() : 0;
359+
}
355360
}
356361
}
357362

app/code/Magento/Sales/Api/Data/OrderInterface.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,10 @@ public function setCreatedAt($createdAt);
913913
/**
914914
* Gets the customer date-of-birth (DOB) for the order.
915915
*
916-
* @return string|null Customer date-of-birth (DOB).
916+
* @return string|null In keeping with current security and privacy best practices, be sure you are aware of any
917+
* potential legal and security risks associated with the storage of customers’ full date of birth
918+
* (month, day, year) along with other personal identifiers (e.g., full name) before collecting or processing
919+
* such data.
917920
*/
918921
public function getCustomerDob();
919922

dev/tests/api-functional/testsuite/Magento/Quote/Api/CartAddingItemsTest.php

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
1111
use Magento\Framework\Webapi\Rest\Request;
1212
use Magento\Integration\Api\CustomerTokenServiceInterface;
13+
use Magento\Quote\Model\Quote;
14+
use Magento\Quote\Model\QuoteIdMask;
1315
use Magento\TestFramework\Helper\Bootstrap;
1416
use Magento\TestFramework\ObjectManager;
1517
use Magento\TestFramework\TestCase\WebapiAbstract;
@@ -29,6 +31,11 @@ class CartAddingItemsTest extends WebapiAbstract
2931
*/
3032
private $productResource;
3133

34+
/**
35+
* @var array
36+
*/
37+
private $createdQuotes = [];
38+
3239
/**
3340
* @inheritDoc
3441
*/
@@ -38,6 +45,71 @@ protected function setUp(): void
3845
$this->productResource = $this->objectManager->get(ProductResource::class);
3946
}
4047

48+
protected function tearDown(): void
49+
{
50+
/** @var Quote $quote */
51+
$quote = $this->objectManager->create(Quote::class);
52+
foreach ($this->createdQuotes as $quoteId) {
53+
$quote->load($quoteId);
54+
$quote->delete();
55+
}
56+
}
57+
58+
/**
59+
* Test qty for cart after adding grouped product qty specified only for goruped product.
60+
*
61+
* @magentoApiDataFixture Magento/GroupedProduct/_files/product_grouped_with_simple.php
62+
* @magentoApiDataFixture Magento/Customer/_files/customer_one_address.php
63+
* @return void
64+
*/
65+
public function testAddToCartGroupedWithParentQuantity(): void
66+
{
67+
$this->_markTestAsRestOnly();
68+
69+
// Get customer ID token
70+
/** @var CustomerTokenServiceInterface $customerTokenService */
71+
$customerTokenService = $this->objectManager->create(CustomerTokenServiceInterface::class);
72+
$token = $customerTokenService->createCustomerAccessToken(
73+
'customer_one_address@test.com',
74+
'password'
75+
);
76+
77+
// Creating empty cart for registered customer.
78+
$serviceInfo = [
79+
'rest' => [
80+
'resourcePath' => '/V1/carts/mine',
81+
'httpMethod' => Request::HTTP_METHOD_POST,
82+
'token' => $token
83+
]
84+
];
85+
86+
$quoteId = $this->_webApiCall($serviceInfo, ['customerId' => 999]); // customerId 999 will get overridden
87+
$this->assertGreaterThan(0, $quoteId);
88+
89+
/** @var CartRepositoryInterface $cartRepository */
90+
$cartRepository = $this->objectManager->get(CartRepositoryInterface::class);
91+
$quote = $cartRepository->get($quoteId);
92+
93+
$quoteItems = $quote->getItemsCollection();
94+
foreach ($quoteItems as $item) {
95+
$quote->removeItem($item->getId())->save();
96+
}
97+
98+
$requestData = [
99+
'cartItem' => [
100+
'quote_id' => $quoteId,
101+
'sku' => 'grouped',
102+
'qty' => 7
103+
]
104+
];
105+
$this->_webApiCall($this->getServiceInfoAddToCart($token), $requestData);
106+
107+
foreach ($quote->getAllItems() as $item) {
108+
$this->assertEquals(7, $item->getQty());
109+
}
110+
$this->createdQuotes[] = $quoteId;
111+
}
112+
41113
/**
42114
* Test price for cart after adding product to.
43115
*
@@ -94,10 +166,11 @@ public function testPriceForCreatingQuoteFromEmptyCart()
94166
$paymentInfo = $this->_webApiCall($serviceInfoForGettingPaymentInfo);
95167
$this->assertEquals($paymentInfo['totals']['grand_total'], 10);
96168

97-
/** @var \Magento\Quote\Model\Quote $quote */
98-
$quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class);
99-
$quote->load($quoteId);
100-
$quote->delete();
169+
$this->createdQuotes[] = $quoteId;
170+
// /** @var \Magento\Quote\Model\Quote $quote */
171+
// $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class);
172+
// $quote->load($quoteId);
173+
// $quote->delete();
101174
}
102175

103176
/**
@@ -163,6 +236,7 @@ public function testAddToCartGroupedCustomQuantity(): void
163236
foreach ($quote->getAllItems() as $item) {
164237
$this->assertEquals($qtyData[$item->getProductId()], $item->getQty());
165238
}
239+
$this->createdQuotes[] = $quoteId;
166240
}
167241

168242
/**
@@ -210,6 +284,8 @@ public function testAddToCartGroupedCustomQuantityNotAllParamsSpecified(): void
210284
]
211285
];
212286

287+
$this->createdQuotes[] = $quoteId;
288+
213289
$this->expectException(\Exception::class);
214290
$this->expectExceptionMessage('Please specify id and qty for grouped options.');
215291

dev/tests/integration/testsuite/Magento/Customer/_files/customer_one_address_rollback.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,22 @@
1818
$registry->register('isSecureArea', true);
1919
/** @var CustomerRepositoryInterface $customerRepo */
2020
$customerRepo = $objectManager->get(CustomerRepositoryInterface::class);
21-
try {
22-
$customer = $customerRepo->get('customer_with_addresses@test.com');
23-
/** @var AddressRepositoryInterface $addressRepo */
24-
$addressRepo = $objectManager->get(AddressRepositoryInterface::class);
25-
foreach ($customer->getAddresses() as $address) {
26-
$addressRepo->delete($address);
21+
$customersEmails = [
22+
'customer_one_address@test.com',
23+
'customer_with_addresses@test.com',
24+
];
25+
$addressRepo = $objectManager->get(AddressRepositoryInterface::class);
26+
foreach ($customersEmails as $customerEmail) {
27+
try {
28+
$customer = $customerRepo->get($customerEmail);
29+
foreach ($customer->getAddresses() as $address) {
30+
$addressRepo->delete($address);
31+
}
32+
$customerRepo->delete($customer);
33+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
34+
} catch (NoSuchEntityException $exception) {
35+
//Already deleted
2736
}
28-
$customerRepo->delete($customer);
29-
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
30-
} catch (NoSuchEntityException $exception) {
31-
//Already deleted
3237
}
3338
$registry->unregister('isSecureArea');
3439
$registry->register('isSecureArea', false);

lib/web/mage/adminhtml/form.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ define([
551551
} else {
552552
if (target) {
553553
target.show();
554+
headElement = jQuery('.field-' + idTo).add('.field-chooser' + idTo);
555+
headElement.show();
554556
}
555557

556558
if (isAnInputOrSelect && !isInheritCheckboxChecked) {
@@ -580,6 +582,9 @@ define([
580582

581583
if (headElement.length > 0) {
582584
headElement.hide();
585+
} else {
586+
headElement = jQuery('.field-' + idTo).add('.field-chooser' + idTo);
587+
headElement.hide();
583588
}
584589

585590
if (target) {

0 commit comments

Comments
 (0)