Mage_GoogleBase_TypesController Class Reference

Inheritance diagram for Mage_GoogleBase_TypesController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 gridAction ()
 newAction ()
 editAction ()
 saveAction ()
 deleteAction ()
 loadAttributesAction ()
 loadItemTypesAction ()
 _getStore ()

Protected Member Functions

 _initItemType ()
 _initAction ()
 loadAttributeSetsAction ()
 _isAllowed ()


Detailed Description

Definition at line 35 of file TypesController.php.


Member Function Documentation

_getStore (  ) 

Definition at line 223 of file TypesController.php.

00224     {
00225         $storeId = (int) $this->getRequest()->getParam('store', 0);
00226         if ($storeId == 0) {
00227             return Mage::app()->getDefaultStoreView();
00228         }
00229         return Mage::app()->getStore($storeId);
00230     }

_initAction (  )  [protected]

Definition at line 46 of file TypesController.php.

00047     {
00048         $this->loadLayout()
00049             ->_setActiveMenu('catalog/googlebase/types')
00050             ->_addBreadcrumb(Mage::helper('adminhtml')->__('Catalog'), Mage::helper('adminhtml')->__('Catalog'))
00051             ->_addBreadcrumb(Mage::helper('adminhtml')->__('Google Base'), Mage::helper('adminhtml')->__('Google Base'));
00052         return $this;
00053     }

_initItemType (  )  [protected]

Definition at line 37 of file TypesController.php.

00038     {
00039         Mage::register('current_item_type', Mage::getModel('googlebase/type'));
00040         $typeId = $this->getRequest()->getParam('id');
00041         if (!is_null($typeId)) {
00042             Mage::registry('current_item_type')->load($typeId);
00043         }
00044     }

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 232 of file TypesController.php.

00233     {
00234         return Mage::getSingleton('admin/session')->isAllowed('catalog/googlebase/types');
00235     }

deleteAction (  ) 

Definition at line 162 of file TypesController.php.

00163     {
00164         try {
00165             $id = $this->getRequest()->getParam('id');
00166             $model = Mage::getModel('googlebase/type');
00167             $model->load($id);
00168             if ($model->getTypeId()) {
00169                 $model->delete();
00170             }
00171             $this->_getSession()->addSuccess($this->__('Item Type was deleted'));
00172         } catch (Exception $e) {
00173             $this->_getSession()->addError($e->getMessage());
00174         }
00175         $this->_redirect('*/*/index', array('store' => $this->_getStore()->getId()));
00176     }

editAction (  ) 

Definition at line 87 of file TypesController.php.

00088     {
00089         $id = $this->getRequest()->getParam('id');
00090         $model = Mage::getModel('googlebase/type');
00091 
00092         try {
00093             $result = array();
00094             if ($id) {
00095                 $model->load($id);
00096                 $collection = Mage::getResourceModel('googlebase/attribute_collection')
00097                     ->addTypeFilter($model->getTypeId())
00098                     ->load();
00099                 foreach ($collection as $attribute) {
00100                     $result[] = $attribute->getData();
00101                 }
00102             }
00103 
00104             Mage::register('current_item_type', $model);
00105             Mage::register('attributes', $result);
00106 
00107             $this->_initAction()
00108                 ->_addBreadcrumb($id ? Mage::helper('googlebase')->__('Edit Item Type') : Mage::helper('googlebase')->__('New Item Type'), $id ? Mage::helper('googlebase')->__('Edit Item Type') : Mage::helper('googlebase')->__('New Item Type'))
00109                 ->_addContent($this->getLayout()->createBlock('googlebase/adminhtml_types_edit'))
00110                 ->renderLayout();
00111         } catch (Exception $e) {
00112             $this->_getSession()->addError($e->getMessage());
00113             $this->_redirect('*/*/index');
00114         }
00115     }

gridAction (  ) 

Grid for AJAX request

Definition at line 66 of file TypesController.php.

00067     {
00068         $this->getResponse()->setBody(
00069             $this->getLayout()->createBlock('googlebase/adminhtml_types_grid')->toHtml()
00070         );
00071     }

indexAction (  ) 

Definition at line 55 of file TypesController.php.

00056     {
00057         $this->_initAction()
00058             ->_addBreadcrumb(Mage::helper('googlebase')->__('Item Types'), Mage::helper('googlebase')->__('Item Types'))
00059             ->_addContent($this->getLayout()->createBlock('googlebase/adminhtml_types'))
00060             ->renderLayout();
00061     }

