Skip to content

Commit 7150e03

Browse files
author
Yaroslav Onischenko
committed
MAGETWO-36793: Fatal error when exporting products
1 parent 596eb3e commit 7150e03

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ protected function getExportData()
802802
}
803803
}
804804
} catch (\Exception $e) {
805-
$this->_logger->logException($e);
805+
$this->_logger->critical($e);
806806
}
807807
return $exportData;
808808
}

app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ public function getConfigurableOptions($product, $attributes)
180180
implode(
181181
' AND ',
182182
[
183-
$this->_getReadAdapter()->quoteInto(
184-
'entity_value.entity_type_id = ?',
185-
$product->getEntityTypeId()
186-
),
187183
'entity_value.attribute_id = super_attribute.attribute_id',
188184
'entity_value.store_id = 0',
189185
'entity_value.entity_id = product_link.product_id'

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,50 @@ public function verifyRow(array $rowData)
125125
);
126126
}
127127
}
128+
129+
/**
130+
* Verifies if exception processing works properly
131+
*
132+
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php
133+
*/
134+
public function testExceptionInGetExportData()
135+
{
136+
$exception = new \Exception('Error');
137+
138+
$rowCustomizerMock = $this->getMockBuilder('Magento\CatalogImportExport\Model\Export\RowCustomizerInterface')
139+
->disableOriginalConstructor()
140+
->getMock();
141+
142+
$loggerMock = $this->getMockBuilder('\Psr\Log\LoggerInterface')->getMock();
143+
144+
$directoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false);
145+
$directoryMock->expects($this->any())->method('getParentDirectory')->will($this->returnValue('some#path'));
146+
$directoryMock->expects($this->any())->method('isWritable')->will($this->returnValue(true));
147+
148+
$filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
149+
$filesystemMock->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($directoryMock));
150+
151+
$exportAdapter = new \Magento\ImportExport\Model\Export\Adapter\Csv($filesystemMock);
152+
153+
$rowCustomizerMock->expects($this->once())->method('prepareData')->willThrowException($exception);
154+
$loggerMock->expects($this->once())->method('critical')->with($exception);
155+
156+
$collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
157+
'\Magento\Catalog\Model\Resource\Product\Collection'
158+
);
159+
160+
/** @var \Magento\CatalogImportExport\Model\Export\Product $model */
161+
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
162+
'Magento\CatalogImportExport\Model\Export\Product',
163+
[
164+
'rowCustomizer' => $rowCustomizerMock,
165+
'logger' => $loggerMock,
166+
'collection' => $collection
167+
]
168+
);
169+
170+
171+
$data = $model->setWriter($exportAdapter)->export();
172+
$this->assertEmpty($data);
173+
}
128174
}

0 commit comments

Comments
 (0)