Skip to content

Commit 1a8dd8c

Browse files
authored
Merge pull request #1027 from magento-south/BUGS
[South] Bug fixes & API Coverage: - MAGETWO-62947 Can't ignore errors during customer Import - MAGETWO-64644 CMS Pages get removed from Store Hierarchy when saved - MAGETWO-64543 Modify authorization-link css class - MAGETWO-65777 API annotation coverage (Customer area)
2 parents e3fc5b7 + 5bdb3de commit 1a8dd8c

File tree

65 files changed

+519
-35
lines changed

Some content is hidden

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

65 files changed

+519
-35
lines changed

app/code/Magento/Contact/Helper/Data.php

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
/**
1616
* Contact base helper
17+
*
18+
* @deprecated
19+
* @see \Magento\Contact\Model\ConfigInterface
1720
*/
1821
class Data extends \Magento\Framework\App\Helper\AbstractHelper
1922
{

app/code/Magento/Customer/CustomerData/JsLayoutDataProviderInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
/**
1010
* Js layout data provider interface
11+
*
12+
* @api
1113
*/
1214
interface JsLayoutDataProviderInterface
1315
{

app/code/Magento/Customer/CustomerData/JsLayoutDataProviderPool.php

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
/**
1010
* Js layout data provider pool
11+
*
12+
* @api
1113
*/
1214
class JsLayoutDataProviderPool implements JsLayoutDataProviderPoolInterface
1315
{

app/code/Magento/Customer/CustomerData/SectionPool.php

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
/**
1212
* Section pool
13+
*
14+
* @api
1315
*/
1416
class SectionPool implements SectionPoolInterface
1517
{

app/code/Magento/Customer/CustomerData/SectionSourceInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
/**
99
* Section source interface
10+
*
11+
* @api Use to define data sections in customer data which are transported from backend to frontend local storage
1012
*/
1113
interface SectionSourceInterface
1214
{

app/code/Magento/Customer/Model/Address/AbstractAddress.php

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
* @method string getPostcode()
3131
* @method bool getShouldIgnoreValidation()
3232
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
33+
*
34+
* @api
3335
*/
3436
class AbstractAddress extends AbstractExtensibleModel implements AddressModelInterface
3537
{

app/code/Magento/Customer/Model/Address/AddressModelInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
/**
1010
* Interface AddressInterface
11+
*
12+
* @api
1113
*/
1214
interface AddressModelInterface
1315
{

app/code/Magento/Customer/Model/Address/CustomAttributeListInterface.php

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Customer\Model\Address;
77

8+
/**
9+
* @api
10+
*/
811
interface CustomAttributeListInterface
912
{
1013
/**

app/code/Magento/Customer/Model/Customer/DataProvider.php

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
/**
3131
* Class DataProvider
3232
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
33+
*
34+
* @api
3335
*/
3436
class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
3537
{

app/code/Magento/Customer/Model/Customer/Source/GroupSourceInterface.php

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Framework\Data\OptionSourceInterface;
99

10+
/**
11+
* @api
12+
*/
1013
interface GroupSourceInterface extends OptionSourceInterface
1114
{
1215

app/code/Magento/Customer/Model/EmailNotificationInterface.php

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Magento\Customer\Api\Data\CustomerInterface;
99
use Magento\Framework\Exception\LocalizedException;
1010

11+
/**
12+
* @api
13+
*/
1114
interface EmailNotificationInterface
1215
{
1316
/**

app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
/**
1414
* Class ProductActions
15+
*
16+
* @api
1517
*/
1618
class Actions extends Column
1719
{

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

+3
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@
329329
<argument name="collectionProcessor" xsi:type="object">Magento\Eav\Model\Api\SearchCriteria\CollectionProcessor</argument>
330330
</arguments>
331331
</type>
332+
<!-- @api -->
332333
<virtualType name="Magento\Customer\Model\Api\SearchCriteria\CollectionProcessor\GroupFilterProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor">
333334
<arguments>
334335
<argument name="fieldMapping" xsi:type="array">
@@ -338,6 +339,7 @@
338339
</argument>
339340
</arguments>
340341
</virtualType>
342+
<!-- @api -->
341343
<virtualType name="Magento\Customer\Model\Api\SearchCriteria\CollectionProcessor\GroupSortingProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\SortingProcessor">
342344
<arguments>
343345
<argument name="fieldMapping" xsi:type="array">
@@ -350,6 +352,7 @@
350352
</argument>
351353
</arguments>
352354
</virtualType>
355+
<!-- @api -->
353356
<virtualType name="Magento\Customer\Model\Api\SearchCriteria\GroupCollectionProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor">
354357
<arguments>
355358
<argument name="processors" xsi:type="array">

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

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
/**
7+
* @api
8+
*/
69
define([
710
'jquery',
811
'underscore',

app/code/Magento/Customer/view/frontend/web/js/model/address-list.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
/**
7+
* @api
8+
*/
69
define([
710
'ko',
811
'./customer-addresses'

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

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
/**
7+
* @api
8+
*/
69
define([
710
'jquery',
811
'ko',

app/code/Magento/Customer/view/frontend/web/js/model/customer.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
/**
7+
* @api
8+
*/
69
define([
710
'jquery',
811
'ko',

app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
/**
7+
* @api
8+
*/
69
define([], function () {
710
'use strict';
811

app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php

+75-21
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
use Magento\ImportExport\Controller\Adminhtml\ImportResult as ImportResultController;
99
use Magento\ImportExport\Model\Import;
10-
use Magento\ImportExport\Block\Adminhtml\Import\Frame\Result as ImportResultBlock;
10+
use Magento\ImportExport\Block\Adminhtml\Import\Frame\Result;
1111
use Magento\Framework\Controller\ResultFactory;
1212
use Magento\Framework\App\Filesystem\DirectoryList;
1313
use Magento\ImportExport\Model\Import\Adapter as ImportAdapter;
14+
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
1415

1516
class Validate extends ImportResultController
1617
{
@@ -29,7 +30,7 @@ public function execute()
2930
$data = $this->getRequest()->getPostValue();
3031
/** @var \Magento\Framework\View\Result\Layout $resultLayout */
3132
$resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT);
32-
/** @var $resultBlock ImportResultBlock */
33+
/** @var $resultBlock Result */
3334
$resultBlock = $resultLayout->getLayout()->getBlock('import.frame.result');
3435
if ($data) {
3536
// common actions
@@ -66,36 +67,27 @@ public function execute()
6667
}
6768

6869
/**
70+
* Process validation result and add required error or success messages to Result block
71+
*
6972
* @param bool $validationResult
70-
* @param ImportResultBlock $resultBlock
73+
* @param Result $resultBlock
7174
* @return void
7275
*/
7376
private function processValidationResult($validationResult, $resultBlock)
7477
{
7578
$import = $this->getImport();
76-
if (!$import->getProcessedRowsCount()) {
77-
if (!$import->getErrorAggregator()->getErrorsCount()) {
78-
$resultBlock->addError(__('This file is empty. Please try another one.'));
79+
$errorAggregator = $import->getErrorAggregator();
80+
81+
if ($import->getProcessedRowsCount()) {
82+
if ($validationResult) {
83+
$this->addMessageForValidResult($resultBlock);
7984
} else {
80-
foreach ($import->getErrorAggregator()->getAllErrors() as $error) {
81-
$resultBlock->addError($error->getErrorMessage());
82-
}
83-
}
84-
} else {
85-
$errorAggregator = $import->getErrorAggregator();
86-
if (!$validationResult) {
8785
$resultBlock->addError(
8886
__('Data validation failed. Please fix the following errors and upload the file again.')
8987
);
9088
$this->addErrorMessages($resultBlock, $errorAggregator);
91-
} else {
92-
if ($import->isImportAllowed()) {
93-
$resultBlock->addSuccess(
94-
__('File is valid! To start import process press "Import" button'),
95-
true
96-
);
97-
} else {
98-
$resultBlock->addError(__('The file is valid, but we can\'t import it for some reason.'));
89+
if ($errorAggregator->getErrorsCount()) {
90+
$this->addMessageToSkipErrors($resultBlock);
9991
}
10092
}
10193
$resultBlock->addNotice(
@@ -107,6 +99,12 @@ private function processValidationResult($validationResult, $resultBlock)
10799
$errorAggregator->getErrorsCount()
108100
)
109101
);
102+
} else {
103+
if ($errorAggregator->getErrorsCount()) {
104+
$this->collectErrors($resultBlock);
105+
} else {
106+
$resultBlock->addError(__('This file is empty. Please try another one.'));
107+
}
110108
}
111109
}
112110

@@ -121,4 +119,60 @@ private function getImport()
121119
}
122120
return $this->import;
123121
}
122+
123+
/**
124+
* Add error message to Result block and allow 'Import' button
125+
*
126+
* If validation strategy is equal to 'validation-skip-errors' and validation error limit is not exceeded,
127+
* then add error message and allow 'Import' button.
128+
*
129+
* @param Result $resultBlock
130+
* @return void
131+
*/
132+
private function addMessageToSkipErrors(Result $resultBlock)
133+
{
134+
$import = $this->getImport();
135+
if (!$import->getErrorAggregator()->hasFatalExceptions()) {
136+
$resultBlock->addSuccess(
137+
__('Please fix errors and re-upload file or simply press "Import" button to skip rows with errors'),
138+
true
139+
);
140+
}
141+
}
142+
143+
/**
144+
* Add success message to Result block
145+
*
146+
* 1. Add message for case when imported data was checked and result is valid.
147+
* 2. Add message for case when imported data was checked and result is valid, but import is not allowed.
148+
*
149+
* @param Result $resultBlock
150+
* @return void
151+
*/
152+
private function addMessageForValidResult(Result $resultBlock)
153+
{
154+
if ($this->getImport()->isImportAllowed()) {
155+
$resultBlock->addSuccess(__('File is valid! To start import process press "Import" button'), true);
156+
} else {
157+
$resultBlock->addError(__('The file is valid, but we can\'t import it for some reason.'));
158+
}
159+
}
160+
161+
/**
162+
* Collect errors and add error messages to Result block
163+
*
164+
* Get all errors from ProcessingErrorAggregatorInterface and add appropriated error messages
165+
* to Result block.
166+
*
167+
* @param Result $resultBlock
168+
* @return void
169+
*/
170+
private function collectErrors(Result $resultBlock)
171+
{
172+
$import = $this->getImport();
173+
$errors = $import->getErrorAggregator()->getAllErrors();
174+
foreach ($errors as $error) {
175+
$resultBlock->addError($error->getErrorMessage());
176+
}
177+
}
124178
}

app/code/Magento/ImportExport/Model/Import.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -560,19 +560,28 @@ protected function _removeBom($sourceFile)
560560
}
561561

562562
/**
563-
* Validates source file and returns validation result.
563+
* Validates source file and returns validation result
564+
*
565+
* Before validate data the method requires to initialize error aggregator (ProcessingErrorAggregatorInterface)
566+
* with 'validation strategy' and 'allowed error count' values to allow using this parameters in validation process.
564567
*
565568
* @param \Magento\ImportExport\Model\Import\AbstractSource $source
566569
* @return bool
567570
*/
568571
public function validateSource(\Magento\ImportExport\Model\Import\AbstractSource $source)
569572
{
570573
$this->addLogComment(__('Begin data validation'));
574+
575+
$errorAggregator = $this->getErrorAggregator();
576+
$errorAggregator->initValidationStrategy(
577+
$this->getData(self::FIELD_NAME_VALIDATION_STRATEGY),
578+
$this->getData(self::FIELD_NAME_ALLOWED_ERROR_COUNT)
579+
);
580+
571581
try {
572582
$adapter = $this->_getEntityAdapter()->setSource($source);
573-
$errorAggregator = $adapter->validateData();
583+
$adapter->validateData();
574584
} catch (\Exception $e) {
575-
$errorAggregator = $this->getErrorAggregator();
576585
$errorAggregator->addError(
577586
\Magento\ImportExport\Model\Import\Entity\AbstractEntity::ERROR_CODE_SYSTEM_EXCEPTION,
578587
ProcessingError::ERROR_LEVEL_CRITICAL,

0 commit comments

Comments
 (0)