loadAttributesAction (  ) 

Definition at line 178 of file TypesController.php.

00179     {
00180         try {
00181             $this->getResponse()->setBody(
00182             $this->getLayout()->createBlock('googlebase/adminhtml_types_edit_attributes')
00183                 ->setAttributeSetId($this->getRequest()->getParam('attribute_set_id'))
00184                 ->setGbaseItemtype($this->getRequest()->getParam('gbase_itemtype'))
00185                 ->setTargetCountry($this->getRequest()->getParam('target_country'))
00186                 ->setAttributeSetSelected(true)
00187                 ->toHtml()
00188             );
00189         } catch (Exception $e) {
00190             // just need to output text with error
00191             $this->_getSession()->addError($e->getMessage());
00192         }
00193     }

loadAttributeSetsAction (  )  [protected]

Definition at line 209 of file TypesController.php.

00210     {
00211         try {
00212             $this->getResponse()->setBody(
00213                 $this->getLayout()->getBlockSingleton('googlebase/adminhtml_types_edit_form')
00214                     ->getAttributeSetsSelectElement($this->getRequest()->getParam('target_country'))
00215                     ->toHtml()
00216             );
00217         } catch (Exception $e) {
00218             // just need to output text with error
00219             $this->_getSession()->addError($e->getMessage());
00220         }
00221     }

loadItemTypesAction (  ) 

Definition at line 195 of file TypesController.php.

00196     {
00197         try {
00198             $this->getResponse()->setBody(
00199                 $this->getLayout()->getBlockSingleton('googlebase/adminhtml_types_edit_form')
00200                     ->getItemTypesSelectElement($this->getRequest()->getParam('target_country'))
00201                     ->toHtml()
00202             );
00203         } catch (Exception $e) {
00204             // just need to output text with error
00205             $this->_getSession()->addError($e->getMessage());
00206         }
00207     }

newAction (  ) 

Definition at line 73 of file TypesController.php.

00074     {
00075         try {
00076             $this->_initItemType();
00077             $this->_initAction()
00078                 ->_addBreadcrumb(Mage::helper('googlebase')->__('New Item Type'), Mage::helper('adminhtml')->__('New Item Type'))
00079                 ->_addContent($this->getLayout()->createBlock('googlebase/adminhtml_types_edit'))
00080                 ->renderLayout();
00081         } catch (Exception $e) {
00082             $this->_getSession()->addError($e->getMessage());
00083             $this->_redirect('*/*/index', array('store' => $this->_getStore()->getId()));
00084         }
00085     }

saveAction (  ) 

Definition at line 117 of file TypesController.php.

00118     {
00119         $typeModel = Mage::getModel('googlebase/type');
00120         $id = $this->getRequest()->getParam('type_id');
00121         if (!is_null($id)) {
00122             $typeModel->load($id);
00123         }
00124 
00125         try {
00126             if ($typeModel->getId()) {
00127                 $collection = Mage::getResourceModel('googlebase/attribute_collection')
00128                     ->addTypeFilter($typeModel->getId())
00129                     ->load();
00130                 foreach ($collection as $attribute) {
00131                     $attribute->delete();
00132                 }
00133             }
00134             $typeModel->setAttributeSetId($this->getRequest()->getParam('attribute_set_id'))
00135                 ->setGbaseItemtype($this->getRequest()->getParam('gbase_itemtype'))
00136                 ->setTargetCountry($this->getRequest()->getParam('target_country'))
00137                 ->save();
00138 
00139 
00140             $attributes = $this->getRequest()->getParam('attributes');
00141             if (is_array($attributes)) {
00142                 $typeId = $typeModel->getId();
00143                 foreach ($attributes as $attrInfo) {
00144                     if (isset($attrInfo['delete']) && $attrInfo['delete'] == 1) {
00145                         continue;
00146                     }
00147                     Mage::getModel('googlebase/attribute')
00148                         ->setAttributeId($attrInfo['attribute_id'])
00149                         ->setGbaseAttribute($attrInfo['gbase_attribute'])
00150                         ->setTypeId($typeId)
00151                         ->save();
00152                 }
00153             }
00154 
00155             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('googlebase')->__('Item type was successfully saved'));
00156         } catch (Exception $e) {
00157             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00158         }
00159         $this->_redirect('*/*/index', array('store' => $this->_getStore()->getId()));
00160     }


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

Generated on Sat Jul 4 17:24:16 2009 for Magento by  doxygen 1.5.8