Mage_Adminhtml_Tax_Class_ProductController Class Reference

Inheritance diagram for Mage_Adminhtml_Tax_Class_ProductController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 newAction ()
 editAction ()
 deleteAction ()

Protected Member Functions

 _initAction ()
 _isAllowed ()


Detailed Description

Definition at line 34 of file ProductController.php.


Member Function Documentation

_initAction (  )  [protected]

Initialize action

Returns:
Mage_Adminhtml_Controller_Action

Definition at line 145 of file ProductController.php.

00146     {
00147         $this->loadLayout()
00148             ->_setActiveMenu('sales/tax/tax_class_product')
00149             ->_addBreadcrumb(Mage::helper('tax')->__('Sales'), Mage::helper('tax')->__('Sales'))
00150             ->_addBreadcrumb(Mage::helper('tax')->__('Tax'), Mage::helper('tax')->__('Tax'))
00151             ->_addBreadcrumb(Mage::helper('tax')->__('Manage Product Tax Classes'), Mage::helper('tax')->__('Manage Product Tax Classes'))
00152         ;
00153         return $this;
00154     }

_isAllowed (  )  [protected]

Check current user permission on resource and privilege

Returns:
bool

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 161 of file ProductController.php.

00162     {
00163         return Mage::getSingleton('admin/session')->isAllowed('sales/tax/classes_product');
00164     }

deleteAction (  ) 

delete class action

Definition at line 90 of file ProductController.php.

00091     {
00092         $classId    = $this->getRequest()->getParam('id');
00093         $classModel = Mage::getModel('tax/class')
00094             ->load($classId);
00095 
00096         if (!$classModel->getId() || $classModel->getClassType() != 'PRODUCT') {
00097             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('This class no longer exists'));
00098             $this->_redirect('*/*/');
00099             return;
00100         }
00101 
00102         $ruleCollection = Mage::getModel('tax/calculation_rule')
00103             ->getCollection()
00104             ->setClassTypeFilter('PRODUCT', $classId);
00105 
00106         if ($ruleCollection->getSize() > 0) {
00107             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('You cannot delete this tax class as it is used in Tax Rules. You have to delete the rules it is used in first.'));
00108             $this->_redirectReferer();
00109             return;
00110         }
00111 
00112         $productCollection = Mage::getModel('catalog/product')
00113             ->getCollection()
00114             ->addAttributeToFilter('tax_class_id', $classId);
00115         $productCount = $productCollection->getSize();
00116 
00117         if ($productCount > 0) {
00118             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('You cannot delete this tax class as it is used for %d products.', $productCount));
00119             $this->_redirectReferer();
00120             return;
00121         }
00122 
00123         try {
00124             $classModel->delete();
00125 
00126             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('tax')->__('Tax class was successfully deleted'));
00127             $this->getResponse()->setRedirect($this->getUrl("*/*/"));
00128             return;
00129         }
00130         catch (Mage_Core_Exception $e) {
00131             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00132         }
00133         catch (Exception $e) {
00134             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('Error while deleting this class. Please try again later.'));
00135         }
00136 
00137         $this->_redirectReferer();
00138     }

editAction (  ) 

edit class action

Definition at line 60 of file ProductController.php.

00061     {
00062         $classId    = $this->getRequest()->getParam('id');
00063         $model      = Mage::getModel('tax/class');
00064         if ($classId) {
00065             $model->load($classId);
00066             if (!$model->getId() || $model->getClassType() != 'PRODUCT') {
00067                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('This class no longer exists'));
00068                 $this->_redirect('*/*/');
00069                 return;
00070             }
00071         }
00072 
00073         $data = Mage::getSingleton('adminhtml/session')->getClassData(true);
00074         if (!empty($data)) {
00075             $model->setData($data);
00076         }
00077 
00078         Mage::register('tax_class', $model);
00079 
00080         $this->_initAction()
00081             ->_addBreadcrumb($classId ? Mage::helper('tax')->__('Edit Class') :  Mage::helper('tax')->__('New Class'), $classId ?  Mage::helper('tax')->__('Edit Class') :  Mage::helper('tax')->__('New Class'))
00082             ->_addContent($this->getLayout()->createBlock('adminhtml/tax_class_edit')->setData('action', $this->getUrl('*/tax_class/save'))->setClassType('PRODUCT'))
00083             ->renderLayout();
00084     }

indexAction (  ) 

view grid

Definition at line 40 of file ProductController.php.

00041     {
00042         $this->_initAction()
00043             ->_addContent($this->getLayout()->createBlock('adminhtml/tax_class')->setClassType('PRODUCT'))
00044             ->renderLayout();
00045     }

newAction (  ) 

new class action

Definition at line 51 of file ProductController.php.

00052     {
00053         $this->_forward('edit');
00054     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:30 2009 for Magento by  doxygen 1.5.8