Skip to content

Commit f0626cf

Browse files
author
Liukshyn Roman
committed
Merge branch 'develop' of https://github.corp.magento.com/magento2/magento2ce into develop-main
2 parents c0103f4 + f1c07c5 commit f0626cf

File tree

106 files changed

+2346
-1315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2346
-1315
lines changed

app/code/Magento/Backend/Model/Session/AdminConfig.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function __construct(
8484
$adminPath = $this->extractAdminPath();
8585
$this->setCookiePath($adminPath);
8686
$this->setName($sessionName);
87+
$this->setCookieSecure($this->_httpRequest->isSecure());
8788
}
8889

8990
/**

app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ public function testSetCookiePathNonDefault()
105105
}
106106

107107
/**
108-
* Test for setting session name for admin
109-
*
108+
* Test for setting session name and secure_cookie for admin
109+
* @dataProvider requestSecureDataProvider
110+
* @param $secureRequest
110111
*/
111-
public function testSetSessionNameByConstructor()
112+
public function testSetSessionSettingsByConstructor($secureRequest)
112113
{
113114
$sessionName = 'admin';
115+
$this->requestMock->expects($this->once())->method('isSecure')->willReturn($secureRequest);
114116

115117
$validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface')
116118
->disableOriginalConstructor()
@@ -136,5 +138,11 @@ public function testSetSessionNameByConstructor()
136138
]
137139
);
138140
$this->assertSame($sessionName, $adminConfig->getName());
141+
$this->assertSame($secureRequest, $adminConfig->getCookieSecure());
142+
}
143+
144+
public function requestSecureDataProvider()
145+
{
146+
return [[true], [false]];
139147
}
140148
}

app/code/Magento/Braintree/Model/Checkout.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ private function ignoreAddressValidation()
119119
*/
120120
protected function importAddressData($address, $exportedAddress)
121121
{
122-
$address->setStreet([$exportedAddress['streetAddress'], $exportedAddress['extendedAddress']]);
122+
$extendedAddress = isset($exportedAddress['extendedAddress']) ? $exportedAddress['extendedAddress'] : null;
123+
$address->setStreet([$exportedAddress['streetAddress'], $extendedAddress]);
123124
$address->setCity($exportedAddress['locality']);
124125
$address->setRegionCode($exportedAddress['region']);
125126
$address->setCountryId($exportedAddress['countryCodeAlpha2']);

app/code/Magento/Braintree/Test/Unit/Model/CheckoutTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ public function testInitializeQuoteForReview(
214214
$this->model->initializeQuoteForReview($paymentMethodNonce, $details);
215215
}
216216

217+
/**
218+
* @return array
219+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
220+
*/
217221
public function initializeQuoteForReviewDataProvider()
218222
{
219223
return [
@@ -311,6 +315,48 @@ public function initializeQuoteForReviewDataProvider()
311315
'payerLastName' => self::LASTNAME,
312316
]
313317
],
318+
'without_shipping_extended_address' => [
319+
'payment_method_nonce' => 'nonce',
320+
'details' => [
321+
'email' => self::EMAIL,
322+
'firstName' => self::FIRSTNAME,
323+
'lastName' => self::LASTNAME,
324+
'shippingAddress' => [
325+
'streetAddress' => self::SHIPPING_STREET_ADDRESS,
326+
'locality' => self::SHIPPING_LOCALITY,
327+
'region' => self::SHIPPING_REGION,
328+
'countryCodeAlpha2' => self::SHIPPING_COUNTRY_CODE,
329+
'postalCode' => self::SHIPPING_POSTAL_CODE,
330+
],
331+
],
332+
'expected_shipping' => [
333+
'setFirstname' => self::FIRSTNAME,
334+
'setLastname' => self::LASTNAME,
335+
'setEmail' => self::EMAIL,
336+
'setCollectShippingRates' => true,
337+
'setStreet' => [self::SHIPPING_STREET_ADDRESS, null],
338+
'setCity' => self::SHIPPING_LOCALITY,
339+
'setRegionCode' => self::SHIPPING_REGION,
340+
'setCountryId' => self::SHIPPING_COUNTRY_CODE,
341+
'setPostCode' => self::SHIPPING_POSTAL_CODE,
342+
],
343+
'expected_billing' => [
344+
'setFirstname' => self::FIRSTNAME,
345+
'setLastname' => self::LASTNAME,
346+
'setEmail' => self::EMAIL,
347+
'setStreet' => [self::SHIPPING_STREET_ADDRESS, null],
348+
'setCity' => self::SHIPPING_LOCALITY,
349+
'setRegionCode' => self::SHIPPING_REGION,
350+
'setCountryId' => self::SHIPPING_COUNTRY_CODE,
351+
'setPostCode' => self::SHIPPING_POSTAL_CODE,
352+
],
353+
'expected_payment_additional_info' => [
354+
'payment_method_nonce' => 'nonce',
355+
'payerEmail' => self::EMAIL,
356+
'payerFirstName' => self::FIRSTNAME,
357+
'payerLastName' => self::LASTNAME,
358+
]
359+
],
314360
];
315361
}
316362
}

