diff --git a/upload/admin/controller/design/layout.php b/upload/admin/controller/design/layout.php index a42b5408..e2cc5bb2 100644 --- a/upload/admin/controller/design/layout.php +++ b/upload/admin/controller/design/layout.php @@ -422,6 +422,8 @@ protected function validateDelete() { $this->load->model('catalog/category'); $this->load->model('catalog/information'); $this->load->model('catalog/manufacturer'); + $this->load->model('blog/category'); + $this->load->model('blog/article'); foreach ($this->request->post['selected'] as $layout_id) { if ($this->config->get('config_layout_id') == $layout_id) { @@ -457,8 +459,20 @@ protected function validateDelete() { if ($information_total) { $this->error['warning'] = sprintf($this->language->get('error_information'), $information_total); } + + $blog_category_total = $this->model_blog_category->getTotalCategoriesByLayoutId($layout_id); + + if ($blog_category_total) { + $this->error['warning'] = sprintf($this->language->get('error_blog_category'), $blog_category_total); + } + + $blog_article_total = $this->model_blog_article->getTotalArticlesByLayoutId($layout_id); + + if ($blog_article_total) { + $this->error['warning'] = sprintf($this->language->get('error_blog_article'), $blog_article_total); + } } return !$this->error; } -} +} \ No newline at end of file diff --git a/upload/admin/language/en-gb/design/layout.php b/upload/admin/language/en-gb/design/layout.php index 397f7b43..1832cba6 100644 --- a/upload/admin/language/en-gb/design/layout.php +++ b/upload/admin/language/en-gb/design/layout.php @@ -38,4 +38,6 @@ $_['error_product'] = 'Warning: This layout cannot be deleted as it is currently assigned to %s products!'; $_['error_category'] = 'Warning: This layout cannot be deleted as it is currently assigned to %s categories!'; $_['error_manufacturer'] = 'Warning: This layout cannot be deleted as it is currently assigned to %s manufacturers!'; -$_['error_information'] = 'Warning: This layout cannot be deleted as it is currently assigned to %s information pages!'; \ No newline at end of file +$_['error_information'] = 'Warning: This layout cannot be deleted as it is currently assigned to %s information pages!'; +$_['error_blog_article'] = 'Warning: This layout cannot be deleted as it is currently assigned to %s blog articles!'; +$_['error_blog_category'] = 'Warning: This layout cannot be deleted as it is currently assigned to %s blog categories!'; diff --git a/upload/admin/model/design/layout.php b/upload/admin/model/design/layout.php index 1cd3bff3..9fe534e9 100644 --- a/upload/admin/model/design/layout.php +++ b/upload/admin/model/design/layout.php @@ -47,6 +47,8 @@ public function deleteLayout($layout_id) { $this->db->query("DELETE FROM " . DB_PREFIX . "category_to_layout WHERE layout_id = '" . (int)$layout_id . "'"); $this->db->query("DELETE FROM " . DB_PREFIX . "product_to_layout WHERE layout_id = '" . (int)$layout_id . "'"); $this->db->query("DELETE FROM " . DB_PREFIX . "information_to_layout WHERE layout_id = '" . (int)$layout_id . "'"); + $this->db->query("DELETE FROM " . DB_PREFIX . "blog_category_to_layout WHERE layout_id = '" . (int)$layout_id . "'"); + $this->db->query("DELETE FROM " . DB_PREFIX . "article_to_layout WHERE layout_id = '" . (int)$layout_id . "'"); } public function getLayout($layout_id) {