Skip to content

Commit 15d6d74

Browse files
author
Aliaksei Yakimovich2
committed
MAGETWO-60918: Fatal error on Import/Export page if deleted category ids exists in category path
- Fixed an import/exposrt issue;
1 parent fb9a02a commit 15d6d74

File tree

1 file changed

+10
-4
lines changed
  • app/code/Magento/CatalogImportExport/Model/Export

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,11 @@ protected function initCategories()
444444
if ($pathSize > 1) {
445445
$path = [];
446446
for ($i = 1; $i < $pathSize; $i++) {
447-
$name = $collection->getItemById($structure[$i])->getName();
448-
$path[] = $this->quoteCategoryDelimiter($name);
447+
$childCategory = $collection->getItemById($structure[$i]);
448+
if ($childCategory) {
449+
$name = $childCategory->getName();
450+
$path[] = $this->quoteCategoryDelimiter($name);
451+
}
449452
}
450453
$this->_rootCategories[$category->getId()] = array_shift($path);
451454
if ($pathSize > 2) {
@@ -673,8 +676,8 @@ protected function prepareLinks(array $productIds)
673676
/**
674677
* Update data row with information about categories. Return true, if data row was updated
675678
*
676-
* @param array &$dataRow
677-
* @param array &$rowCategories
679+
* @param array $dataRow
680+
* @param array $rowCategories
678681
* @param int $productId
679682
* @return bool
680683
*/
@@ -840,6 +843,7 @@ protected function paginateCollection($page, $pageSize)
840843
public function export()
841844
{
842845
//Execution time may be very long
846+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
843847
set_time_limit(0);
844848

845849
$writer = $this->getWriter();
@@ -963,6 +967,7 @@ protected function loadCollection(): array
963967
* @return array
964968
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
965969
* @SuppressWarnings(PHPMD.NPathComplexity)
970+
* phpcs:disable Generic.Metrics.NestingLevel
966971
*/
967972
protected function collectRawData()
968973
{
@@ -1057,6 +1062,7 @@ protected function collectRawData()
10571062

10581063
return $data;
10591064
}
1065+
//phpcs:enable Generic.Metrics.NestingLevel
10601066

10611067
/**
10621068
* Wrap values with double quotes if "Fields Enclosure" option is enabled

0 commit comments

Comments
 (0)