Skip to content

Commit e80727a

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #15845: Update webapi.xml to fix typo (by @mhaack) - #16306: Captcha: Added integration tests for checking customer login attempts cleanup (by @rogyar) - #16300: Captcha: Added integration test for checking admin login attempts cleanup (by @rogyar) - #16286: Add UpdatedAtListProvider to NotSyncedDataProvider for invoice grid (by @JeroenVanLeusden) - #15929: Postpone instantiation of session config by using a proxy (by @fmarangi) - #15872: Fix missing PHPDocs hinting for AdvancedPricingImportExport module (by @dmytro-ch) - #15774: [Backport] Fix issue #14895 - Change Password warning message appear two times (by @sanjay-wagento) - #12771: #12695: Unable to change attribute type from swatch (by @eugene-shab) Fixed GitHub Issues: - #15205: Upgraded to Magento 2.2.4 from Magento 2.1.9 - Locale and Store Configuration issues 'Store View' Locale not being used on frontend, 'Default Config' Locale being used instead (reported by @callumstar) has been fixed in #15929 by @fmarangi in 2.2-develop branch Related commits: 1. d23c198 2. b0b82d0 3. 7e835c3 - #15245: 2.2.4: Wrong home page loaded in multi store setup (reported by @jokeputs) has been fixed in #15929 by @fmarangi in 2.2-develop branch Related commits: 1. d23c198 2. b0b82d0 3. 7e835c3 - #14895: Change Password warning message appear two times (reported by @cnviradiya) has been fixed in #15774 by @sanjay-wagento in 2.2-develop branch Related commits: 1. b2cc966 2. cfe58e1 - #9307: Color attribute taking swatch instead of Drop down option for configurable options, (reported by @vishveskrish) has been fixed in #12771 by @eugene-shab in 2.2-develop branch Related commits: 1. 39b1ef3 2. 94539b7 3. 3d76096 4. 0b079e0 5. 71d30b7 6. 47b2f48 7. 707f1cd 8. 9153fe2 9. 1bd4acf 10. f499027 11. 3fa9ed2 12. 8fa792a 13. 7cd7ade 14. 54ad76c 15. bd12651 16. cb6975c - #9923: Upgrading to 2.1.7 changed dropdown attributes to swatches (reported by @roseofgold) has been fixed in #12771 by @eugene-shab in 2.2-develop branch Related commits: 1. 39b1ef3 2. 94539b7 3. 3d76096 4. 0b079e0 5. 71d30b7 6. 47b2f48 7. 707f1cd 8. 9153fe2 9. 1bd4acf 10. f499027 11. 3fa9ed2 12. 8fa792a 13. 7cd7ade 14. 54ad76c 15. bd12651 16. cb6975c - #11403: Product Attributes Not Updating on Frontend (reported by @rbur0425) has been fixed in #12771 by @eugene-shab in 2.2-develop branch Related commits: 1. 39b1ef3 2. 94539b7 3. 3d76096 4. 0b079e0 5. 71d30b7 6. 47b2f48 7. 707f1cd 8. 9153fe2 9. 1bd4acf 10. f499027 11. 3fa9ed2 12. 8fa792a 13. 7cd7ade 14. 54ad76c 15. bd12651 16. cb6975c - #11703: Changing Swatches to Drop-down does not remove swatches from existing products (reported by @expgabe) has been fixed in #12771 by @eugene-shab in 2.2-develop branch Related commits: 1. 39b1ef3 2. 94539b7 3. 3d76096 4. 0b079e0 5. 71d30b7 6. 47b2f48 7. 707f1cd 8. 9153fe2 9. 1bd4acf 10. f499027 11. 3fa9ed2 12. 8fa792a 13. 7cd7ade 14. 54ad76c 15. bd12651 16. cb6975c - #12695: Unable to change attribute type from swatch to dropdown (reported by @alena-marchenko) has been fixed in #12771 by @eugene-shab in 2.2-develop branch Related commits: 1. 39b1ef3 2. 94539b7 3. 3d76096 4. 0b079e0 5. 71d30b7 6. 47b2f48 7. 707f1cd 8. 9153fe2 9. 1bd4acf 10. f499027 11. 3fa9ed2 12. 8fa792a 13. 7cd7ade 14. 54ad76c 15. bd12651 16. cb6975c
2 parents 4052cf6 + d44ec51 commit e80727a

