Skip to content

Commit 8aa1d46

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Accepted Community Pull Requests: - #28896: Remove related products that not exist in map list. (by @forfin) - #29833: [MFTF] Removed redundant action group (by @Usik2203) - #27857: Fixed wrong customer group assign to order 26976 (by @ProkopovVitaliy) Fixed GitHub Issues: - #28892: Disable product that relate to another product make graphql break when query. (reported by @forfin) has been fixed in #28896 by @forfin in 2.4-develop branch Related commits: 1. a57dbd6 2. ed40853 3. d8314a1 - #29839: [Issue] [MFTF] Removed redundant action group (reported by @m2-assistant[bot]) has been fixed in #29833 by @Usik2203 in 2.4-develop branch Related commits: 1. c67c5f8 2. e2cc35c 3. 7f311a3 4. c56157b 5. d32100e 6. 4c66066 7. 3095bbe 8. ce46ca6 9. 9b16538 10. d2c7d4c 11. babb4ef - #26976: Wrong Customer Group assign to order (reported by @prashantbarot) has been fixed in #27857 by @ProkopovVitaliy in 2.4-develop branch Related commits: 1. a84629f 2. 24793f9 3. 669c923 4. 92bd591 5. a6cf5cb 6. 245453e 7. eb3fe20 8. 183a2a0 9. c38d1ef 10. c6ebe35 11. 38ae3b1 12. 3ed5e1c 13. 07e9b1c 14. cae2258 15. 7153359 16. 2ce9abd 17. 32be93c 18. a5dba17 19. d231549 20. c1fbef5 21. a9e6752 22. 22f98a6 23. d64c0e7 24. 7c6b7f7 25. 74c0c92 26. 818a7fa 27. 0d97464 28. 50bf2f5 29. a8ffe0b
2 parents 72f253e + 0ee1c6c commit 8aa1d46

File tree

10 files changed

+217
-35
lines changed

10 files changed

+217
-35
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontCustomerCheckoutWithCustomerGroupTest">
11+
<annotations>
12+
<features value="Customer Checkout"/>
13+
<stories value="Customer checkout with Customer Group assigned"/>
14+
<title value="Place order by Customer with Customer Group assigned"/>
15+
<description value="Customer Group should be assigned to Order when setting Auto Group Assign is enabled for Customer"/>
16+
<testCaseId value="MC-37259"/>
17+
<severity value="MAJOR"/>
18+
<group value="checkout"/>
19+
<group value="customer"/>
20+
</annotations>
21+
<before>
22+
23+
<magentoCLI command="config:set customer/create_account/auto_group_assign 1" stepKey="enableAutoGroupAssign"/>
24+
25+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
26+
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
30+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
31+
32+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
33+
34+
<actionGroup ref="AdminUpdateCustomerGroupByEmailActionGroup" stepKey="updateCustomerGroup">
35+
<argument name="emailAddress" value="$$createCustomer.email$$"/>
36+
<argument name="customerGroup" value="Retail"/>
37+
</actionGroup>
38+
39+
</before>
40+
<after>
41+
<magentoCLI command="config:set customer/create_account/auto_group_assign 0" stepKey="disableAutoGroupAssign"/>
42+
43+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/>
44+
<deleteData createDataKey="createCustomer" stepKey="deleteUsCustomer"/>
45+
<actionGroup ref="AdminClearCustomersFiltersActionGroup" stepKey="resetCustomerFilters"/>
46+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
47+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
48+
<deleteData createDataKey="createCategory" stepKey="deleteSimpleCategory"/>
49+
</after>
50+
51+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="storefrontCustomerLogin">
52+
<argument name="Customer" value="$$createCustomer$$"/>
53+
</actionGroup>
54+
55+
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="navigateToCategoryPage">
56+
<argument name="category" value="$$createCategory$$"/>
57+
</actionGroup>
58+
59+
<waitForPageLoad stepKey="waitForCatalogPageLoad"/>
60+
61+
<actionGroup ref="StorefrontAddCategoryProductToCartActionGroup" stepKey="addProductToCart">
62+
<argument name="product" value="$$createSimpleProduct$$"/>
63+
<argument name="productCount" value="CONST.one"/>
64+
</actionGroup>
65+
66+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
67+
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRate"/>
68+
<actionGroup ref="StorefrontCheckoutForwardFromShippingStepActionGroup" stepKey="goToReview"/>
69+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyOrder"/>
70+
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="clickOnPlaceOrder">
71+
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage"/>
72+
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage"/>
73+
</actionGroup>
74+
75+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="orderNumber"/>
76+
77+
<actionGroup ref="OpenOrderByIdActionGroup" stepKey="addFilterToGridAndOpenOrder">
78+
<argument name="orderId" value="{$orderNumber}"/>
79+
</actionGroup>
80+
81+
<see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="verifyOrderStatus"/>
82+
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="Customer" stepKey="verifyAccountInformation"/>
83+
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="$$createCustomer.email$$" stepKey="verifyCustomerEmail"/>
84+
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="Retail" stepKey="verifyCustomerGroup"/>
85+
<see selector="{{AdminOrderDetailsInformationSection.billingAddress}}" userInput="{{US_Address_TX.street[0]}}" stepKey="verifyBillingAddress"/>
86+
<see selector="{{AdminOrderDetailsInformationSection.shippingAddress}}" userInput="{{US_Address_TX.street[0]}}" stepKey="verifyShippingAddress"/>
87+
<see selector="{{AdminOrderDetailsInformationSection.itemsOrdered}}" userInput="$$createSimpleProduct.name$$" stepKey="verifyProductName"/>
88+
89+
</test>
90+
</tests>

