Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit d57fcb0

Browse files
WilXPVolodymyr Kublytskyi
authored andcommitted
Forward port of magento-partners/magento2ce#63 from 2.1 to 2.3
1 parent 14a4df8 commit d57fcb0

File tree

1 file changed

+9
-1
lines changed
  • app/code/Magento/ImportExport/Model/ResourceModel/Import

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,17 @@ public function getNextBunch()
159159
*/
160160
public function saveBunch($entity, $behavior, array $data)
161161
{
162+
$encodedData = $this->jsonHelper->jsonEncode($data);
163+
164+
if (json_last_error()!==JSON_ERROR_NONE && empty($encodedData)) {
165+
throw new \Magento\Framework\Exception\ValidatorException(
166+
__('Error in CSV: ' . json_last_error_msg())
167+
);
168+
}
169+
162170
return $this->getConnection()->insert(
163171
$this->getMainTable(),
164-
['behavior' => $behavior, 'entity' => $entity, 'data' => $this->jsonHelper->jsonEncode($data)]
172+
['behavior' => $behavior, 'entity' => $entity, 'data' => $encodedData]
165173
);
166174
}
167175
}

0 commit comments

Comments
 (0)