Skip to content

Commit 61938e9

Browse files
committed
Merge branch '2.3-develop' into ENGCOM-3449-magento-magento2-19180
2 parents 09937b6 + 069d5cd commit 61938e9

File tree

96 files changed

+3170
-450
lines changed

Some content is hidden

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

96 files changed

+3170
-450
lines changed

app/code/Magento/Backend/Model/AdminPathConfig.php

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,37 @@ public function __construct(
4848
}
4949

5050
/**
51-
* {@inheritdoc}
52-
*
53-
* @param \Magento\Framework\App\RequestInterface $request
54-
* @return string
51+
* @inheritdoc
5552
*/
5653
public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
5754
{
5855
return $this->url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
5956
}
6057

6158
/**
62-
* {@inheritdoc}
63-
*
64-
* @param string $path
65-
* @return bool
59+
* @inheritdoc
6660
*/
6761
public function shouldBeSecure($path)
6862
{
69-
return parse_url(
70-
(string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default'),
71-
PHP_URL_SCHEME
72-
) === 'https'
73-
|| $this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)
74-
&& parse_url(
75-
(string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default'),
76-
PHP_URL_SCHEME
77-
) === 'https';
63+
$baseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
64+
if (parse_url($baseUrl, PHP_URL_SCHEME) === 'https') {
65+
return true;
66+
}
67+
68+
if ($this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)) {
69+
if ($this->backendConfig->isSetFlag('admin/url/use_custom')) {
70+
$adminBaseUrl = (string)$this->coreConfig->getValue('admin/url/custom', 'default');
71+
} else {
72+
$adminBaseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default');
73+
}
74+
return parse_url($adminBaseUrl, PHP_URL_SCHEME) === 'https';
75+
}
76+
77+
return false;
7878
}
7979

8080
/**
81-
* {@inheritdoc}
82-
*
83-
* @return string
81+
* @inheritdoc
8482
*/
8583
public function getDefaultPath()
8684
{

app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,35 @@ public function testGetCurrentSecureUrl()
7676
* @param $unsecureBaseUrl
7777
* @param $useSecureInAdmin
7878
* @param $secureBaseUrl
79+
* @param $useCustomUrl
80+
* @param $customUrl
7981
* @param $expected
8082
* @dataProvider shouldBeSecureDataProvider
8183
*/
82-
public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureBaseUrl, $expected)
83-
{
84-
$coreConfigValueMap = [
84+
public function testShouldBeSecure(
85+
$unsecureBaseUrl,
86+
$useSecureInAdmin,
87+
$secureBaseUrl,
88+
$useCustomUrl,
89+
$customUrl,
90+
$expected
91+
) {
92+
$coreConfigValueMap = $this->returnValueMap([
8593
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default', null, $unsecureBaseUrl],
8694
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default', null, $secureBaseUrl],
87-
];
88-
$this->coreConfig->expects($this->any())->method('getValue')->will($this->returnValueMap($coreConfigValueMap));
89-
$this->backendConfig->expects($this->any())->method('isSetFlag')->willReturn($useSecureInAdmin);
95+
['admin/url/custom', 'default', null, $customUrl],
96+
]);
97+
$backendConfigFlagsMap = $this->returnValueMap([
98+
[\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, $useSecureInAdmin],
99+
['admin/url/use_custom', $useCustomUrl],
100+
]);
101+
$this->coreConfig->expects($this->atLeast(1))->method('getValue')
102+
->will($coreConfigValueMap);
103+
$this->coreConfig->expects($this->atMost(2))->method('getValue')
104+
->will($coreConfigValueMap);
105+
106+
$this->backendConfig->expects($this->atMost(2))->method('isSetFlag')
107+
->will($backendConfigFlagsMap);
90108
$this->assertEquals($expected, $this->adminPathConfig->shouldBeSecure(''));
91109
}
92110

@@ -96,13 +114,13 @@ public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureB
96114
public function shouldBeSecureDataProvider()
97115
{
98116
return [
99-
['http://localhost/', false, 'default', false],
100-
['http://localhost/', true, 'default', false],
101-
['https://localhost/', false, 'default', true],
102-
['https://localhost/', true, 'default', true],
103-
['http://localhost/', false, 'https://localhost/', false],
104-
['http://localhost/', true, 'https://localhost/', true],
105-
['https://localhost/', true, 'https://localhost/', true],
117+
['http://localhost/', false, 'default', false, '', false],
118+
['http://localhost/', true, 'default', false, '', false],
119+
['https://localhost/', false, 'default', false, '', true],
120+
['https://localhost/', true, 'default', false, '', true],
121+
['http://localhost/', false, 'https://localhost/', false, '', false],
122+
['http://localhost/', true, 'https://localhost/', false, '', true],
123+
['https://localhost/', true, 'https://localhost/', false, '', true],
106124
];
107125
}
108126

app/code/Magento/Catalog/Model/Product/Gallery/ReadHandler.php

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function __construct(
4747
}
4848

4949
/**
50+
* Execute read handler for catalog product gallery
51+
*
5052
* @param Product $entity
5153
* @param array $arguments
5254
* @return object
@@ -55,9 +57,6 @@ public function __construct(
5557
*/
5658
public function execute($entity, $arguments = [])
5759
{
58-
$value = [];
59-
$value['images'] = [];
60-
6160
$mediaEntries = $this->resourceModel->loadProductGalleryByAttributeId(
6261
$entity,
6362
$this->getAttribute()->getAttributeId()
@@ -72,47 +71,27 @@ public function execute($entity, $arguments = [])
7271
}
7372

7473
/**
74+
* Add media data to product
75+
*
7576
* @param Product $product
7677
* @param array $mediaEntries
7778
* @return void
7879
* @since 101.0.1
7980
*/
8081
public function addMediaDataToProduct(Product $product, array $mediaEntries)
8182
{
82-
$attrCode = $this->getAttribute()->getAttributeCode();
83-
$value = [];
84-
$value['images'] = [];
85-
$value['values'] = [];
86-
87-
foreach ($mediaEntries as $mediaEntry) {
88-
$mediaEntry = $this->substituteNullsWithDefaultValues($mediaEntry);
89-
$value['images'][$mediaEntry['value_id']] = $mediaEntry;
90-
}
91-
$product->setData($attrCode, $value);
92-
}
93-
94-
/**
95-
* @param array $rawData
96-
* @return array
97-
*/
98-
private function substituteNullsWithDefaultValues(array $rawData)
99-
{
100-
$processedData = [];
101-
foreach ($rawData as $key => $rawValue) {
102-
if (null !== $rawValue) {
103-
$processedValue = $rawValue;
104-
} elseif (isset($rawData[$key . '_default'])) {
105-
$processedValue = $rawData[$key . '_default'];
106-
} else {
107-
$processedValue = null;
108-
}
109-
$processedData[$key] = $processedValue;
110-
}
111-
112-
return $processedData;
83+
$product->setData(
84+
$this->getAttribute()->getAttributeCode(),
85+
[
86+
'images' => array_column($mediaEntries, null, 'value_id'),
87+
'values' => []
88+
]
89+
);
11390
}
11491

11592
/**
93+
* Get attribute
94+
*
11695
* @return \Magento\Catalog\Api\Data\ProductAttributeInterface
11796
* @since 101.0.0
11897
*/
@@ -126,6 +105,8 @@ public function getAttribute()
126105
}
127106

128107
/**
108+
* Find default value
109+
*
129110
* @param string $key
130111
* @param string[] &$image
131112
* @return string

app/code/Magento/Catalog/Model/ResourceModel/Product/Gallery.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public function __construct(
4949
}
5050

5151
/**
52-
* {@inheritdoc}
52+
* @inheritdoc
53+
*
5354
* @since 101.0.0
5455
*/
5556
protected function _construct()
@@ -58,7 +59,8 @@ protected function _construct()
5859
}
5960