app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1010
<actionGroup name="AdminOpenCmsPageActionGroup">
11+
<annotations>
12+
<description>Open CMS edit page.</description>
13+
</annotations>
1114
<arguments>
1215
<argument name="page_id" type="string"/>
1316
</arguments>

app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml

-16
This file was deleted.

app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
119119

120120
$groupId = null;
121121
if (empty($customerVatNumber) || false == $this->customerVat->isCountryInEU($customerCountryCode)) {
122-
$groupId = $customer->getId() ? $this->groupManagement->getDefaultGroup(
123-
$storeId
124-
)->getId() : $this->groupManagement->getNotLoggedInGroup()->getId();
122+
$groupId = $customer->getId() ? $quote->getCustomerGroupId() :
123+
$this->groupManagement->getNotLoggedInGroup()->getId();
125124
} else {
126125
// Magento always has to emulate group even if customer uses default billing/shipping address
127126
$groupId = $this->customerVat->getCustomerGroupIdBasedOnVatNumber(

app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php

+9-14
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@
1313
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
1414
use Magento\Customer\Api\Data\GroupInterface;
1515
use Magento\Customer\Api\GroupManagementInterface;
16-
use Magento\Customer\Helper\Address;
16+
use Magento\Customer\Helper\Address as CustomerAddress;
1717
use Magento\Customer\Model\Session;
1818
use Magento\Customer\Model\Vat;
1919
use Magento\Framework\Event\Observer;
2020
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
2121
use Magento\Quote\Api\Data\ShippingAssignmentInterface;
2222
use Magento\Quote\Api\Data\ShippingInterface;
2323
use Magento\Quote\Model\Quote;
24+
use Magento\Quote\Model\Quote\Address;
2425
use Magento\Quote\Observer\Frontend\Quote\Address\CollectTotalsObserver;
2526
use Magento\Quote\Observer\Frontend\Quote\Address\VatValidator;
26-
use PHPUnit\Framework\MockObject\MockObject;
2727
use PHPUnit\Framework\TestCase;
28+
use PHPUnit\Framework\MockObject\MockObject;
2829

2930
/**
3031
* Class CollectTotalsTest
@@ -124,7 +125,7 @@ protected function setUp(): void
124125
true,
125126
['getStoreId', 'getCustomAttribute', 'getId', '__wakeup']
126127
);
127-
$this->customerAddressMock = $this->createMock(Address::class);
128+
$this->customerAddressMock = $this->createMock(CustomerAddress::class);
128129
$this->customerVatMock = $this->createMock(Vat::class);
129130
$this->customerDataFactoryMock = $this->getMockBuilder(CustomerInterfaceFactory::class)
130131
->addMethods(['mergeDataObjectWithArray'])
@@ -174,6 +175,7 @@ protected function setUp(): void
174175

175176
$shippingAssignmentMock = $this->getMockForAbstractClass(ShippingAssignmentInterface::class);
176177
$shippingMock = $this->getMockForAbstractClass(ShippingInterface::class);
178+
177179
$shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn($shippingMock);
178180
$shippingMock->expects($this->once())->method('getAddress')->willReturn($this->quoteAddressMock);
179181

@@ -185,7 +187,6 @@ protected function setUp(): void
185187
$this->quoteMock->expects($this->any())
186188
->method('getCustomer')
187189
->willReturn($this->customerMock);
188-
189190
$this->addressRepository = $this->getMockForAbstractClass(AddressRepositoryInterface::class);
190191
$this->customerSession = $this->getMockBuilder(Session::class)
191192
->disableOriginalConstructor()
@@ -266,26 +267,20 @@ public function testDispatchWithDefaultCustomerGroupId()
266267
->willReturn('customerCountryCode');
267268
$this->quoteAddressMock->expects($this->once())->method('getVatId')->willReturn(null);
268269

269-
$this->quoteMock->expects($this->once())
270+
$this->quoteMock->expects($this->exactly(2))
270271
->method('getCustomerGroupId')
271272
->willReturn('customerGroupId');
272273
$this->customerMock->expects($this->once())->method('getId')->willReturn('1');
273-
$this->groupManagementMock->expects($this->once())
274-
->method('getDefaultGroup')
275-
->willReturn($this->groupInterfaceMock);
276-
$this->groupInterfaceMock->expects($this->once())
277-
->method('getId')->willReturn('defaultCustomerGroupId');
274+
278275
/** Assertions */
279276
$this->quoteAddressMock->expects($this->once())
280277
->method('setPrevQuoteCustomerGroupId')
281278
->with('customerGroupId');
282-
$this->quoteMock->expects($this->once())->method('setCustomerGroupId')->with('defaultCustomerGroupId');
283279
$this->customerDataFactoryMock->expects($this->any())
284280
->method('create')
285281
->willReturn($this->customerMock);
286282

287283
$this->quoteMock->expects($this->once())->method('setCustomer')->with($this->customerMock);
288-
289284
/** SUT execution */
290285
$this->model->execute($this->observerMock);
291286
}
@@ -343,7 +338,7 @@ public function testDispatchWithAddressCustomerVatIdAndCountryId()
343338
$customerVat = "123123123";
344339
$defaultShipping = 1;
345340

346-
$customerAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
341+
$customerAddress = $this->createMock(Address::class);
347342
$customerAddress->expects($this->any())
348343
->method("getVatId")
349344
->willReturn($customerVat);
@@ -379,8 +374,8 @@ public function testDispatchWithEmptyShippingAddress()
379374
$customerCountryCode = "DE";
380375
$customerVat = "123123123";
381376
$defaultShipping = 1;
382-
383377
$customerAddress = $this->getMockForAbstractClass(AddressInterface::class);
378+
384379
$customerAddress->expects($this->once())
385380
->method("getCountryId")
386381
->willReturn($customerCountryCode);

app/code/Magento/RelatedProductGraphQl/Model/Resolver/Batch/AbstractLikedProducts.php

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ private function findRelations(array $products, array $loadAttributes, int $link
110110
//Matching products with related products.
111111
$relationsData = [];
112112
foreach ($relations as $productId => $relatedIds) {
113+
//Remove related products that not exist in map list.
114+
$relatedIds = array_filter($relatedIds, function ($relatedId) use ($relatedProducts) {
115+
return isset($relatedProducts[$relatedId]);
116+
});
113117
$relationsData[$productId] = array_map(
114118
function ($id) use ($relatedProducts) {
115119
return $relatedProducts[$id];

dev/tests/api-functional/testsuite/Magento/GraphQl/RelatedProduct/GetRelatedProductsTest.php

+35-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\TestFramework\TestCase\GraphQlAbstract;
1111

1212
/**
13-
* Get related products test
13+
* Test coverage for get related products
1414
*/
1515
class GetRelatedProductsTest extends GraphQlAbstract
1616
{
@@ -49,6 +49,40 @@ public function testQueryRelatedProducts()
4949
self::assertRelatedProducts($relatedProducts);
5050
}
5151

52+
/**
53+
* @magentoApiDataFixture Magento/Catalog/_files/products_related_disabled.php
54+
*/
55+
public function testQueryDisableRelatedProduct()
56+
{
57+
$productSku = 'simple_with_cross';
58+
59+
$query = <<<QUERY
60+
{
61+
products(filter: {sku: {eq: "{$productSku}"}})
62+
{
63+
items {
64+
related_products
65+
{
66+
sku
67+
name
68+
url_key
69+
created_at
70+
}
71+
}
72+
}
73+
}
74+
QUERY;
75+
$response = $this->graphQlQuery($query);
76+
77+
self::assertArrayHasKey('products', $response);
78+
self::assertArrayHasKey('items', $response['products']);
79+
self::assertCount(1, $response['products']['items']);
80+
self::assertArrayHasKey(0, $response['products']['items']);
81+
self::assertArrayHasKey('related_products', $response['products']['items'][0]);
82+
$relatedProducts = $response['products']['items'][0]['related_products'];
83+
self::assertCount(0, $relatedProducts);
84+
}
85+
5286
/**
5387
* @magentoApiDataFixture Magento/Catalog/_files/products_crosssell.php
5488
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
9+
/** @var $product \Magento\Catalog\Model\Product */
10+
$product = $objectManager->create(\Magento\Catalog\Model\Product::class);
11+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
12+
->setAttributeSetId(4)
13+
->setName('Simple Related Product')
14+
->setSku('simple')
15+
->setPrice(10)
16+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
17+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED)
18+
->setWebsiteIds([1])
19+
->setStockData(['qty' => 100, 'is_in_stock' => 1, 'manage_stock' => 1])
20+
->save();
21+
22+
/** @var \Magento\Catalog\Api\Data\ProductLinkInterface $productLink */
23+
$productLink = $objectManager->create(\Magento\Catalog\Api\Data\ProductLinkInterface::class);
24+
$productLink->setSku('simple_with_cross');
25+
$productLink->setLinkedProductSku('simple');
26+
$productLink->setPosition(1);
27+
$productLink->setLinkType('related');
28+
29+
$product = $objectManager->create(\Magento\Catalog\Model\Product::class);
30+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
31+
->setAttributeSetId(4)
32+
->setName('Simple Product With Related Product')
33+
->setSku('simple_with_cross')
34+
->setPrice(10)
35+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
36+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
37+
->setWebsiteIds([1])
38+
->setStockData(['qty' => 100, 'is_in_stock' => 1, 'manage_stock' => 1])
39+
->setProductLinks([$productLink])
40+
->save();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
9+
/** @var \Magento\Framework\Registry $registry */
10+
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
11+
12+
$registry->unregister('isSecureArea');
13+
$registry->register('isSecureArea', true);
14+
15+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
16+
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
17+
18+
try {
19+
$firstProduct = $productRepository->get('simple', false, null, true);
20+
$productRepository->delete($firstProduct);
21+
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
22+
//Product already removed
23+
}
24+
25+
try {
26+
$secondProduct = $productRepository->get('simple_with_cross', false, null, true);
27+
$productRepository->delete($secondProduct);
28+
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
29+
//Product already removed
30+
}
31+
32+
$registry->unregister('isSecureArea');
33+
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,6 @@ public function testChangeQuoteCustomerGroupIdForCustomerWithEnabledAutomaticGro
133133
);
134134
$this->model->execute($eventObserver);
135135

136-
$this->assertEquals(1, $quote->getCustomer()->getGroupId());
136+
$this->assertEquals(2, $quote->getCustomer()->getGroupId());
137137
}
138138
}

0 commit comments

Comments
 (0)