本文整理汇总了PHP中Magento\Framework\Model\Resource\Db\AbstractDb::_prepareDataForTable方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractDb::_prepareDataForTable方法的具体用法?PHP AbstractDb::_prepareDataForTable怎么用?PHP AbstractDb::_prepareDataForTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\Resource\Db\AbstractDb
的用法示例。
在下文中一共展示了AbstractDb::_prepareDataForTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareDataForSave
/**
* Prepares data for saving and removes update time (if exists).
* This prevents saving same update time on each entity update.
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return array
*/
protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $object)
{
$data = parent::_prepareDataForTable($object, $this->getMainTable());
if (isset($data['updated_at'])) {
unset($data['updated_at']);
}
return $data;
}
示例2: _prepareDataForTable
/**
* Use qty correction for qty column update
*
* @param \Magento\Framework\Object $object
* @param string $table
* @return array
*/
protected function _prepareDataForTable(\Magento\Framework\Object $object, $table)
{
$data = parent::_prepareDataForTable($object, $table);
$ifNullSql = $this->_getWriteAdapter()->getIfNullSql('qty');
if (!$object->isObjectNew() && $object->getQtyCorrection()) {
if ($object->getQty() === null) {
$data['qty'] = null;
} elseif ($object->getQtyCorrection() < 0) {
$data['qty'] = new \Zend_Db_Expr($ifNullSql . '-' . abs($object->getQtyCorrection()));
} else {
$data['qty'] = new \Zend_Db_Expr($ifNullSql . '+' . $object->getQtyCorrection());
}
}
return $data;
}