6061
/**
61-
* {@inheritdoc}
62+
* @inheritdoc
63+
*
6264
* @since 101.0.0
6365
*/
6466
public function getConnection()
@@ -67,6 +69,8 @@ public function getConnection()
6769
}
6870

6971
/**
72+
* Load data from table by valueId
73+
*
7074
* @param string $tableNameAlias
7175
* @param array $ids
7276
* @param int|null $storeId
@@ -111,6 +115,8 @@ public function loadDataFromTableByValueId(
111115
}
112116

113117
/**
118+
* Load product gallery by attributeId
119+
*
114120
* @param \Magento\Catalog\Model\Product $product
115121
* @param int $attributeId
116122
* @return array
@@ -132,6 +138,8 @@ public function loadProductGalleryByAttributeId($product, $attributeId)
132138
}
133139

134140
/**
141+
* Create base load select
142+
*
135143
* @param int $entityId
136144
* @param int $storeId
137145
* @param int $attributeId
@@ -151,6 +159,8 @@ protected function createBaseLoadSelect($entityId, $storeId, $attributeId)
151159
}
152160

153161
/**
162+
* Create batch base select
163+
*
154164
* @param int $storeId
155165
* @param int $attributeId
156166
* @return \Magento\Framework\DB\Select
@@ -190,7 +200,7 @@ public function createBatchBaseSelect($storeId, $attributeId)
190200
'value.' . $linkField . ' = entity.' . $linkField,
191201
]
192202
),
193-
['label', 'position', 'disabled']
203+
[]
194204
)->joinLeft(
195205
['default_value' => $this->getTable(self::GALLERY_VALUE_TABLE)],
196206
implode(
@@ -201,8 +211,15 @@ public function createBatchBaseSelect($storeId, $attributeId)
201211
'default_value.' . $linkField . ' = entity.' . $linkField,
202212
]
203213
),
204-
['label_default' => 'label', 'position_default' => 'position', 'disabled_default' => 'disabled']
205-
)->where(
214+
[]
215+
)->columns([
216+
'label' => $this->getConnection()->getIfNullSql('`value`.`label`', '`default_value`.`label`'),
217+
'position' => $this->getConnection()->getIfNullSql('`value`.`position`', '`default_value`.`position`'),
218+
'disabled' => $this->getConnection()->getIfNullSql('`value`.`disabled`', '`default_value`.`disabled`'),
219+
'label_default' => 'default_value.label',
220+
'position_default' => 'default_value.position',
221+
'disabled_default' => 'default_value.disabled'
222+
])->where(
206223
$mainTableAlias . '.attribute_id = ?',
207224
$attributeId
208225
)->where(
@@ -240,6 +257,8 @@ protected function removeDuplicates(&$result)
240257
}
241258

242259
/**
260+
* Get main table alias
261+
*
243262
* @return string
244263
* @since 101.0.0
245264
*/
@@ -249,6 +268,8 @@ public function getMainTableAlias()
249268
}
250269

