diff --git a/app/code/Magento/Customer/Api/Data/CustomerInterface.php b/app/code/Magento/Customer/Api/Data/CustomerInterface.php index 9e8f9a12d5a48..f03889050ef82 100644 --- a/app/code/Magento/Customer/Api/Data/CustomerInterface.php +++ b/app/code/Magento/Customer/Api/Data/CustomerInterface.php @@ -6,7 +6,8 @@ namespace Magento\Customer\Api\Data; /** - * Customer interface. + * Customer entity interface for API handling. + * * @api * @since 100.0.2 */ @@ -161,7 +162,10 @@ public function setCreatedIn($createdIn); /** * Get date of birth * - * @return string|null + * @return string|null In keeping with current security and privacy best practices, be sure you are aware of any + * potential legal and security risks associated with the storage of customers’ full date of birth + * (month, day, year) along with other personal identifiers (e.g., full name) before collecting or processing + * such data. */ public function getDob(); diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php index b56e8657df722..24e4e49f51b9c 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php @@ -351,7 +351,12 @@ protected function getProductInfo(\Magento\Framework\DataObject $buyRequest, $pr if ($isStrictProcessMode && !$subProduct->getQty() && $subProduct->isSalable()) { return __('Please specify the quantity of product(s).')->render(); } - $productsInfo[$subProduct->getId()] = $subProduct->isSalable() ? (float)$subProduct->getQty() : 0; + if (isset($buyRequest['qty']) && !isset($buyRequest['super_group'])) { + $subProductQty = (float)$subProduct->getQty() * (float)$buyRequest['qty']; + $productsInfo[$subProduct->getId()] = $subProduct->isSalable() ? $subProductQty : 0; + } else { + $productsInfo[$subProduct->getId()] = $subProduct->isSalable() ? (float)$subProduct->getQty() : 0; + } } } diff --git a/app/code/Magento/Sales/Api/Data/OrderInterface.php b/app/code/Magento/Sales/Api/Data/OrderInterface.php index b45fddc7d7354..b483930fd7e1b 100644 --- a/app/code/Magento/Sales/Api/Data/OrderInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderInterface.php @@ -913,7 +913,10 @@ public function setCreatedAt($createdAt); /** * Gets the customer date-of-birth (DOB) for the order. * - * @return string|null Customer date-of-birth (DOB). + * @return string|null In keeping with current security and privacy best practices, be sure you are aware of any + * potential legal and security risks associated with the storage of customers’ full date of birth + * (month, day, year) along with other personal identifiers (e.g., full name) before collecting or processing + * such data. */ public function getCustomerDob(); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartAddingItemsTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartAddingItemsTest.php index bb2a4e68212cf..9208fb731bc51 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartAddingItemsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartAddingItemsTest.php @@ -10,6 +10,8 @@ use Magento\Catalog\Model\ResourceModel\Product as ProductResource; use Magento\Framework\Webapi\Rest\Request; use Magento\Integration\Api\CustomerTokenServiceInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\QuoteIdMask; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\WebapiAbstract; @@ -29,6 +31,11 @@ class CartAddingItemsTest extends WebapiAbstract */ private $productResource; + /** + * @var array + */ + private $createdQuotes = []; + /** * @inheritDoc */ @@ -38,6 +45,71 @@ protected function setUp(): void $this->productResource = $this->objectManager->get(ProductResource::class); } + protected function tearDown(): void + { + /** @var Quote $quote */ + $quote = $this->objectManager->create(Quote::class); + foreach ($this->createdQuotes as $quoteId) { + $quote->load($quoteId); + $quote->delete(); + } + } + + /** + * Test qty for cart after adding grouped product qty specified only for goruped product. + * + * @magentoApiDataFixture Magento/GroupedProduct/_files/product_grouped_with_simple.php + * @magentoApiDataFixture Magento/Customer/_files/customer_one_address.php + * @return void + */ + public function testAddToCartGroupedWithParentQuantity(): void + { + $this->_markTestAsRestOnly(); + + // Get customer ID token + /** @var CustomerTokenServiceInterface $customerTokenService */ + $customerTokenService = $this->objectManager->create(CustomerTokenServiceInterface::class); + $token = $customerTokenService->createCustomerAccessToken( + 'customer_one_address@test.com', + 'password' + ); + + // Creating empty cart for registered customer. + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/carts/mine', + 'httpMethod' => Request::HTTP_METHOD_POST, + 'token' => $token + ] + ]; + + $quoteId = $this->_webApiCall($serviceInfo, ['customerId' => 999]); // customerId 999 will get overridden + $this->assertGreaterThan(0, $quoteId); + + /** @var CartRepositoryInterface $cartRepository */ + $cartRepository = $this->objectManager->get(CartRepositoryInterface::class); + $quote = $cartRepository->get($quoteId); + + $quoteItems = $quote->getItemsCollection(); + foreach ($quoteItems as $item) { + $quote->removeItem($item->getId())->save(); + } + + $requestData = [ + 'cartItem' => [ + 'quote_id' => $quoteId, + 'sku' => 'grouped', + 'qty' => 7 + ] + ]; + $this->_webApiCall($this->getServiceInfoAddToCart($token), $requestData); + + foreach ($quote->getAllItems() as $item) { + $this->assertEquals(7, $item->getQty()); + } + $this->createdQuotes[] = $quoteId; + } + /** * Test price for cart after adding product to. * @@ -94,10 +166,11 @@ public function testPriceForCreatingQuoteFromEmptyCart() $paymentInfo = $this->_webApiCall($serviceInfoForGettingPaymentInfo); $this->assertEquals($paymentInfo['totals']['grand_total'], 10); - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); - $quote->load($quoteId); - $quote->delete(); + $this->createdQuotes[] = $quoteId; +// /** @var \Magento\Quote\Model\Quote $quote */ +// $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); +// $quote->load($quoteId); +// $quote->delete(); } /** @@ -163,6 +236,7 @@ public function testAddToCartGroupedCustomQuantity(): void foreach ($quote->getAllItems() as $item) { $this->assertEquals($qtyData[$item->getProductId()], $item->getQty()); } + $this->createdQuotes[] = $quoteId; } /** @@ -210,6 +284,8 @@ public function testAddToCartGroupedCustomQuantityNotAllParamsSpecified(): void ] ]; + $this->createdQuotes[] = $quoteId; + $this->expectException(\Exception::class); $this->expectExceptionMessage('Please specify id and qty for grouped options.'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_one_address_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_one_address_rollback.php index 441700389840d..3e39a87d12e38 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_one_address_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_one_address_rollback.php @@ -18,17 +18,22 @@ $registry->register('isSecureArea', true); /** @var CustomerRepositoryInterface $customerRepo */ $customerRepo = $objectManager->get(CustomerRepositoryInterface::class); -try { - $customer = $customerRepo->get('customer_with_addresses@test.com'); - /** @var AddressRepositoryInterface $addressRepo */ - $addressRepo = $objectManager->get(AddressRepositoryInterface::class); - foreach ($customer->getAddresses() as $address) { - $addressRepo->delete($address); +$customersEmails = [ + 'customer_one_address@test.com', + 'customer_with_addresses@test.com', +]; +$addressRepo = $objectManager->get(AddressRepositoryInterface::class); +foreach ($customersEmails as $customerEmail) { + try { + $customer = $customerRepo->get($customerEmail); + foreach ($customer->getAddresses() as $address) { + $addressRepo->delete($address); + } + $customerRepo->delete($customer); + // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock + } catch (NoSuchEntityException $exception) { + //Already deleted } - $customerRepo->delete($customer); -// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock -} catch (NoSuchEntityException $exception) { - //Already deleted } $registry->unregister('isSecureArea'); $registry->register('isSecureArea', false); diff --git a/lib/web/mage/adminhtml/form.js b/lib/web/mage/adminhtml/form.js index 20ca1d505bb21..85ee38f966fa6 100644 --- a/lib/web/mage/adminhtml/form.js +++ b/lib/web/mage/adminhtml/form.js @@ -551,6 +551,8 @@ define([ } else { if (target) { target.show(); + headElement = jQuery('.field-' + idTo).add('.field-chooser' + idTo); + headElement.show(); } if (isAnInputOrSelect && !isInheritCheckboxChecked) { @@ -580,6 +582,9 @@ define([ if (headElement.length > 0) { headElement.hide(); + } else { + headElement = jQuery('.field-' + idTo).add('.field-chooser' + idTo); + headElement.hide(); } if (target) {