app/code/Magento/Bundle/Model/LinkManagement.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ public function addChild(
254254

255255
try {
256256
$selectionModel->save();
257+
$resource->addProductRelations($product->getId(), [$linkProductModel->getId()]);
257258
} catch (\Exception $e) {
258259
throw new CouldNotSaveException(__('Could not save child: "%1"', $e->getMessage()), $e);
259260
}
@@ -294,7 +295,7 @@ public function removeChild($sku, $optionId, $childSku)
294295
/* @var $resource \Magento\Bundle\Model\ResourceModel\Bundle */
295296
$resource = $this->bundleFactory->create();
296297
$resource->dropAllUnneededSelections($product->getId(), $excludeSelectionIds);
297-
$resource->saveProductRelations($product->getId(), array_unique($usedProductIds));
298+
$resource->removeProductRelations($product->getId(), array_unique($usedProductIds));
298299

299300
return true;
300301
}

app/code/Magento/Bundle/Model/OptionRepository.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,22 @@ public function save(
170170
$option->setParentId($product->getId());
171171

172172
$optionId = $option->getOptionId();
173-
$linksToAdd = [];
174173
if (!$optionId) {
174+
$linksToAdd = [];
175175
$option->setDefaultTitle($option->getTitle());
176176
if (is_array($option->getProductLinks())) {
177177
$linksToAdd = $option->getProductLinks();
178178
}
179+
try {
180+
$this->optionResource->save($option);
181+
} catch (\Exception $e) {
182+
throw new CouldNotSaveException(__('Could not save option'), $e);
183+
}
184+
185+
/** @var \Magento\Bundle\Api\Data\LinkInterface $linkedProduct */
186+
foreach ($linksToAdd as $linkedProduct) {
187+
$this->linkManagement->addChild($product, $option->getOptionId(), $linkedProduct);
188+
}
179189
} else {
180190
$optionCollection = $this->type->getOptionsCollection($product);
181191

@@ -188,19 +198,13 @@ public function save(
188198

189199
$option->setData(array_merge($existingOption->getData(), $option->getData()));
190200
$this->updateOptionSelection($product, $option);
201+
try {
202+
$this->optionResource->save($option);
203+
} catch (\Exception $e) {
204+
throw new CouldNotSaveException(__('Could not save option'), $e);
205+
}
191206
}
192-
193-
try {
194-
$this->optionResource->save($option);
195-
} catch (\Exception $e) {
196-
throw new CouldNotSaveException(__('Could not save option'), $e);
197-
}
198-
199-
/** @var \Magento\Bundle\Api\Data\LinkInterface $linkedProduct */
200-
foreach ($linksToAdd as $linkedProduct) {
201-
$this->linkManagement->addChild($product, $option->getOptionId(), $linkedProduct);
202-
}
203-
207+
$product->setIsRelationsChanged(true);
204208
return $option->getOptionId();
205209
}
206210

app/code/Magento/Bundle/Model/ResourceModel/Bundle.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,30 @@ public function saveProductRelations($parentId, $childIds)
142142

143143
return $this;
144144
}
145+
146+
/**
147+
* Add product relations
148+
*
149+
* @param int $parentId
150+
* @param array $childIds
151+
* @return $this
152+
*/
153+
public function addProductRelations($parentId, $childIds)
154+
{
155+
$this->_productRelation->addRelations($parentId, $childIds);
156+
return $this;
157+
}
158+
159+
/**
160+
* Remove product relations
161+
*
162+
* @param int $parentId
163+
* @param array $childIds
164+
* @return $this
165+
*/
166+
public function removeProductRelations($parentId, $childIds)
167+
{
168+
$this->_productRelation->removeRelations($parentId, $childIds);
169+
return $this;
170+
}
145171
}

app/code/Magento/Bundle/Test/Unit/Model/LinkManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ public function testRemoveChild()
868868
$this->product->expects($this->any())->method('getId')->will($this->returnValue(3));
869869

870870
$bundle->expects($this->once())->method('dropAllUnneededSelections')->with(3, []);
871-
$bundle->expects($this->once())->method('saveProductRelations')->with(3, []);
871+
$bundle->expects($this->once())->method('removeProductRelations')->with(3, []);
872872
//Params come in lowercase to method
873873
$this->assertTrue($this->model->removeChild($productSku, $optionId, $childSku));
874874
}

app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ public function testSaveExistingOption()
408408
->method('getProductLinks')
409409
->willReturn([$productLinkUpdate, $productLinkNew]);
410410

411-
$this->optionResourceMock->expects($this->once())->method('save')->with($optionMock)->willReturnSelf();
412411
$this->linkManagementMock->expects($this->once())
413412
->method('addChild')
414413
->with($productMock, $optionId, $productLinkNew);

app/code/Magento/Bundle/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<plugin name="bundle" type="Magento\Bundle\Model\Plugin\PriceBackend" sortOrder="100" />
7979
</type>
8080
<type name="Magento\Catalog\Api\ProductRepositoryInterface">
81-
<plugin name="bundleSaveOptions" type="\Magento\Bundle\Model\Plugin\BundleSaveOptions"/>
81+
<plugin name="bundleSaveOptions" type="\Magento\Bundle\Model\Plugin\BundleSaveOptions" sortOrder="100"/>
8282
</type>
8383
<type name="Magento\Catalog\Model\Product">
8484
<plugin name="bundleLoadOptions" type="\Magento\Bundle\Model\Plugin\BundleLoadOptions"/>

0 commit comments

Comments
 (0)