251270
/**
271+
* Bind value to entity
272+
*
252273
* @param int $valueId
253274
* @param int $entityId
254275
* @return int
@@ -266,6 +287,8 @@ public function bindValueToEntity($valueId, $entityId)
266287
}
267288

268289
/**
290+
* Save data row
291+
*
269292
* @param string $table
270293
* @param array $data
271294
* @param array $fields

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,30 @@
237237
</arguments>
238238
<amOnPage url="{{AdminCategoryPage.page}}" stepKey="amOnCategoryPage"/>
239239
<waitForPageLoad stepKey="waitForPageLoad1"/>
240-
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree(Category.Name)}}" stepKey="navigateToCreatedCategory" />
240+
<click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandAll"/>
241241
<waitForPageLoad stepKey="waitForPageLoad2"/>
242+
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree(Category.Name)}}" stepKey="navigateToCreatedCategory" />
242243
<waitForLoadingMaskToDisappear stepKey="waitForSpinner" />
243244
</actionGroup>
245+
246+
<actionGroup name="ChangeSeoUrlKey">
247+
<arguments>
248+
<argument name="value" type="string"/>
249+
</arguments>
250+
<click selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="openSeoSection"/>
251+
<fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="{{value}}" stepKey="enterURLKey"/>
252+
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/>
253+
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="assertSuccessMessage"/>
254+
</actionGroup>
255+
256+
<actionGroup name="ChangeSeoUrlKeyForSubCategory">
257+
<arguments>
258+
<argument name="value" type="string"/>
259+
</arguments>
260+
<click selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="openSeoSection"/>
261+
<uncheckOption selector="{{AdminCategorySEOSection.UrlKeyDefaultValueCheckbox}}" stepKey="uncheckDefaultValue"/>
262+
<fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="{{value}}" stepKey="enterURLKey"/>
263+
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/>
264+
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="assertSuccessMessage"/>
265+
</actionGroup>
244266
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontCategoryActionGroup.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,19 @@
6666
<click selector="{{StorefrontCategoryMainSection.modeListButton}}" stepKey="switchCategoryViewToListMode"/>
6767
<waitForElement selector="{{StorefrontCategoryMainSection.CategoryTitle}}" time="30" stepKey="waitForCategoryReload"/>
6868
</actionGroup>
69+
70+
<actionGroup name="GoToSubCategoryPage">
71+
<arguments>
72+
<argument name="parentCategory"/>
73+
<argument name="subCategory"/>
74+
<argument name="urlPath" type="string"/>
75+
</arguments>
76+
<moveMouseOver selector="{{StorefrontHeaderSection.NavigationCategoryByName(parentCategory.name)}}" stepKey="moveMouseOnMainCategory"/>
77+
<waitForElementVisible selector="{{StorefrontHeaderSection.NavigationCategoryByName(subCategory.name)}}" stepKey="waitForSubCategoryVisible"/>
78+
<click selector="{{StorefrontHeaderSection.NavigationCategoryByName(subCategory.name)}}" stepKey="goToCategory"/>
79+
<waitForPageLoad stepKey="waitForPageLoad"/>
80+
<seeInCurrentUrl url="{{urlPath}}.html" stepKey="checkUrl"/>
81+
<seeInTitle userInput="{{subCategory.name}}" stepKey="assertCategoryNameInTitle"/>
82+
<see userInput="{{subCategory.name}}" selector="{{StorefrontCategoryMainSection.CategoryTitle}}" stepKey="assertCategoryName"/>
83+
</actionGroup>
6984
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryContentSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
<element name="uploadImageFile" type="input" selector=".file-uploader-area>input"/>
1616
<element name="imageFileName" type="text" selector=".file-uploader-filename"/>
1717
<element name="removeImageButton" type="button" selector=".file-uploader-summary .action-remove"/>
18+
<element name="AddCMSBlock" type="select" selector="//*[@name='landing_page']"/>
1819
</section>
1920
</sections>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminCategoryDisplaySettingsSection">
12+
<element name="settingsHeader" type="button" selector="//*[contains(text(),'Display Settings')]" timeout="30"/>
13+
<element name="displayMode" type="button" selector="//*[@name='display_mode']"/>
14+
</section>
15+
</sections>

0 commit comments

Comments
 (0)