当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage::getResourceHelper方法代码示例

本文整理汇总了PHP中Mage::getResourceHelper方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::getResourceHelper方法的具体用法?PHP Mage::getResourceHelper怎么用?PHP Mage::getResourceHelper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage的用法示例。


在下文中一共展示了Mage::getResourceHelper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _productLimitationJoinPrice

 /**
  * Adds an additional indexed_price column to as the regular price gets over-ridden elsewhere\
  * 
  * This field seems to only appear when the collection has ->addPriceData();
  * 
  * @see Mage_Catalog_Model_Resource_Product_Collection::_productLimitationJoinPrice()
  */
 protected function _productLimitationJoinPrice()
 {
     $filters = $this->_productLimitationFilters;
     if (empty($filters['use_price_index'])) {
         return $this;
     }
     $helper = Mage::getResourceHelper('core');
     $connection = $this->getConnection();
     $select = $this->getSelect();
     $joinCond = join(' AND ', array('price_index.entity_id = e.entity_id', $connection->quoteInto('price_index.website_id = ?', $filters['website_id']), $connection->quoteInto('price_index.customer_group_id = ?', $filters['customer_group_id'])));
     $fromPart = $select->getPart(Zend_Db_Select::FROM);
     if (!isset($fromPart['price_index'])) {
         $least = $connection->getLeastSql(array('price_index.min_price', 'price_index.tier_price'));
         $minimalExpr = $connection->getCheckSql('price_index.tier_price IS NOT NULL', $least, 'price_index.min_price');
         $indexedExpr = new Zend_Db_Expr('price_index.price');
         $colls = array('indexed_price' => $indexedExpr, 'price', 'tax_class_id', 'final_price', 'minimal_price' => $minimalExpr, 'min_price', 'max_price', 'tier_price');
         $tableName = array('price_index' => $this->getTable('catalog/product_index_price'));
         $select->join($tableName, $joinCond, $colls);
         // Set additional field filters
         foreach ($this->_priceDataFieldFilters as $filterData) {
             $select->where(call_user_func_array('sprintf', $filterData));
         }
     } else {
         $fromPart['price_index']['joinCondition'] = $joinCond;
         $select->setPart(Zend_Db_Select::FROM, $fromPart);
     }
     //Clean duplicated fields
     $helper->prepareColumnsList($select);
     return $this;
 }
开发者ID:BeeHealthLimited,项目名称:magento-configurable-simple,代码行数:37,代码来源:Collection.php

示例2: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     /** @var $resource Mage_Core_Model_Resource */
     $resource = Mage::getSingleton('index/resource_lock_resource');
     $this->_connection = $resource->getConnection('index_write', 'default_lock');
     $this->_helper = Mage::getResourceHelper('index');
 }
开发者ID:okite11,项目名称:frames21,代码行数:10,代码来源:Db.php

