All Classes Namespaces Files Functions Variables Pages
Mage_CatalogSearch_Model_Resource_Fulltext Class Reference
Inheritance diagram for Mage_CatalogSearch_Model_Resource_Fulltext:
Mage_Core_Model_Resource_Db_Abstract Mage_Core_Model_Resource_Abstract Mage_CatalogSearch_Model_Mysql4_Fulltext

Public Member Functions

 getSeparator ()
 
 rebuildIndex ($storeId=null, $productIds=null)
 
 resetSearchResults ()
 
 cleanIndex ($storeId=null, $productId=null)
 
 prepareResult ($object, $queryText, $query)
 
 getEavConfig ()
 
 setAllowTableChanges ($value=true)
 
 updateCategoryIndex ($productIds, $categoryIds)
 
- Public Member Functions inherited from Mage_Core_Model_Resource_Db_Abstract
 getIdFieldName ()
 
 getMainTable ()
 
 getTable ($entityName)
 
 getValueTable ($entityName, $valueType)
 
 getReadConnection ()
 
 load (Mage_Core_Model_Abstract $object, $value, $field=null)
 
 save (Mage_Core_Model_Abstract $object)
 
 forsedSave (Mage_Core_Model_Abstract $object)
 
 delete (Mage_Core_Model_Abstract $object)
 
 addUniqueField ($field)
 
 resetUniqueField ()
 
 unserializeFields (Mage_Core_Model_Abstract $object)
 
 getUniqueFields ()
 
 hasDataChanged ($object)
 
 afterLoad (Mage_Core_Model_Abstract $object)
 
 getChecksum ($table)
 
- Public Member Functions inherited from Mage_Core_Model_Resource_Abstract
 __construct ()
 
 beginTransaction ()
 
 addCommitCallback ($callback)
 
 commit ()
 
 rollBack ()
 
 formatDate ($date, $includeTime=true)
 
 mktime ($str)
 

Protected Member Functions

 _construct ()
 
 _rebuildStoreIndex ($storeId, $productIds=null)
 
 _getSearchableProducts ($storeId, array $staticFields, $productIds=null, $lastProductId=0, $limit=100)
 
 _getSearchableAttributes ($backendType=null)
 
 _getSearchableAttribute ($attribute)
 
 _unifyField ($field, $backendType= 'varchar')
 
 _getProductAttributes ($storeId, array $productIds, array $attributeTypes)
 
 _getProductTypeInstance ($typeId)
 
 _getProductChildIds ($productId, $typeId)
 
 _getProductEmulator ()
 
 _prepareProductIndex ($indexData, $productData, $storeId)
 
 _getAttributeValue ($attributeId, $value, $storeId)
 
 _saveProductIndex ($productId, $storeId, $index)
 
 _saveProductIndexes ($storeId, $productIndexes)
 
 _getStoreDate ($storeId, $date=null)
 
- Protected Member Functions inherited from Mage_Core_Model_Resource_Db_Abstract
 _init ($mainTable, $idFieldName)
 
 _setResource ($connections, $tables=null)
 
 _setMainTable ($mainTable, $idFieldName=null)
 
 _getConnection ($connectionName)
 
 _getReadAdapter ()
 
 _getWriteAdapter ()
 
 _getLoadSelect ($field, $value, $object)
 
 _initUniqueFields ()
 
 _prepareDataForSave (Mage_Core_Model_Abstract $object)
 
 _prepareValueForSave ($value, $type)
 
 _checkUnique (Mage_Core_Model_Abstract $object)
 
 _afterLoad (Mage_Core_Model_Abstract $object)
 
 _beforeSave (Mage_Core_Model_Abstract $object)
 
 _afterSave (Mage_Core_Model_Abstract $object)
 
 _beforeDelete (Mage_Core_Model_Abstract $object)
 
 _afterDelete (Mage_Core_Model_Abstract $object)
 
 _serializeFields (Mage_Core_Model_Abstract $object)
 
