Skip to content

Commit e092238

Browse files
authored
Merge pull request #7559 from magento-gl/L3_Arrows_PR_20220406
L3 Arrows PR 20220406
2 parents 01652f4 + c2db1e5 commit e092238

File tree

9 files changed

+393
-33
lines changed

9 files changed

+393
-33
lines changed

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,33 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
3838
/**
3939
* Value that means all entities (e.g. websites, groups etc.)
4040
*/
41-
const VALUE_ALL = 'all';
41+
public const VALUE_ALL = 'all';
4242

4343
/**
4444
* Permanent column names.
4545
*
4646
* Names that begins with underscore is not an attribute. This name convention is for
4747
* to avoid interference with same attribute name.
4848
*/
49-
const COL_STORE = '_store';
49+
public const COL_STORE = '_store';
5050

51-
const COL_ATTR_SET = '_attribute_set';
51+
public const COL_ATTR_SET = '_attribute_set';
5252

53-
const COL_TYPE = '_type';
53+
public const COL_TYPE = '_type';
5454

55-
const COL_PRODUCT_WEBSITES = '_product_websites';
55+
public const COL_PRODUCT_WEBSITES = '_product_websites';
5656

57-
const COL_CATEGORY = '_category';
57+
public const COL_CATEGORY = '_category';
5858

59-
const COL_ROOT_CATEGORY = '_root_category';
59+
public const COL_ROOT_CATEGORY = '_root_category';
6060

61-
const COL_SKU = 'sku';
61+
public const COL_SKU = 'sku';
6262

63-
const COL_VISIBILITY = 'visibility';
63+
public const COL_VISIBILITY = 'visibility';
6464

65-
const COL_MEDIA_IMAGE = '_media_image';
65+
public const COL_MEDIA_IMAGE = '_media_image';
6666

67-
const COL_ADDITIONAL_ATTRIBUTES = 'additional_attributes';
67+
public const COL_ADDITIONAL_ATTRIBUTES = 'additional_attributes';
6868

6969
/**
7070
* Pairs of attribute set ID-to-name.
@@ -123,14 +123,14 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
123123
protected $_storeIdToCode = [];
124124

125125
/**
126-
* Website ID-to-code.
126+
* Array of Website ID-to-code.
127127
*
128128
* @var array
129129
*/
130130
protected $_websiteIdToCode = [];
131131

132132
/**
133-
* Attribute types
133+
* Attributes type
134134
*
135135
* @var array
136136
*/
@@ -284,6 +284,18 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
284284
'custom_design_to'
285285
];
286286

287+
/**
288+
* Image labels array
289+
*
290+
* @var array
291+
*/
292+
private $imageLabelAttributes = [
293+
'base_image_label',
294+
'small_image_label',
295+
'thumbnail_image_label',
296+
'swatch_image_label',
297+
];
298+
287299
/**
288300
* Attributes codes which are appropriate for export and not the part of additional_attributes.
289301
*
@@ -346,7 +358,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
346358
protected $metadataPool;
347359

348360
/**
349-
* Product entity link field
361+
* Link field of Product entity
350362
*
351363
* @var string
352364
*/
@@ -828,12 +840,12 @@ protected function getItemsPerPage()
828840
switch ($lastMemoryLimitLetter) {
829841
case 'g':
830842
$memoryLimit *= 1024;
831-
// fall-through intentional
832-
// no break
843+
// fall-through intentional
844+
// no break
833845
case 'm':
834846
$memoryLimit *= 1024;
835-
// fall-through intentional
836-
// no break
847+
// fall-through intentional
848+
// no break
837849
case 'k':
838850
$memoryLimit *= 1024;
839851
break;
@@ -962,6 +974,7 @@ protected function getExportData()
962974
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
963975
$dataRow = array_merge($dataRow, $stockItemRows[$productId]);
964976
}
977+
$this->updateGalleryImageData($dataRow, $rawData);
965978
$this->appendMultirowData($dataRow, $multirawData);
966979
if ($dataRow) {
967980
$exportData[] = $dataRow;
@@ -1370,6 +1383,29 @@ private function appendMultirowData(&$dataRow, $multiRawData)
13701383
return $dataRow;
13711384
}
13721385

