本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::isDeleted方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::isDeleted方法的具体用法?PHP AbstractModel::isDeleted怎么用?PHP AbstractModel::isDeleted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::isDeleted方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsDeleted
/**
* Tests \Magento\Framework\Object->isDeleted()
*/
public function testIsDeleted()
{
$this->assertFalse($this->model->isDeleted());
$this->model->isDeleted();
$this->assertFalse($this->model->isDeleted());
$this->model->isDeleted(true);
$this->assertTrue($this->model->isDeleted());
}
示例2: save
/**
* @inheritdoc
*/
public function save(\Magento\Framework\Model\AbstractModel $object)
{
/**
* Direct deleted items to delete method
*/
if ($object->isDeleted()) {
return $this->delete($object);
}
$this->beginTransaction();
try {
if (!$this->isModified($object)) {
$this->entityRelationComposite->processRelations($object);
$this->commit();
return $this;
}
$object->validateBeforeSave();
$object->beforeSave();
if ($object->isSaveAllowed()) {
if (!$this->isPartialSave()) {
$this->loadAllAttributes($object);
}
if ($this->getEntityTable() == \Magento\Eav\Model\Entity::DEFAULT_ENTITY_TABLE && !$object->getEntityTypeId()) {
$object->setEntityTypeId($this->getTypeId());
}
$object->setParentId((int) $object->getParentId());
$this->objectRelationProcessor->validateDataIntegrity($this->getEntityTable(), $object->getData());
$this->_beforeSave($object);
$this->_processSaveData($this->_collectSaveData($object));
$this->_afterSave($object);
$this->entitySnapshot->registerSnapshot($object);
$object->afterSave();
$this->entityRelationComposite->processRelations($object);
}
$this->addCommitCallback([$object, 'afterCommitCallback'])->commit();
$object->setHasDataChanges(false);
} catch (\Exception $e) {
$this->rollBack();
$object->setHasDataChanges(true);
throw $e;
}
return $this;
}
示例3: save
/**
* @inheritDoc
*/
public function save(AbstractModel $object)
{
if ($object->isDeleted()) {
return $this->delete($object);
}
$this->beginTransaction();
try {
if (!$this->isModified($object)) {
$this->processNotModifiedSave($object);
$this->commit();
$object->setHasDataChanges(false);
return $this;
}
$object->validateBeforeSave();
$object->beforeSave();
if ($object->isSaveAllowed()) {
$this->_serializeFields($object);
$this->_beforeSave($object);
$this->_checkUnique($object);
$this->objectRelationProcessor->validateDataIntegrity($this->getMainTable(), $object->getData());
$this->entityManager->save(PageInterface::class, $object);
$this->unserializeFields($object);
$this->processAfterSaves($object);
}
$this->addCommitCallback([$object, 'afterCommitCallback'])->commit();
$object->setHasDataChanges(false);
} catch (\Exception $e) {
$this->rollBack();
$object->setHasDataChanges(true);
throw $e;
}
return $this;
}
示例4: save
/**
* Save Product Index data (forced save)
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this|\Magento\Framework\Model\Resource\Db\AbstractDb
*/
public function save(\Magento\Framework\Model\AbstractModel $object)
{
if ($object->isDeleted()) {
return $this->delete($object);
}
$this->_serializeFields($object);
$this->_beforeSave($object);
$this->_checkUnique($object);
$data = $this->_prepareDataForSave($object);
unset($data[$this->getIdFieldName()]);
$matchFields = ['product_id', 'store_id'];
$this->_resourceHelper->mergeVisitorProductIndex($this->getMainTable(), $data, $matchFields);
$this->unserializeFields($object);
$this->_afterSave($object);
return $this;
}
示例5: save
/**
* Save entity
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
* @throws \Exception
*/
public function save(\Magento\Framework\Model\AbstractModel $object)
{
if ($object->isDeleted()) {
return $this->delete($object);
}
if (!$this->entitySnapshot->isModified($object)) {
$this->entityRelationComposite->processRelations($object);
return $this;
}
$this->beginTransaction();
try {
$object->validateBeforeSave();
$object->beforeSave();
if ($object->isSaveAllowed()) {
$this->_serializeFields($object);
$this->_beforeSave($object);
$this->_checkUnique($object);
$this->objectRelationProcessor->validateDataIntegrity($this->getMainTable(), $object->getData());
if ($object->getId() !== null && (!$this->_useIsObjectNew || !$object->isObjectNew())) {
$condition = $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
$data = $this->_prepareDataForSave($object);
unset($data[$this->getIdFieldName()]);
$this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition);
} else {
$bind = $this->_prepareDataForSave($object);
unset($bind[$this->getIdFieldName()]);
$this->_getWriteAdapter()->insert($this->getMainTable(), $bind);
$object->setId($this->_getWriteAdapter()->lastInsertId($this->getMainTable()));
if ($this->_useIsObjectNew) {
$object->isObjectNew(false);
}
}
$this->unserializeFields($object);
$this->_afterSave($object);
$this->entitySnapshot->registerSnapshot($object);
$object->afterSave();
$this->entityRelationComposite->processRelations($object);
}
$this->addCommitCallback([$object, 'afterCommitCallback'])->commit();
$object->setHasDataChanges(false);
} catch (\Exception $e) {
$this->rollBack();
$object->setHasDataChanges(true);
throw $e;
}
return $this;
}
示例6: save
/**
* Save object object data
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @api
*/
public function save(\Magento\Framework\Model\AbstractModel $object)
{
if ($object->isDeleted()) {
return $this->delete($object);
}
if (!$object->hasDataChanges()) {
return $this;
}
$this->beginTransaction();
try {
$object->validateBeforeSave();
$object->beforeSave();
if ($object->isSaveAllowed()) {
$this->_serializeFields($object);
$this->_beforeSave($object);
$this->_checkUnique($object);
$this->objectRelationProcessor->validateDataIntegrity($this->getMainTable(), $object->getData());
if ($object->getId() !== null && (!$this->_useIsObjectNew || !$object->isObjectNew())) {
$condition = $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
/**
* Not auto increment primary key support
*/
if ($this->_isPkAutoIncrement) {
$data = $this->prepareDataForUpdate($object);
if (!empty($data)) {
$this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition);
}
} else {
$select = $this->_getWriteAdapter()->select()->from(
$this->getMainTable(),
[$this->getIdFieldName()]
)->where(
$condition
);
if ($this->_getWriteAdapter()->fetchOne($select) !== false) {
$data = $this->prepareDataForUpdate($object);
if (!empty($data)) {
$this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition);
}
} else {
$this->_getWriteAdapter()->insert(
$this->getMainTable(),
$this->_prepareDataForSave($object)
);
}
}
} else {
$bind = $this->_prepareDataForSave($object);
if ($this->_isPkAutoIncrement) {
unset($bind[$this->getIdFieldName()]);
}
$this->_getWriteAdapter()->insert($this->getMainTable(), $bind);
$object->setId($this->_getWriteAdapter()->lastInsertId($this->getMainTable()));
if ($this->_useIsObjectNew) {
$object->isObjectNew(false);
}
}
$this->unserializeFields($object);
$this->_afterSave($object);
$object->afterSave();
}
$this->addCommitCallback([$object, 'afterCommitCallback'])->commit();
$object->setHasDataChanges(false);
} catch (\Exception $e) {
$this->rollBack();
$object->setHasDataChanges(true);
throw $e;
}
return $this;
}