public function editAction() { $id = $this->getRequest()->getParam('id'); $model = AO::getModel('salesrule/rule'); if ($id) { $model->load($id); if (!$model->getRuleId()) { AO::getSingleton('adminhtml/session')->addError(AO::helper('salesrule')->__('This rule no longer exists')); $this->_redirect('*/*'); return; } } // set entered data if was error when we do save $data = AO::getSingleton('adminhtml/session')->getPageData(true); if (!empty($data)) { $model->addData($data); } $model->getConditions()->setJsFormObject('rule_conditions_fieldset'); $model->getActions()->setJsFormObject('rule_actions_fieldset'); AO::register('current_promo_quote_rule', $model); $block = $this->getLayout()->createBlock('adminhtml/promo_quote_edit')->setData('action', $this->getUrl('*/*/save')); $this->_initAction(); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)->setCanLoadRulesJs(true); $this->_addBreadcrumb($id ? AO::helper('salesrule')->__('Edit Rule') : AO::helper('salesrule')->__('New Rule'), $id ? AO::helper('salesrule')->__('Edit Rule') : AO::helper('salesrule')->__('New Rule'))->_addContent($block)->_addLeft($this->getLayout()->createBlock('adminhtml/promo_quote_edit_tabs'))->renderLayout(); }
/** * Initialize requested category and put it into registry. * Root category can be returned, if inappropriate store/category is specified * * @param bool $getRootInstead * @return Mage_Catalog_Model_Category */ protected function _initCategory($getRootInstead = false) { $categoryId = (int) $this->getRequest()->getParam('id', false); $storeId = (int) $this->getRequest()->getParam('store'); $category = AO::getModel('catalog/category'); $category->setStoreId($storeId); if ($categoryId) { $category->load($categoryId); if ($storeId) { $rootId = AO::app()->getStore($storeId)->getRootCategoryId(); if (!in_array($rootId, $category->getPathIds())) { // load root category instead wrong one if ($getRootInstead) { $category->load($rootId); } else { $this->_redirect('*/*/', array('_current' => true, 'id' => null)); return false; } } } } if ($activeTabId = (string) $this->getRequest()->getParam('active_tab_id')) { AO::getSingleton('admin/session')->setActiveTabId($activeTabId); } AO::register('category', $category); AO::register('current_category', $category); return $category; }
public function editAction() { $id = $this->getRequest()->getParam('attribute_id'); $model = AO::getModel('catalog/entity_attribute'); if ($id) { $model->load($id); if (!$model->getId()) { AO::getSingleton('adminhtml/session')->addError(AO::helper('catalog')->__('This attribute no longer exists')); $this->_redirect('*/*/'); return; } // entity type check if ($model->getEntityTypeId() != $this->_entityTypeId) { AO::getSingleton('adminhtml/session')->addError(AO::helper('catalog')->__('You cannot edit this attribute')); $this->_redirect('*/*/'); return; } } // set entered data if was error when we do save $data = AO::getSingleton('adminhtml/session')->getAttributeData(true); if (!empty($data)) { $model->setData($data); } AO::register('entity_attribute', $model); $this->_initAction()->_addBreadcrumb($id ? AO::helper('catalog')->__('Edit Product Attribute') : AO::helper('catalog')->__('New Product Attribute'), $id ? AO::helper('catalog')->__('Edit Product Attribute') : AO::helper('catalog')->__('New Product Attribute'))->_addContent($this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit')->setData('action', $this->getUrl('*/catalog_product_attribute/save')))->_addLeft($this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit_tabs'))->_addJs($this->getLayout()->createBlock('adminhtml/template')->setIsPopup((bool) $this->getRequest()->getParam('popup'))->setTemplate('catalog/product/attribute/js.phtml'))->renderLayout(); }
protected function _prepareColumns() { $baseUrl = $this->getUrl(); $this->addColumn('name', array('header' => AO::helper('tag')->__('Tag'), 'index' => 'name')); $this->addColumn('total_used', array('header' => AO::helper('tag')->__('Uses'), 'width' => '140px', 'align' => 'right', 'index' => 'uses', 'type' => 'number')); $this->addColumn('products', array('header' => AO::helper('tag')->__('Products'), 'width' => '140px', 'align' => 'right', 'index' => 'products', 'type' => 'number')); $this->addColumn('customers', array('header' => AO::helper('tag')->__('Customers'), 'width' => '140px', 'align' => 'right', 'index' => 'customers', 'type' => 'number')); $this->addColumn('popularity', array('header' => AO::helper('tag')->__('Popularity'), 'width' => '140px', 'align' => 'right', 'index' => 'popularity', 'type' => 'number')); /* $this->addColumn('status', array( 'header' => AO::helper('tag')->__('Status'), 'width' => '90px', 'index' => 'status', 'type' => 'options', 'filter' => false, 'sortable' => false, 'options' => array( Mage_Tag_Model_Tag::STATUS_DISABLED => AO::helper('tag')->__('Disabled'), Mage_Tag_Model_Tag::STATUS_PENDING => AO::helper('tag')->__('Pending'), Mage_Tag_Model_Tag::STATUS_APPROVED => AO::helper('tag')->__('Approved'), ), )); */ // Collection for stores filters if (!($collection = AO::registry('stores_select_collection'))) { $collection = AO::app()->getStore()->getResourceCollection()->load(); AO::register('stores_select_collection', $collection); } if (!AO::app()->isSingleStoreMode()) { $this->addColumn('visible_in', array('header' => AO::helper('tag')->__('Visible In'), 'type' => 'store', 'index' => 'stores', 'sortable' => false, 'store_view' => true)); } $this->addColumn('actions', array('header' => AO::helper('tag')->__('Actions'), 'width' => '100px', 'type' => 'action', 'sortable' => false, 'filter' => false, 'actions' => array(array('caption' => AO::helper('tag')->__('Edit Tag'), 'url' => $this->getUrl('*/*/edit', array('ret' => 'pending', 'tag_id' => '$tag_id'))), array('caption' => AO::helper('tag')->__('View Products'), 'url' => $this->getUrl('*/*/product', array('ret' => 'pending', 'tag_id' => '$tag_id'))), array('caption' => AO::helper('tag')->__('View Customers'), 'url' => $this->getUrl('*/*/customer', array('ret' => 'pending', 'tag_id' => '$tag_id')))))); return parent::_prepareColumns(); }
/** * Init currency by currency code from request * * @return Mage_Adminhtml_Controller_Action */ protected function _initCurrency() { $code = $this->getRequest()->getParam('currency'); $currency = AO::getModel('directory/currency')->load($code); AO::register('currency', $currency); return $this; }
/** * Retrieve current product model * * @return Mage_Catalog_Model_Product */ public function getProduct() { if (!AO::registry('product') && $this->getProductId()) { $product = AO::getModel('catalog/product')->load($this->getProductId()); AO::register('product', $product); } return AO::registry('product'); }
protected function _prepareCollection() { $roleId = $this->getRequest()->getParam('rid'); AO::register('RID', $roleId); $collection = AO::getModel('admin/roles')->getUsersCollection(); $this->setCollection($collection); return parent::_prepareCollection(); }
public function getCollection() { if (is_null($this->_websiteCollection)) { $this->_websiteCollection = AO::getResourceModel('core/website_collection')->load(); } AO::register('website_collection', $this->_websiteCollection); return $this->_websiteCollection; }
protected function _initGroup() { AO::register('current_group', AO::getModel('customer/group')); $groupId = $this->getRequest()->getParam('id'); if (!is_null($groupId)) { AO::registry('current_group')->load($groupId); } }
public function __construct() { parent::__construct(); $this->setTemplate('system/email/template/edit.phtml'); AO::register('email_template', AO::getModel('core/email_template')); if ($templateId = (int) $this->getRequest()->getParam('id')) { $this->getEmailTemplate()->load($templateId); } }
public function toOptionArray() { if (!($collection = AO::registry('config_system_email_template'))) { $collection = AO::getResourceModel('core/email_template_collection')->load(); AO::register('config_system_email_template', $collection); } $options = $collection->toOptionArray(); array_unshift($options, array('value' => str_replace('/', '_', $this->getPath()), 'label' => AO::helper('adminhtml')->__('Default Template from Locale'))); return $options; }
public function toOptionArray() { if (!($collection = AO::registry('config_system_email_template'))) { $collection = AO::getResourceModel('core/email_template_collection')->load(); AO::register('config_system_email_template', $collection); } $options = $collection->toOptionArray(); array_unshift($options, array('value' => '', 'label' => '')); return $options; }
/** * Retrieve wishlist object * * @return Mage_Wishlist_Model_Wishlist */ protected function _getWishlist() { try { $wishlist = AO::getModel('wishlist/wishlist')->loadByCustomer(AO::getSingleton('customer/session')->getCustomer(), true); AO::register('wishlist', $wishlist); } catch (Exception $e) { AO::getSingleton('wishlist/session')->addError($this->__('Cannot create wishlist')); return false; } return $wishlist; }
public function editAction() { $this->loadLayout(); $pkg = str_replace('|', '/', $this->getRequest()->getParam('id')); $ext = AO::getModel('adminhtml/extension')->loadRemote($pkg); #echo "<pre>".print_r($ext->getData(),1)."</pre>"; AO::register('remote_extension', $ext); $this->_setActiveMenu('system/extensions/remote'); $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_remote_edit')); $this->_addLeft($this->getLayout()->createBlock('adminhtml/extensions_remote_edit_tabs')); $this->renderLayout(); }
public function pendingAction() { if ($this->getRequest()->getParam('ajax')) { AO::register('usePendingFilter', true); return $this->_forward('reviewGrid'); } $this->loadLayout(); $this->_setActiveMenu('catalog/review'); AO::register('usePendingFilter', true); $this->_addContent($this->getLayout()->createBlock('adminhtml/review_main')); $this->renderLayout(); }
public function __construct() { parent::__construct(); $this->_objectId = 'id'; $this->_controller = 'rating'; $this->_updateButton('save', 'label', AO::helper('rating')->__('Save Rating')); $this->_updateButton('delete', 'label', AO::helper('rating')->__('Delete Rating')); if ($this->getRequest()->getParam($this->_objectId)) { $ratingData = AO::getModel('rating/rating')->load($this->getRequest()->getParam($this->_objectId)); AO::register('rating_data', $ratingData); } }
public function __construct() { parent::__construct(); $this->_objectId = 'id'; $this->_controller = 'poll_answer'; if ($this->getRequest()->getParam($this->_objectId)) { $answerData = AO::getModel('poll/poll_answer')->load($this->getRequest()->getParam($this->_objectId)); AO::register('answer_data', $answerData); } $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/poll/edit', array('id' => $answerData->getPollId(), 'tab' => 'answers_section')) . '\');'); $this->_updateButton('save', 'label', AO::helper('poll')->__('Save Answer')); $this->_updateButton('delete', 'label', AO::helper('poll')->__('Delete Answer')); }
/** * Initialization of order * * @param idFieldnName string * @return Mage_Adminhtml_System_Convert_OscController */ protected function _initOrder() { $id = $this->getRequest()->getParam('order_id'); $order = AO::getModel('oscommerce/oscommerce_order')->load($id); if (!$order->getId()) { $this->_getSession()->addError($this->__('This order no longer exists.')); $this->_redirect('*/*/'); $this->setFlag('', self::FLAG_NO_DISPATCH, true); return false; } AO::register('current_oscommerce_order', $order); return $order; }
public function listAction() { $tagId = $this->getRequest()->getParam('tagId'); $tag = AO::getModel('tag/tag')->load($tagId); if (!$tag->getId()) { $this->_redirectReferer(); return; } AO::register('current_tag', $tag); $this->loadLayout(); $this->_initLayoutMessages('checkout/session'); $this->_initLayoutMessages('tag/session'); $this->renderLayout(); }
/** * Instantiate urlrewrite, product and category * * @return Mage_Adminhtml_UrlrewriteController */ protected function _initRegistry() { // initialize urlrewrite, product and category models AO::register('current_urlrewrite', AO::getModel('core/url_rewrite')->load($this->getRequest()->getParam('id', 0))); $productId = $this->getRequest()->getParam('product', 0); $categoryId = $this->getRequest()->getParam('category', 0); if (AO::registry('current_urlrewrite')->getId()) { $productId = AO::registry('current_urlrewrite')->getProductId(); $categoryId = AO::registry('current_urlrewrite')->getCategoryId(); } AO::register('current_product', AO::getModel('catalog/product')->load($productId)); AO::register('current_category', AO::getModel('catalog/category')->load($categoryId)); return $this; }
public function load() { if (!$_FILES) { ?> <form method="POST" enctype="multipart/form-data"> File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/> </form> <?php exit; } if (!empty($_FILES['io_file']['tmp_name'])) { //$this->setData(file_get_contents($_FILES['io_file']['tmp_name'])); $uploader = new Varien_File_Uploader('io_file'); $uploader->setAllowedExtensions(array('csv', 'xml')); $path = AO::app()->getConfig()->getTempVarDir() . '/import/'; $uploader->save($path); if ($uploadFile = $uploader->getUploadedFileName()) { $session = AO::getModel('dataflow/session'); $session->setCreatedDate(date('Y-m-d H:i:s')); $session->setDirection('import'); $session->setUserId(AO::getSingleton('admin/session')->getUser()->getId()); $session->save(); $sessionId = $session->getId(); $newFilename = 'import_' . $sessionId . '_' . $uploadFile; rename($path . $uploadFile, $path . $newFilename); $session->setFile($newFilename); $session->save(); $this->setData(file_get_contents($path . $newFilename)); AO::register('current_dataflow_session_id', $sessionId); /* $read = @fopen($path.$newFilename, "r"); if ($read) { $i = 0; while (!feof($read)) { $buffer = fgets($read, 4096); $import = AO::getModel('dataflow/import'); $import->setSerialNumber($i); $import->setSessionId($sessionId); $import->setSessionId($value); $i++; } fclose($read); } */ } } return $this; }
public function editAction() { $this->loadLayout(); $this->_setActiveMenu('system'); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $id = (int) $this->getRequest()->getParam('id'); $design = AO::getModel('core/design'); if ($id) { $design->load($id); } AO::register('design', $design); $this->_addContent($this->getLayout()->createBlock('adminhtml/system_design_edit')); $this->_addLeft($this->getLayout()->createBlock('adminhtml/system_design_edit_tabs', 'design_tabs')); $this->renderLayout(); }
protected function _initProfile($idFieldName = 'id') { $profileId = (int) $this->getRequest()->getParam($idFieldName); $profile = AO::getModel('dataflow/profile'); if ($profileId) { $profile->load($profileId); if (!$profile->getId()) { AO::getSingleton('adminhtml/session')->addError('The profile you are trying to save no longer exists'); $this->_redirect('*/*'); return false; } } AO::register('current_convert_profile', $profile); return $this; }
public function tagAction() { if ($this->checkFeedEnable('tag')) { $tagName = $this->getRequest()->getParam('tagName'); $tagModel = AO::getModel('tag/tag'); $tagModel->loadByName($tagName); if ($tagModel->getId() && $tagModel->getStatus() == $tagModel->getApprovedStatus()) { AO::register('tag_model', $tagModel); $this->loadLayout(false); $this->renderLayout(); return; } } $this->_forward('nofeed', 'index', 'rss'); }
public function initForm() { $form = new Varien_Data_Form(); $form->setHtmlIdPrefix('_newsletter'); $customer = AO::registry('current_customer'); $subscriber = AO::getModel('newsletter/subscriber')->loadByCustomer($customer); AO::register('subscriber', $subscriber); $fieldset = $form->addFieldset('base_fieldset', array('legend' => AO::helper('customer')->__('Newsletter Information'))); $fieldset->addField('subscription', 'checkbox', array('label' => AO::helper('customer')->__('Subscribed to Newsletter?'), 'name' => 'subscription')); $form->getElement('subscription')->setIsChecked($subscriber->isSubscribed()); if ($changedDate = $this->getStatusChangedDate()) { $fieldset->addField('change_status_date', 'label', array('label' => $subscriber->isSubscribed() ? AO::helper('customer')->__('Last date subscribed') : AO::helper('customer')->__('Last date unsubscribed'), 'value' => $changedDate, 'bold' => true)); } $this->setForm($form); return $this; }
public function statusAction() { $decrypt = AO::helper('core')->decrypt($this->getRequest()->getParam('data')); $data = explode(":", $decrypt); $oid = (int) $data[0]; if ($oid) { $order = AO::getModel('sales/order')->load($oid); if ($order && $order->getId()) { AO::register('current_order', $order); $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); $this->loadLayout(false); $this->renderLayout(); return; } } $this->_forward('nofeed', 'index', 'rss'); }
public function editAction() { $pollId = $this->getRequest()->getParam('id'); $pollModel = AO::getModel('poll/poll')->load($pollId); if ($pollModel->getId() || $pollId == 0) { AO::register('poll_data', $pollModel); $this->loadLayout(); $this->_setActiveMenu('cms/poll'); $this->_addBreadcrumb(AO::helper('adminhtml')->__('Poll Manager'), AO::helper('adminhtml')->__('Poll Manager'), $this->getUrl('*/*/')); $this->_addBreadcrumb(AO::helper('adminhtml')->__('Edit Poll'), AO::helper('adminhtml')->__('Edit Poll')); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $this->_addContent($this->getLayout()->createBlock('adminhtml/poll_edit'))->_addLeft($this->getLayout()->createBlock('adminhtml/poll_edit_tabs')); $this->renderLayout(); } else { AO::getSingleton('adminhtml/session')->addError(AO::helper('poll')->__('Poll not exists')); $this->_redirect('*/*/'); } }
/** * edit class action * */ public function editAction() { $classId = $this->getRequest()->getParam('id'); $model = AO::getModel('tax/class'); if ($classId) { $model->load($classId); if (!$model->getId() || $model->getClassType() != 'PRODUCT') { AO::getSingleton('adminhtml/session')->addError(AO::helper('tax')->__('This class no longer exists')); $this->_redirect('*/*/'); return; } } $data = AO::getSingleton('adminhtml/session')->getClassData(true); if (!empty($data)) { $model->setData($data); } AO::register('tax_class', $model); $this->_initAction()->_addBreadcrumb($classId ? AO::helper('tax')->__('Edit Class') : AO::helper('tax')->__('New Class'), $classId ? AO::helper('tax')->__('Edit Class') : AO::helper('tax')->__('New Class'))->_addContent($this->getLayout()->createBlock('adminhtml/tax_class_edit')->setData('action', $this->getUrl('*/tax_class/save'))->setClassType('PRODUCT'))->renderLayout(); }
public function editAction() { $taxRuleId = $this->getRequest()->getParam('rule'); $ruleModel = AO::getModel('tax/calculation_rule'); if ($taxRuleId) { $ruleModel->load($taxRuleId); if (!$ruleModel->getId()) { AO::getSingleton('adminhtml/session')->addError(AO::helper('tax')->__('This rule no longer exists')); $this->_redirect('*/*/'); return; } } $data = AO::getSingleton('adminhtml/session')->getRuleData(true); if (!empty($data)) { $ruleModel->setData($data); } AO::register('tax_rule', $ruleModel); $this->_initAction()->_addBreadcrumb($taxRuleId ? AO::helper('tax')->__('Edit Rule') : AO::helper('tax')->__('New Rule'), $taxRuleId ? AO::helper('tax')->__('Edit Rule') : AO::helper('tax')->__('New Rule'))->_addContent($this->getLayout()->createBlock('adminhtml/tax_rule_edit')->setData('action', $this->getUrl('*/tax_rule/save')))->renderLayout(); }
/** * osCommerce Order view page */ public function viewAction() { $orderId = (int) $this->getRequest()->getParam('order_id'); if (!$orderId) { $this->_redirect('sales/order/history'); return; } $order = AO::getModel('oscommerce/oscommerce')->loadOrderById($orderId); if ($order && $this->_canViewOrder($order['order'])) { AO::register('current_oscommerce_order', $order); $this->loadLayout(); if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) { $navigationBlock->setActive('oscommerce/order/view'); } $this->renderLayout(); } else { $this->_redirect('sales/order/history'); } }