- Protected Member Functions inherited from Mage_Core_Model_Resource_Abstract
 _construct ()
 
 _getReadAdapter ()
 
 _getWriteAdapter ()
 
 _serializeField (Varien_Object $object, $field, $defaultValue=null, $unsetEmpty=false)
 
 _unserializeField (Varien_Object $object, $field, $defaultValue=null)
 
 _prepareDataForTable (Varien_Object $object, $table)
 
 _prepareTableValueForSave ($value, $type)
 

Protected Attributes

 $_searchableAttributes = null
 
 $_separator = '|'
 
 $_dates = array()
 
 $_productTypes = array()
 
 $_engine = null
 
 $_allowTableChanges = true
 
- Protected Attributes inherited from Mage_Core_Model_Resource_Db_Abstract
 $_resources
 
 $_resourcePrefix
 
 $_connections = array()
 
 $_resourceModel
 
 $_tables = array()
 
 $_mainTable
 
 $_idFieldName
 
 $_isPkAutoIncrement = true
 
 $_useIsObjectNew = false
 
 $_fieldsForUpdate = array()
 
 $_mainTableFields
 
 $_uniqueFields = null
 
 $_serializableFields = array()
 

Additional Inherited Members

- Public Attributes inherited from Mage_Core_Model_Resource_Db_Abstract
const CHECKSUM_KEY_NAME = 'Checksum'
 
- Static Protected Attributes inherited from Mage_Core_Model_Resource_Abstract
static $_commitCallbacks = array()
 

Detailed Description

Definition at line 35 of file Fulltext.php.

Member Function Documentation

_construct ( )
protected

Init resource model

Definition at line 88 of file Fulltext.php.

References Mage_Core_Model_Resource_Db_Abstract\_init(), and Mage\helper().

{
$this->_init('catalogsearch/fulltext', 'product_id');
$this->_engine = Mage::helper('catalogsearch')->getEngine();
}
_getAttributeValue (   $attributeId,
  $value,
  $storeId 
)
protected

Retrieve attribute source value for search

Parameters
int$attributeId
mixed$value
int$storeId
Returns
mixed

Definition at line 663 of file Fulltext.php.

References $attribute, $attributeId, _getSearchableAttribute(), _getStoreDate(), and Mage\app().

{
if (!$attribute->getIsSearchable()) {
if ($this->_engine->allowAdvancedIndex()) {
if ($attribute->getAttributeCode() == 'visibility') {
return $value;
} elseif (!($attribute->getIsVisibleInAdvancedSearch()
|| $attribute->getIsFilterable()
|| $attribute->getIsFilterableInSearch()
|| $attribute->getUsedForSortBy())
) {
return null;
}
} else {
return null;
}
}
if ($attribute->usesSource()) {
if ($this->_engine->allowAdvancedIndex()) {
return $value;
}
$attribute->setStoreId($storeId);
$value = $attribute->getSource()->getOptionText($value);
if (is_array($value)) {
$value = implode($this->_separator, $value);
} elseif (empty($value)) {
$inputType = $attribute->getFrontend()->getInputType();
if ($inputType == 'select' || $inputType == 'multiselect') {
return null;
}
}
} elseif ($attribute->getBackendType() == 'datetime') {
$value = $this->_getStoreDate($storeId, $value);
} else {
$inputType = $attribute->getFrontend()->getInputType();
if ($inputType == 'price') {
$value = Mage::app()->getStore($storeId)->roundPrice($value);
}
}
$value = preg_replace("#\s+#siu", ' ', trim(strip_tags($value)));
return $value;
}
_getProductAttributes (   $storeId,
array  $productIds,
array  $attributeTypes 
)
protected

Load product(s) attributes

Parameters
int$storeId
array$productIds
array$attributeTypes
Returns
array

Definition at line 487 of file Fulltext.php.