示例3: _getSimpleSelect

 /**
  * Prepare simple select by given parameters
  *
  * @param mixed $table
  * @param string $fields
  * @param array | string $where
  * @return string
  */
 protected function _getSimpleSelect($table, $fields, $where = null)
 {
     $_where = array();
     if (!is_null($where)) {
         if (is_array($where)) {
             $_where = $where;
         } else {
             $_where[] = $where;
         }
     }
     $likeOptions = array('position' => 'any');
     if ($this->getEvent()->getCode() !== 'rollback') {
         $itemXmlConfig = $this->getConfig();
         if ($itemXmlConfig->ignore_nodes) {
             foreach ($itemXmlConfig->ignore_nodes->children() as $node) {
                 $path = (string) $node->path;
                 /* $helper Mage_Core_Model_Resource_Helper_Abstract */
                 $helper = Mage::getResourceHelper('core');
                 $_where[] = 'path NOT LIKE ' . $helper->addLikeEscape($path, $likeOptions);
             }
         }
     }
     $select = parent::_getSimpleSelect($table, $fields, $_where);
     return $select;
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:33,代码来源:Config.php

示例4: rotate

 /**
  * Rotate logs - get from database and pump to CSV-file
  *
  * @param int $lifetime
  */
 public function rotate($lifetime)
 {
     //        $this->beginTransaction();
     //        try {
     $readAdapter = $this->_getReadAdapter();
     $writeAdapter = $this->_getWriteAdapter();
     $table = $this->getTable('enterprise_logging/event');
     // get the latest log entry required to the moment
     $clearBefore = $this->formatDate(time() - $lifetime);
     $select = $readAdapter->select()->from($this->getMainTable(), 'log_id')->where('time < ?', $clearBefore)->order('log_id DESC')->limit(1);
     $latestLogEntry = $readAdapter->fetchOne($select);
     if ($latestLogEntry) {
         // make sure folder for dump file will exist
         $archive = Mage::getModel('enterprise_logging/archive');
         $archive->createNew();
         $expr = Mage::getResourceHelper('enterprise_logging')->getInetNtoaExpr('ip');
         $select = $readAdapter->select()->from($this->getMainTable())->where('log_id <= ?', $latestLogEntry)->columns($expr);
         $rows = $readAdapter->fetchAll($select);
         // dump all records before this log entry into a CSV-file
         $csv = fopen($archive->getFilename(), 'w');
         foreach ($rows as $row) {
             fputcsv($csv, $row);
         }
         fclose($csv);
         $writeAdapter->delete($this->getMainTable(), array('log_id <= ?' => $latestLogEntry));
         //                $this->commit();
     }
     //        } catch (Exception $e) {
     //            $this->rollBack();
     //        }
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:36,代码来源:Event.php

示例5: saveAttributesAfter

 public function saveAttributesAfter($observer)
 {
     $data = $observer->getControllerAction()->getRequest()->getPost();
     if ($data['is_configurable'] && $data['is_global']) {
         $baseDir = Mage::getBaseDir('media') . DIRECTORY_SEPARATOR . 'swatches' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR;
         if (isset($_FILES['swatches_img']) && isset($_FILES['swatches_img']['error'])) {
             foreach ($_FILES['swatches_img']['error'] as $optionId => $errorCode) {
                 if ($errorCode == UPLOAD_ERR_OK) {
                     if (strpos($optionId, 'option') === false) {
                         move_uploaded_file($_FILES['swatches_img']['tmp_name'][$optionId], $baseDir . $optionId . '.jpg');
                     } else {
                         $newOptionId = Mage::getResourceHelper('importexport')->getNextAutoincrement(Mage::getSingleton('core/resource')->getTableName('eav/attribute_option')) - 1;
                         move_uploaded_file($_FILES['swatches_img']['tmp_name'][$optionId], $baseDir . $newOptionId . '.jpg');
                     }
                 }
             }
         }
         if (Mage::app()->getRequest()->isPost('useSwatches')) {
             $confAttr = Mage::getModel('bluecom_swatches/attribute')->load($data['attribute_id'], 'attribute_id');
             if (!$confAttr->getId()) {
                 $confAttr->setAttributeId($data['attribute_id']);
             }
             $confAttr->setUseSwatches(intval(Mage::app()->getRequest()->getPost('useSwatches')));
             $confAttr->save();
         }
         // $deleteArr = $data['swatches_img_delete'];
         if (isset($data['swatches_img_delete']) && !empty($data['swatches_img_delete'])) {
             foreach ($data['swatches_img_delete'] as $optionId => $value) {
                 if ($value) {
                     unlink($baseDir . $optionId . '.jpg');
                 }
             }
         }
     }
 }
开发者ID:bele90,项目名称:magento-test2,代码行数:35,代码来源:Observer.php

示例6: _prepareSelectIndex

 /**
  * Prepare data index for indexable select attributes
  *
  * @param array $entityIds the entity ids limitation
  * @param int $attributeId the attribute id limitation
  * @return Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source
  */
 protected function _prepareSelectIndex($entityIds = null, $attributeId = null)
 {
     $adapter = $this->_getWriteAdapter();
     $idxTable = $this->getIdxTable();
     // prepare select attributes
     if (is_null($attributeId)) {
         $attrIds = $this->_getIndexableAttributes(false);
     } else {
         $attrIds = array($attributeId);
     }
     if (!$attrIds) {
         return $this;
     }
     /**@var $subSelect Varien_Db_Select */
     $subSelect = $adapter->select()->from(array('s' => $this->getTable('core/store')), array('store_id', 'website_id'))->joinLeft(array('d' => $this->getValueTable('catalog/product', 'int')), '1 = 1 AND d.store_id = 0', array('entity_id', 'attribute_id', 'value'))->where('s.store_id != 0 and d.attribute_id IN (?)', array_map('intval', $attrIds));
     if (!is_null($entityIds)) {
         $subSelect->where('d.entity_id IN(?)', array_map('intval', $entityIds));
     }
     /**@var $select Varien_Db_Select */
     $select = $adapter->select()->from(array('pid' => new Zend_Db_Expr(sprintf('(%s)', $subSelect->assemble()))), array())->joinLeft(array('pis' => $this->getValueTable('catalog/product', 'int')), 'pis.entity_id = pid.entity_id AND pis.attribute_id = pid.attribute_id AND pis.store_id = pid.store_id', array())->columns(array('pid.entity_id', 'pid.attribute_id', 'pid.store_id', 'value' => $adapter->getIfNullSql('pis.value', 'pid.value')))->where('pid.attribute_id IN(?)', $attrIds);
     $select->where(Mage::getResourceHelper('catalog')->getIsNullNotNullCondition('pis.value', 'pid.value'));
     /**
      * Add additional external limitation
      */
     Mage::dispatchEvent('prepare_catalog_product_index_select', array('select' => $select, 'entity_field' => new Zend_Db_Expr('pid.entity_id'), 'website_field' => new Zend_Db_Expr('pid.website_id'), 'store_field' => new Zend_Db_Expr('pid.store_id')));
     $query = $select->insertFromSelect($idxTable);
     $adapter->query($query);
     return $this;
 }
开发者ID:z4kko,项目名称:smartdevs-indexer,代码行数:36,代码来源:Source.php

示例7: getCondition

 /**
  * Collection condition filter getter
  *
  * @return array
  */
 public function getCondition()
 {
     $value = $this->getValue();
     if (preg_match('/^(\\d+\\.){3}\\d+$/', $value)) {
         return ip2long($value);
     }
     $expr = Mage::getResourceHelper('enterprise_logging')->getInetNtoaExpr();
     return array('field_expr' => $expr, 'like' => "%{$this->_escapeValue($value)}%");
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:14,代码来源:Ip.php

示例8: getCondition

 /**
  * Collection condition filter getter
  *
  * @return array
  */
 public function getCondition()
 {
     $value = $this->getValue();
     if (preg_match('/^(\\d+\\.){3}\\d+$/', $value) || preg_match('/^(([0-9a-f]{1,4})?(:([0-9a-f]{1,4})?){1,}:([0-9a-f]{1,4}))(%[0-9a-z]+)?$/i', $value)) {
         return inet_pton($value);
     }
     $expr = Mage::getResourceHelper('enterprise_logging')->getInetNtoaExpr();
     return array('field_expr' => $expr, 'like' => "%{$this->_escapeValue($value)}%");
 }
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:14,代码来源:Ip.php

示例9: addFulltextSearchTerm

 /**
  *
  * @param string $searchTerm
  */
 public function addFulltextSearchTerm($searchTerm)
 {
     $select = $this->getSelect();
     $preparedTerms = Mage::getResourceHelper('catalogsearch')->prepareTerms($searchTerm);
     $select->join(array('fs' => 'catalogsearch_fulltext'), 'fs.product_id = e.entity_id', array());
     $select->where(new Zend_Db_Expr('MATCH (fs.data_index) AGAINST (:query IN BOOLEAN MODE)'));
     $this->addBindParam(':query', implode(' ', $preparedTerms[0]));
     $select->group('e.entity_id');
 }
开发者ID:styladev,项目名称:magentoStylaConnect,代码行数:13,代码来源:Collection.php

示例10: addIpFilter

 /**
  * Add IP filter to collection
  *
  * @param string $value
  * @return Enterprise_Logging_Model_Resource_Event_Collection
  */
 public function addIpFilter($value)
 {
     if (preg_match('/^(\\d+\\.){3}\\d+$/', $value)) {
         return $this->addFieldToFilter('ip', ip2long($value));
     }
     $condition = $this->getConnection()->prepareSqlCondition(Mage::getResourceHelper('enterprise_logging')->getInetNtoaExpr('ip'), array('like' => Mage::getResourceHelper('core')->addLikeEscape($value, array('position' => 'any'))));
     $this->getSelect()->where($condition);
     return $this;
 }
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:15,代码来源:Collection.php

示例11: getCondition

 /**
  * Retrieve condition
  *
  * @return array
  */
 public function getCondition()
 {
     $id = $this->getValue();
     $length = strlen($id);
     $search = "{s:4:\"type\";s:{$length}:\"{$id}\"";
     $helper = Mage::getResourceHelper('core');
     $likeExpression = $helper->addLikeEscape($search, array('position' => 'any'));
     return array('like' => $likeExpression);
 }
开发者ID:jsiefer,项目名称:emarketing,代码行数:14,代码来源:Filter.php

示例12: prepareResult

 /**
  * Prepare results for query
  *
  * @param Mage_CatalogSearch_Model_Fulltext $object
  * @param string $queryText
  * @param Mage_CatalogSearch_Model_Query $query
  * @return Mage_CatalogSearch_Model_Resource_Fulltext
  */
 public function prepareResult($object, $queryText, $query)
 {
     $adapter = $this->_getWriteAdapter();
     if (!$query->getIsProcessed()) {
         $searchType = $object->getSearchType($query->getStoreId());
         $preparedTerms = Mage::getResourceHelper('catalogsearch')->prepareTerms($queryText, $query->getMaxQueryWords());
         $bind = array();
         $like = array();
         $likeCond = '';
         if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE) {
             $helper = Mage::getResourceHelper('core');
             $words = Mage::helper('core/string')->splitWords($queryText, true, $query->getMaxQueryWords());
             foreach ($words as $word) {
                 $like[] = $helper->getCILike('s.data_index', $word, array('position' => 'any'));
             }
             if ($like) {
                 $likeCond = '(' . join(' OR ', $like) . ')';
             }
         }
         $mainTableAlias = 's';
         $fields = array('query_id' => new Zend_Db_Expr($query->getId()), 'product_id');
         $select = $adapter->select()->from(array($mainTableAlias => $this->getMainTable()), $fields)->joinInner(array('e' => $this->getTable('catalog/product')), 'e.entity_id = s.product_id', array())->where($mainTableAlias . '.store_id = ?', (int) $query->getStoreId());
         if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_FULLTEXT || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE) {
             $bind[':query'] = implode(' ', $preparedTerms[0]);
             $where = Mage::getResourceHelper('catalogsearch')->chooseFulltext($this->getMainTable(), $mainTableAlias, $select);
         }
         if ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE) {
             $where .= ($where ? ' OR ' : '') . $likeCond;
         } elseif ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE) {
             $select->columns(array('relevance' => new Zend_Db_Expr(0)));
             $where = $likeCond;
         }
         if ($where != '') {
             $select->where($where);
         }
         /*
         $sql = $adapter->insertFromSelect($select,
             $this->getTable('catalogsearch/result'),
             array(),
             Varien_Db_Adapter_Interface::INSERT_ON_DUPLICATE);
         $adapter->query($sql, $bind);
         */
         $conn = new Connection();
         $conn->setParams(array('host' => '127.0.0.1', 'port' => 9306));
         /** @var SphinxQL $sphinxQuery */
         $sphinxQuery = SphinxQL::create($conn)->select(array('*', SphinxQL::expr('WEIGHT()')))->from('fulltext')->option('ranker', 'bm25')->option('field_weights', SphinxQL::expr('(name=7, attributes=3, data_index=1)'))->option('cutoff', 5000)->option('max_matches', 1000)->limit(0, 100)->match('*', $queryText);
         $results = $sphinxQuery->execute();
         foreach ($results as $result) {
             // Ensure we log query results into the Magento table.
             $sql = sprintf("INSERT INTO {$this->getTable('catalogsearch/result')} " . " (query_id, product_id, relevance) VALUES " . " (%d, %d, %f) " . " ON DUPLICATE KEY UPDATE relevance = %f", $query->getId(), $result['id'], $result['weight()'] / 1000, $result['weight()'] / 1000);
             $this->_getWriteAdapter()->query($sql, $bind);
         }
         $conn->close();
         $query->setIsProcessed(1);
     }
     return $this;
 }
