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


PHP Mage_Catalog_Model_Resource_Product_Collection::_beforeLoad方法代码示例

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


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

示例1: _beforeLoad

 /**
  * Add tax class id attribute to select and join price rules data if needed
  *
  * @return Mage_Catalog_Model_Resource_Product_Collection
  */
 protected function _beforeLoad()
 {
     if (isset($this->_productLimitationFilters['category_id']) && is_array($this->_productLimitationFilters['category_id'])) {
         $this->getSelect()->group('e.entity_id');
     }
     return parent::_beforeLoad();
 }
开发者ID:kumardhirendra1,项目名称:Magento_Filter,代码行数:12,代码来源:Collection.php

示例2: _beforeLoad

 /**
  * Redeclare parent method for store filters applying
  *
  * @return Mage_Review_Model_Resource_Review_Product_Collection
  */
 protected function _beforeLoad()
 {
     parent::_beforeLoad();
     $this->_applyStoresFilterToSelect();
     return $this;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:11,代码来源:Collection.php

示例3: _beforeLoad

 /**
  * Handles collection filtering by ids retrieves from search engine.
  * Will also stores faceted data and total records.
  *
  * @return Mage_Catalog_Model_Resource_Product_Collection
  */
 protected function _beforeLoad()
 {
     $this->_prepareQuery();
     $ids = array();
     if (!empty($this->_facets)) {
         $this->getSearchEngineQuery()->resetFacets();
     }
     $result = $this->getSearchEngineQuery()->search();
     $ids = isset($result['ids']) ? $result['ids'] : array();
     if (isset($result['facets'])) {
         $this->_facets = array_merge($this->_facets, $result['facets']);
     }
     $this->_totalRecords = isset($result['total_count']) ? $result['total_count'] : null;
     $this->_isSpellChecked = $this->getSearchEngineQuery()->isSpellchecked();
     if (empty($ids)) {
         $ids = array(0);
         // Fix for no result
     }
     $this->addIdFilter($ids);
     $this->_searchedEntityIds = $ids;
     $this->_pageSize = false;
     return parent::_beforeLoad();
 }
开发者ID:diglin,项目名称:smile-magento-elasticsearch,代码行数:29,代码来源:Collection.php

示例4: _beforeLoad

 /**
  * Join linked products when specified link model
  *
  * @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection
  */
 protected function _beforeLoad()
 {
     if ($this->getLinkModel()) {
         $this->_joinLinks();
     }
     return parent::_beforeLoad();
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:12,代码来源:Collection.php

示例5: _beforeLoad

 /**
  * Search documents by query
  * Set found ids and number of found results
  *
  * @return Enterprise_Search_Model_Resource_Collection
  */
 protected function _beforeLoad()
 {
     $ids = array();
     if ($this->_engine) {
         list($query, $params) = $this->_prepareBaseParams();
         if ($this->_sortBy) {
             $params['sort_by'] = $this->_sortBy;
         }
         if ($this->_pageSize !== false) {
             $page = $this->_curPage > 0 ? (int) $this->_curPage : 1;
             $rowCount = $this->_pageSize > 0 ? (int) $this->_pageSize : 1;
             $params['offset'] = $rowCount * ($page - 1);
             $params['limit'] = $rowCount;
         }
         $needToLoadFacetedData = !$this->_facetedDataIsLoaded && !empty($this->_facetedConditions);
         if ($needToLoadFacetedData) {
             $params['solr_params']['facet'] = 'on';
             $params['facet'] = $this->_facetedConditions;
         }
         $result = $this->_engine->getIdsByQuery($query, $params);
         $ids = (array) $result['ids'];
         if ($needToLoadFacetedData) {
             $this->_facetedData = $result['faceted_data'];
             $this->_facetedDataIsLoaded = true;
         }
     }
     $this->_searchedEntityIds =& $ids;
     $this->getSelect()->where('e.entity_id IN (?)', $this->_searchedEntityIds);
     /**
      * To prevent limitations to the collection, because of new data logic.
      * On load collection will be limited by _pageSize and appropriate offset,
      * but third party search engine retrieves already limited ids set
      */
     $this->_storedPageSize = $this->_pageSize;
     $this->_pageSize = false;
     return parent::_beforeLoad();
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:43,代码来源:Collection.php

示例6: _beforeLoad

 /**
  * Handles collection filtering by ids retrieves from search engine.
  * Will also stores faceted data and total records.
  *
  * @return Mage_Catalog_Model_Resource_Product_Collection
  */
 protected function _beforeLoad()
 {
     $ids = array();
     if ($this->_engine) {
         $result = $this->_engine->getIdsByQuery($this->_getQuery(), $this->_getParams());
         $ids = isset($result['ids']) ? $result['ids'] : array();
         $this->_facetedData = isset($result['faceted_data']) ? $result['faceted_data'] : array();
         $this->_totalRecords = isset($result['total_count']) ? $result['total_count'] : null;
     }
     if (empty($ids)) {
         $ids = array(0);
         // Fix for no result
     }
     $this->addIdFilter($ids);
     $this->_searchedEntityIds = $ids;
     $this->_pageSize = false;
     return parent::_beforeLoad();
 }
开发者ID:,项目名称:,代码行数:24,代码来源:

示例7: _beforeLoad

 /**
  * Apply MongoDB filtering before loading the collection
  *
  * @return Smile_MongoCore_Model_Resource_Override_Catalog_Product_Collection Self reference
  */
 protected function _beforeLoad()
 {
     parent::_beforeLoad();
     $documentFilter = array();
     foreach ($this->_documentFilters as $attribute => $filter) {
         $filter = $this->_buildDocumentFilter($attribute, $filter);
         if (!is_null($filter)) {
             $documentFilter[] = $filter;
         }
     }
     if (!empty($documentFilter)) {
         $productIds = null;
         if ($this->_hasSqlFilter !== false) {
             $productIds = $this->getAllIds();
         }
         $documentIds = array();
         if (!is_null($productIds) && !empty($productIds)) {
             $documentFilter = array('$and' => array($this->getResource()->getIdsFilter($productIds), array('$and' => $documentFilter)));
         } else {
             $documentFilter = array('$and' => array_values($documentFilter));
         }
         $storeFilter = array_unique(array('attr_' . $this->getDefaultStoreId(), 'attr_' . $this->getStoreId()));
         $cursor = $this->_getDocumentCollection()->find($documentFilter, $storeFilter)->limit($this->getPageSize());
         while ($cursor->hasNext()) {
             $document = $cursor->getNext();
             $documentIds[] = $document['_id'];
         }
         $this->getSelect()->where('e.entity_id IN(?)', $documentIds);
     }
 }
开发者ID:nouchka,项目名称:mongogento,代码行数:35,代码来源:Collection.php

示例8: _beforeLoad

 /**
  * @return Mage_Catalog_Model_Resource_Product_Collection|void
  */
 protected function _beforeLoad()
 {
     $query = $this->_getQuery();
     $fQuery = $this->_getFQuery($query);
     $result = $this->_engine->search($fQuery);
     $ids = $this->_getResultIds($result);
     $this->getSelect()->where('e.entity_id IN (?)', $ids);
     $this->_storedPageSize = $this->_pageSize;
     $this->_pageSize = false;
     return parent::_beforeLoad();
 }
开发者ID:adrianoaguiar,项目名称:magento-elasticsearch-module,代码行数:14,代码来源:Collection.php

示例9: _beforeLoad

 /**
  * Filters collection by id.
  * Will also stores faceted data and total records.
  *
  * @return Mage_Catalog_Model_Resource_Product_Collection
  */
 protected function _beforeLoad()
 {
     if (Mage::helper('nanowebg_elasticsearch')->isLog()) {
         Mage::log('NanoWebG_ElasticSearch_Model_Resource_Catalog_Product_Collection _beforeLoad', null, 'elasticsearch_debug.log');
     }
     $ids = $this->getSearchResultIds();
     if (empty($ids)) {
         $ids = array(0);
         // Fix for no result
     }
     $page_ids = array();
     $params = $this->_getParams();
     $limit = (int) $params['limit'] ? (int) $params['limit'] : count($ids);
     $offset = (int) $params['offset'] ? (int) $params['offset'] : 0;
     // $max_offset = floor(count($ids)/$limit);
     $max = $offset + $limit;
     $max = $max > count($ids) ? count($ids) : $max;
     $offset = $offset + $limit > $max ? (int) floor($max / $limit) * $limit : $offset;
     foreach ($ids as $key => $value) {
         if ($key < $offset) {
             continue;
         }
         if ($key > $max) {
             break;
         }
         if ($key >= $offset && $key < $max) {
             $page_ids[] = $value;
         }
     }
     $this->addIdFilter($page_ids);
     $this->_entityIds = $page_ids;
     $this->_pageSize = false;
     Mage::dispatchEvent('nanowebg_elasticsearch_product_collection_before', array('collection' => $this));
     return parent::_beforeLoad();
 }
开发者ID:javik223,项目名称:Evron-Magento,代码行数:41,代码来源:Collection.php

示例10: _beforeLoad

 /**
  * Search documents by query
  * Set found ids and number of found results
  *
  * @return Celebros_Conversionpro_Model_Resource_Collection
  */
 protected function _beforeLoad()
 {
     $ids = array();
     if ($this->_engine) {
         list($query, $params) = $this->_prepareBaseParams();
         if ($this->_sortBy) {
             $params['sort_by'] = $this->_sortBy;
         }
         if ($this->_pageSize !== false) {
             $page = $this->_curPage > 0 ? (int) $this->_curPage : 1;
             $rowCount = $this->_pageSize > 0 ? (int) $this->_pageSize : 1;
             $params['offset'] = $rowCount * ($page - 1);
             $params['limit'] = $rowCount;
         }
         $result = $this->_engine->getIdsByQuery($query, $params);
         $ids = (array) $result['ids'];
         $this->_facetedData = array();
     }
     $this->_searchedEntityIds =& $ids;
     $this->getSelect()->where('e.entity_id IN (?)', $this->_searchedEntityIds);
     $this->_totalRecords = $this->_engine->getLastNumFound();
     //In case Quiser tells us to, we should cancel conversionpro and re-run the search.
     //Right now this feature isn't in use, but we're leaving it here just in case.
     if (false) {
         $status = Mage::getSingleton('conversionpro/session')->getConversionproDisabler();
         //This prevents the redirect from looping forever. We'll only redirect in case we haven't already enabled the disabler.
         if (!isset($status) || !$status) {
             Mage::helper('conversionpro')->enableConversionproDisabler();
             Mage::app()->getResponse()->setRedirect(Mage::helper('core/url')->getCurrentUrl());
         }
     }
     //Handle the case of a single search result (only when not in an ajax request).
     if ($this->_totalRecords == 1 && Mage::getStoreConfig('conversionpro/display_settings/go_to_product_on_one_result') && !Mage::app()->getRequest()->isXmlHttpRequest()) {
         $searchResults = Mage::helper('conversionpro')->getSearchResults();
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getModel('catalog/product')->load($ids[0])->getProductUrl());
     }
     /**
      * To prevent limitations to the collection, because of new data logic.
      * On load collection will be limited by _pageSize and appropriate offset,
      * but third party search engine retrieves already limited ids set
      */
     $this->_storedPageSize = $this->_pageSize;
     $this->_pageSize = false;
     return parent::_beforeLoad();
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:51,代码来源:Collection.php


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