Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_CatalogSearch_AdvancedController
  • Mage_CatalogSearch_AjaxController
  • Mage_CatalogSearch_Block_Advanced_Form
  • Mage_CatalogSearch_Block_Advanced_Result
  • Mage_CatalogSearch_Block_Autocomplete
  • Mage_CatalogSearch_Block_Layer
  • Mage_CatalogSearch_Block_Layer_Filter_Attribute
  • Mage_CatalogSearch_Block_Result
  • Mage_CatalogSearch_Block_Term
  • Mage_CatalogSearch_Helper_Data
  • Mage_CatalogSearch_Model_Advanced
  • Mage_CatalogSearch_Model_Fulltext
  • Mage_CatalogSearch_Model_Fulltext_Observer
  • Mage_CatalogSearch_Model_Indexer_Fulltext
  • Mage_CatalogSearch_Model_Layer
  • Mage_CatalogSearch_Model_Layer_Filter_Attribute
  • Mage_CatalogSearch_Model_Mysql4_Advanced
  • Mage_CatalogSearch_Model_Mysql4_Advanced_Collection
  • Mage_CatalogSearch_Model_Mysql4_Fulltext
  • Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
  • Mage_CatalogSearch_Model_Mysql4_Fulltext_Engine
  • Mage_CatalogSearch_Model_Mysql4_Indexer_Fulltext
  • Mage_CatalogSearch_Model_Mysql4_Query
  • Mage_CatalogSearch_Model_Mysql4_Query_Collection
  • Mage_CatalogSearch_Model_Mysql4_Search_Collection
  • Mage_CatalogSearch_Model_Query
  • Mage_CatalogSearch_Model_Resource_Advanced
  • Mage_CatalogSearch_Model_Resource_Advanced_Collection
  • Mage_CatalogSearch_Model_Resource_Fulltext
  • Mage_CatalogSearch_Model_Resource_Fulltext_Collection
  • Mage_CatalogSearch_Model_Resource_Fulltext_Engine
  • Mage_CatalogSearch_Model_Resource_Indexer_Fulltext
  • Mage_CatalogSearch_Model_Resource_Query
  • Mage_CatalogSearch_Model_Resource_Query_Collection
  • Mage_CatalogSearch_Model_Resource_Search_Collection
  • Mage_CatalogSearch_Model_Session
  • Mage_Catalogsearch_Model_System_Config_Backend_Sitemap
  • Mage_CatalogSearch_ResultController
  • Mage_CatalogSearch_TermController
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_CatalogSearch
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Collection Advanced
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_CatalogSearch
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_CatalogSearch_Model_Resource_Advanced_Collection extends Mage_Catalog_Model_Resource_Product_Collection
 36: {
 37:     /**
 38:      * Add not indexable fields to search
 39:      *
 40:      * @param array $fields
 41:      * @return Mage_CatalogSearch_Model_Resource_Advanced_Collection
 42:      */
 43:     public function addFieldsToFilter($fields)
 44:     {
 45:         if ($fields) {
 46:             $previousSelect = null;
 47:             $conn = $this->getConnection();
 48:             foreach ($fields as $table => $conditions) {
 49:                 foreach ($conditions as $attributeId => $conditionValue) {
 50:                     $select = $conn->select();
 51:                     $select->from(array('t1' => $table), 'entity_id');
 52:                     $conditionData = array();
 53: 
 54:                     if (!is_numeric($attributeId)) {
 55:                         $field = 't1.'.$attributeId;
 56:                     }
 57:                     else {
 58:                         $storeId = $this->getStoreId();
 59:                         $onCondition = 't1.entity_id = t2.entity_id'
 60:                                 . ' AND t1.attribute_id = t2.attribute_id'
 61:                                 . ' AND t2.store_id=?';
 62: 
 63:                         $select->joinLeft(
 64:                             array('t2' => $table),
 65:                             $conn->quoteInto($onCondition, $storeId),
 66:                             array()
 67:                         );
 68:                         $select->where('t1.store_id = ?', 0);
 69:                         $select->where('t1.attribute_id = ?', $attributeId);
 70: 
 71:                         if (array_key_exists('price_index', $this->getSelect()->getPart(Varien_Db_Select::FROM))) {
 72:                             $select->where('t1.entity_id = price_index.entity_id');
 73:                         }
 74: 
 75:                         $field = $this->getConnection()->getCheckSql('t2.value_id>0', 't2.value', 't1.value');
 76: 
 77:                     }
 78: 
 79:                     if (is_array($conditionValue)) {
 80:                         if (isset($conditionValue['in'])){
 81:                             $conditionData[] = array('in' => $conditionValue['in']);
 82:                         }
 83:                         elseif (isset($conditionValue['in_set'])) {
 84:                             $conditionParts = array();
 85:                             foreach ($conditionValue['in_set'] as $value) {
 86:                                 $conditionParts[] = array('finset' => $value);
 87:                             }
 88:                             $conditionData[] = $conditionParts;
 89:                         }
 90:                         elseif (isset($conditionValue['like'])) {
 91:                             $conditionData[] = array ('like' => $conditionValue['like']);
 92:                         }
 93:                         elseif (isset($conditionValue['from']) && isset($conditionValue['to'])) {
 94:                             $invalidDateMessage = Mage::helper('catalogsearch')->__('Specified date is invalid.');
 95:                             if ($conditionValue['from']) {
 96:                                 if (!Zend_Date::isDate($conditionValue['from'])) {
 97:                                     Mage::throwException($invalidDateMessage);
 98:                                 }
 99:                                 if (!is_numeric($conditionValue['from'])){
100:                                     $conditionValue['from'] = Mage::getSingleton('core/date')
101:                                         ->gmtDate(null, $conditionValue['from']);
102:                                     if (!$conditionValue['from']) {
103:                                         $conditionValue['from'] = Mage::getSingleton('core/date')->gmtDate();
104:                                     }
105:                                 }
106:                                 $conditionData[] = array('gteq' => $conditionValue['from']);
107:                             }
108:                             if ($conditionValue['to']) {
109:                                 if (!Zend_Date::isDate($conditionValue['to'])) {
110:                                     Mage::throwException($invalidDateMessage);
111:                                 }
112:                                 if (!is_numeric($conditionValue['to'])){
113:                                     $conditionValue['to'] = Mage::getSingleton('core/date')
114:                                         ->gmtDate(null, $conditionValue['to']);
115:                                     if (!$conditionValue['to']) {
116:                                         $conditionValue['to'] = Mage::getSingleton('core/date')->gmtDate();
117:                                     }
118:                                 }
119:                                 $conditionData[] = array('lteq' => $conditionValue['to']);
120:                             }
121: 
122:                         }
123:                     } else {
124:                         $conditionData[] = array('eq' => $conditionValue);
125:                     }
126: 
127: 
128:                     foreach ($conditionData as $data) {
129:                         $select->where($conn->prepareSqlCondition($field, $data));
130:                     }
131: 
132:                     if (!is_null($previousSelect)) {
133:                         $select->where('t1.entity_id IN (?)', new Zend_Db_Expr($previousSelect));
134:                     }
135:                     $previousSelect = $select;
136:                 }
137:             }
138:             $this->addFieldToFilter('entity_id', array('in' => new Zend_Db_Expr($select)));
139:         }
140: 
141:         return $this;
142:     }
143: }
144: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0