Skip to content

Commit 594aa1c

Browse files
committed
Expose application context factory method
1 parent 1e76a68 commit 594aa1c

File tree

1 file changed

+27
-18
lines changed
  • src/app/code/community/IntegerNet/Solr/Helper

1 file changed

+27
-18
lines changed

src/app/code/community/IntegerNet/Solr/Helper/Factory.php

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,8 @@ public function getProductIndexer()
8787
public function getSolrRequest($requestMode = self::REQUEST_MODE_AUTODETECT)
8888
{
8989
$storeId = Mage::app()->getStore()->getId();
90-
$config = new IntegerNet_Solr_Model_Config_Store($storeId);
91-
if ($config->getGeneralConfig()->isLog()) {
92-
$logger = $this->_getLogger();
93-
if ($logger instanceof IntegerNet_Solr_Helper_Log) {
94-
$logger->setFile('solr.log');
95-
}
96-
} else {
97-
$logger = new NullLogger;
98-
}
99-
10090
$isCategoryPage = Mage::helper('integernet_solr')->page()->isCategoryPage();
101-
$applicationContext = new ApplicationContext(
102-
$this->_getAttributeRepository(),
103-
$config->getResultsConfig(),
104-
$config->getAutosuggestConfig(),
105-
$this->_getEventDispatcher(),
106-
$logger
107-
);
91+
$applicationContext = $this->getApplicationContext();
10892
if (Mage::app()->getLayout() && $block = Mage::app()->getLayout()->getBlock('product_list_toolbar')) {
10993
$pagination = $this->_bridgeFactory->createPaginationToolbar($block);
11094
$applicationContext->setPagination($pagination);
@@ -131,7 +115,7 @@ public function getSolrRequest($requestMode = self::REQUEST_MODE_AUTODETECT)
131115
break;
132116
default:
133117
$applicationContext
134-
->setFuzzyConfig($config->getFuzzySearchConfig())
118+
->setFuzzyConfig($this->getCurrentStoreConfig()->getFuzzySearchConfig())
135119
->setQuery($this->_getSearchTermSynonymHelper());
136120
$factory = new SearchRequestFactory(
137121
$applicationContext,
@@ -197,6 +181,31 @@ protected function _getIndexCategoryRepository()
197181
return $this->_bridgeFactory->getIndexCategoryRepository();
198182
}
199183

184+
/**
185+
* @return ApplicationContext
186+
*/
187+
public function getApplicationContext()
188+
{
189+
$config = $this->getCurrentStoreConfig();
190+
if ($config->getGeneralConfig()->isLog()) {
191+
$logger = $this->_getLogger();
192+
if ($logger instanceof IntegerNet_Solr_Helper_Log) {
193+
$logger->setFile('solr.log');
194+
}
195+
} else {
196+
$logger = new NullLogger;
197+
}
198+
199+
$applicationContext = new ApplicationContext(
200+
$this->_getAttributeRepository(),
201+
$config->getResultsConfig(),
202+
$config->getAutosuggestConfig(),
203+
$this->_getEventDispatcher(),
204+
$logger
205+
);
206+
return $applicationContext;
207+
}
208+
200209
/**
201210
* @return IntegerNet_Solr_Model_Bridge_CategoryRepository
202211
*/

0 commit comments

Comments
 (0)