References $adapter, $attributeIds, $query, $result, $row, $select, $tableName, Mage_Core_Model_Resource_Db_Abstract\_getWriteAdapter(), _unifyField(), array, Mage_Core_Model_Resource_Db_Abstract\getTable(), and Zend_Db_Select\SQL_UNION_ALL.

{
$selects = array();
$ifStoreValue = $adapter->getCheckSql('t_store.value_id > 0', 't_store.value', 't_default.value');
foreach ($attributeTypes as $backendType => $attributeIds) {
$tableName = $this->getTable(array('catalog/product', $backendType));
$selects[] = $adapter->select()
->from(
array('t_default' => $tableName),
array('entity_id', 'attribute_id'))
->joinLeft(
array('t_store' => $tableName),
$adapter->quoteInto(
't_default.entity_id=t_store.entity_id' .
' AND t_default.attribute_id=t_store.attribute_id' .
' AND t_store.store_id=?',
$storeId),
array('value' => $this->_unifyField($ifStoreValue, $backendType)))
->where('t_default.store_id=?', 0)
->where('t_default.attribute_id IN (?)', $attributeIds)
->where('t_default.entity_id IN (?)', $productIds);
}
}
if ($selects) {
$select = $adapter->select()->union($selects, Zend_Db_Select::SQL_UNION_ALL);
$query = $adapter->query($select);
while ($row = $query->fetch()) {
$result[$row['entity_id']][$row['attribute_id']] = $row['value'];
}
}
return $result;
}
_getProductChildIds (   $productId,
  $typeId 
)
protected

Return all product children ids

Parameters
int$productIdProduct Entity Id
string$typeIdSuper Product Link Type
Returns
array

Definition at line 550 of file Fulltext.php.

References $select, _getProductTypeInstance(), Mage_Core_Model_Resource_Db_Abstract\_getReadAdapter(), array, and Mage_Core_Model_Resource_Db_Abstract\getTable().

{
$typeInstance = $this->_getProductTypeInstance($typeId);
$relation = $typeInstance->isComposite()
? $typeInstance->getRelationInfo()
: false;
if ($relation && $relation->getTable() && $relation->getParentFieldName() && $relation->getChildFieldName()) {
$select = $this->_getReadAdapter()->select()
->from(
array('main' => $this->getTable($relation->getTable())),
array($relation->getChildFieldName()))
->where("{$relation->getParentFieldName()}=?", $productId);
if (!is_null($relation->getWhere())) {
$select->where($relation->getWhere());
}
return $this->_getReadAdapter()->fetchCol($select);
}
return null;
}
_getProductEmulator ( )
protected

Retrieve Product Emulator (Varien Object)

Returns
Varien_Object

Definition at line 577 of file Fulltext.php.

{
$productEmulator = new Varien_Object();
$productEmulator->setIdFieldName('entity_id');
return $productEmulator;
}
_getProductTypeInstance (   $typeId)
protected

Retrieve Product Type Instance

Parameters
string$typeId
Returns
Mage_Catalog_Model_Product_Type_Abstract

Definition at line 531 of file Fulltext.php.

References _getProductEmulator(), and Mage\getSingleton().

{
if (!isset($this->_productTypes[$typeId])) {
$productEmulator = $this->_getProductEmulator();
$productEmulator->setTypeId($typeId);
$this->_productTypes[$typeId] = Mage::getSingleton('catalog/product_type')
->factory($productEmulator);
}
return $this->_productTypes[$typeId];
}
_getSearchableAttribute (   $attribute)
protected

Retrieve searchable attribute by Id or code

Parameters
int | string$attribute
Returns
Mage_Eav_Model_Entity_Attribute

Definition at line 443 of file Fulltext.php.

References $attribute, $attributes, _getSearchableAttributes(), Mage_Catalog_Model_Product\ENTITY, and getEavConfig().

{
if (is_numeric($attribute)) {
if (isset($attributes[$attribute])) {
}
} elseif (is_string($attribute)) {
foreach ($attributes as $attributeModel) {
if ($attributeModel->getAttributeCode() == $attribute) {
return $attributeModel;
}
}
}
}
_getSearchableAttributes (   $backendType = null)
protected

