Skip to content

Commit 06208c2

Browse files
committed
MAGETWO-66727: Update performance profiles with swatches
- fix memory limit
1 parent f8e3640 commit 06208c2

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

setup/src/Magento/Setup/Model/FixtureGenerator/EntityGenerator.php

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Setup\Model\FixtureGenerator;
88

9+
use Magento\Framework\Exception\LocalizedException;
910
use Magento\Framework\Exception\ValidatorException;
1011

1112
/**
@@ -138,14 +139,25 @@ public function __construct(
138139
* @param TemplateEntityGeneratorInterface $entityGenerator
139140
* @param int $entitiesAmount
140141
* @param callable $fixture
142+
* @throws LocalizedException
141143
* @return void
142144
*/
143145
public function generate(TemplateEntityGeneratorInterface $entityGenerator, $entitiesAmount, callable $fixture)
144146
{
145-
$this->sqlCollector->enable();
146-
$entity = $entityGenerator->generateEntity();
147-
$this->sqlCollector->disable();
148-
$entity->delete();
147+
$this->getConnection()->beginTransaction();
148+
try {
149+
$this->sqlCollector->enable();
150+
$entity = $entityGenerator->generateEntity();
151+
$this->sqlCollector->disable();
152+
$entity->delete();
153+
$this->getConnection()->commit();
154+
} catch (\Exception $e) {
155+
$this->getConnection()->rollBack();
156+
throw new LocalizedException(
157+
__('Cannot generate entities - error occurred during template creation: %1', $e->getMessage()),
158+
$e
159+
);
160+
}
149161

150162
$map = [];
151163
$processed = 0;
@@ -239,11 +251,22 @@ private function bindWithCustomHandler($table, $entityId, $entityNumber, $fixtur
239251
*
240252
* @param array $map
241253
* @return void
254+
* @throws LocalizedException
242255
*/
243256
private function saveEntities(array &$map)
244257
{
245-
foreach ($map as $table => $data) {
246-
$this->getConnection()->insertMultiple($table, $data);
258+
$this->getConnection()->beginTransaction();
259+
try {
260+
foreach ($map as $table => $data) {
261+
$this->getConnection()->insertMultiple($table, $data);
262+
}
263+
$this->getConnection()->commit();
264+
} catch (\Exception $e) {
265+
$this->getConnection()->rollBack();
266+
throw new LocalizedException(
267+
__('Cannot save entity. Error occurred: %1', $e->getMessage()),
268+
$e
269+
);
247270
}
248271

249272
$map = [];

0 commit comments

Comments
 (0)