I´m in the middle of building a search module for Magento, and I´m currently facing a little bit of trouble, specifically regarding applying "Search Types" (Like, Fulltext or Combine) according to the admin configuration.
Here is my working query code:
$searchQuery = 'my search';
$storeId = '1';
$collection = Mage::getResourceModel("catalog/product_collection")->addAttributeToSelect("*");
$query = Mage::helper("catalogSearch")->getQuery();
$query->setStoreId($storeId);
$query->setQueryText($searchQuery);
$collection = $query->getSearchCollection();
$collection->addSearchFilter($searchQuery);
$collection->addAttributeToSelect("*");
$collection->addCategoryIds();
$collection->addFinalPrice();
$collection->addUrlRewrite();
$collection->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
$collection->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
$collection->setPageSize(20);
The only thing I need is to somehow define "Search Types" so it´s either "like", "fulltext" or "combine" depending on the shop configuration.
In other words, if the shop owner has set "Search Type" to "Combine(Like and Fulltext)" - then my query must also be search type "combine".
My problem is that I don´t know where to apply search type in the query.
I hope someone out there can help.
P.S. I normally work in Joomla, so I´m a complete novice when it comes to the Magento framework..