示例#1
0
 /**
  * Save value
  *
  * @return Enterprise_UrlRewrite_Model_System_Config_Backend_MatcherPriority
  */
 public function save()
 {
     if ($this->getOldValue() !== $this->getValue()) {
         $matchers = explode('-', $this->getValue());
         $priority = 0;
         /** @var $configModel Mage_Core_Model_Config */
         $configModel = $this->_factory->getSingleton('core/config');
         foreach ($matchers as $matcher) {
             $priority += 10;
             $path = sprintf(Enterprise_UrlRewrite_Model_Url_Rewrite::REWRITE_MATCHERS_PRIORITY_PATH, $matcher);
             $configModel->saveConfig($path, $priority);
         }
     }
     return $this;
 }
示例#2
0
 /**
  * ACL validation before html generation
  *
  * @return string
  */
 protected function _toHtml()
 {
     if ($this->_factory->getSingleton('admin/session')->isAllowed('system/config/tax')) {
         return parent::_toHtml();
     }
     return '';
 }
示例#3
0
 /**
  * Restore locale of the initial store
  *
  * @param string $initialLocaleCode
  * @param string $initialArea
  *
  * @return Mage_Core_Model_App_Emulation
  */
 protected function _restoreInitialLocale($initialLocaleCode, $initialArea = Mage_Core_Model_App_Area::AREA_ADMINHTML)
 {
     $currentLocaleCode = $this->_app->getLocale()->getLocaleCode();
     if ($currentLocaleCode != $initialLocaleCode) {
         $this->_app->getLocale()->setLocaleCode($initialLocaleCode);
         $this->_factory->getSingleton('core/translate')->setLocale($initialLocaleCode)->init($initialArea, true);
     }
     return $this;
 }
示例#4
0
 /**
  * Load url rewrite entity by request_path
  *
  * @param array $paths
  * @return Enterprise_UrlRewrite_Model_Url_Rewrite
  */
 public function loadByRequestPath($paths)
 {
     $this->setId(null);
     $rewriteRows = $this->_getResource()->getRewrites($paths);
     $matchers = $this->_factory->getSingleton('enterprise_urlrewrite/system_config_source_matcherPriority')->getRewriteMatchers();
     foreach ($matchers as $matcherIndex) {
         $matcher = $this->_factory->getSingleton($this->_factory->getConfig()->getNode(sprintf(self::REWRITE_MATCHERS_MODEL_PATH, $matcherIndex), 'default'));
         foreach ($rewriteRows as $row) {
             if ($matcher->match($row, $paths['request'])) {
                 $this->setData($row);
                 break 2;
             }
         }
     }
     $this->_afterLoad();
     $this->setOrigData();
     $this->_hasDataChanges = false;
     return $this;
 }
 /**
  * Prepare temporary data
  *
  * @param Mage_Core_Model_Website $website
  * @return Varien_Db_Select
  */
 protected function _prepareTemporarySelect(Mage_Core_Model_Website $website)
 {
     /** @var $catalogFlatHelper Mage_Catalog_Helper_Product_Flat */
     $catalogFlatHelper = $this->_factory->getHelper('catalog/product_flat');
     /** @var $eavConfig Mage_Eav_Model_Config */
     $eavConfig = $this->_factory->getSingleton('eav/config');
     $priceAttribute = $eavConfig->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'price');
     $select = $this->_connection->select()->from(array('rp' => $this->_resource->getTable('catalogrule/rule_product')), array())->joinInner(array('r' => $this->_resource->getTable('catalogrule/rule')), 'r.rule_id = rp.rule_id', array())->where('rp.website_id = ?', $website->getId())->order(array('rp.product_id', 'rp.customer_group_id', 'rp.sort_order', 'rp.rule_product_id'))->joinLeft(array('pg' => $this->_resource->getTable('catalog/product_attribute_group_price')), 'pg.entity_id = rp.product_id AND pg.customer_group_id = rp.customer_group_id' . ' AND pg.website_id = rp.website_id', array())->joinLeft(array('pgd' => $this->_resource->getTable('catalog/product_attribute_group_price')), 'pgd.entity_id = rp.product_id AND pgd.customer_group_id = rp.customer_group_id' . ' AND pgd.website_id = 0', array());
     $storeId = $website->getDefaultStore()->getId();
     if ($catalogFlatHelper->isEnabled() && $storeId && $catalogFlatHelper->isBuilt($storeId)) {
         $select->joinInner(array('p' => $this->_resource->getTable('catalog/product_flat') . '_' . $storeId), 'p.entity_id = rp.product_id', array());
         $priceColumn = $this->_connection->getIfNullSql($this->_connection->getIfNullSql('pg.value', 'pgd.value'), 'p.price');
     } else {
         $select->joinInner(array('pd' => $this->_resource->getTable(array('catalog/product', $priceAttribute->getBackendType()))), 'pd.entity_id = rp.product_id AND pd.store_id = 0 AND pd.attribute_id = ' . $priceAttribute->getId(), array())->joinLeft(array('p' => $this->_resource->getTable(array('catalog/product', $priceAttribute->getBackendType()))), 'p.entity_id = rp.product_id AND p.store_id = ' . $storeId . ' AND p.attribute_id = pd.attribute_id', array());
         $priceColumn = $this->_connection->getIfNullSql($this->_connection->getIfNullSql('pg.value', 'pgd.value'), $this->_connection->getIfNullSql('p.value', 'pd.value'));
     }
     $select->columns(array('grouped_id' => $this->_connection->getConcatSql(array('rp.product_id', 'rp.customer_group_id'), '-'), 'product_id' => 'rp.product_id', 'customer_group_id' => 'rp.customer_group_id', 'from_date' => 'r.from_date', 'to_date' => 'r.to_date', 'action_amount' => 'rp.action_amount', 'action_operator' => 'rp.action_operator', 'action_stop' => 'rp.action_stop', 'sort_order' => 'rp.sort_order', 'price' => $priceColumn, 'rule_product_id' => 'rp.rule_product_id', 'from_time' => 'rp.from_time', 'to_time' => 'rp.to_time'));
     return $select;
 }
示例#6
0
 protected function _reindex()
 {
     $factory = new Mage_Core_Model_Factory();
     $processes = array();
     $indexer = $factory->getSingleton($factory->getIndexClassAlias());
     $collection = $indexer->getProcessesCollection();
     foreach ($collection as $process) {
         if ($process->getIndexer()->isVisible() === false) {
             continue;
         }
         $processes[] = $process;
     }
     foreach ($processes as $process) {
         /* @var $process Mage_Index_Model_Process */
         try {
             $this->_log("Reindexing " . $process->getIndexerCode());
             $process->reindexEverything();
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
 }
 /**
  * Retrieve client instance
  *
  * @return Enterprise_Mview_Model_Client
  */
 protected function _getClient()
 {
     return $this->_factory->getSingleton('enterprise_mview/client');
 }