Skip to content

Commit 7c68c24

Browse files
committed
5558 Add version info and handle missing libraries
1 parent edf6920 commit 7c68c24

File tree

7 files changed

+132
-19
lines changed

7 files changed

+132
-19
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class IntegerNet_Solr_Helper_Filter extends Mage_Core_Helper_Abstract
1313
{
1414
public function getFilterPosition()
1515
{
16+
if (!class_exists('CategoryConfig')) {
17+
return '';
18+
}
1619
if( $category = Mage::registry('current_category') ){
1720
switch ( $category->getData('filter_position') ){
1821
case CategoryConfig::FILTER_POSITION_DEFAULT:

src/app/code/community/IntegerNet/Solr/Model/Configuration.php

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function getMessages($storeId = null)
2828
protected function _checkConfiguration($storeId = null)
2929
{
3030
$this->_createGeneralInfoMessages($storeId);
31-
31+
3232
if (!$this->_isStoreEnabled($storeId)) {
3333
return;
3434
}
@@ -75,8 +75,13 @@ protected function _checkConfiguration($storeId = null)
7575
protected function _createGeneralInfoMessages($storeId)
7676
{
7777
$this->_addNoticeMessage(
78-
Mage::helper('integernet_solr')->__('Module version: %s', Mage::getConfig()->getModuleConfig('IntegerNet_Solr')->version)
78+
Mage::helper('integernet_solr')->__('Module version: %s', $this->_getModuleVersion())
79+
);
80+
81+
$this->_addNoticeMessage(
82+
Mage::helper('integernet_solr')->__('Library version: %s', $this->_getLibraryVersion())
7983
);
84+
8085
if (method_exists('Mage', 'getEdition')) {
8186
$this->_addNoticeMessage(
8287
Mage::helper('integernet_solr')->__('Magento version: %s (%s Edition)', Mage::getVersion(), Mage::getEdition())
@@ -155,7 +160,7 @@ protected function _isModuleLicensed()
155160

156161
} else {
157162
if (!Mage::helper('integernet_solr')->module()->isKeyValid(Mage::getStoreConfig('integernet_solr/general/license_key'))) {
158-
163+
159164
if ($installTimestamp = Mage::getStoreConfig('integernet_solr/general/install_date')) {
160165

161166
$diff = time() - $installTimestamp;
@@ -374,4 +379,54 @@ protected function _addNoticeMessage($text)
374379
{
375380
$this->_addMessage($text, 'notice');
376381
}
382+
383+
/**
384+
* @return string
385+
*/
386+
protected function _getModuleVersion()
387+
{
388+
$moduleVersion = Mage::getConfig()->getModuleConfig('IntegerNet_Solr')->version;
389+
if ($versionSuffix = Mage::getConfig()->getModuleConfig('IntegerNet_Solr')->version_suffix) {
390+
$moduleVersion .= ' ' . $versionSuffix;
391+
}
392+
if (Mage::helper('core')->isModuleEnabled('IntegerNet_SolrPro')) {
393+
$proModuleVersion = Mage::getConfig()->getModuleConfig('IntegerNet_SolrPro')->version;
394+
if ($versionSuffix = Mage::getConfig()->getModuleConfig('IntegerNet_SolrPro')->version_suffix) {
395+
$proModuleVersion .= ' ' . $versionSuffix;
396+
}
397+
$moduleVersion .= ' (Pro: ' . $proModuleVersion . ')';
398+
}
399+
return $moduleVersion;
400+
}
401+
402+
/**
403+
* @return string
404+
*/
405+
protected function _getLibraryVersion()
406+
{
407+
if (!class_exists('\IntegerNet\Solr\Util\Version')) {
408+
Mage::throwException(
409+
Mage::helper('integernet_solr')->__(
410+
'The IntegerNet_Solr library is not installed. You can get it from <a href="%s" target="_blank">%s</a>.',
411+
'https://github.com/integer-net/solr-base',
412+
'https://github.com/integer-net/solr-base'
413+
)
414+
);
415+
}
416+
$libraryVersion = \IntegerNet\Solr\Util\Version::getVersion();
417+
418+
if (Mage::helper('core')->isModuleEnabled('IntegerNet_SolrPro')) {
419+
if (!class_exists('\IntegerNet\SolrSuggest\Util\Version')) {
420+
Mage::throwException(
421+
Mage::helper('integernet_solr')->__(
422+
'The IntegerNet_Solr Pro library is not installed. You can get it from <a href="%s" target="_blank">%s</a>.',
423+
'https://github.com/integer-net/solr-pro',
424+
'https://github.com/integer-net/solr-pro'
425+
)
426+
);
427+
}
428+
$libraryVersion .= ' (Pro: ' . \IntegerNet\SolrSuggest\Util\Version::getVersion() . ')';
429+
}
430+
return $libraryVersion;
431+
}
377432
}

src/app/code/community/IntegerNet/Solr/Model/Indexer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,14 @@ protected function _deleteCategoriesIndex($categoryIds)
243243
*/
244244
protected function _useCategoryIndexer()
245245
{
246-
return Mage::getStoreConfigFlag('integernet_solr/category/is_indexer_active');
246+
return Mage::helper('core')->isModuleEnabled('IntegerNet_SolrPro') && Mage::getStoreConfigFlag('integernet_solr/category/is_indexer_active');
247247
}
248248

249249
/**
250250
* @return bool
251251
*/
252252
protected function _useCmsIndexer()
253253
{
254-
return Mage::getStoreConfigFlag('integernet_solr/cms/is_active');
254+
return Mage::helper('core')->isModuleEnabled('IntegerNet_SolrPro') && Mage::getStoreConfigFlag('integernet_solr/cms/is_active');
255255
}
256256
}

src/app/code/community/IntegerNet/Solr/Model/Observer.php

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,33 @@ public function adminhtmlCatalogProductAttributeEditPrepareForm(Varien_Event_Obs
3131
$field->setValue('1.0000');
3232
}
3333

34+
public function controllerActionPredispatchAdminhtmlSystemConfigEdit(Varien_Event_Observer $observer)
35+
{
36+
if ($observer->getControllerAction()->getRequest()->getParam('section') != 'integernet_solr') {
37+
return;
38+
}
39+
if (!class_exists('\IntegerNet\Solr\Util\Version')) {
40+
Mage::throwException(
41+
Mage::helper('integernet_solr')->__(
42+
'The IntegerNet_Solr library is not installed. You can get it from <a href="%s" target="_blank">%s</a>.',
43+
'https://github.com/integer-net/solr-base',
44+
'https://github.com/integer-net/solr-base'
45+
)
46+
);
47+
}
48+
if (Mage::helper('core')->isModuleEnabled('IntegerNet_SolrPro')) {
49+
if (!class_exists('\IntegerNet\SolrSuggest\Util\Version')) {
50+
Mage::throwException(
51+
Mage::helper('integernet_solr')->__(
52+
'The IntegerNet_Solr Pro library is not installed. You can get it from <a href="%s" target="_blank">%s</a>.',
53+
'https://github.com/integer-net/solr-pro',
54+
'https://github.com/integer-net/solr-pro'
55+
)
56+
);
57+
}
58+
}
59+
}
60+
3461
/**
3562
* Add new column "solr_boost" to attribute grid
3663
*
@@ -68,7 +95,32 @@ public function coreBlockAbstractToHtmlBefore(Varien_Event_Observer $observer)
6895
*/
6996
public function controllerActionPredispatchCatalogsearchResultIndex(Varien_Event_Observer $observer)
7097
{
71-
if (Mage::getStoreConfigFlag('integernet_solr/general/is_active') && !$this->_getPingResult()) {
98+
if (!Mage::getStoreConfigFlag('integernet_solr/general/is_active')) {
99+
return;
100+
}
101+
102+
if (!class_exists('\IntegerNet\Solr\Util\Version')) {
103+
Mage::throwException(
104+
Mage::helper('integernet_solr')->__(
105+
'The IntegerNet_Solr library is not installed. You can get it from <a href="%s" target="_blank">%s</a>.',
106+
'https://github.com/integer-net/solr-base',
107+
'https://github.com/integer-net/solr-base'
108+
)
109+
);
110+
}
111+
if (Mage::helper('core')->isModuleEnabled('IntegerNet_SolrPro')) {
112+
if (!class_exists('\IntegerNet\SolrSuggest\Util\Version')) {
113+
Mage::throwException(
114+
Mage::helper('integernet_solr')->__(
115+
'The IntegerNet_Solr Pro library is not installed. You can get it from <a href="%s" target="_blank">%s</a>.',
116+
'https://github.com/integer-net/solr-pro',
117+
'https://github.com/integer-net/solr-pro'
118+
)
119+
);
120+
}
121+
}
122+
123+
if (!$this->_getPingResult()) {
72124
Mage::app()->getStore()->setConfig('integernet_solr/general/is_active', 0);
73125
}
74126

src/app/code/community/IntegerNet/Solr/etc/config.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<config>
33
<modules>
44
<IntegerNet_Solr>
5-
<version>1.6.0.5</version>
5+
<version>1.7.0.0</version>
6+
<version_suffix>beta1</version_suffix>
67
</IntegerNet_Solr>
78
</modules>
89
<global>
@@ -131,16 +132,6 @@
131132
</setup>
132133
</integernet_solr_setup>
133134
</resources>
134-
135-
<template>
136-
<email>
137-
<integernet_solr_connection_check_email_template translate="label" module="integernet_solr">
138-
<label>Solr Connection Check Notification</label>
139-
<file>integernet_solr/connection_check.txt</file>
140-
<type>text</type>
141-
</integernet_solr_connection_check_email_template>
142-
</email>
143-
</template>
144135
</global>
145136

146137
<adminhtml>
@@ -172,6 +163,15 @@
172163
</integernet_solr>
173164
</observers>
174165
</adminhtml_catalog_product_attribute_edit_prepare_form>
166+
<controller_action_predispatch_adminhtml_system_config_edit>
167+
<observers>
168+
<integernet_solr>
169+
<type>singleton</type>
170+
<class>integernet_solr/observer</class>
171+
<method>controllerActionPredispatchAdminhtmlSystemConfigEdit</method>
172+
</integernet_solr>
173+
</observers>
174+
</controller_action_predispatch_adminhtml_system_config_edit>
175175
</events>
176176
</adminhtml>
177177

src/app/locale/de_DE/IntegerNet_Solr.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
"Maybe the configuration files are not installed correctly on the Solr swap core.","Möglicherweise sind die Konfigurationsdateien nicht korrekt auf dem Austausch-Core des Solr-Servers eingespielt."
7676
"You can get a meaningful error message from the tab ""Logging"" on the Solr Admin Interface.","Sie können eine aussagekräftige Fehlermeldung im Tab ""Logging"" der Solr-Adminoberfläche einsehen."
7777
"Module version: %s","Modul-Version: %s"
78+
"Library version: %s","Library-Version: %s"
79+
"The IntegerNet_Solr library is not installed. You can get it from <a href=""%s"" target=""_blank"">%s</a>.","Die IntegerNet_Solr-Bibliothek ist nicht installiert. Sie erhalten sie unter <a href=""%s"" target=""_blank"">%s</a>."
80+
"The IntegerNet_Solr Pro library is not installed. You can get it from <a href=""%s"" target=""_blank"">%s</a>.","Die IntegerNet_Solr-Pro-Bibliothek ist nicht installiert. Sie erhalten sie unter <a href=""%s"" target=""_blank"">%s</a>."
7881
"Magento version: %s","Magento-Version: %s"
7982
"Magento version: %s (%s Edition)","Magento-Version: %s (%s Edition)"
8083
"Solr version: %s","Solr-Version: %s"

src/shell/integernet-solr.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ protected function _getDefaultEntityTypes()
139139
*/
140140
protected function _useCategoryIndexer()
141141
{
142-
return Mage::getStoreConfigFlag('integernet_solr/category/is_indexer_active');
142+
return Mage::helper('core')->isModuleEnabled('IntegerNet_SolrPro') && Mage::getStoreConfigFlag('integernet_solr/category/is_indexer_active');
143143
}
144144

145145
/**
146146
* @return bool
147147
*/
148148
protected function _useCmsIndexer()
149149
{
150-
return Mage::getStoreConfigFlag('integernet_solr/cms/is_active');
150+
return Mage::helper('core')->isModuleEnabled('IntegerNet_SolrPro') && Mage::getStoreConfigFlag('integernet_solr/cms/is_active');
151151
}
152152
}
153153

0 commit comments

Comments
 (0)