Example #1
1
 /**
  *
  */
 public function initControllerRouters($observer)
 {
     $request = $observer->getEvent()->getFront()->getRequest();
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('brand_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $route = trim(Mage::getStoreConfig('ves_brand/general_setting/route'));
     if ($identifier) {
         if (preg_match("#^" . $route . "(\\.html)?\$#", $identifier, $match)) {
             $request->setModuleName('venusbrand')->setControllerName('brand')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         }
         return true;
     }
     return false;
 }
Example #2
0
 /**
  * Save config section
  * Require set: section, website, store and groups
  *
  * @return Mage_Adminhtml_Model_Config_Data
  */
 public function save()
 {
     Mage::dispatchEvent('searchanise_adminhtml_config_data_save_before', array('object' => $this));
     $ret = parent::save();
     Mage::dispatchEvent('searchanise_adminhtml_config_data_save_after', array('object' => $ret));
     return $ret;
 }
Example #3
0
 protected function _prepareForm()
 {
     /*
      * Checking if user have permissions to save information
      */
     if ($this->_isAllowedAction('save')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     $form = new Varien_Data_Form();
     $form->setHtmlIdPrefix('page_');
     $model = Mage::registry('cms_page');
     $layoutFieldset = $form->addFieldset('layout_fieldset', array('legend' => Mage::helper('cms')->__('Page Layout'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled));
     $layoutFieldset->addField('root_template', 'select', array('name' => 'root_template', 'label' => Mage::helper('cms')->__('Layout'), 'required' => true, 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(), 'disabled' => $isElementDisabled));
     if (!$model->getId()) {
         $model->setRootTemplate(Mage::getSingleton('page/source_layout')->getDefaultValue());
     }
     $layoutFieldset->addField('layout_update_xml', 'textarea', array('name' => 'layout_update_xml', 'label' => Mage::helper('cms')->__('Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled));
     $designFieldset = $form->addFieldset('design_fieldset', array('legend' => Mage::helper('cms')->__('Custom Design'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled));
     $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
     $designFieldset->addField('custom_theme_from', 'date', array('name' => 'custom_theme_from', 'label' => Mage::helper('cms')->__('Custom Design From'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso, 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_theme_to', 'date', array('name' => 'custom_theme_to', 'label' => Mage::helper('cms')->__('Custom Design To'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso, 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_theme', 'select', array('name' => 'custom_theme', 'label' => Mage::helper('cms')->__('Custom Theme'), 'values' => Mage::getModel('core/design_source_design')->getAllOptions(), 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_root_template', 'select', array('name' => 'custom_root_template', 'label' => Mage::helper('cms')->__('Custom Layout'), 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(true), 'disabled' => $isElementDisabled));
     $designFieldset->addField('custom_layout_update_xml', 'textarea', array('name' => 'custom_layout_update_xml', 'label' => Mage::helper('cms')->__('Custom Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled));
     Mage::dispatchEvent('adminhtml_cms_page_edit_tab_design_prepare_form', array('form' => $form));
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
 /**
  * Controller pre-dispatch method
  *
  * @return Mage_XmlConnect_Controller_AdminAction
  */
 public function preDispatch()
 {
     Mage::getSingleton('adminhtml/url')->turnOffSecretKey();
     // override admin store design settings via stores section
     Mage::getDesign()->setArea($this->_currentArea)->setPackageName((string) Mage::getConfig()->getNode('stores/admin/design/package/name'))->setTheme((string) Mage::getConfig()->getNode('stores/admin/design/theme/default'));
     foreach (array('layout', 'template', 'skin', 'locale') as $type) {
         $value = (string) Mage::getConfig()->getNode("stores/admin/design/theme/{$type}");
         if ($value) {
             Mage::getDesign()->setTheme($type, $value);
         }
     }
     $this->getLayout()->setArea($this->_currentArea);
     Mage::dispatchEvent('adminhtml_controller_action_predispatch_start', array());
     Mage_Core_Controller_Varien_Action::preDispatch();
     if ($this->getRequest()->isDispatched() && $this->getRequest()->getActionName() !== 'denied' && !$this->_isAllowed()) {
         $this->_forward('denied');
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
         return $this;
     }
     if (is_null(Mage::getSingleton('adminhtml/session')->getLocale())) {
         Mage::getSingleton('adminhtml/session')->setLocale(Mage::app()->getLocale()->getLocaleCode());
     }
     $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
     if ($this->_isCheckCookieRequired()) {
         $this->_checkCookie();
     }
     return $this;
 }
Example #5
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectMagento($output, true);
     $noReinitOption = $input->getOption('no-reinit');
     if (!$noReinitOption) {
         $this->banUseCache();
     }
     if (!$this->initMagento()) {
         return;
     }
     \Mage::app()->loadAreaPart('adminhtml', 'events');
     \Mage::dispatchEvent('adminhtml_cache_flush_all', array('output' => $output));
     $result = \Mage::app()->getCacheInstance()->flush();
     if ($result) {
         $output->writeln('<info>Cache cleared</info>');
     } else {
         $output->writeln('<error>Failed to clear Cache</error>');
     }
     if (!$noReinitOption) {
         $this->reinitCache();
     }
     /* Since Magento 1.10 we have an own cache handler for FPC */
     if ($this->isEnterpriseFullPageCachePresent()) {
         $result = \Enterprise_PageCache_Model_Cache::getCacheInstance()->flush();
         if ($result) {
             $output->writeln('<info>FPC cleared</info>');
         } else {
             $output->writeln('<error>Failed to clear FPC</error>');
         }
     }
 }
Example #6
0
 public function getStoreAttributes()
 {
     $storeAttribute = new Varien_Object(array('store_attribute' => array('name', 'affiliate_type', 'status', 'description', 'commission_type', 'commission', 'sec_commission', 'sec_commission_type', 'secondary_commission', 'discount_type', 'discount', 'sec_discount', 'sec_discount_type', 'secondary_discount', 'customer_group_ids', 'show_in_welcome', 'use_tier_config', 'max_level', 'tier_commission', 'use_sec_tier', 'sec_tier_commission')));
     /** Thanhpv - add even $this->_eventPrefix . '_get_store_attributes' (2012-10-11) */
     Mage::dispatchEvent($this->_eventPrefix . '_get_store_attributes', array($this->_eventObject => $this, 'attributes' => $storeAttribute));
     return $storeAttribute->getStoreAttribute();
 }
Example #7
0
 /**
  * Element output getter
  *
  * @return string
  */
 public function getElementHtml()
 {
     $result = new StdClass();
     $result->output = '';
     Mage::dispatchEvent('catalog_product_edit_form_render_recurring', array('result' => $result, 'product_element' => $this->_element, 'product' => Mage::registry('current_product')));
     return $result->output;
 }
Example #8
0
 /**
  * Setup GermanSetup as if a user sends the adminhtml form
  * See method _getDefaultParams for possible params
  *
  * @param array $params
  * @return FireGento_GermanSetup_Model_Setup
  */
 public function setup($params = array())
 {
     $defaultParams = $this->_getDefaultParams();
     $params = array_merge($defaultParams, $params);
     Mage::register('setup_country', $params['country']);
     if ($params['systemconfig']) {
         Mage::getSingleton('germansetup/setup_systemconfig')->setup();
     }
     if ($params['cms']) {
         Mage::getSingleton('germansetup/setup_cms')->setup();
     }
     if ($params['agreements']) {
         Mage::getSingleton('germansetup/setup_agreements')->setup();
     }
     if ($params['email']) {
         Mage::getSingleton('germansetup/setup_email')->setup($params['email_locale'], $params['overwrite_emails']);
     }
     if ($params['tax']) {
         Mage::getSingleton('germansetup/setup_tax')->setup();
         $this->_updateProductTaxClasses($params);
     }
     // Set a config flag to indicate that the setup has been initialized and refresh config cache.
     Mage::getModel('eav/entity_setup', 'core_setup')->setConfigData('germansetup/is_initialized', '1');
     Mage::app()->getCacheInstance()->cleanType('config');
     Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
     return $this;
 }
Example #9
0
 /**
  * Validate and Match Manufacturer Page and modify request
  *
  * @param Zend_Controller_Request_Http $request
  * @return bool
  */
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $router = 'manufacturers';
     $identifier = trim(str_replace('/manufacturers/', '', $request->getPathInfo()), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('manufacturer_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $manufacturer = Mage::getModel('zeon_manufacturer/manufacturer');
     $manufacturerId = $manufacturer->checkIdentifier($identifier, Mage::app()->getStore()->getId());
     if (trim($identifier) && $manufacturerId) {
         $request->setModuleName('manufacturers')->setControllerName('index')->setActionName('view')->setParam('manufacturer_id', $manufacturerId);
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $router . '/' . $identifier);
         return true;
     }
     return false;
 }
 protected function _prepareForm()
 {
     /** @var $model Mage_Cms_Model_Page */
     $model = Mage::registry('cms_page');
     /*
      * Checking if user have permissions to save information
      */
     if ($this->_isAllowedAction('save')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     $form = new Varien_Data_Form();
     $form->setHtmlIdPrefix('page_');
     $fieldset = $form->addFieldset('content_fieldset', array('legend' => Mage::helper('cms')->__('Content'), 'class' => 'fieldset-wide'));
     $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('tab_id' => $this->getTabId()));
     $fieldset->addField('content_heading', 'text', array('name' => 'content_heading', 'label' => Mage::helper('cms')->__('Content Heading'), 'title' => Mage::helper('cms')->__('Content Heading'), 'disabled' => $isElementDisabled));
     $contentField = $fieldset->addField('content', 'editor', array('name' => 'content', 'style' => 'height:36em;', 'required' => true, 'disabled' => $isElementDisabled, 'config' => $wysiwygConfig));
     // Setting custom renderer for content field to remove label column
     $renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element')->setTemplate('cms/page/edit/form/renderer/content.phtml');
     $contentField->setRenderer($renderer);
     $form->setValues($model->getData());
     $this->setForm($form);
     Mage::dispatchEvent('adminhtml_cms_page_edit_tab_content_prepare_form', array('form' => $form));
     return parent::_prepareForm();
 }
 public function saveAction()
 {
     $data = $this->getRequest()->getParams();
     $data['api_key'] = trim($data['api_key']);
     $model = Mage::getModel('pdfpro/key');
     $data['store_ids'] = implode(',', $data['store_ids']);
     $data['customer_group_ids'] = implode(',', $data['customer_group_ids']);
     $model->setData($data)->setId($this->getRequest()->getParam('id'));
     Mage::dispatchEvent('ves_pdfpro_apikey_form_save_before', array('model' => $model));
     try {
         $model->save();
         Mage::dispatchEvent('ves_pdfpro_apikey_form_save_after', array('model' => $model));
         Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('pdfpro')->__('The API Key has been saved.'));
         Mage::getSingleton('adminhtml/session')->setGroupData(false);
         if ($this->getRequest()->getParam('back')) {
             $this->_redirect('*/*/edit', array('id' => $model->getId()));
             return;
         }
         $this->_redirect('*/*/');
         return;
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
         Mage::getSingleton('adminhtml/session')->setGroupData($data);
         $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
         return;
     }
 }
Example #12
0
 /**
  * Prepare Mail Target Rule Edit form
  *
  * @return Enterprise_TargetRule_Block_Adminhtml_Targetrule_Edit_Tab_Main
  */
 protected function _prepareForm()
 {
     /* @var $model Enterprise_TargetRule_Model_Rule */
     $model = Mage::registry('current_target_rule');
     $form = new Varien_Data_Form();
     $form->setHtmlIdPrefix('rule_');
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('enterprise_targetrule')->__('General Rule Information')));
     if ($model->getId()) {
         $fieldset->addField('rule_id', 'hidden', array('name' => 'rule_id'));
     }
     $fieldset->addField('name', 'text', array('name' => 'name', 'label' => Mage::helper('enterprise_targetrule')->__('Rule Name'), 'required' => true));
     $fieldset->addField('sort_order', 'text', array('name' => 'sort_order', 'label' => Mage::helper('enterprise_targetrule')->__('Priority')));
     $fieldset->addField('is_active', 'select', array('label' => Mage::helper('enterprise_targetrule')->__('Status'), 'name' => 'is_active', 'required' => true, 'options' => array('1' => Mage::helper('enterprise_targetrule')->__('Active'), '0' => Mage::helper('enterprise_targetrule')->__('Inactive'))));
     if (!$model->getId()) {
         $model->setData('is_active', '1');
     }
     $fieldset->addField('apply_to', 'select', array('label' => Mage::helper('enterprise_targetrule')->__('Apply To'), 'name' => 'apply_to', 'required' => true, 'options' => Mage::getSingleton('enterprise_targetrule/rule')->getAppliesToOptions(true)));
     // TODO: fix possible issues with date format
     $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
     $fieldset->addField('from_date', 'date', array('name' => 'from_date', 'label' => Mage::helper('enterprise_targetrule')->__('From Date'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
     $fieldset->addField('to_date', 'date', array('name' => 'to_date', 'label' => Mage::helper('enterprise_targetrule')->__('To Date'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
     $fieldset->addField('positions_limit', 'text', array('name' => 'positions_limit', 'label' => Mage::helper('enterprise_targetrule')->__('Result Limit'), 'note' => Mage::helper('enterprise_targetrule')->__('Maximum number of products that can be matched by this Rule. Capped to 20.')));
     Mage::dispatchEvent('targetrule_edit_tab_main_after_prepare_form', array('model' => $model, 'form' => $form, 'block' => $this));
     $form->setValues($model->getData());
     if ($model->isReadonly()) {
         foreach ($fieldset->getElements() as $element) {
             $element->setReadonly(true, true);
         }
     }
     $this->setForm($form);
     return parent::_prepareForm();
 }
Example #13
0
 /**
  * Cleanup blocks HTML cache if value has been changed
  *
  * @return Enterprise_WebsiteRestriction_Model_System_Config_Backend_Active
  */
 protected function _afterSave()
 {
     if ($this->isValueChanged()) {
         Mage::dispatchEvent('clean_cache_by_tags', array('tags' => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)));
     }
     return parent::_afterSave();
 }
Example #14
0
 /**
  * @param bool $deleteSource
  *
  * @return bool
  */
 public function mergeCategories($deleteSource = false)
 {
     $this->_deleteSource = $deleteSource;
     try {
         // Check if both categories exist
         if (!$this->_source->getId() || !$this->_target->getId()) {
             return false;
         }
         $this->_moveProducts();
         $this->_moveChildrenCategories();
         // Just delete a category which is not parent of the target
         if ($this->_deleteSource && !in_array($this->_source->getId(), $this->_target->getParentIds())) {
             $this->_source->delete();
         }
         /** @var $index Mage_Index_Model_Process */
         $index = Mage::getModel('index/process')->load('catalog_category_product', 'indexer_code');
         if ($index->getId() && $index->getMode() == Mage_Index_Model_Process::MODE_REAL_TIME) {
             $index->reindexEverything();
         }
         Mage::dispatchEvent('mkleine_category_merge_finished', array('source_category' => $this->_source, 'target_category' => $this->_target));
         return true;
     } catch (Exception $e) {
         Mage::logException($e);
         return false;
     }
 }
Example #15
0
 /**
  *
  */
 public function initControllerRouters($observer)
 {
     Mage::getSingleton('core/session', array('name' => 'adminhtml'));
     if (!is_null(Mage::registry("_singleton/admin/session"))) {
         if (Mage::getSingleton('admin/session')->isLoggedIn()) {
             /*Is admin*/
             //do stuff
             return;
         }
     }
     $request = $observer->getEvent()->getFront()->getRequest();
     if (!Mage::app()->isInstalled()) {
         /*
         Mage::app()->getFrontController()->getResponse()
             ->setRedirect(Mage::getUrl('install'))
             ->sendResponse();
         */
         return;
     }
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('blog_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     $identifier = trim($identifier, "/");
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     $route = trim(Mage::getStoreConfig('ves_blog/general_setting/route'));
     if ($identifier) {
         if (preg_match("#^" . $route . "(\\.html)?\$#", $identifier, $match)) {
             $request->setModuleName('venusblog')->setControllerName('index')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (str_replace('/rss', '', str_replace($route, '', $identifier)) == '') {
             $request->setModuleName('venusblog')->setControllerName('rss')->setActionName('index');
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (preg_match("#" . $route . "/tag/(\\w+)\\.?#", $identifier, $match)) {
             if (count($match) <= 1) {
                 return false;
             }
             $request->setModuleName('venusblog')->setControllerName('list')->setActionName('show')->setParam("tag", $match[1]);
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         } elseif (preg_match("#" . $route . "/archive/(\\w+)\\.?#", $identifier, $match)) {
             if (count($match) <= 1) {
                 return false;
             }
             $request->setModuleName('venusblog')->setControllerName('list')->setActionName('show')->setParam("archive", $match[1]);
             $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
             return true;
         }
     }
     return false;
 }
Example #16
0
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
     Mage::dispatchEvent('magicproduct_controller_router_match_before', array('router' => $this, 'condition' => $condition));
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
         $request->setDispatched(true);
         return true;
     }
     if (!$condition->getContinue()) {
         return false;
     }
     if (!in_array($identifier, $this->router)) {
         return false;
     }
     $request->setModuleName('magicproduct')->setControllerName('index')->setActionName('product')->setParam('type', $identifier);
     $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return true;
 }
Example #17
0
 /**
  * Initialize requested vendor object
  *
  * @return Ced_CsMarketplace_Model_Vendor
  */
 protected function _initVendor()
 {
     Mage::dispatchEvent('csmarketplace_controller_vshops_init_before', array('controller_action' => $this));
     if (!Mage::helper('csmarketplace/acl')->isEnabled()) {
         return false;
     }
     $shopUrl = Mage::getModel('csmarketplace/vendor')->getShopUrlKey($this->getRequest()->getParam('shop_url', ''));
     if (!strlen($shopUrl)) {
         return false;
     }
     $vendor = Mage::getModel('csmarketplace/vendor')->setStoreId(Mage::app()->getStore()->getId())->loadByAttribute('shop_url', $shopUrl);
     if (!Mage::helper('csmarketplace')->canShow($vendor)) {
         return false;
     } else {
         if (!Mage::helper('csmarketplace')->isShopEnabled($vendor)) {
             return false;
         }
     }
     //Mage::getSingleton('catalog/session')->setLastVisitedCategoryId($category->getId());
     Mage::register('current_vendor', $vendor);
     //Mage::register('current_entity_key', $category->getPath());
     try {
         Mage::dispatchEvent('csmarketplace_controller_vshops_init_after', array('vendor' => $vendor, 'controller_action' => $this));
     } catch (Mage_Core_Exception $e) {
         Mage::logException($e);
         return false;
     }
     return $vendor;
 }
Example #18
0
 /**
  * Modifies filter items and filter model itself as specified by extensions subscribed to 
  * morphes_filters_process_items event.
  * @param Mage_Catalog_Model_Layer_Filter_Abstract $filter
  * @param array $items
  */
 public function processFilterItems($filter, $items)
 {
     $wrappedItems = new Varien_Object();
     $wrappedItems->setItems($items);
     Mage::dispatchEvent('morphes_filters_process_items', array('filter' => $filter, 'items' => $wrappedItems));
     return $wrappedItems->getItems();
 }
 public function indexAction()
 {
     // init category
     $categoryId = (int) Mage::app()->getStore()->getRootCategoryId();
     if (!$categoryId) {
         $this->_forward('noRoute');
         return;
     }
     $category = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($categoryId);
     Mage::register('current_category', $category);
     Mage::getSingleton('catalog/session')->setLastVisitedCategoryId($category->getId());
     // need to prepare layer params
     try {
         Mage::dispatchEvent('catalog_controller_category_init_after', array('category' => $category, 'controller_action' => $this));
     } catch (Mage_Core_Exception $e) {
         Mage::logException($e);
         return;
     }
     // observer can change value
     if (!$category->getId()) {
         $this->_forward('noRoute');
         return;
     }
     $this->loadLayout();
     $this->checkAddRwdBlocks();
     $this->renderLayout();
 }
Example #20
0
 /**
  * prepare tab form's information
  *
  * @return Magestore_RewardPoints_Block_Adminhtml_Spending_Edit_Tab_Form
  */
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     if (Mage::getSingleton('adminhtml/session')->getFormData()) {
         $data = Mage::getSingleton('adminhtml/session')->getFormData();
         Mage::getSingleton('adminhtml/session')->setFormData(null);
     } elseif (Mage::registry('rate_data')) {
         $data = Mage::registry('rate_data')->getData();
     }
     $fieldset = $form->addFieldset('rewardpoints_form', array('legend' => Mage::helper('rewardpoints')->__('Rate information')));
     $dataObj = new Varien_Object($data);
     $data = $dataObj->getData();
     $fieldset->addField('points', 'text', array('label' => Mage::helper('rewardpoints')->__('Spending Point(s)'), 'title' => Mage::helper('rewardpoints')->__('Spending Point(s)'), 'required' => true, 'name' => 'points'));
     $fieldset->addField('money', 'text', array('name' => 'money', 'label' => Mage::helper('rewardpoints')->__('Discount received'), 'title' => Mage::helper('rewardpoints')->__('Discount received'), 'required' => true, 'after_element_html' => '<strong>[' . Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE) . ']</strong>', 'note' => Mage::helper('rewardpoints')->__('the equivalent value of points')));
     //Hai.Tran 12/11/2013 fix gioi han spend points
     $fieldset->addField('max_price_spended_type', 'select', array('label' => Mage::helper('rewardpoints')->__('Limit spending points based on'), 'title' => Mage::helper('rewardpoints')->__('Limit spending points based on'), 'name' => 'max_price_spended_type', 'options' => array('none' => Mage::helper('rewardpoints')->__('None'), 'by_price' => Mage::helper('rewardpoints')->__('A fixed amount of Total Order Value'), 'by_percent' => Mage::helper('rewardpoints')->__('A percentage of Total Order Value')), 'onchange' => 'toggleMaxPriceSpend()', 'note' => Mage::helper('rewardpoints')->__('Select the type to limit spending points')));
     $fieldset->addField('max_price_spended_value', 'text', array('label' => Mage::helper('rewardpoints')->__('Limit value allowed to spend points at'), 'title' => Mage::helper('rewardpoints')->__('Limit value allowed to spend points at'), 'name' => 'max_price_spended_value', 'note' => Mage::helper('rewardpoints')->__('If empty or zero, there is no limitation.')));
     //End Hai.Tran 12/11/2013
     if (!Mage::app()->isSingleStoreMode()) {
         $fieldset->addField('website_ids', 'multiselect', array('name' => 'website_ids[]', 'label' => Mage::helper('rewardpoints')->__('Websites'), 'title' => Mage::helper('rewardpoints')->__('Websites'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_config_source_website')->toOptionArray()));
     } else {
         $fieldset->addField('website_ids', 'hidden', array('name' => 'website_ids[]', 'value' => Mage::app()->getStore(true)->getWebsiteId()));
         $data['website_ids'] = Mage::app()->getStore(true)->getWebsiteId();
     }
     $fieldset->addField('customer_group_ids', 'multiselect', array('label' => Mage::helper('rewardpoints')->__('Customer groups'), 'title' => Mage::helper('rewardpoints')->__('Customer groups'), 'name' => 'customer_group_ids', 'required' => true, 'values' => Mage::getResourceModel('customer/group_collection')->addFieldToFilter('customer_group_id', array('gt' => 0))->load()->toOptionArray()));
     $fieldset->addField('sort_order', 'text', array('label' => Mage::helper('rewardpoints')->__('Priority'), 'label' => Mage::helper('rewardpoints')->__('Priority'), 'required' => false, 'name' => 'sort_order', 'note' => Mage::helper('rewardpoints')->__('Higher priority Rate will be applied first')));
     $form->setValues($data);
     $this->setForm($form);
     Mage::dispatchEvent('rewardpoints_adminhtml_spending_rate_form', array('tab_form' => $this, 'form' => $form, 'data' => $dataObj));
     return parent::_prepareForm();
 }
Example #21
0
 protected function _prepareForm()
 {
     $model = Mage::getModel('webforms/webforms');
     $form = new Varien_Data_Form();
     $renderer = $this->getLayout()->createBlock('webforms/adminhtml_element_field');
     $form->setFieldsetElementRenderer($renderer);
     $form->setFieldNameSuffix('field');
     $form->setDataObject(Mage::registry('field'));
     $this->setForm($form);
     $fieldset = $form->addFieldset('webforms_form', array('legend' => Mage::helper('webforms')->__('Validation')));
     $fieldset->addField('validate_length_min', 'text', array('label' => Mage::helper('webforms')->__('Minimum length'), 'class' => 'validate-number', 'name' => 'validate_length_min'));
     $fieldset->addField('validate_length_max', 'text', array('label' => Mage::helper('webforms')->__('Maximum length'), 'class' => 'validate-number', 'name' => 'validate_length_max'));
     $fieldset->addField('validate_regex', 'text', array('label' => Mage::helper('webforms')->__('Validation RegEx'), 'name' => 'validate_regex', 'note' => Mage::helper('webforms')->__('Validate with custom regular expression')));
     $fieldset->addField('validate_message', 'textarea', array('label' => Mage::helper('webforms')->__('Validation error message'), 'name' => 'validate_message', 'note' => Mage::helper('webforms')->__('Displayed error message text if regex validation fails')));
     Mage::dispatchEvent('webforms_adminhtml_fields_edit_tab_design_prepare_form', array('form' => $form, 'fieldset' => $fieldset));
     if (Mage::registry('field')->getData('validate_length_min') == 0) {
         Mage::registry('field')->setData('validate_length_min', '');
     }
     if (Mage::registry('field')->getData('validate_length_max') == 0) {
         Mage::registry('field')->setData('validate_length_max', '');
     }
     if (Mage::getSingleton('adminhtml/session')->getWebFormsData()) {
         $form->setValues(Mage::getSingleton('adminhtml/session')->getWebFormsData());
         Mage::getSingleton('adminhtml/session')->setWebFormsData(null);
     } elseif (Mage::registry('field')) {
         $form->setValues(Mage::registry('field')->getData());
     }
     return parent::_prepareForm();
 }
Example #22
0
 public function actionAfter(Varien_Event_Observer $o)
 {
     if ($o->getEvent()->getControllerAction()->getFullActionName() == 'review_product_post') {
         Mage::dispatchEvent("review_product_post_after", array('request' => $o->getControllerAction()->getRequest()));
     }
     return $o;
 }
Example #23
0
 public function _getJsonConfig()
 {
     $config = array();
     if (!$this->hasOptions()) {
         return Mage::helper('core')->jsonEncode($config);
     }
     $_request = Mage::getSingleton('tax/calculation')->getRateRequest(false, false, false);
     /* @var $product Mage_Catalog_Model_Product */
     $product = $this->getProduct();
     $_request->setProductClassId($product->getTaxClassId());
     $defaultTax = Mage::getSingleton('tax/calculation')->getRate($_request);
     $_request = Mage::getSingleton('tax/calculation')->getRateRequest();
     $_request->setProductClassId($product->getTaxClassId());
     $currentTax = Mage::getSingleton('tax/calculation')->getRate($_request);
     $_regularPrice = $product->getPrice();
     $_finalPrice = $product->getFinalPrice();
     $_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true);
     $_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice);
     $_tierPrices = array();
     $_tierPricesInclTax = array();
     foreach ($product->getTierPrice() as $tierPrice) {
         $_tierPrices[] = Mage::helper('core')->currency($tierPrice['website_price'], false, false);
         $_tierPricesInclTax[] = Mage::helper('core')->currency(Mage::helper('tax')->getPrice($product, (int) $tierPrice['website_price'], true), false, false);
     }
     $config = array('productId' => $product->getId(), 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false', 'showIncludeTax' => Mage::helper('tax')->displayPriceIncludingTax(), 'showBothPrices' => Mage::helper('tax')->displayBothPrices(), 'productPrice' => Mage::helper('core')->currency($_finalPrice, false, false), 'productOldPrice' => Mage::helper('core')->currency($_regularPrice, false, false), 'priceInclTax' => Mage::helper('core')->currency($_priceInclTax, false, false), 'priceExclTax' => Mage::helper('core')->currency($_priceExclTax, false, false), 'skipCalculate' => $_priceExclTax != $_priceInclTax ? 0 : 1, 'defaultTax' => $defaultTax, 'currentTax' => $currentTax, 'idSuffix' => '_cloneover', 'oldPlusDisposition' => 0, 'plusDisposition' => 0, 'plusDispositionTax' => 0, 'oldMinusDisposition' => 0, 'minusDisposition' => 0, 'tierPrices' => $_tierPrices, 'tierPricesInclTax' => $_tierPricesInclTax);
     $responseObject = new Varien_Object();
     Mage::dispatchEvent('catalog_product_view_config', array('response_object' => $responseObject));
     if (is_array($responseObject->getAdditionalOptions())) {
         foreach ($responseObject->getAdditionalOptions() as $option => $value) {
             $config[$option] = $value;
         }
     }
     return Mage::helper('core')->jsonEncode($config);
 }
Example #24
0
 /**
  * Render RSS
  *
  * @return string
  */
 protected function _toHtml()
 {
     $newUrl = Mage::getUrl('rss/catalog/notifystock');
     /* @var $helper Mage_Rss_Helper_Data */
     $helper = Mage::helper('Mage_Rss_Helper_Data');
     $title = $helper->__('Low Stock Products');
     $rssObj = Mage::getModel('Mage_Rss_Model_Rss');
     $data = array('title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8');
     $rssObj->_addHeader($data);
     $configManageStock = (int) Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
     $globalNotifyStockQty = (double) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY);
     $helper->disableFlat();
     /* @var $product Mage_Catalog_Model_Product */
     $product = Mage::getModel('Mage_Catalog_Model_Product');
     /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
     $collection = $product->getCollection();
     $stockItemTable = $collection->getTable('cataloginventory_stock_item');
     $stockItemWhere = '({{table}}.low_stock_date is not null) ' . " AND ( ({{table}}.use_config_manage_stock=1 AND {$configManageStock}=1)" . " AND {{table}}.qty < " . "IF({$stockItemTable}.`use_config_notify_stock_qty`, {$globalNotifyStockQty}, {{table}}.notify_stock_qty)" . ' OR ({{table}}.use_config_manage_stock=0 AND {{table}}.manage_stock=1) )';
     $collection->addAttributeToSelect('name', true)->joinTable('cataloginventory_stock_item', 'product_id=entity_id', array('qty' => 'qty', 'notify_stock_qty' => 'notify_stock_qty', 'use_config' => 'use_config_notify_stock_qty', 'low_stock_date' => 'low_stock_date'), $stockItemWhere, 'inner')->setOrder('low_stock_date');
     $collection->addAttributeToFilter('status', array('in' => Mage::getSingleton('Mage_Catalog_Model_Product_Status')->getVisibleStatusIds()));
     Mage::dispatchEvent('rss_catalog_notify_stock_collection_select', array('collection' => $collection));
     /*
     using resource iterator to load the data one by one
     instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
     */
     Mage::getSingleton('Mage_Core_Model_Resource_Iterator')->walk($collection->getSelect(), array(array($this, 'addNotifyItemXmlCallback')), array('rssObj' => $rssObj, 'product' => $product, 'globalQty' => $globalNotifyStockQty));
     return $rssObj->createRssXml();
 }
Example #25
0
 protected function _beforeToHtml()
 {
     $this->addTab('form_information', array('label' => Mage::helper('webforms')->__('Information'), 'title' => Mage::helper('webforms')->__('Information'), 'content' => $this->getLayout()->createBlock('webforms/adminhtml_fields_edit_tab_information')->toHtml()));
     $this->addTab('form_design', array('label' => Mage::helper('webforms')->__('Design'), 'title' => Mage::helper('webforms')->__('Design'), 'content' => $this->getLayout()->createBlock('webforms/adminhtml_fields_edit_tab_design')->toHtml()));
     Mage::dispatchEvent('webforms_adminhtml_fields_edit_tabs_before_to_html', array('tabs' => $this));
     return parent::_beforeToHtml();
 }
 /**
  * Regenerate all Stores index
  *
  * Examples:
  * (null, null) => Regenerate index for all stores
  * (1, null)    => Regenerate index for store Id=1
  * (1, 2)       => Regenerate index for product Id=2 and its store view Id=1
  * (null, 2)    => Regenerate index for all store views of product Id=2
  *
  * @param int|null $storeId Store View Id
  * @param int|array|null $productIds Product Entity Id
  *
  * @return Mage_CatalogSearch_Model_Fulltext
  */
 public function rebuildIndex($storeId = null, $productIds = null)
 {
     Mage::dispatchEvent('catalogsearch_index_process_start', array('store_id' => $storeId, 'product_ids' => $productIds));
     $this->getResource()->rebuildIndex($storeId, $productIds);
     Mage::dispatchEvent('catalogsearch_index_process_complete', array());
     return $this;
 }
Example #27
0
 /**
  * Prepare data index for indexable attributes
  *
  * @param array $entityIds      the entity ids limitation
  * @param int $attributeId      the attribute id limitation
  * @return Mage_Catalog_Model_Resource_Product_Indexer_Eav_Decimal
  */
 protected function _prepareIndex($entityIds = null, $attributeId = null)
 {
     $write = $this->_getWriteAdapter();
     $idxTable = $this->getIdxTable();
     // prepare select attributes
     if (is_null($attributeId)) {
         $attrIds = $this->_getIndexableAttributes();
     } else {
         $attrIds = array($attributeId);
     }
     if (!$attrIds) {
         return $this;
     }
     $productValueExpression = $write->getCheckSql('pds.value_id > 0', 'pds.value', 'pdd.value');
     $select = $write->select()->from(array('pdd' => $this->getValueTable('catalog/product', 'decimal')), array('entity_id', 'attribute_id'))->join(array('cs' => $this->getTable('core/store')), '', array('store_id'))->joinLeft(array('pds' => $this->getValueTable('catalog/product', 'decimal')), 'pds.entity_id = pdd.entity_id AND pds.attribute_id = pdd.attribute_id' . ' AND pds.store_id=cs.store_id', array('value' => $productValueExpression))->where('pdd.store_id=?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)->where('cs.store_id!=?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)->where('pdd.attribute_id IN(?)', $attrIds)->where("{$productValueExpression} IS NOT NULL");
     $statusCond = $write->quoteInto('=?', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
     $this->_addAttributeToSelect($select, 'status', 'pdd.entity_id', 'cs.store_id', $statusCond);
     if (!is_null($entityIds)) {
         $select->where('pdd.entity_id IN(?)', $entityIds);
     }
     /**
      * Add additional external limitation
      */
     Mage::dispatchEvent('prepare_catalog_product_index_select', array('select' => $select, 'entity_field' => new Zend_Db_Expr('pdd.entity_id'), 'website_field' => new Zend_Db_Expr('cs.website_id'), 'store_field' => new Zend_Db_Expr('cs.store_id')));
     $query = $select->insertFromSelect($idxTable);
     $write->query($query);
     return $this;
 }
Example #28
0
 protected function _prepareLayout()
 {
     $this->setChild('uploader', $this->getLayout()->createBlock('adminhtml/media_uploader'));
     $this->getUploader()->getConfig()->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/catalog_product_gallery/upload'))->setFileField('image')->setFilters(array('images' => array('label' => Mage::helper('adminhtml')->__('Images (.gif, .jpg, .png)'), 'files' => array('*.gif', '*.jpg', '*.jpeg', '*.png'))));
     Mage::dispatchEvent('catalog_product_gallery_prepare_layout', array('block' => $this));
     return parent::_prepareLayout();
 }
Example #29
0
 /**
  * Get product input types as option array
  *
  * @return array
  */
 public function toOptionArray()
 {
     $inputTypes = array(array('value' => 'price', 'label' => Mage::helper('catalog')->__('Price')), array('value' => 'media_image', 'label' => Mage::helper('catalog')->__('Media Image')));
     $response = new Varien_Object();
     $response->setTypes(array());
     Mage::dispatchEvent('adminhtml_product_attribute_types', array('response' => $response));
     $_disabledTypes = array();
     $_hiddenFields = array();
     foreach ($response->getTypes() as $type) {
         $inputTypes[] = $type;
         if (isset($type['hide_fields'])) {
             $_hiddenFields[$type['value']] = $type['hide_fields'];
         }
         if (isset($type['disabled_types'])) {
             $_disabledTypes[$type['value']] = $type['disabled_types'];
         }
     }
     if (Mage::registry('attribute_type_hidden_fields') === null) {
         Mage::register('attribute_type_hidden_fields', $_hiddenFields);
     }
     if (Mage::registry('attribute_type_disabled_types') === null) {
         Mage::register('attribute_type_disabled_types', $_disabledTypes);
     }
     return array_merge(parent::toOptionArray(), $inputTypes);
 }
Example #30
0
 /**
  * Performs the scan for associated products
  *
  * @return array
  */
 public function collect()
 {
     if (is_null($this->_recommendation)) {
         Mage::throwException('Product Recommendation is required for collecting recommended products');
     }
     Mage::dispatchEvent("bronto_product_before_collect", array('collect' => $this, 'recommendation' => $this->_recommendation));
     foreach ($this->_recommendation->getSources() as $source => $method) {
         if ($this->_recommendation->isProductRelated($source)) {
             if (empty($this->_hash)) {
                 Mage::helper('bronto_product')->writeInfo('originalHash cannot be empty for a product related source. Skipping');
                 continue;
             }
             foreach ($this->_hash as $productId => $product) {
                 if ($this->isReachedMax()) {
                     break;
                 }
                 $this->_invokeSource($source, $method, $product);
             }
         } else {
             $this->_invokeSource($source, $method);
         }
     }
     Mage::dispatchEvent("bronto_product_after_collect", array('collect' => $this, 'recommendation' => $this->_recommendation));
     return $this->_products;
 }