开发者ID:siment,项目名称:magento-sphinx-search,代码行数:65,代码来源:Fulltext.php

示例13: setQueryFilter

 /**
  * Override of parent
  *
  * - Like match position
  *
  * @param string $query
  * @return Mage_CatalogSearch_Model_Resource_Query_Collection
  */
 public function setQueryFilter($query)
 {
     $ifSynonymFor = $this->getConnection()->getIfNullSql('synonym_for', 'query_text');
     $this->getSelect()->reset(Zend_Db_Select::FROM)->distinct(true)->from(array('main_table' => $this->getTable('catalogsearch/search_query')), array('query' => $ifSynonymFor, 'num_results'))->where('num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?', Mage::getResourceHelper('core')->addLikeEscape($query, array('position' => Mage::getStoreConfig('catalog/search/like_match_position'))))->order('popularity ' . Varien_Db_Select::SQL_DESC);
     if ($this->getStoreId()) {
         $this->getSelect()->where('store_id = ?', (int) $this->getStoreId());
     }
     return $this;
 }
开发者ID:gil--,项目名称:Mpchadwick_SearchAutocompleteConfigmarator,代码行数:17,代码来源:Collection.php

示例14: _prepareConditionsSql

 /**
  * Prepare base condition select which related with current condition combine
  *
  * @param $customer
  * @param $website
  * @return Varien_Db_Select
  */
 protected function _prepareConditionsSql($customer, $website)
 {
     $resource = $this->getResource();
     $select = $resource->createSelect();
     $addressEntityType = Mage::getSingleton('eav/config')->getEntityType('customer_address');
     $addressTable = $resource->getTable($addressEntityType->getEntityTable());
     $select->from(array('customer_address' => $addressTable), array(new Zend_Db_Expr(1)));
     $select->where('customer_address.entity_type_id = ?', $addressEntityType->getId());
     $select->where($this->_createCustomerFilter($customer, 'customer_address.parent_id'));
     Mage::getResourceHelper('enterprise_customersegment')->setOneRowLimit($select);
     return $select;
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:19,代码来源:Address.php

示例15: saveEntityIndexes

 /**
  * Multi add entities data to fulltext search table
  *
  * @param int $storeId
  * @param array $entityIndexes
  * @param string $entity 'product'|'cms'
  * @return Mage_CatalogSearch_Model_Resource_Fulltext_Engine
  */
 public function saveEntityIndexes($storeId, $entityIndexes, $entity = 'product')
 {
     $data = array();
     $storeId = (int) $storeId;
     foreach ($entityIndexes as $entityId => $index) {
         $data[] = array('product_id' => (int) $entityId, 'store_id' => $storeId, 'data_index' => $index);
     }
     if ($data) {
         Mage::getResourceHelper('catalogsearch')->insertOnDuplicate($this->getMainTable(), $data, array('data_index'));
     }
     return $this;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:20,代码来源:Engine.php


注:本文中的Mage::getResourceHelper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。