/**
  * {@inheritdoc}
  */
 public function delete($object)
 {
     try {
         $this->transactionManager->start($this->getConnection());
         if (is_numeric($object)) {
             //$id = (int) $object;
         } elseif ($object instanceof \Magento\Framework\Model\AbstractModel) {
             $object->beforeDelete();
             //$id = (int) $object->getData($this->getLinkField());
         }
         $this->_beforeDelete($object);
         $this->entityManager->delete(\Magento\Catalog\Api\Data\ProductInterface::class, $object);
         //$this->evaluateDelete(
         //    $object,
         //    $id,
         //    $connection
         //);
         $this->_afterDelete($object);
         if ($object instanceof \Magento\Framework\Model\AbstractModel) {
             $object->isDeleted(true);
             $object->afterDelete();
         }
         $this->transactionManager->commit();
         if ($object instanceof \Magento\Framework\Model\AbstractModel) {
             $object->afterDeleteCommit();
         }
     } catch (\Exception $e) {
         $this->transactionManager->rollBack();
         throw $e;
     }
     $this->eventManager->dispatch('catalog_product_delete_after_done', ['product' => $object]);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * @inheritDoc
  */
 public function delete(AbstractModel $object)
 {
     $this->transactionManager->start($this->getConnection());
     try {
         $object->beforeDelete();
         $this->_beforeDelete($object);
         $this->entityManager->delete(PageInterface::class, $object);
         $this->_afterDelete($object);
         $object->isDeleted(true);
         $object->afterDelete();
         $this->transactionManager->commit();
         $object->afterDeleteCommit();
     } catch (\Exception $e) {
         $this->transactionManager->rollBack();
         throw $e;
     }
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Delete the object
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Exception
  */
 public function delete(AbstractModel $object)
 {
     $this->transactionManager->start($this->getConnection());
     try {
         $object->beforeDelete();
         $this->_beforeDelete($object);
         $this->entityManager->delete('Magento\\SalesRule\\Api\\Data\\RuleInterface', $object);
         $this->_afterDelete($object);
         $object->isDeleted(true);
         $object->afterDelete();
         $this->transactionManager->commit();
         $object->afterDeleteCommit();
     } catch (\Exception $exception) {
         $this->transactionManager->rollBack();
         throw $exception;
     }
     return $this;
 }
Exemplo n.º 4
0
 /**
  * @param AbstractModel $object
  * @return $this
  * @throws \Exception
  */
 public function delete(\Magento\Framework\Model\AbstractModel $object)
 {
     //TODO: add object relation processor support (MAGETWO-49297)
     $this->transactionManager->start($this->getConnection());
     try {
         $object->beforeDelete();
         $this->_beforeDelete($object);
         $this->entityManager->delete('Magento\\CatalogRule\\Api\\Data\\RuleInterface', $object);
         $this->_afterDelete($object);
         $object->isDeleted(true);
         $object->afterDelete();
         $this->transactionManager->commit();
         $object->afterDeleteCommit();
     } catch (\Exception $e) {
         $this->transactionManager->rollBack();
         throw $e;
     }
     return $this;
 }
 public function testDelete()
 {
     $this->orchestratorPool->expects($this->once())->method('getWriteOperation')->with('Test\\Entity\\Type', 'delete')->willReturn($this->writeOperation);
     $this->writeOperation->expects($this->once())->method('execute')->with('Test\\Entity\\Type', $this->abstractEntity)->willReturn(true);
     $this->assertTrue($this->subject->delete('Test\\Entity\\Type', $this->abstractEntity));
 }