Retrieve searchable attributes

Parameters
string$backendType
Returns
array

Definition at line 393 of file Fulltext.php.

References $_searchableAttributes, $attribute, $attributeId, $attributes, array, Mage\dispatchEvent(), Mage_Catalog_Model_Product\ENTITY, getEavConfig(), and Mage\getResourceModel().

{
if (is_null($this->_searchableAttributes)) {
$this->_searchableAttributes = array();
$productAttributeCollection = Mage::getResourceModel('catalog/product_attribute_collection');
if ($this->_engine && $this->_engine->allowAdvancedIndex()) {
$productAttributeCollection->addToIndexFilter(true);
} else {
$productAttributeCollection->addSearchableAttributeFilter();
}
$attributes = $productAttributeCollection->getItems();
Mage::dispatchEvent('catelogsearch_searchable_attributes_load_after', array(
'engine' => $this->_engine,
'attributes' => $attributes
));
$entity = $this->getEavConfig()
->getEntity();
foreach ($attributes as $attribute) {
$attribute->setEntity($entity);
}
$this->_searchableAttributes = $attributes;
}
if (!is_null($backendType)) {
foreach ($this->_searchableAttributes as $attributeId => $attribute) {
if ($attribute->getBackendType() == $backendType) {
}
}
return $attributes;
}
}
_getSearchableProducts (   $storeId,
array  $staticFields,
  $productIds = null,
  $lastProductId = 0,
  $limit = 100 
)
protected

Retrieve searchable products per store

Parameters
int$storeId
array$staticFields
array | int$productIds
int$lastProductId
int$limit
Returns
array

Definition at line 228 of file Fulltext.php.

References $result, $select, Mage_Core_Model_Resource_Db_Abstract\_getWriteAdapter(), Mage\app(), array, Mage_Core_Model_Resource_Db_Abstract\getTable(), and join.

{
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
$writeAdapter = $this->_getWriteAdapter();
$select = $writeAdapter->select()
->useStraightJoin(true)
->from(
array('e' => $this->getTable('catalog/product')),
array_merge(array('entity_id', 'type_id'), $staticFields)
)
->join(
array('website' => $this->getTable('catalog/product_website')),
$writeAdapter->quoteInto(
'website.product_id=e.entity_id AND website.website_id=?',
$websiteId
),
)
->join(
array('stock_status' => $this->getTable('cataloginventory/stock_status')),
$writeAdapter->quoteInto(
'stock_status.product_id=e.entity_id AND stock_status.website_id=?',
$websiteId
),
array('in_stock' => 'stock_status')
);
if (!is_null($productIds)) {
$select->where('e.entity_id IN(?)', $productIds);
}
$select->where('e.entity_id>?', $lastProductId)
->limit($limit)
->order('e.entity_id');
$result = $writeAdapter->fetchAll($select);
return $result;
}
_getStoreDate (   $storeId,
  $date = null 
)
protected

Retrieve Date value for store

Parameters
int$storeId
string$date
Returns
string

Definition at line 752 of file Fulltext.php.

References array, Varien_Date\DATETIME_INTERNAL_FORMAT, Mage\getStoreConfig(), is_empty_date(), Mage_Core_Model_Locale\XML_PATH_DEFAULT_LOCALE, and Mage_Core_Model_Locale\XML_PATH_DEFAULT_TIMEZONE.

