over 11 years ago
Delete category and Products By Ids in Magento by following the steps:
1 - Deleting Category: send category id with Query String to controller such as
Then write the controller as
- public function deletcatAction(){
- Mage::register('isSecureArea', 1);
- $categoryId = $_REQUEST['id'];
- $category = Mage::getModel('catalog/category')->load($categoryId);
- try{
- $category->delete();
- }
- catch (Exception $e){
- echo $e->getMessage();
- }
- }
public function deletcatAction(){ Mage::register('isSecureArea', 1); $categoryId = $_REQUEST['id']; $category = Mage::getModel('catalog/category')->load($categoryId); try{ $category->delete(); } catch (Exception $e){ echo $e->getMessage(); } }
Deleting Products:
send category id with Query String to controller such as
Then write the controller as
- public function deletprdctAction(){
- Mage::register('isSecureArea', 1);
- $productId = $_REQUEST['id'];
- $product = Mage::getModel('catalog/product')->load($productId);
- try{
- $product->delete();
- $this->_redirect('manager/account/dashboardedit');
- }
- catch (Exception $e){
- echo $e->getMessage();
- }
- }
public function deletprdctAction(){ Mage::register('isSecureArea', 1); $productId = $_REQUEST['id']; $product = Mage::getModel('catalog/product')->load($productId); try{ $product->delete(); $this->_redirect('manager/account/dashboardedit'); } catch (Exception $e){ echo $e->getMessage(); } }
0 Comment(s)