Example #1
0
 /**
  * Check if group uses as default
  *
  * @param  \Magento\Framework\Model\AbstractModel $group
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $group)
 {
     if ($group->usesAsDefault()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('You can\'t delete group "%1".', $group->getCode()));
     }
     return parent::_beforeDelete($group);
 }
Example #2
0
 /**
  * Check if group uses as default
  *
  * @param  \Magento\Framework\Model\AbstractModel $group
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $group)
 {
     if ($group->usesAsDefault()) {
         throw new \Magento\Framework\Model\Exception(__('The group "%1" cannot be deleted', $group->getCode()));
     }
     return parent::_beforeDelete($group);
 }
Example #3
0
 /**
  * Process page data before deleting
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object)
 {
     $condition = array('page_id = ?' => (int) $object->getId());
     $this->_getWriteAdapter()->delete($this->getTable('cms_page_store'), $condition);
     return parent::_beforeDelete($object);
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 /**
  * 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->_getWriteAdapter()->delete($this->getTable('sample_news_author_store'), $condition);
     return parent::_beforeDelete($object);
 }
Example #6
0
 /**
  * Process brand data before deleting
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object)
 {
     $condition = ['brand_id = ?' => (int) $object->getId()];
     $this->getConnection()->delete($this->getTable('ves_brand_store'), $condition);
     return parent::_beforeDelete($object);
 }