{
if (!isset($this->_dates[$storeId])) {
$locale = new Zend_Locale($locale);
$dateObj = new Zend_Date(null, null, $locale);
$dateObj->setTimezone($timezone);
$this->_dates[$storeId] = array($dateObj, $locale->getTranslation(null, 'date', $locale));
}
if (!is_empty_date($date)) {
list($dateObj, $format) = $this->_dates[$storeId];
$dateObj->setDate($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
return $dateObj->toString($format);
}
return null;
}
_prepareProductIndex (   $indexData,
  $productData,
  $storeId 
)
protected

Prepare Fulltext index value for product

Parameters
array$indexData
array$productData
int$storeId
Returns
string

Definition at line 593 of file Fulltext.php.

References $attribute, $attributeId, $data, _getAttributeValue(), _getProductEmulator(), _getProductTypeInstance(), _getSearchableAttribute(), _getSearchableAttributes(), array, and Mage\helper().

{
$index = array();
foreach ($this->_getSearchableAttributes('static') as $attribute) {
$attributeCode = $attribute->getAttributeCode();
if (isset($productData[$attributeCode])) {
$value = $this->_getAttributeValue($attribute->getId(), $productData[$attributeCode], $storeId);
if ($value) {
//For grouped products
if (isset($index[$attributeCode])) {
if (!is_array($index[$attributeCode])) {
$index[$attributeCode] = array($index[$attributeCode]);
}
$index[$attributeCode][] = $value;
}
//For other types of products
else {
$index[$attributeCode] = $value;
}
}
}
}
foreach ($indexData as $entityId => $attributeData) {
foreach ($attributeData as $attributeId => $attributeValue) {
$value = $this->_getAttributeValue($attributeId, $attributeValue, $storeId);
if (!is_null($value) && $value !== false) {
$attributeCode = $this->_getSearchableAttribute($attributeId)->getAttributeCode();
if (isset($index[$attributeCode])) {
$index[$attributeCode][$entityId] = $value;
} else {
$index[$attributeCode] = array($entityId => $value);
}
}
}
}
if (!$this->_engine->allowAdvancedIndex()) {
$product = $this->_getProductEmulator()
->setId($productData['entity_id'])
->setTypeId($productData['type_id'])
->setStoreId($storeId);
$typeInstance = $this->_getProductTypeInstance($productData['type_id']);
if ($data = $typeInstance->getSearchableData($product)) {
$index['options'] = $data;
}
}
if (isset($productData['in_stock'])) {
$index['in_stock'] = $productData['in_stock'];
}
if ($this->_engine) {
return $this->_engine->prepareEntityIndex($index, $this->_separator);
}
return Mage::helper('catalogsearch')->prepareIndexdata($index, $this->_separator);
}
_rebuildStoreIndex (   $storeId,
  $productIds = null 
)
protected

Regenerate search index for specific store

Parameters
int$storeIdStore View Id
int | array$productIdsProduct Entity Id
Returns
Mage_CatalogSearch_Model_Resource_Fulltext

Definition at line 132 of file Fulltext.php.

References $attribute, _getProductAttributes(), _getProductChildIds(), _getSearchableAttribute(), _getSearchableAttributes(), _getSearchableProducts(), _prepareProductIndex(), _saveProductIndexes(), array, cleanIndex(), Mage\getSingleton(), and resetSearchResults().

{
$this->cleanIndex($storeId, $productIds);
// prepare searchable attributes
$staticFields = array();
foreach ($this->_getSearchableAttributes('static') as $attribute) {
$staticFields[] = $attribute->getAttributeCode();
}
$dynamicFields = array(
'int' => array_keys($this->_getSearchableAttributes('int')),
'varchar' => array_keys($this->_getSearchableAttributes('varchar')),
'text' => array_keys($this->_getSearchableAttributes('text')),
'decimal' => array_keys($this->_getSearchableAttributes('decimal')),
'datetime' => array_keys($this->_getSearchableAttributes('datetime')),
);
// status and visibility filter
$visibility = $this->_getSearchableAttribute('visibility');
$status = $this->_getSearchableAttribute('status');
$statusVals = Mage::getSingleton('catalog/product_status')->getVisibleStatusIds();
$allowedVisibilityValues = $this->_engine->getAllowedVisibility();
$lastProductId = 0;
while (true) {
$products = $this->_getSearchableProducts($storeId, $staticFields, $productIds, $lastProductId);
if (!$products) {
break;
}
$productAttributes = array();
$productRelations = array();
foreach ($products as $productData) {
$lastProductId = $productData['entity_id'];
$productAttributes[$productData['entity_id']] = $productData['entity_id'];
$productChildren = $this->_getProductChildIds($productData['entity_id'], $productData['type_id']);
$productRelations[$productData['entity_id']] = $productChildren;
if ($productChildren) {
foreach ($productChildren as $productChildId) {
$productAttributes[$productChildId] = $productChildId;
}
}
}
$productIndexes = array();
$productAttributes = $this->_getProductAttributes($storeId, $productAttributes, $dynamicFields);
foreach ($products as $productData) {
if (!isset($productAttributes[$productData['entity_id']])) {
continue;
}
$productAttr = $productAttributes[$productData['entity_id']];
if (!isset($productAttr[$visibility->getId()])
|| !in_array($productAttr[$visibility->getId()], $allowedVisibilityValues)
) {
continue;
}
if (!isset($productAttr[$status->getId()]) || !in_array($productAttr[$status->getId()], $statusVals)) {
continue;
}
$productIndex = array(
$productData['entity_id'] => $productAttr
);
if ($productChildren = $productRelations[$productData['entity_id']]) {
foreach ($productChildren as $productChildId) {
if (isset($productAttributes[$productChildId])) {
$productIndex[$productChildId] = $productAttributes[$productChildId];
}
}
}
$index = $this->_prepareProductIndex($productIndex, $productData, $storeId);
$productIndexes[$productData['entity_id']] = $index;
}
$this->_saveProductIndexes($storeId, $productIndexes);
}
return $this;
}
_saveProductIndex (   $productId,
  $storeId,
  $index 
)
protected

Save Product index

Parameters
int$productId
int$storeId
string$index
Returns
Mage_CatalogSearch_Model_Resource_Fulltext

Definition at line 720 of file Fulltext.php.

{
if ($this->_engine) {
$this->_engine->saveEntityIndex($productId, $storeId, $index);
}
return $this;
}
_saveProductIndexes (   $storeId,
  $productIndexes 
)
protected

Save Multiply Product indexes

Parameters
int$storeId
array$productIndexes
Returns
Mage_CatalogSearch_Model_Resource_Fulltext

Definition at line 736 of file Fulltext.php.

{
if ($this->_engine) {
$this->_engine->saveEntityIndexes($storeId, $productIndexes);
}
return $this;
}
_unifyField (   $field,
  $backendType = 'varchar' 
)
protected

Returns expresion for field unification

Parameters
string$field
string$backendType
Returns
Zend_Db_Expr

Definition at line 468 of file Fulltext.php.

References Mage_Core_Model_Resource_Db_Abstract\_getReadAdapter(), and Mage\getResourceHelper().

{
if ($backendType == 'datetime') {
$expr = Mage::getResourceHelper('catalogsearch')->castField(
$this->_getReadAdapter()->getDateFormatSql($field, '%Y-%m-%d %H:%i:%s'));
} else {
$expr = Mage::getResourceHelper('catalogsearch')->castField($field);
}
return $expr;
}
cleanIndex (   $storeId = null,
  $productId = null 
)

Delete search index data for store

Parameters
int$storeIdStore View Id
int$productIdProduct Entity Id
Returns
Mage_CatalogSearch_Model_Resource_Fulltext

Definition at line 293 of file Fulltext.php.

{
if ($this->_engine) {
$this->_engine->cleanIndex($storeId, $productId);
}
return $this;
}
getEavConfig ( )

Retrieve EAV Config Singleton

Returns
Mage_Eav_Model_Config

Definition at line 382 of file Fulltext.php.

References Mage\getSingleton().

{
return Mage::getSingleton('eav/config');
}
getSeparator ( )

Return options separator

Returns
string

Definition at line 99 of file Fulltext.php.

References $_separator.

{
}
prepareResult (   $object,
  $queryText,
  $query 
)

Prepare results for query

Parameters
Mage_CatalogSearch_Model_Fulltext$object
string$queryText
Mage_CatalogSearch_Model_Query$query
Returns
Mage_CatalogSearch_Model_Resource_Fulltext

Definition at line 310 of file Fulltext.php.

References $adapter, $fields, $query, $select, $sql, Mage_Core_Model_Resource_Db_Abstract\_getWriteAdapter(), array, Mage_Core_Model_Resource_Db_Abstract\getMainTable(), Mage\getResourceHelper(), Mage_Core_Model_Resource_Db_Abstract\getTable(), Mage\helper(), Varien_Db_Adapter_Interface\INSERT_ON_DUPLICATE, join, Mage_CatalogSearch_Model_Fulltext\SEARCH_TYPE_COMBINE, Mage_CatalogSearch_Model_Fulltext\SEARCH_TYPE_FULLTEXT, and Mage_CatalogSearch_Model_Fulltext\SEARCH_TYPE_LIKE.

{
if (!$query->getIsProcessed()) {
$searchType = $object->getSearchType($query->getStoreId());
$preparedTerms = Mage::getResourceHelper('catalogsearch')
->prepareTerms($queryText, $query->getMaxQueryWords());
$bind = array();
$like = array();
$likeCond = '';
) {
$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';
'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());
) {
$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(),
$adapter->query($sql, $bind);
$query->setIsProcessed(1);
}
return $this;
}
rebuildIndex (   $storeId = null,
  $productIds = null 
)

Regenerate search index for store(s)

Parameters
int | null$storeId
int | array | null$productIds
Returns
Mage_CatalogSearch_Model_Resource_Fulltext

Definition at line 111 of file Fulltext.php.

References $storeIds, _rebuildStoreIndex(), and Mage\app().

{
if (is_null($storeId)) {
$storeIds = array_keys(Mage::app()->getStores());
foreach ($storeIds as $storeId) {
$this->_rebuildStoreIndex($storeId, $productIds);
}
} else {
$this->_rebuildStoreIndex($storeId, $productIds);
}
return $this;
}
resetSearchResults ( )

Reset search results

Returns
Mage_CatalogSearch_Model_Resource_Fulltext

Definition at line 275 of file Fulltext.php.

References $adapter, Mage_Core_Model_Resource_Db_Abstract\_getWriteAdapter(), array, Mage\dispatchEvent(), and Mage_Core_Model_Resource_Db_Abstract\getTable().

{
$adapter->update($this->getTable('catalogsearch/search_query'), array('is_processed' => 0));
$adapter->delete($this->getTable('catalogsearch/result'));
Mage::dispatchEvent('catalogsearch_reset_search_result');
return $this;
}
setAllowTableChanges (   $value = true)

Set whether table changes are allowed

Deprecated:
after 1.6.1.0
Parameters
bool$value
Returns
Mage_CatalogSearch_Model_Resource_Fulltext

Definition at line 787 of file Fulltext.php.

{
$this->_allowTableChanges = $value;
return $this;
}
updateCategoryIndex (   $productIds,
  $categoryIds 
)

Update category products indexes

deprecated after 1.6.2.0

Parameters
array$productIds
array$categoryIds
Returns
Mage_CatalogSearch_Model_Resource_Fulltext

Definition at line 802 of file Fulltext.php.

{
return $this;
}

Member Data Documentation

$_allowTableChanges = true
protected

Definition at line 78 of file Fulltext.php.

$_dates = array()
protected

Definition at line 56 of file Fulltext.php.

$_engine = null
protected

Definition at line 70 of file Fulltext.php.

$_productTypes = array()
protected

Definition at line 63 of file Fulltext.php.

$_searchableAttributes = null
protected

Definition at line 42 of file Fulltext.php.

$_separator = '|'
protected

Definition at line 49 of file Fulltext.php.


The documentation for this class was generated from the following file: