ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace JR\NetSuite\Model\ResourceModel\Location;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
use JR\NetSuite\Model\Location;
|
||||
use JR\NetSuite\Model\ResourceModel\Location as LocationResource;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(Location::class, LocationResource::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert or update based on UNIQUE combo 'key-processing'
|
||||
* @param $key
|
||||
* @param $value
|
||||
*/
|
||||
public function insertOrUpdate($item)
|
||||
{
|
||||
$connection = $this->getConnection();
|
||||
try {
|
||||
// Start a transaction
|
||||
// $connection->beginTransaction();
|
||||
|
||||
// Insert new item or update existing one
|
||||
$connection->insertOnDuplicate($this->getMainTable(), $item, ['data', 'status']);
|
||||
|
||||
// Commit the transaction
|
||||
// $connection->commit();
|
||||
} catch (\Exception $e) {
|
||||
// Rollback the transaction in case of an error
|
||||
$connection->rollBack();
|
||||
throw new \Magento\Framework\Exception\LocalizedException(
|
||||
__('Error in insertOrUpdate: %1', $e->getMessage()),
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user