/** * Process category data before deleting * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object) { $condition = ['category_id = ?' => (int) $object->getId()]; $this->getConnection()->delete($this->getTable('magefan_blog_category_store'), $condition); $this->getConnection()->delete($this->getTable('magefan_blog_post_category'), $condition); return parent::_beforeDelete($object); }
/** * Process page data before deleting * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object) { $condition = ['slider_id = ?' => (int) $object->getId()]; $this->getConnection()->delete($this->getTable('magebase_carousel_join'), $condition); $this->getConnection()->delete($this->getTable('slider_store_join'), $condition); return parent::_beforeDelete($object); }
/** * Process page data before deleting * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object) { $condition = ['page_id = ?' => (int)$object->getId()]; $this->getConnection()->delete($this->getTable('cms_page_store'), $condition); return parent::_beforeDelete($object); }
/** * Process post data before deleting * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object) { $condition = ['post_id = ?' => (int) $object->getId()]; $tableSufixs = ['store', 'category', 'tag', 'relatedproduct', 'relatedpost', 'relatedpost']; foreach ($tableSufixs as $sufix) { $this->getConnection()->delete($this->getTable('magefan_blog_post_' . $sufix), $sufix == 'relatedpost' ? ['related_id = ?' => (int) $object->getId()] : $condition); } return parent::_beforeDelete($object); }
/** * Process download data before deleting * * @param \Magento\Framework\Model\AbstractModel $object * * @return $this */ protected function _beforeDelete(AbstractModel $object) { $condition = ['download_id = ?' => (int) $object->getId()]; $this->getConnection()->delete($this->getTable('sebwite_product_downloads'), $condition); return parent::_beforeDelete($object); }
/** * Process author data before deleting * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _beforeDelete(AbstractModel $object) { $condition = ['author_id = ?' => (int) $object->getId()]; $this->getConnection()->delete($this->getTable('sample_news_author_store'), $condition); return parent::_beforeDelete($object); }
/** * Process page data before deleting * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object) { $condition = ['form_id = ?' => (int) $object->getId()]; $this->getConnection()->delete($this->getTable(self::STORE_TABLE_NAME), $condition); return parent::_beforeDelete($object); }
/** * @param AbstractModel $object * @return $this */ protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object) { parent::_beforeDelete($object); /** * Update children count for all parent Categories */ $parentIds = $object->getParentIds(); if ($parentIds) { $childDecrease = $object->getChildrenCount() + 1; // +1 is itself $data = ['children_count' => new \Zend_Db_Expr('children_count - ' . $childDecrease)]; $where = ['category_id IN(?)' => $parentIds]; $this->getConnection()->update($this->getMainTable(), $data, $where); } $this->deleteChildren($object); return $this; }
/** * Process article data before deleting * * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ protected function _beforeDelete(AbstractModel $object) { $condition = ['article_id = ?' => (int) $object->getId()]; $this->getConnection()->delete($this->getTable('gemtoo_blog_article_store'), $condition); return parent::_beforeDelete($object); }
/** * Perform actions before object delete * * @param \Magento\Framework\Model\AbstractModel $object * @return $this * @throws \Magento\Framework\Exception\StateException * @throws \Magento\Framework\Exception\LocalizedException */ protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object) { /** @var \Magento\Eav\Api\Data\AttributeSetInterface $object */ $defaultAttributeSetId = $this->eavConfig->getEntityType($object->getEntityTypeId())->getDefaultAttributeSetId(); if ($object->getAttributeSetId() == $defaultAttributeSetId) { throw new \Magento\Framework\Exception\StateException(__('Default attribute set can not be deleted')); } return parent::_beforeDelete($object); }