Example #1
0
 /**
  * Before delete process
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  * @return $this
  */
 public function beforeDelete()
 {
     if ($this->getResource()->isForbiddenToDelete($this->getId())) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Can\'t delete root category.'));
     }
     return parent::beforeDelete();
 }
Example #2
0
 /**
  * Clear cache related with product and protect delete from not admin
  * Register indexing event before delete product
  *
  * @return \Magento\Catalog\Model\Product
  */
 public function beforeDelete()
 {
     $this->cleanCache();
     return parent::beforeDelete();
 }