1386+
/**
1387+
* Add image column if image label exists for all scope
1388+
*
1389+
* @param array $dataRow
1390+
* @param array $rawData
1391+
* @return void
1392+
*/
1393+
private function updateGalleryImageData(&$dataRow, $rawData)
1394+
{
1395+
$storeId = $dataRow['store_id'];
1396+
$productId = $dataRow['product_id'];
1397+
foreach ($this->imageLabelAttributes as $imageLabelCode) {
1398+
$imageAttributeCode = str_replace('_label', '', $imageLabelCode);
1399+
if ($storeId != Store::DEFAULT_STORE_ID
1400+
&& isset($dataRow[$imageLabelCode])
1401+
&& $dataRow[$imageLabelCode]
1402+
&& (!isset($dataRow[$imageAttributeCode]) || !$dataRow[$imageAttributeCode])
1403+
) {
1404+
$dataRow[$imageAttributeCode] = $rawData[$productId][Store::DEFAULT_STORE_ID][$imageAttributeCode];
1405+
}
1406+
}
1407+
}
1408+
13731409
/**
13741410
* Add multi row data to export
13751411
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminExportSimpleProductWithImageAndImageAltForDiffrentScopeTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Admin product export with different Alt Text for multiple stores"/>
15+
<title value="Admin product export with different Alt Text for multiple stores"/>
16+
<description value="Admin product export with different Alt Text for multiple stores"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="ACP2E-561"/>
19+
<group value="catalog_import_export"/>
20+
</annotations>
21+
<before>
22+
<!-- Login Admin -->
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
24+
<!-- Create Store View English -->
25+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreViewEn">
26+
<argument name="customStore" value="customStoreEN"/>
27+
</actionGroup>
28+
<!-- Create Store View France -->
29+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreViewFr">
30+
<argument name="customStore" value="customStoreFR"/>
31+
</actionGroup>
32+
<!-- Create Category and Simple Product -->
33+
<createData entity="_defaultCategory" stepKey="createCategory"/>
34+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
35+
<requiredEntity createDataKey="createCategory"/>
36+
<field key="price">100</field>
37+
</createData>
38+
<!-- Upload Image All Store View -->
39+
<createData entity="ApiProductAttributeMediaGalleryEntryTestImage" stepKey="createProductImage">
40+
<requiredEntity createDataKey="createSimpleProduct"/>
41+
</createData>
42+
</before>
43+
<after>
44+
<!-- Delete Store View English -->
45+
<actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreViewEn">
46+
<argument name="customStore" value="customStoreEN"/>
47+
</actionGroup>
48+
<!-- Delete Store View France -->
49+
<actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreViewFr">
50+
<argument name="customStore" value="customStoreFR"/>
51+
</actionGroup>
52+
<!-- Clear Filter Store -->
53+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="resetFiltersOnStorePage"/>
54+
<!-- Delete Category and Simple Product -->
55+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
56+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
57+
<!-- Clear Filter Product -->
58+
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearProductFilters"/>
59+
<!-- Logout Admin -->
60+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
61+
</after>
62+
<!-- Search Product and Open Edit -->
63+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchProduct">
64+
<argument name="product" value="$$createSimpleProduct$$"/>
65+
</actionGroup>
66+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct">
67+
<argument name="product" value="$$createSimpleProduct$$"/>
68+
</actionGroup>
69+
<actionGroup ref="AdminAssignImageRolesActionGroup" stepKey="assignImageRole">
70+
<argument name="image" value="$$createProductImage$$"/>
71+
</actionGroup>
72+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
73+
74+
<!-- Switch to the English store view -->
75+
<actionGroup ref="AdminSwitchStoreViewActionGroup" stepKey="switchStoreViewEnglishProduct">
76+
<argument name="storeView" value="customStoreEN.name"/>
77+
</actionGroup>
78+
<actionGroup ref="AdminProductChangeImageAltTextActionGroup" stepKey="changeEnglishImageAltTextOnProduct">
79+
<argument name="image" value="$$createProductImage$$"/>
80+
<argument name="altText" value="english image alt text 1"/>
81+
</actionGroup>
82+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct1"/>
83+
84+
<!-- Switch to the French store view -->
85+
<actionGroup ref="AdminSwitchStoreViewActionGroup" stepKey="switchStoreViewFrenchProduct">
86+
<argument name="storeView" value="customStoreFR.name"/>
87+
</actionGroup>
88+
<actionGroup ref="AdminProductChangeImageAltTextActionGroup" stepKey="changeFrenchImageAltTextOnProduct">
89+
<argument name="image" value="$$createProductImage$$"/>
90+
<argument name="altText" value="french image alt text 1"/>
91+
</actionGroup>
92+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct2"/>
93+
94+
<actionGroup ref="AdminNavigateToExportPageActionGroup" stepKey="goToExportIndexPage"/>
95+
<actionGroup ref="ExportProductsFilterByAttributeActionGroup" stepKey="exportProductBySku">
96+
<argument name="attribute" value="sku"/>
97+
<argument name="attributeData" value="$$createSimpleProduct.sku$$"/>
98+
</actionGroup>
99+
<actionGroup ref="CliConsumerStartActionGroup" stepKey="startMessageQueue">
100+
<argument name="consumerName" value="{{AdminExportMessageConsumerData.consumerName}}"/>
101+
<argument name="maxMessages" value="{{AdminExportMessageConsumerData.messageLimit}}"/>
102+
</actionGroup>
103+
<reloadPage stepKey="refreshPage"/>
104+
<waitForPageLoad stepKey="waitForReload"/>
105+
<waitForElementVisible selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="waitForFileName"/>
106+
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="getFilename"/>
107+
<actionGroup ref="AdminGetExportFilenameOnServerActionGroup" stepKey="grabNameFile">
108+
<argument name="rowIndex" value="0"/>
109+
</actionGroup>
110+
<!-- Validate Export File on File System: Configurable Product -->
111+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertExportFileExists">
112+
<argument name="filePath">var/export/{$grabNameFile}</argument>
113+
</helper>
114+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsConfigurableProduct">
115+
<argument name="filePath">var/export/{$grabNameFile}</argument>
116+
<argument name="text">$createProductImage.entry[content][name]$,"english image alt text 1"</argument>
117+
</helper>
118+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileContainsString" stepKey="assertExportFileContainsConfigurableProduct1">
119+
<argument name="filePath">var/export/{$grabNameFile}</argument>
120+
<argument name="text">$createProductImage.entry[content][name]$,"french image alt text 1"</argument>
121+
</helper>
122+
</test>
123+
</tests>

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
*/
6767
class ProductTest extends AbstractImportTestCase
6868
{
69-
const MEDIA_DIRECTORY = 'media/import';
69+
private const MEDIA_DIRECTORY = 'media/import';
7070

71-
const ENTITY_TYPE_ID = 1;
71+
private const ENTITY_TYPE_ID = 1;
7272

73-
const ENTITY_TYPE_CODE = 'catalog_product';
73+
private const ENTITY_TYPE_CODE = 'catalog_product';
7474

75-
const ENTITY_ID = 13;
75+
private const ENTITY_ID = 13;
7676

7777
/**
7878
* @var AdapterInterface|MockObject
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontCustomerDataStorageOnSessionTimeoutTest">
12+
<annotations>
13+
<features value="Customer"/>
14+
<stories value="Login"/>
15+
<title value="Remove customer data storage on session timeout "/>
16+
<description value="Verify customer data storage removal on session cookie timeout only"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="AC-2420"/>
19+
<group value="customer"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
23+
<actionGroup ref="AdminNavigateToDefaultCookieSettingsActionGroup" stepKey="navigateToDefaultCookieSettingsPage"/>
24+
<actionGroup ref="AdminUncheckUseSystemValueActionGroup" stepKey="uncheckUseSystemValue">
25+
<argument name="rowId" value="row_web_cookie_cookie_lifetime"/>
26+
</actionGroup>
27+
<actionGroup ref="AdminFillCookieLifetimeActionGroup" stepKey="fillCookieLifetime">
28+
<argument name="cookieLifetime" value="15" />
29+
</actionGroup>
30+
<actionGroup ref="AdminClickFormActionButtonActionGroup" stepKey="clickSaveButtonWithString">
31+
<argument name="buttonSelector" value="{{AdminMainActionsSection.save}}"/>
32+
</actionGroup>
33+
<createData entity="John_Smith_Customer" stepKey="customer" />
34+
</before>
35+
<after>
36+
<actionGroup ref="AdminNavigateToDefaultCookieSettingsActionGroup" stepKey="navigateToDefaultCookieSettingsPage2"/>
37+
<actionGroup ref="AdminFillCookieLifetimeActionGroup" stepKey="fillCookieLifetimeFieldWithNumber">
38+
<argument name="cookieLifetime" value="3600"/>
39+
</actionGroup>
40+
<actionGroup ref="AdminCheckUseSystemValueActionGroup" stepKey="checkUseSystemValue">
41+
<argument name="rowId" value="row_web_cookie_cookie_lifetime"/>
42+
</actionGroup>
43+
<actionGroup ref="AdminClickFormActionButtonActionGroup" stepKey="clickSaveButton">
44+
<argument name="buttonSelector" value="{{AdminMainActionsSection.save}}"/>
45+
</actionGroup>
46+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsAdmin" />
47+
</after>
48+
49+
<actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/>
50+
<actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm">
51+
<argument name="customer" value="John_Smith_Customer"/>
52+
</actionGroup>
53+
<actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/>
54+
<actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage">
55+
<argument name="messageType" value="success"/>
56+
<argument name="message" value="Thank you for registering with Main Website Store."/>
57+
</actionGroup>
58+
<waitForPageLoad stepKey="waitForPageLoad"/>
59+
<see userInput="Welcome, {{John_Smith_Customer.fullname}}" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="verifyMessage1"/>
60+
61+
<wait time="5" stepKey="waitSometime" />
62+
<reloadPage stepKey="refreshSessionCookieByPageRefresh" />
63+
<waitForPageLoad stepKey="waitForPageLoad2"/>
64+
<see userInput="Welcome, {{John_Smith_Customer.fullname}}" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="verifyMessage2"/>
65+
66+
<wait time="7" stepKey="waitSometime2" />
67+
<reloadPage stepKey="refreshSessionCookieByPageRefresh2" />
68+
<waitForPageLoad stepKey="waitForPageLoad3"/>
69+
<see userInput="Welcome, {{John_Smith_Customer.fullname}}" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="verifyMessage3"/>
70+
71+
<wait time="15" stepKey="waitSometime3" />
72+
<reloadPage stepKey="refreshSessionCookieByPageRefresh3" />
73+
<waitForPageLoad stepKey="waitForPageLoad4"/>
74+
<dontSee userInput="Welcome, {{John_Smith_Customer.fullname}}" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="verifyMessage4"/>
75+
76+
<deleteData createDataKey="customer" stepKey="deleteCustomer" />
77+
</test>
78+
</tests>

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ define([
4848
*/
4949
invalidateCacheByCloseCookieSession = function () {
5050
if (!$.cookieStorage.isSet('mage-cache-sessid')) {
51-
$.cookieStorage.set('mage-cache-sessid', true);
5251
storage.removeAll();
5352
}
53+
54+
$.cookieStorage.set('mage-cache-sessid', true);
5455
};
5556

5657
dataProvider = {

app/code/Magento/Swatches/Test/Mftf/Data/SwatchProductAttributeFrontendLabelData.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
<data key="store_id">0</data>
1313
<data key="label" unique="suffix">Swatch-Attribute-</data>
1414
</entity>
15+
<entity name="SwatchProductSizeAttribute" type="FrontendLabel">
16+
<data key="frontend_label">Set Size</data>
17+
<data key="attribute_code">set_size</data>
18+
</entity>
1519
</entities>

0 commit comments

Comments
 (0)