File tree

23 files changed

+361
-13
lines changed

23 files changed

+361
-13
lines changed

app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ class AdvancedPricing extends \Magento\CatalogImportExport\Model\Export\Product
103103
* @param \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer
104104
* @param ImportProduct\StoreResolver $storeResolver
105105
* @param \Magento\Customer\Api\GroupRepositoryInterface $groupRepository
106-
* @throws \Magento\Framework\Exception\LocalizedException
107106
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
108107
*/
109108
public function __construct(
@@ -192,6 +191,7 @@ protected function initTypeModels()
192191
* Export process
193192
*
194193
* @return string
194+
* @throws \Magento\Framework\Exception\LocalizedException
195195
*/
196196
public function export()
197197
{
@@ -461,6 +461,7 @@ protected function getTierPrices(array $productLinksIds, $table)
461461
*
462462
* @param int $websiteId
463463
* @return string
464+
* @throws \Magento\Framework\Exception\LocalizedException
464465
*/
465466
protected function _getWebsiteCode(int $websiteId): string
466467
{
@@ -491,6 +492,8 @@ protected function _getWebsiteCode(int $websiteId): string
491492
* @param int $customerGroupId
492493
* @param int $allGroups
493494
* @return string
495+
* @throws \Magento\Framework\Exception\LocalizedException
496+
* @throws \Magento\Framework\Exception\NoSuchEntityException
494497
*/
495498
protected function _getCustomerGroupById(
496499
int $customerGroupId,

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
99
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface;
1010
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
11-
use Magento\Framework\App\ResourceConnection;
1211

1312
/**
1413
* Class AdvancedPricing
@@ -619,6 +618,7 @@ protected function processCountNewPrices(array $tierPrices)
619618
* Get product entity link field
620619
*
621620
* @return string
621+
* @throws \Exception
622622
*/
623623
private function getProductEntityLinkField()
624624
{

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function __construct($validators = [])
2828
*
2929
* @param array $value
3030
* @return bool
31+
* @throws \Zend_Validate_Exception
3132
*/
3233
public function isValid($value)
3334
{

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ protected function tearDown()
347347
* @param $object
348348
* @param $property
349349
* @return mixed
350+
* @throws \ReflectionException
350351
*/
351352
protected function getPropertyValue($object, $property)
352353
{
@@ -362,6 +363,8 @@ protected function getPropertyValue($object, $property)
362363
* @param $object
363364
* @param $property
364365
* @param $value
366+
* @return mixed
367+
* @throws \ReflectionException
365368
*/
366369
protected function setPropertyValue(&$object, $property, $value)
367370
{

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ public function isValidAddMessagesCallDataProvider()
346346
* @param object $object
347347
* @param string $property
348348
* @return mixed
349+
* @throws \ReflectionException
349350
*/
350351
protected function getPropertyValue($object, $property)
351352
{
@@ -363,6 +364,7 @@ protected function getPropertyValue($object, $property)
363364
* @param string $property
364365
* @param mixed $value
365366
* @return object
367+
* @throws \ReflectionException
366368
*/
367369
protected function setPropertyValue(&$object, $property, $value)
368370
{

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ public function testGetEntityTypeCode()
209209
* Test method validateRow against its result.
210210
*
211211
* @dataProvider validateRowResultDataProvider
212+
* @param array $rowData
213+
* @param string|null $behavior
214+
* @param bool $expectedResult
215+
* @throws \ReflectionException
212216
*/
213217
public function testValidateRowResult($rowData, $behavior, $expectedResult)
214218
{
@@ -234,6 +238,10 @@ public function testValidateRowResult($rowData, $behavior, $expectedResult)
234238
* Test method validateRow whether AddRowError is called.
235239
*
236240
* @dataProvider validateRowAddRowErrorCallDataProvider
241+
* @param array $rowData
242+
* @param string|null $behavior
243+
* @param string $error
244+
* @throws \ReflectionException
237245
*/
238246
public function testValidateRowAddRowErrorCall($rowData, $behavior, $error)
239247
{
@@ -324,6 +332,13 @@ public function testSaveAdvancedPricing()
324332
* Take into consideration different data and check relative internal calls.
325333
*
326334
* @dataProvider saveAndReplaceAdvancedPricesAppendBehaviourDataProvider
335+
* @param array $data
336+
* @param string $tierCustomerGroupId
337+
* @param string $groupCustomerGroupId
338+
* @param string $tierWebsiteId
339+
* @param string $groupWebsiteId
340+
* @param array $expectedTierPrices
341+
* @throws \ReflectionException
327342
*/
328343
public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
329344
$data,
@@ -956,6 +971,7 @@ public function processCountExistingPricesDataProvider()
956971
* @param $object
957972
* @param $property
958973
* @return mixed
974+
* @throws \ReflectionException
959975
*/
960976
protected function getPropertyValue($object, $property)
961977
{
@@ -972,6 +988,8 @@ protected function getPropertyValue($object, $property)
972988
* @param $object
973989
* @param $property
974990
* @param $value
991+
* @return mixed
992+
* @throws \ReflectionException
975993
*/
976994
protected function setPropertyValue(&$object, $property, $value)
977995
{
@@ -990,7 +1008,8 @@ protected function setPropertyValue(&$object, $property, $value)
9901008
* @param string $method
9911009
* @param array $args
9921010
*
993-
* @return mixed the method result.
1011+
* @return mixed
1012+
* @throws \ReflectionException
9941013
*/
9951014
private function invokeMethod($object, $method, $args = [])
9961015
{
@@ -1007,6 +1026,7 @@ private function invokeMethod($object, $method, $args = [])
10071026
* @param array $methods
10081027
*
10091028
* @return \PHPUnit_Framework_MockObject_MockObject
1029+
* @throws \ReflectionException
10101030
*/
10111031
private function getAdvancedPricingMock($methods = [])
10121032
{

app/code/Magento/Checkout/etc/webapi.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<resource ref="anonymous" />
105105
</resources>
106106
</route>
107-
<!-- Managing My shipping information -->
107+
<!-- Managing My payment information -->
108108
<route url="/V1/carts/mine/set-payment-information" method="POST">
109109
<service class="Magento\Checkout\Api\PaymentInformationManagementInterface" method="savePaymentInformation"/>
110110
<resources>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<arguments>
121121
<argument name="providers" xsi:type="array">
122122
<item name="default" xsi:type="string">Magento\Sales\Model\ResourceModel\Provider\UpdatedIdListProvider</item>
123+
<item name="updated_at" xsi:type="string">Magento\Sales\Model\ResourceModel\Provider\UpdatedAtListProvider</item>
123124
</argument>
124125
</arguments>
125126
</type>

app/code/Magento/Swatches/Model/Plugin/EavAttribute.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Exception\InputException;
1111
use Magento\Framework\Serialize\Serializer\Json;
1212
use Magento\Swatches\Model\Swatch;
13+
use Magento\Swatches\Model\ResourceModel\Swatch as SwatchResource;
1314

1415
/**
1516
* Plugin model for Catalog Resource Attribute
@@ -18,6 +19,11 @@ class EavAttribute
1819
{
1920
const DEFAULT_STORE_ID = 0;
2021

22+
/**
23+
* @var SwatchResource
24+
*/
25+
private $swatchResource;
26+
2127
/**
2228
* Base option title used for string operations to detect is option already exists or new
2329
*/
@@ -64,17 +70,20 @@ class EavAttribute
6470
* @param \Magento\Swatches\Model\SwatchFactory $swatchFactory
6571
* @param \Magento\Swatches\Helper\Data $swatchHelper
6672
* @param Json|null $serializer
73+
* @param SwatchResource|null $swatchResource
6774
*/
6875
public function __construct(
6976
\Magento\Swatches\Model\ResourceModel\Swatch\CollectionFactory $collectionFactory,
7077
\Magento\Swatches\Model\SwatchFactory $swatchFactory,
7178
\Magento\Swatches\Helper\Data $swatchHelper,
72-
Json $serializer = null
79+
Json $serializer = null,
80+
SwatchResource $swatchResource = null
7381
) {
7482
$this->swatchCollectionFactory = $collectionFactory;
7583
$this->swatchFactory = $swatchFactory;
7684
$this->swatchHelper = $swatchHelper;
7785
$this->serializer = $serializer ?: ObjectManager::getInstance()->create(Json::class);
86+
$this->swatchResource = $swatchResource ?: ObjectManager::getInstance()->create(SwatchResource::class);
7887
}
7988

8089
/**
@@ -148,6 +157,7 @@ protected function setProperOptionsArray(Attribute $attribute)
148157
* Prepare attribute for conversion from any swatch type to dropdown
149158
*
150159
* @param Attribute $attribute
160+
* @throws \Magento\Framework\Exception\LocalizedException
151161
* @return void
152162
*/
153163
protected function convertSwatchToDropdown(Attribute $attribute)
@@ -157,6 +167,7 @@ protected function convertSwatchToDropdown(Attribute $attribute)
157167
if (!empty($additionalData)) {
158168
$additionalData = $this->serializer->unserialize($additionalData);
159169
if (is_array($additionalData) && isset($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY])) {
170+
$this->cleanEavAttributeOptionSwatchValues($attribute->getOption());
160171
unset($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY]);
161172
$attribute->setData('additional_data', $this->serializer->serialize($additionalData));
162173
}
@@ -235,6 +246,7 @@ protected function saveSwatchParams(Attribute $attribute)
235246
{
236247
if ($this->swatchHelper->isVisualSwatch($attribute)) {
237248
$this->processVisualSwatch($attribute);
249+
$this->cleanTextSwatchValuesAfterSwitch($attribute->getOptiontext());
238250
} elseif ($this->swatchHelper->isTextSwatch($attribute)) {
239251
$this->processTextualSwatch($attribute);
240252
}
@@ -267,6 +279,33 @@ protected function processVisualSwatch(Attribute $attribute)
267279
}
268280
}
269281

282+
/**
283+
* Clean swatch option values after switching to the dropdown type.
284+
*
285+
* @param array $attributeOptions
286+
* @param null $swatchType
287+
* @throws \Magento\Framework\Exception\LocalizedException
288+
*/
289+
private function cleanEavAttributeOptionSwatchValues($attributeOptions, $swatchType = null)
290+
{
291+
if (count($attributeOptions) && isset($attributeOptions['value'])) {
292+
$optionsIDs = array_keys($attributeOptions['value']);
293+
294+
$this->swatchResource->clearSwatchOptionByOptionIdAndType($optionsIDs, $swatchType);
295+
}
296+
}
297+
298+
/**
299+
* Cleaning the text type of swatch option values after switching.
300+
*
301+
* @param array $attributeOptions
302+
* @throws \Magento\Framework\Exception\LocalizedException
303+
*/
304+
private function cleanTextSwatchValuesAfterSwitch($attributeOptions)
305+
{
306+
$this->cleanEavAttributeOptionSwatchValues($attributeOptions, Swatch::SWATCH_TYPE_TEXTUAL);
307+
}
308+
270309
/**
271310
* @param string $value
272311
* @return int

app/code/Magento/Swatches/Model/ResourceModel/Swatch.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,24 @@ public function saveDefaultSwatchOption($id, $defaultValue)
3737
$this->getConnection()->update($this->getTable('eav_attribute'), $bind, $where);
3838
}
3939
}
40+
41+
/**
42+
* Cleaned swatch option values when switching to dropdown input type
43+
*
44+
* @param $optionIDs
45+
* @param $type
46+
* @throws \Magento\Framework\Exception\LocalizedException
47+
*/
48+
public function clearSwatchOptionByOptionIdAndType($optionIDs, $type = null)
49+
{
50+
if (count($optionIDs)) {
51+
foreach ($optionIDs as $optionId) {
52+
$where = ['option_id' => $optionId];
53+
if ($type !== null) {
54+
$where['type = ?'] = $type;
55+
}
56+
$this->getConnection()->delete($this->getMainTable(), $where);
57+
}
58+
}
59+
}
4060
}

app/code/Magento/Swatches/Model/SwatchAttributesProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class SwatchAttributesProvider
3939
private $swatchTypeChecker;
4040

4141
/**
42+
* SwatchAttributesProvider constructor.
43+
*
4244
* @param Configurable $typeConfigurable
4345
* @param SwatchAttributeCodes $swatchAttributeCodes
4446
* @param SwatchAttributeType|null $swatchTypeChecker

app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function setUp()
4444
{
4545
$this->typeConfigurable = $this->createPartialMock(
4646
Configurable::class,
47-
['getConfigurableAttributes', 'getCodes']
47+
['getConfigurableAttributes', 'getCodes', 'getProductAttribute']
4848
);
4949

5050
$this->swatchAttributeCodes = $this->createMock(SwatchAttributeCodes::class);
@@ -65,8 +65,9 @@ public function testProvide()
6565
$this->productMock->method('getTypeId')
6666
->willReturn(Configurable::TYPE_CODE);
6767

68-
$productAttributeMock = $this->getMockBuilder(Attribute::class)
68+
$attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
6969
->disableOriginalConstructor()
70+
->setMethods(['setStoreId', 'getData', 'setData', 'getSource', 'hasData'])
7071
->getMock();
7172

7273
$configAttributeMock = $this->createPartialMock(
@@ -79,7 +80,7 @@ public function testProvide()
7980

8081
$configAttributeMock
8182
->method('getProductAttribute')
82-
->willReturn($productAttributeMock);
83+
->willReturn($attributeMock);
8384

8485
$this->typeConfigurable
8586
->method('getConfigurableAttributes')
@@ -92,8 +93,9 @@ public function testProvide()
9293
->willReturn($swatchAttributes);
9394

9495
$this->swatchTypeChecker->expects($this->once())->method('isSwatchAttribute')->willReturn(true);
96+
9597
$result = $this->swatchAttributeProvider->provide($this->productMock);
9698

97-
$this->assertEquals([1 => $productAttributeMock], $result);
99+
$this->assertEquals([1 => $attributeMock], $result);
98100
}
99101
}

app/code/Magento/User/Model/User.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class User extends AbstractModel implements StorageInterface, UserInterface
4747
/** @deprecated */
4848
const XML_PATH_RESET_PASSWORD_TEMPLATE = 'admin/emails/reset_password_template';
4949

50+
const MESSAGE_ID_PASSWORD_EXPIRED = 'magento_user_password_expired';
51+
5052
/**
5153
* Model event prefix
5254
*

app/code/Magento/User/Observer/Backend/AuthObserver.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function execute(EventObserver $observer)
149149
/**
150150
* Update locking information for the user
151151
*
152-
* @param \Magento\User\Model\User $user
152+
* @param User $user
153153
* @return void
154154
*/
155155
private function _updateLockingInformation($user)
@@ -195,10 +195,16 @@ private function _checkExpiredPassword($latestPassword)
195195
$myAccountUrl = $this->url->getUrl('adminhtml/system_account/');
196196
$message = __('It\'s time to <a href="%1">change your password</a>.', $myAccountUrl);
197197
}
198+
199+
$messages = $this->messageManager->getMessages();
200+
201+
// Remove existing messages with same ID to avoid duplication
202+
$messages->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED);
203+
198204
$this->messageManager->addNoticeMessage($message);
199-
$message = $this->messageManager->getMessages()->getLastAddedMessage();
205+
$message = $messages->getLastAddedMessage();
200206
if ($message) {
201-
$message->setIdentifier('magento_user_password_expired')->setIsSticky(true);
207+
$message->setIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED)->setIsSticky(true);
202208
$this->authSession->setPciAdminUserIsPasswordExpired(true);
203209
}
204210
}

0 commit comments

Comments
 (0)