Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch errors during bunch encoding #404

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* ImportExport import data resource model
*
* @category AvS
* @package AvS_FastSimpleImport
* @author Aoe Magento Team <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software Licence 3.0 (OSL-3.0)
* @link https://github.com/AOEpeople/AvS_FastSimpleImport
*/
class AvS_FastSimpleImport_Model_Resource_Import_Data extends Mage_ImportExport_Model_Resource_Import_Data {

/**
* Save import rows bunch.
*
* @param string $entity
* @param string $behavior
* @param array $data
* @return int
* @throws Exception
*/
public function saveBunch($entity, $behavior, array $data)
{
$json = Mage::helper('core')->jsonEncode($data);
if (false === $json) {
$error = json_last_error_msg();
throw new Exception(sprintf('Error encoding data for save: %s', $error));
}
return $this->_getWriteAdapter()->insert(
$this->getMainTable(),
array('behavior' => $behavior, 'entity' => $entity, 'data' => $json)
);
}
}
5 changes: 5 additions & 0 deletions src/app/code/community/AvS/FastSimpleImport/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<import_entity_product>AvS_FastSimpleImport_Model_Import_Entity_Product</import_entity_product>
</rewrite>
</importexport>
<importexport_resource>
<rewrite>
<import_data>AvS_FastSimpleImport_Model_Resource_Import_Data</import_data>
</rewrite>
</importexport_resource>
</models>

<helpers>
Expand Down