slisearch - Version 3.0.5

Version Notes

Changes since last release:
* Fixed issues related to cron job creation
* Improved format of exported feed
* Smarter feed encoding capability
* Optimized feed processing
* Fixed potential security issue
* Improved email notification format
* Improved support for tiered and group pricing
* Better support for required attributes
* Improved logging capability

Download this release

Release Info

Developer Platform support
Extension slisearch
Version 3.0.5
Comparing to
See all releases


Code changes from version 2.1.4 to 3.0.5

Files changed (84) hide show
  1. app/code/community/SLI/Search/Block/Search/Form/Mini.php +47 -0
  2. app/code/community/SLI/Search/Block/Search/Js/Bottom.php +46 -0
  3. app/code/community/SLI/Search/Block/Search/Js/Top.php +45 -0
  4. app/code/{local → community}/SLI/Search/Block/System/Config/Form.php +28 -27
  5. app/code/community/SLI/Search/Block/System/Config/Form/Field/Minigrid.php +147 -0
  6. app/code/community/SLI/Search/Block/System/Config/Form/Field/Version.php +42 -0
  7. app/code/community/SLI/Search/Block/System/Config/Frontend/Feed/Generate.php +104 -0
  8. app/code/community/SLI/Search/Block/System/Config/Frontend/Feed/Generate/Js.php +53 -0
  9. app/code/community/SLI/Search/Block/System/Config/Frontend/Feed/Next.php +74 -0
  10. app/code/community/SLI/Search/Exception.php +34 -0
  11. app/code/{local → community}/SLI/Search/Helper/Data.php +578 -602
  12. app/code/community/SLI/Search/Helper/Feed.php +275 -0
  13. app/code/community/SLI/Search/Helper/FeedLogger.php +188 -0
  14. app/code/community/SLI/Search/Helper/XmlWriter.php +129 -0
  15. app/code/community/SLI/Search/Model/Cron.php +87 -0
  16. app/code/community/SLI/Search/Model/Email.php +63 -0
  17. app/code/community/SLI/Search/Model/FeedGenerator.php +82 -0
  18. app/code/community/SLI/Search/Model/FeedManager.php +181 -0
  19. app/code/community/SLI/Search/Model/Generators/AttributeGenerator.php +133 -0
  20. app/code/community/SLI/Search/Model/Generators/CategoryGenerator.php +94 -0
  21. app/code/community/SLI/Search/Model/Generators/DemoGenerator.php +89 -0
  22. app/code/community/SLI/Search/Model/Generators/GeneratorContext.php +180 -0
  23. app/code/community/SLI/Search/Model/Generators/GeneratorInterface.php +40 -0
  24. app/code/community/SLI/Search/Model/Generators/MetaGenerator.php +71 -0
  25. app/code/community/SLI/Search/Model/Generators/PriceGenerator.php +247 -0
  26. app/code/community/SLI/Search/Model/Generators/ProductGenerator.php +237 -0
  27. app/code/community/SLI/Search/Model/Resource/FeedManager.php +69 -0
  28. app/code/community/SLI/Search/Model/System/Config/Backend/Cron.php +79 -0
  29. app/code/community/SLI/Search/Model/System/Config/Backend/Loglevel.php +60 -0
  30. app/code/{local → community}/SLI/Search/Model/System/Config/Backend/Minigrid.php +94 -79
  31. app/code/community/SLI/Search/Model/System/Config/Source/Attributes.php +151 -0
  32. app/code/community/SLI/Search/Model/System/Config/Source/Cron/Frequency.php +74 -0
  33. app/code/community/SLI/Search/Model/System/Config/Source/Emailsetting.php +62 -0
  34. app/code/community/SLI/Search/Model/System/Config/Source/Minigrid/Abstract.php +62 -0
  35. app/code/community/SLI/Search/Model/System/Config/Source/Minigrid/Attributes.php +49 -0
  36. app/code/community/SLI/Search/NotificationException.php +34 -0
  37. app/code/community/SLI/Search/controllers/Adminhtml/SliController.php +84 -0
  38. app/code/community/SLI/Search/controllers/ApiController.php +65 -0
  39. app/code/community/SLI/Search/controllers/SearchController.php +46 -0
  40. app/code/community/SLI/Search/etc/adminhtml.xml +59 -0
  41. app/code/{local → community}/SLI/Search/etc/config.xml +164 -133
  42. app/code/{local → community}/SLI/Search/etc/system.xml +373 -390
  43. app/code/community/SLI/Search/sql/sli_search_setup/install-1.0.0.php +45 -0
  44. app/code/local/SLI/Search/Block/Search/Form/Mini.php +0 -71
  45. app/code/local/SLI/Search/Block/Search/Js/Bottom.php +0 -33
  46. app/code/local/SLI/Search/Block/Search/Js/Top.php +0 -33
  47. app/code/local/SLI/Search/Block/System/Config/Form/Field/Minigrid.php +0 -134
  48. app/code/local/SLI/Search/Block/System/Config/Form/Field/Minigrid/Js.php +0 -211
  49. app/code/local/SLI/Search/Block/System/Config/Form/Field/Version.php +0 -30
  50. app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Generate.php +0 -82
  51. app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Generate/Js.php +0 -42
  52. app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Next.php +0 -57
  53. app/code/local/SLI/Search/Block/Widget/Minigrid/Form.php +0 -153
  54. app/code/local/SLI/Search/Exception.php +0 -20
  55. app/code/local/SLI/Search/Helper/Feed.php +0 -169
  56. app/code/local/SLI/Search/Model/Cron.php +0 -56
  57. app/code/local/SLI/Search/Model/Email.php +0 -64
  58. app/code/local/SLI/Search/Model/Feed.php +0 -78
  59. app/code/local/SLI/Search/Model/System/Config/Backend/Cron.php +0 -62
  60. app/code/local/SLI/Search/Model/System/Config/Backend/Enabledsetting.php +0 -43
  61. app/code/local/SLI/Search/Model/System/Config/Backend/Loglevel.php +0 -43
  62. app/code/local/SLI/Search/Model/System/Config/Source/Attributes.php +0 -132
  63. app/code/local/SLI/Search/Model/System/Config/Source/Cron/Frequency.php +0 -64
  64. app/code/local/SLI/Search/Model/System/Config/Source/Emailsetting.php +0 -49
  65. app/code/local/SLI/Search/Model/System/Config/Source/Minigrid/Abstract.php +0 -50
  66. app/code/local/SLI/Search/Model/System/Config/Source/Minigrid/Attributes.php +0 -36
  67. app/code/local/SLI/Search/NotificationException.php +0 -23
  68. app/code/local/SLI/Search/controllers/ApiController.php +0 -53
  69. app/code/local/SLI/Search/controllers/SearchController.php +0 -103
  70. app/code/local/SLI/Search/doc/changelog.txt +0 -2
  71. app/code/local/SLI/Search/doc/design.txt +0 -84
  72. app/code/local/SLI/Search/doc/makeTar.txt +0 -18
  73. app/code/local/SLI/Search/dropdown.sql +0 -59
  74. app/code/local/SLI/Search/etc/adminhtml.xml +0 -42
  75. app/code/local/SLI/Search/sql/sli_search_setup/install-1.0.0.php +0 -61
  76. app/design/adminhtml/default/default/template/sli/search/email/messages.phtml +40 -0
  77. app/design/adminhtml/default/default/template/sli/search/sysconfig/ba_minigrid_js.phtml +219 -0
  78. app/design/adminhtml/default/default/template/sli/search/sysconfig/generate/js.phtml +56 -22
  79. app/design/frontend/base/default/layout/sli/search.xml +65 -51
  80. app/design/frontend/base/default/template/sli/search/form.mini.phtml +0 -46
  81. app/etc/modules/SLI_Search.xml +13 -13
  82. app/locale/en_US/template/email/sli/feed_email_template.html +27 -0
  83. package.xml +15 -10
  84. shell/sli/feed.php +102 -74
app/code/community/SLI/Search/Block/Search/Form/Mini.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Search Mini Form block.
27
+ * Replaces the Search form with the contents of the Form Code block in the UI
28
+ *
29
+ * @package SLI
30
+ * @subpackage Search
31
+ */
32
+ class SLI_Search_Block_Search_Form_Mini extends Mage_Core_Block_Template
33
+ {
34
+ /**
35
+ * Use the default SLI layout or the custom layout from the DB
36
+ * Retrieve the form code from the database for this site
37
+ *
38
+ * @return string
39
+ */
40
+ protected function _toHtml()
41
+ {
42
+ /* @var $helper SLI_Search_Helper_Data */
43
+ $helper = Mage::helper('sli_search');
44
+
45
+ return $helper->getFormData();
46
+ }
47
+ }
app/code/community/SLI/Search/Block/Search/Js/Bottom.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Bottom javascript block for before body end. Includes javascript from
27
+ * system configuration
28
+ *
29
+ * @package SLI
30
+ * @subpackage Search
31
+ */
32
+ class SLI_Search_Block_Search_JS_Bottom extends Mage_Core_Block_Text
33
+ {
34
+ /**
35
+ * Set text to be javascript from system configuration
36
+ */
37
+ protected function _construct()
38
+ {
39
+ parent::_construct();
40
+ /* @var $helper SLI_Search_Helper_Data */
41
+ $helper = Mage::helper('sli_search');
42
+ if ($helper->isFormEnabled(Mage::app()->getStore()->getId())) {
43
+ $this->addText($helper->getFooterJs());
44
+ }
45
+ }
46
+ }
app/code/community/SLI/Search/Block/Search/Js/Top.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Top javascript included in head block
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Block_Search_JS_Top extends Mage_Core_Block_Text
32
+ {
33
+ /**
34
+ * Set text to be javascript from system configuration
35
+ */
36
+ protected function _construct()
37
+ {
38
+ parent::_construct();
39
+ /* @var $helper SLI_Search_Helper_Data */
40
+ $helper = Mage::helper('sli_search');
41
+ if ($helper->isFormEnabled(Mage::app()->getStore()->getId())) {
42
+ $this->addText($helper->getHeaderJs());
43
+ }
44
+ }
45
+ }
app/code/{local → community}/SLI/Search/Block/System/Config/Form.php RENAMED
@@ -1,27 +1,28 @@
1
- <?php
2
- /**
3
- * System config form
4
- * This form overwrites the System Config form block in order
5
- * to add the grid as a frontend type to forms in the system
6
- * config.
7
- *
8
- * @package SLI
9
- * @subpackage Search
10
- * @author Blue Acorn: Brys Sepulveda
11
- */
12
- class SLI_Search_Block_System_Config_Form extends Mage_Adminhtml_Block_System_Config_Form {
13
-
14
- /**
15
- * Add the additional grid type as a viable type on the form
16
- *
17
- * @return array
18
- */
19
- protected function _getAdditionalElementTypes()
20
- {
21
- $types = parent::_getAdditionalElementTypes();
22
- $types["version"] = Mage::getConfig()->getBlockClassName('sli_search/system_config_form_field_version');
23
- $types["minigrid"] = Mage::getConfig()->getBlockClassName("sli_search/system_config_form_field_minigrid");
24
- return $types;
25
- }
26
-
27
- }
 
1
+ <?php
2
+
3
+ /**
4
+ * System config form
5
+ * This form overwrites the System Config form block in order
6
+ * to add the grid as a frontend type to forms in the system
7
+ * config.
8
+ *
9
+ * @package SLI
10
+ * @subpackage Search
11
+ * @author Blue Acorn: Brys Sepulveda
12
+ */
13
+ class SLI_Search_Block_System_Config_Form extends Mage_Adminhtml_Block_System_Config_Form
14
+ {
15
+ /**
16
+ * Add the additional grid type as a viable type on the form
17
+ *
18
+ * @return array
19
+ */
20
+ protected function _getAdditionalElementTypes()
21
+ {
22
+ $types = parent::_getAdditionalElementTypes();
23
+ $types["version"] = Mage::getConfig()->getBlockClassName('sli_search/system_config_form_field_version');
24
+ $types["minigrid"] = Mage::getConfig()->getBlockClassName("sli_search/system_config_form_field_minigrid");
25
+
26
+ return $types;
27
+ }
28
+ }
app/code/community/SLI/Search/Block/System/Config/Form/Field/Minigrid.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Minigrid system config field element type
27
+ * Displays the minigid in a usable backend fashion. Requires a source
28
+ * model to properly display;
29
+ *
30
+ * @package SLI
31
+ * @subpackage Search
32
+ */
33
+ class SLI_Search_Block_System_Config_Form_Field_Minigrid extends Varien_Data_Form_Element_Abstract
34
+ {
35
+ /**
36
+ * Add the js block which contains the js that makes
37
+ * the mini grids work only once to the admin js
38
+ * block
39
+ */
40
+ protected function addJsIfNecessary()
41
+ {
42
+ $alias = 'ba.minigrid.js';
43
+ $block = Mage::app()->getLayout()
44
+ ->createBlock('core/template', $alias)
45
+ ->setTemplate('sli/search/sysconfig/ba_minigrid_js.phtml');
46
+
47
+ $js = Mage::app()->getLayout()->getBlock('js');
48
+ if (!$js->getChild($alias)) {
49
+ Mage::app()->getLayout()->getBlock('js')->append($block, $alias);
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Default values of field array. Field array defines
55
+ * the fields on the grid.
56
+ *
57
+ * @return array
58
+ */
59
+ protected function getDefaultSourceValues()
60
+ {
61
+ return array(
62
+ "{$this->getLabel()}" => array("width" => "98%", "type" => "text"),
63
+ );
64
+ }
65
+
66
+ /**
67
+ * Element rendererd html. Called by getDefaultHtml which combines
68
+ * the label html with this html to render the full element. Specifically,
69
+ * this is the html to render the field input
70
+ *
71
+ * NOTE: We are breaking php runtime to fall into html directly
72
+ * in this function instead of using a template to keep this module
73
+ * succinct, contained, and to avoid rendering html/js via strings
74
+ * as is the convention for form and form element renderers.
75
+ *
76
+ * Providing optional parameters for required inputs if this block is being
77
+ * used outside of its normal use case (such as outside of system config)
78
+ *
79
+ * @param string $tableId
80
+ * @param string $fieldName
81
+ * @param array $fields
82
+ * @param array $rowData
83
+ *
84
+ * @return string
85
+ */
86
+ public function getElementHtml($tableId = null, $fieldName = null, $fields = array(), $rowData = array())
87
+ {
88
+ $this->addJsIfNecessary();
89
+
90
+ $label = $this->getLabel();
91
+ $tableId = ($tableId) ? $tableId : $this->getHtmlId();
92
+ $fieldName = ($fieldName) ? $fieldName : $this->getName();
93
+
94
+ $fields = (empty($fields)) ? $this->getValues() : $fields;
95
+ if (!$fields) {
96
+ $fields = $this->getDefaultSourceValues();
97
+ }
98
+ $rowData = (empty($rowData)) ? $this->getValue() : $rowData;
99
+ if (!is_array($rowData)) {
100
+ $rowData = array();
101
+ }
102
+
103
+ ob_start();
104
+ ?>
105
+ <div class="grid">
106
+ <table id="ba-<?php echo $tableId ?>-table" class="option-header" cellpadding="0" cellspacing="0">
107
+ <thead>
108
+ <tr class="headings">
109
+ <?php foreach ($fields as $header => $def) : ?>
110
+ <th style="width:<?php echo $def['width'] ?>"><?php echo ucwords(
111
+ str_replace("_", " ", $header)
112
+ ) ?></th>
113
+ <?php endforeach; ?>
114
+ <th style="width:30px">Remove</th>
115
+ </tr>
116
+ </thead>
117
+ <tbody id="ba-<?php echo $tableId ?>">
118
+ </tbody>
119
+ <tfoot>
120
+ <tr>
121
+ <td colspan="<?php echo count($fields) + 1 ?>" class="a-right">
122
+ <button id="ba-add-<?php echo $tableId ?>" class="scalable add" type="button">
123
+ <span>Add <?php echo ucwords($label) ?></span></button>
124
+ </td>
125
+ </tr>
126
+ </tfoot>
127
+ </table>
128
+ <input type="text" class="validate-minigrid-attributes" style="opacity:0" value="">
129
+ </div>
130
+ <style>
131
+ select.validation-failed {
132
+ border: 1px solid red;
133
+ }
134
+ </style>
135
+ <script type="text/javascript">
136
+ Event.observe(window, 'load', function () {
137
+ (new baMiniGrid()).init($("ba-<?php echo $tableId?>"),
138
+ $('ba-add-<?php echo $tableId?>'),
139
+ "<?php echo $fieldName?>",
140
+ <?php echo json_encode($rowData)?>,
141
+ <?php echo json_encode($fields)?>);
142
+ });
143
+ </script>
144
+ <?php
145
+ return ob_get_clean();
146
+ }
147
+ }
app/code/community/SLI/Search/Block/System/Config/Form/Field/Version.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Custom field to display the version number of the SLI module in the system configuration
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Block_System_Config_Form_Field_Version extends Varien_Data_Form_Element_Abstract
32
+ {
33
+ public function getElementHtml()
34
+ {
35
+ /* @var $modules Mage_Core_Model_Config_Element */
36
+
37
+ $modules = Mage::getConfig()->getNode('modules')->children();
38
+ $info = $modules->SLI_Search->asArray();
39
+
40
+ return isset($info['version']) ? $info['version'] : '';
41
+ }
42
+ }
app/code/community/SLI/Search/Block/System/Config/Frontend/Feed/Generate.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Source renderer for product attributes data.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Block_System_Config_Frontend_Feed_Generate extends Mage_Adminhtml_Block_System_Config_Form_Field
32
+ {
33
+ protected $_buttonId = "generate_feed_button";
34
+
35
+ /**
36
+ * Programmatically include the generate feed javascript in the adminhtml
37
+ * JS block.
38
+ *
39
+ * @return Mage_Core_Block_Abstract
40
+ */
41
+ protected function _prepareLayout()
42
+ {
43
+ $block = $this->getLayout()->createBlock("sli_search/system_config_frontend_feed_generate_js");
44
+ $block->setData("button_id", $this->_buttonId);
45
+
46
+ $this->getLayout()->getBlock('js')->append($block);
47
+
48
+ return parent::_prepareLayout();
49
+ }
50
+
51
+ /**
52
+ * Return element html
53
+ *
54
+ * @param Varien_Data_Form_Element_Abstract $element
55
+ *
56
+ * @return string
57
+ */
58
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
59
+ {
60
+ $button = $this->getButtonHtml();
61
+
62
+ $notice = "";
63
+ if ($this->feedGenIsLocked()) {
64
+ $notice = "<p id='sli_display_msg' class='note'>" . Mage::helper("sli_search/feed")->getAjaxNotice()
65
+ . "</p>";
66
+ }
67
+
68
+ return $button . $notice;
69
+ }
70
+
71
+ /**
72
+ * Generate button html for the feed button
73
+ *
74
+ * @return string
75
+ */
76
+ public function getButtonHtml()
77
+ {
78
+ /** @var Mage_Adminhtml_Block_Widget_Button $button */
79
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
80
+ ->setData(
81
+ array(
82
+ 'id' => $this->_buttonId,
83
+ 'label' => $this->helper('sli_search')->__('Generate Feed'),
84
+ 'onclick' => 'javascript:sliSearch.generateFeed(); return false;'
85
+ )
86
+ );
87
+
88
+ if ($this->feedGenIsLocked()) {
89
+ $button->setDisabled(true);
90
+ }
91
+
92
+ return $button->toHtml();
93
+ }
94
+
95
+ /**
96
+ * Check to see if there are any locks for any feeds at the moment
97
+ *
98
+ * @return boolean
99
+ */
100
+ protected function feedGenIsLocked()
101
+ {
102
+ return Mage::helper('sli_search/feed')->feedLocksExist();
103
+ }
104
+ }
app/code/community/SLI/Search/Block/System/Config/Frontend/Feed/Generate/Js.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Javascript block for adminhtml JS text_list block to add functionality to the
27
+ * generate feed button on the system configuration for Feed Settings.
28
+ *
29
+ * @package SLI
30
+ * @subpackage Search
31
+ */
32
+ class SLI_Search_Block_System_Config_Frontend_Feed_Generate_Js extends Mage_Adminhtml_Block_Template
33
+ {
34
+ /**
35
+ * Sets javascript template to be included in the adminhtml js text_list block
36
+ */
37
+ protected function _construct()
38
+ {
39
+ parent::_construct();
40
+
41
+ $this->setTemplate('sli/search/sysconfig/generate/js.phtml');
42
+ }
43
+
44
+ /**
45
+ * Returns the run all feeds async url
46
+ *
47
+ * @return string
48
+ */
49
+ public function getGenerateUrl()
50
+ {
51
+ return Mage::helper("adminhtml")->getUrl('adminhtml/sli/generateFeeds/');
52
+ }
53
+ }
app/code/community/SLI/Search/Block/System/Config/Frontend/Feed/Next.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license � please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Determines next time the feed cron will run.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Block_System_Config_Frontend_Feed_Next extends Mage_Adminhtml_Block_System_Config_Form_Field
32
+ {
33
+ /**
34
+ * Renders the next scheduled cron time first from the cron table and then
35
+ * from the set cron time if Magento hasnt scheduled it.
36
+ *
37
+ * @param Varien_Data_Form_Element_Abstract $element
38
+ *
39
+ * @return Zend_Date
40
+ */
41
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
42
+ {
43
+ /** @var SLI_Search_Helper_Data $dataHelper */
44
+ $dataHelper = Mage::helper('sli_search/data');
45
+
46
+ if (!$dataHelper->isCronEnabled()) {
47
+ return 'Disabled';
48
+ }
49
+
50
+ /** @var Mage_Cron_Model_Resource_Schedule_Collection $cronScheduleCollection */
51
+ $cronScheduleCollection = Mage::getResourceModel('cron/schedule_collection');
52
+ // find pending feed schedules
53
+ $cronScheduleCollection
54
+ ->addFieldToFilter('job_code', SLI_Search_Model_Cron::JOB_CODE_GENERATE_FEEDS)
55
+ ->addFieldToFilter('status', Mage_Cron_Model_Schedule::STATUS_PENDING);
56
+ // limit to lowest scheduled_at datet
57
+ $cronScheduleCollection
58
+ ->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns(array('scheduled_at' => 'min(scheduled_at)'));
59
+
60
+ // next scheduled date
61
+ $scheduledAt = $cronScheduleCollection->getFirstItem()->getData('scheduled_at');
62
+
63
+ // if nothing scheduled, calculate based on our cron config
64
+ if ($scheduledAt) {
65
+ /** @var Mage_Core_Model_Locale $locale */
66
+ $locale = Mage::app()->getLocale();
67
+ $scheduledAt = $locale->storeDate(null, $scheduledAt, true);
68
+ } else {
69
+ $scheduledAt = $dataHelper->getNextRunDateFromCronTime();
70
+ }
71
+
72
+ return $scheduledAt;
73
+ }
74
+ }
app/code/community/SLI/Search/Exception.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Namespaced exception for the SLI Search
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Exception extends Mage_Core_Exception
32
+ {
33
+
34
+ }
app/code/{local → community}/SLI/Search/Helper/Data.php RENAMED
@@ -1,602 +1,578 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Translation and systems configuration helper
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Helper_Data extends Mage_Core_Helper_Abstract {
20
-
21
- const SECTION = "sli_search/";
22
- const GENERAL_GROUP = "general/";
23
- const FEED_GROUP = "feed/";
24
- const FTP_GROUP = "ftp/";
25
- const FORM_GROUP = "form/";
26
- const JS_GROUP = "js/";
27
- const CRON_GROUP = "cron/";
28
- const ATTR_GROUP = "attributes/";
29
- const DEFAULT_ATTRS = "default_attributes/";
30
- const ENABLED = 1;
31
-
32
- /**
33
- * Returns true/false on whether or not the module is enabled
34
- *
35
- * @return boolean
36
- */
37
- public function isFormEnabled($store_id = 0) {
38
- $formEnabled = Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::GENERAL_GROUP . 'form_enabled');
39
- return (bool) ($formEnabled == self::ENABLED) ? 1 : 0;
40
- }
41
-
42
- /**
43
- * Returns true/false on whether or not the feed is enabled
44
- *
45
- * @return boolean
46
- */
47
- public function isFeedEnabled($store_id = 0) {
48
- $feedEnabled = Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::GENERAL_GROUP . 'feed_enabled');
49
- return (bool) ($feedEnabled == self::ENABLED) ? 1 : 0;
50
- }
51
-
52
- /**
53
- * Returns true/false on whether or not the price feed is enabled
54
- *
55
- * @return boolean
56
- */
57
- public function isPriceFeedEnabled($store_id = 0) {
58
- return (bool) Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::GENERAL_GROUP . 'price_feed');
59
- }
60
-
61
- /**
62
- * Returns an integer which is the log level
63
- *
64
- * @return int
65
- */
66
- public function getLogLevel($store_id = 0) {
67
- return (int) Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::GENERAL_GROUP . 'log_level');
68
- }
69
-
70
- /**
71
- * Return the email setting
72
- *
73
- * @return int
74
- */
75
- public function getEmailSetting() {
76
- return Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . 'email_setting');
77
- }
78
-
79
- /**
80
- * Return the email address of the person to send to
81
- *
82
- * @return string
83
- */
84
- public function getFeedEmail() {
85
- return Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "emailto");
86
- }
87
-
88
- /**
89
- * Returns true/false on whether or not we should backup feeds
90
- *
91
- * @return boolean
92
- */
93
- public function isBackupFeed() {
94
- return (bool) Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "backup");
95
- }
96
-
97
- /**
98
- * Returns true/false on whether or not we should drop tables
99
- *
100
- * @return boolean
101
- */
102
- public function isDataPersistent() {
103
- return (bool) Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "persistent_data");
104
- }
105
-
106
- /**
107
- * Returns true/false on whether or not to include out of stock items in feed
108
- *
109
- * @return boolean
110
- */
111
- public function isIncludeOutOfStockItems($store_id = 0) {
112
- return (bool) Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::FEED_GROUP . "stockstatus");
113
- }
114
-
115
- /**
116
- * Returns true/false on whether or not to include disabled categories in feed
117
- *
118
- * @return boolean
119
- */
120
- public function isIncludeDisabledCategories($store_id = 0) {
121
- return (bool) Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::FEED_GROUP . "categorystatus");
122
- }
123
-
124
- /**
125
- * Returns true/false on whether or not we should drop tables;
126
- *
127
- * @return int
128
- */
129
- public function getWriteBatch() {
130
- return (int) Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "write_batch");
131
- }
132
-
133
- /**
134
- * Returns true/false on whether or not we should use ftp on feed generation
135
- *
136
- * @return boolean
137
- */
138
- public function isUseFtp() {
139
- return (bool) Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "enabled");
140
- }
141
-
142
- /**
143
- * Returns the user by which to log into the ftp server
144
- *
145
- * @return string
146
- */
147
- public function getFtpUser() {
148
- return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "user");
149
- }
150
-
151
- /**
152
- * Returns the password for the user to log into the ftp server
153
- *
154
- * @return string
155
- */
156
- public function getFtpPass() {
157
- return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "pass");
158
- }
159
-
160
- /**
161
- * Returns the host that we will log into via ftp
162
- *
163
- * @return string
164
- */
165
- public function getFtpHost() {
166
- return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "host");
167
- }
168
-
169
- /**
170
- * Returns the path on the ftp server that we will drop the feed into
171
- *
172
- * @return string
173
- */
174
- public function getFtpPath() {
175
- return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "path");
176
- }
177
-
178
- /**
179
- * Returns the javascript that goes into the html head block
180
- *
181
- * @return string
182
- */
183
- public function getHeaderJs() {
184
- return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "header");
185
- }
186
-
187
- /**
188
- * Returns the javascript that goes into the before_body_end
189
- *
190
- * @return string
191
- */
192
- public function getFooterJs() {
193
- return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "footer");
194
- }
195
-
196
- /**
197
- * Returns the javascript that goes under the mini search form to provide
198
- * autocomplete features from SLI
199
- *
200
- * @return string
201
- */
202
- public function getAutocompleteJs() {
203
- return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "autocomplete");
204
- }
205
-
206
- /**
207
- * Returns the external search domain to the SLI externally hosted search page
208
- *
209
- * @return string
210
- */
211
- public function getSearchDomain() {
212
- return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "domain");
213
- }
214
-
215
- /**
216
- * Returns the email to send notifications to when the cron runs
217
- *
218
- * @return string
219
- */
220
- public function getCronEmail() {
221
- return Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "email");
222
- }
223
-
224
- /**
225
- * Returns the frequency that the cron should run.
226
- *
227
- * @return string
228
- */
229
- public function getCronFrequency() {
230
- return Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "frequency");
231
- }
232
-
233
- /**
234
- * Returns the time of day that the cron should run at.
235
- *
236
- * @return string
237
- */
238
- public function getCronTime() {
239
- return Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "time");
240
- }
241
-
242
- /**
243
- * Returns an array of attributes to be included in the feed
244
- *
245
- * @return array
246
- */
247
- public function getAttributes() {
248
- $attrs = Mage::getStoreConfig(self::SECTION . self::ATTR_GROUP . "attributes", Mage::app()->getStore()->getId());
249
- $default_attributes = Mage::getStoreConfig(self::SECTION . self::DEFAULT_ATTRS . "attributes", Mage::app()->getStore()->getId());
250
-
251
- $defaults = array();
252
-
253
- foreach(explode(',',$default_attributes) as $attr) {
254
- if($attr && trim($attr) != '') $defaults[] = array('attribute'=>trim($attr));
255
- }
256
-
257
- if($attrs){
258
- return array_merge($defaults, $attrs);
259
- }
260
- else{
261
- return $defaults;
262
- }
263
- }
264
-
265
-
266
- /**
267
- * Return crontab formatted time for cron set time.
268
- *
269
- * @param string $frequency
270
- * @param array $time
271
- * @return string
272
- */
273
- public function getCronTimeAsCrontab($frequency, $time) {
274
- list($hours, $minutes, $seconds) = $time;
275
- /**
276
- * [0] = minutes
277
- * [1] = hours
278
- * [2] = day of month
279
- * [3] = month
280
- * [4] = day of week
281
- */
282
- $cron = array("*", "*", "*", "*", "*");
283
-
284
- //Parse through time
285
- if ($minutes) {
286
- $cron[0] = $minutes;
287
- }
288
-
289
- if ($hours) {
290
- $cron[1] = $hours;
291
- }
292
-
293
- //Parse through frequencies
294
- switch ($frequency) {
295
- case "3H":
296
- $cron[1] = '*/3';
297
- $cron[0] = '00';
298
- break;
299
- case "6H":
300
- $cron[1] = '*/6';
301
- $cron[0] = '00';
302
- break;
303
- case "12H":
304
- $cron[1] = '*/12';
305
- $cron[0] = '00';
306
- break;
307
- case "W":
308
- $cron[4] = 0;
309
- break;
310
- case "M":
311
- $cron[2] = 1;
312
- break;
313
- }
314
-
315
- return implode(" ", $cron);
316
- }
317
-
318
- /**
319
- * Gets the next run date based on cron settings.
320
- *
321
- * @return Zend_Date
322
- */
323
- public function getNextRunDateFromCronTime() {
324
- $now = Mage::app()->getLocale()->date();
325
- $frequency = $this->getCronFrequency();
326
- list($hours, $minutes, $seconds) = explode(',', $this->getCronTime());
327
-
328
- $time = Mage::app()->getLocale()->date();
329
- $time->setHour(0)->setMinute(0)->setSecond(0);
330
-
331
- //Parse through frequencies
332
- switch ($frequency) {
333
- case "3H":
334
- if ($time->compare($now) == -1) {
335
- while($time->isEarlier($now)){
336
- $time->addHour(3);
337
- }
338
- }
339
- break;
340
- case "6H":
341
- if ($time->compare($now) == -1) {
342
- while($time->isEarlier($now)){
343
- $time->addHour(6);
344
- }
345
- }
346
- break;
347
- case "12H":
348
- if ($time->compare($now) == -1) {
349
- while($time->isEarlier($now)){
350
- $time->addHour(12);
351
- }
352
- }
353
- break;
354
- case "D":
355
- $time->setHour($hours)->setMinute($minutes)->setSecond($seconds);
356
- if ($time->compare($now) == -1) {
357
- $time->addDay(1);
358
- }
359
- break;
360
- case "W":
361
- $time->setHour($hours)->setMinute($minutes)->setSecond($seconds);
362
- $time->setWeekday(7);
363
- if ($time->compare($now) == -1) {
364
- $time->addWeek(1);
365
- }
366
- break;
367
- case "M":
368
- $time->setHour($hours)->setMinute($minutes)->setSecond($seconds);
369
- $time->setDay(1);
370
- if ($time->compare($now) == -1) {
371
- $time->addMonth(1);
372
- }
373
- break;
374
- }
375
-
376
- return $time;
377
- }
378
-
379
- function mtime() {
380
- list($usec, $sec) = explode(" ", microtime());
381
- return ((float) $usec + (float) $sec);
382
- }
383
-
384
- /**
385
- * Returns domain(s) as a js var
386
- *
387
- * @return url
388
- */
389
- public function getSLIDomainJs() {
390
- $searchURL = $this->getSearchDomain();
391
- $scheme = parse_url($searchURL, PHP_URL_SCHEME);
392
- if (!$scheme) {
393
- $searchURL = "http://".$searchURL;
394
- }
395
- preg_match('/http(s|):\/\/(.+?)\//',$searchURL,$matches);
396
- $searchURLBase = $searchURL;
397
- if (isset($matches[2])) {
398
- $searchURLBase = $matches[2];
399
- }
400
- $returnJS = "\n<script type=\"text/javascript\">\nvar slibaseurlsearch = '" . $searchURL ."';\nvar slibaseurl = '" . $searchURLBase . "';\n</script>\n";
401
-
402
- return $returnJS;
403
- }
404
-
405
-
406
- /**
407
- * Checks to see if the the custom form code should be used
408
- *
409
- * @return bool
410
- */
411
- public function useCustomForm() {
412
- return (bool) Mage::getStoreConfig(self::SECTION . self::FORM_GROUP . "customform");
413
- }
414
-
415
-
416
- /**
417
- * This returns the form code from the DB
418
- *
419
- * @return string
420
- */
421
- public function getFormData() {
422
- return Mage::getStoreConfig(self::SECTION . self::FORM_GROUP . "formcode");
423
- }
424
-
425
- /**
426
- * Render the cart grand total and total item within the cart
427
- * @param Mage_Sales_Model_Quote $quote
428
- * @return array
429
- */
430
- private function _renderCartTotal( $quote )
431
- {
432
- if( !$quote ) return false;
433
-
434
- //Declare the array container
435
- $cartInfoArray = array();
436
- $quoteItemCount = intval($quote->getItemsQty());
437
-
438
- //Store the item count to array
439
- $cartInfoArray['NumberOfItems'] = $quoteItemCount;
440
-
441
- $totals = $quote->getTotals();
442
- if( $totals )
443
- {
444
- if( isset($totals['grand_total']) )
445
- $cartInfoArray['TotalPrice'] = $this->formatCurrency($totals['grand_total']->getValue());
446
-
447
- if( isset($totals['tax']) )
448
- $cartInfoArray['TotalTax'] = $this->formatCurrency($totals['tax']->getValue());
449
- }
450
-
451
- //Get The Cart Total Discount Amount
452
- $items = $quote->getAllVisibleItems();
453
- $itemDiscount = 0;
454
- foreach( $items as $item )
455
- {
456
- if( !$item ) continue;
457
- $itemDiscount += $item->getDiscountAmount();
458
- }
459
- $cartInfoArray['TotalDiscount'] = $this->formatCurrency($itemDiscount);
460
-
461
- //Get The Delivery Cost if applicable
462
- $shippingCost = $quote->getShippingAddress()->getShippingAmount();
463
- $shippingCostTax = $quote->getShippingAddress()->getShippingTaxAmount();
464
- if($shippingCost == (float)0){
465
- $cartInfoArray['DeliveryCost'] = $this->formatCurrency(0);
466
- }else{
467
- $cartInfoArray['DeliveryCost'] = $this->formatCurrency((float)$shippingCost + (float)$shippingCostTax);
468
- }
469
-
470
- return $cartInfoArray;
471
- }
472
-
473
- /**
474
- * Render the cart item detail
475
- * @param Mage_Sales_Model_Quote $quote
476
- * @return array
477
- */
478
- private function _renderItemsDetail( $quote )
479
- {
480
- //Array of items
481
- $itemsArray = array();
482
- if( !$quote ) return false;
483
-
484
- $items = $quote->getAllVisibleItems();
485
-
486
- foreach( $items as $item )
487
- {
488
- /** @var $item Mage_Sales_Model_Quote_Item */
489
- if( !$item ) continue;
490
-
491
- //Declare an array to store item information
492
- $itemInfo = array();
493
- /** @var $itemProduct Mage_Catalog_Model_Product */
494
- $itemProduct = $item->getProduct();
495
-
496
- $itemInfo[ 'title' ] = $item->getName();
497
- $itemInfo[ 'sku' ] = $item->getSku();
498
- $itemInfo[ 'qty' ] = intval($item->getQty());
499
- //Get the item Product Object
500
- $product = $item->getProduct();
501
- //Get the original price for item product
502
- $itemInfo[ 'price' ] = $this->formatCurrency($product->getPrice());
503
- //Get the sale price
504
- $itemInfo[ 'sale_price' ] = $this->formatCurrency($item->getPriceInclTax());
505
-
506
- $itemInfo[ 'item_url' ] = $this->getItemUrl($item);
507
- $itemInfo[ 'remove_url' ] = Mage::getUrl('checkout/cart/delete/', array('id'=>$item->getId()));
508
- $itemInfo[ 'image_url' ] = Mage::getModel('catalog/product_media_config')->getMediaUrl($itemProduct->getThumbnail());
509
-
510
- $itemsArray[] = $itemInfo;
511
- }
512
- return $itemsArray;
513
- }
514
-
515
- /**
516
- * Get the item url
517
- * @param $item Mage_Sales_Model_Quote_Item
518
- * @return string
519
- */
520
- public function getItemUrl($item)
521
- {
522
- if ($item->getRedirectUrl()) {
523
- return $item->getRedirectUrl();
524
- }
525
-
526
- $product = $item->getProduct();
527
- $option = $item->getOptionByCode('product_type');
528
- if ($option) {
529
- $product = $option->getProduct();
530
- }
531
- return $product->getUrlModel()->getUrl($product);
532
-
533
- }
534
-
535
-
536
- /**
537
- * Render the JSONP object for SLI
538
- *
539
- * @param Mage_Sales_Model_Quote $quote
540
- * @return string
541
- */
542
- public function getCartJSONP( $quote )
543
- {
544
- $key_values['form_key'] = Mage::getSingleton('core/session')->getFormKey();
545
- $key_values['logged_in'] = Mage::getSingleton('customer/session')->isLoggedIn();
546
- $key_values['user_name'] = $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName());
547
-
548
- $cart = $this->_renderCartTotal( $quote );
549
- $items['items'] = $this->_renderItemsDetail( $quote );
550
-
551
- $result = array_merge($key_values, $cart, $items);
552
- $jsonResult = json_encode( $result );
553
- //Wrap up as jsonp object
554
- $jsonpResult = "sliCartRequest($jsonResult)";
555
- return $jsonpResult;
556
- }
557
-
558
-
559
- /**
560
- * Return whether an email should be sent or not
561
- *
562
- * @param $error
563
- *
564
- * @return bool
565
- */
566
- public function sendEmail($error) {
567
- $emailLevel = $this->getEmailSetting();
568
- if($emailLevel == 3) {
569
- return true;
570
- }else if($emailLevel == 2 && isset($error) && $error) {
571
- return true;
572
- }else {
573
- return false;
574
- }
575
- }
576
-
577
- /**
578
- * Format output for email
579
- *
580
- * @param $messageArray
581
- *
582
- * @return string
583
- */
584
- public function formatEmailOutput($messageArray){
585
- $output = "";
586
- foreach($messageArray as $key => $value) {
587
- $output .= "$key: $value\n";
588
- }
589
- return $output;
590
- }
591
-
592
- /**
593
- * Currency formatting
594
- *
595
- * @param $val
596
- * @return string
597
- */
598
- public function formatCurrency( $val )
599
- {
600
- return Mage::helper('checkout')->getQuote()->getStore()->formatPrice($val, false);
601
- }
602
- }
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Translation and systems configuration helper
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Helper_Data extends Mage_Core_Helper_Abstract
32
+ {
33
+ const SECTION = "sli_search/";
34
+ const GENERAL_GROUP = "general/";
35
+ const FEED_GROUP = "feed/";
36
+ const FTP_GROUP = "ftp/";
37
+ const FORM_GROUP = "form/";
38
+ const JS_GROUP = "js/";
39
+ const CRON_GROUP = "cron/";
40
+ const ATTR_GROUP = "attributes/";
41
+ const DEFAULT_ATTRS = "default_attributes/";
42
+ const ENABLED = 1;
43
+
44
+ /**
45
+ * Returns true/false on whether or not the module is enabled
46
+ *
47
+ * @param int $storeId
48
+ *
49
+ * @return bool
50
+ */
51
+ public function isFormEnabled($storeId = 0)
52
+ {
53
+ $formEnabled = Mage::app()->getStore($storeId)->getConfig(
54
+ self::SECTION . self::GENERAL_GROUP . 'form_enabled'
55
+ );
56
+
57
+ return (bool)($formEnabled == self::ENABLED) ? 1 : 0;
58
+ }
59
+
60
+ /**
61
+ * Returns true/false on whether or not the feed is enabled
62
+ *
63
+ * @param int $storeId
64
+ *
65
+ * @return bool
66
+ */
67
+ public function isFeedEnabled($storeId = 0)
68
+ {
69
+ $feedEnabled = Mage::app()->getStore($storeId)->getConfig(
70
+ self::SECTION . self::GENERAL_GROUP . 'feed_enabled'
71
+ );
72
+
73
+ return (bool)($feedEnabled == self::ENABLED) ? 1 : 0;
74
+ }
75
+
76
+ /**
77
+ * Returns true/false on whether or not the price feed is enabled
78
+ *
79
+ * @param int $storeId
80
+ *
81
+ * @return bool
82
+ */
83
+ public function isPriceFeedEnabled($storeId = 0)
84
+ {
85
+ return (bool)Mage::app()->getStore($storeId)->getConfig(self::SECTION . self::GENERAL_GROUP . 'price_feed');
86
+ }
87
+
88
+ /**
89
+ * Returns an integer which is the log level
90
+ *
91
+ * @param int $storeId
92
+ *
93
+ * @return int
94
+ */
95
+ public function getLogLevel($storeId = 0)
96
+ {
97
+ return (int)Mage::app()->getStore($storeId)->getConfig(self::SECTION . self::GENERAL_GROUP . 'log_level');
98
+ }
99
+
100
+ /**
101
+ * Return the email setting
102
+ *
103
+ * @return int
104
+ */
105
+ public function getEmailSetting()
106
+ {
107
+ return Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . 'email_setting');
108
+ }
109
+
110
+ /**
111
+ * Return the email address of the person to send to
112
+ *
113
+ * @return string
114
+ */
115
+ public function getFeedEmail()
116
+ {
117
+ return Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "emailto");
118
+ }
119
+
120
+ /**
121
+ * Returns true/false on whether or not we should backup feeds
122
+ *
123
+ * @return boolean
124
+ */
125
+ public function isBackupFeed()
126
+ {
127
+ return (bool)Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "backup");
128
+ }
129
+
130
+ /**
131
+ * Returns true/false on whether or not to include out of stock items in feed
132
+ *
133
+ * @param int $storeId
134
+ *
135
+ * @return bool
136
+ */
137
+ public function isIncludeOutOfStockItems($storeId = 0)
138
+ {
139
+ return (bool)Mage::app()->getStore($storeId)->getConfig(self::SECTION . self::FEED_GROUP . "stockstatus");
140
+ }
141
+
142
+ /**
143
+ * Returns batch count (alias page size)
144
+ *
145
+ * @return int
146
+ */
147
+ public function getWriteBatch()
148
+ {
149
+ return (int)Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "write_batch");
150
+ }
151
+
152
+ /**
153
+ * Returns true/false on whether or not we should use ftp on feed generation
154
+ *
155
+ * @return boolean
156
+ */
157
+ public function isUseFtp()
158
+ {
159
+ return (bool)Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "enabled");
160
+ }
161
+
162
+ /**
163
+ * Returns the user by which to log into the ftp server
164
+ *
165
+ * @return string
166
+ */
167
+ public function getFtpUser()
168
+ {
169
+ return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "user");
170
+ }
171
+
172
+ /**
173
+ * Returns the password for the user to log into the ftp server
174
+ *
175
+ * @return string
176
+ */
177
+ public function getFtpPass()
178
+ {
179
+ return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "pass");
180
+ }
181
+
182
+ /**
183
+ * Returns the host that we will log into via ftp
184
+ *
185
+ * @return string
186
+ */
187
+ public function getFtpHost()
188
+ {
189
+ return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "host");
190
+ }
191
+
192
+ /**
193
+ * Returns the path on the ftp server that we will drop the feed into
194
+ *
195
+ * @return string
196
+ */
197
+ public function getFtpPath()
198
+ {
199
+ return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "path");
200
+ }
201
+
202
+ /**
203
+ * Returns the javascript that goes into the html head block
204
+ *
205
+ * @return string
206
+ */
207
+ public function getHeaderJs()
208
+ {
209
+ return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "header");
210
+ }
211
+
212
+ /**
213
+ * Returns the javascript that goes into the before_body_end
214
+ *
215
+ * @return string
216
+ */
217
+ public function getFooterJs()
218
+ {
219
+ return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "footer");
220
+ }
221
+
222
+ /**
223
+ * Returns the email to send notifications to when the cron runs
224
+ *
225
+ * @return string
226
+ */
227
+ public function getCronEmail()
228
+ {
229
+ return Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "email");
230
+ }
231
+
232
+ /**
233
+ * Returns the frequency that the cron should run.
234
+ *
235
+ * @return string
236
+ */
237
+ public function getCronFrequency()
238
+ {
239
+ return Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "frequency");
240
+ }
241
+
242
+ /**
243
+ * Returns the time of day that the cron should run at.
244
+ *
245
+ * @return string
246
+ */
247
+ public function getCronTime()
248
+ {
249
+ return Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "time");
250
+ }
251
+
252
+ /**
253
+ * Checks if cron is enabled.
254
+ *
255
+ * @return bool
256
+ */
257
+ public function isCronEnabled()
258
+ {
259
+ return !(bool)Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "disabled");
260
+ }
261
+
262
+ /**
263
+ * Returns an array of attributes configured (UI) to be included in the feed.
264
+ *
265
+ * @return array
266
+ */
267
+ public function getAttributes()
268
+ {
269
+ return Mage::getStoreConfig(self::SECTION . self::ATTR_GROUP . "attributes", Mage::app()->getStore()->getId());
270
+ }
271
+
272
+ /**
273
+ * Return crontab formatted time for cron set time.
274
+ *
275
+ * @param string $frequency
276
+ * @param array $time
277
+ *
278
+ * @return string
279
+ */
280
+ public function getCronTimeAsCrontab($frequency, $time)
281
+ {
282
+ list($hours, $minutes, $ignored) = $time;
283
+ /**
284
+ * [0] = minutes
285
+ * [1] = hours
286
+ * [2] = day of month
287
+ * [3] = month
288
+ * [4] = day of week
289
+ */
290
+ $cron = array('*', '*', '*', '*', '*');
291
+
292
+ // Parse through time
293
+ if (!empty($minutes) || '0' === $minutes) {
294
+ $cron[0] = (int)$minutes;
295
+ }
296
+
297
+ if (!empty($hours) || '0' === $hours) {
298
+ $cron[1] = (int)$hours;
299
+ }
300
+
301
+ // Parse through frequencies
302
+ switch ($frequency) {
303
+ case SLI_Search_Model_System_Config_Source_Cron_Frequency::CRON_EVERY_HOUR:
304
+ $cron[1] = '*/1';
305
+ $cron[0] = '0';
306
+ break;
307
+ case SLI_Search_Model_System_Config_Source_Cron_Frequency::CRON_3_HOURLY:
308
+ $cron[1] = '*/3';
309
+ $cron[0] = '0';
310
+ break;
311
+ case SLI_Search_Model_System_Config_Source_Cron_Frequency::CRON_6_HOURLY:
312
+ $cron[1] = '*/6';
313
+ $cron[0] = '0';
314
+ break;
315
+ case SLI_Search_Model_System_Config_Source_Cron_Frequency::CRON_12_HOURLY:
316
+ $cron[1] = '*/12';
317
+ $cron[0] = '0';
318
+ break;
319
+ }
320
+
321
+ return implode(' ', $cron);
322
+ }
323
+
324
+ /**
325
+ * Gets the next run date based on cron settings.
326
+ *
327
+ * @return Zend_Date
328
+ */
329
+ public function getNextRunDateFromCronTime()
330
+ {
331
+ $now = Mage::app()->getLocale()->date();
332
+ $frequency = $this->getCronFrequency();
333
+ list($hours, $minutes) = explode(',', $this->getCronTime());
334
+ $seconds = 0;
335
+
336
+ $time = Mage::app()->getLocale()->date();
337
+ $time->setHour(0)->setMinute(0)->setSecond(0);
338
+
339
+ //Parse through frequencies
340
+ switch ($frequency) {
341
+ case SLI_Search_Model_System_Config_Source_Cron_Frequency::CRON_EVERY_HOUR:
342
+ if ($time->compare($now) == -1) {
343
+ while ($time->isEarlier($now)) {
344
+ $time->addHour(1);
345
+ }
346
+ }
347
+ break;
348
+ case SLI_Search_Model_System_Config_Source_Cron_Frequency::CRON_3_HOURLY:
349
+ if ($time->compare($now) == -1) {
350
+ while ($time->isEarlier($now)) {
351
+ $time->addHour(3);
352
+ }
353
+ }
354
+ break;
355
+ case SLI_Search_Model_System_Config_Source_Cron_Frequency::CRON_6_HOURLY:
356
+ if ($time->compare($now) == -1) {
357
+ while ($time->isEarlier($now)) {
358
+ $time->addHour(6);
359
+ }
360
+ }
361
+ break;
362
+ case SLI_Search_Model_System_Config_Source_Cron_Frequency::CRON_12_HOURLY:
363
+ if ($time->compare($now) == -1) {
364
+ while ($time->isEarlier($now)) {
365
+ $time->addHour(12);
366
+ }
367
+ }
368
+ break;
369
+ case SLI_Search_Model_System_Config_Source_Cron_Frequency::CRON_DAILY:
370
+ $time->setHour($hours)->setMinute($minutes)->setSecond($seconds);
371
+ if ($time->compare($now) == -1) {
372
+ $time->addDay(1);
373
+ }
374
+ break;
375
+ }
376
+
377
+ return $time;
378
+ }
379
+
380
+ /**
381
+ * Return a float of current Unix timestamp with microseconds
382
+ *
383
+ * @return float
384
+ */
385
+ public function mtime()
386
+ {
387
+ list($usec, $sec) = explode(" ", microtime());
388
+
389
+ return ((float)$usec + (float)$sec);
390
+ }
391
+
392
+ /**
393
+ * This returns the form code from the DB
394
+ *
395
+ * @return string
396
+ */
397
+ public function getFormData()
398
+ {
399
+ return Mage::getStoreConfig(self::SECTION . self::FORM_GROUP . "formcode");
400
+ }
401
+
402
+ /**
403
+ * Render the cart grand total and total item within the cart
404
+ *
405
+ * @param Mage_Sales_Model_Quote $quote
406
+ *
407
+ * @return array
408
+ */
409
+ protected function renderCartTotal($quote)
410
+ {
411
+ if (!$quote) {
412
+ return false;
413
+ }
414
+
415
+ //Declare the array container
416
+ $cartInfoArray = array();
417
+ $quoteItemCount = intval($quote->getItemsQty());
418
+
419
+ //Store the item count to array
420
+ $cartInfoArray['NumberOfItems'] = $quoteItemCount;
421
+
422
+ $totals = $quote->getTotals();
423
+ if ($totals) {
424
+ if (isset($totals['grand_total'])) {
425
+ $cartInfoArray['TotalPrice'] = $this->formatCurrency($totals['grand_total']->getValue());
426
+ }
427
+
428
+ if (isset($totals['tax'])) {
429
+ $cartInfoArray['TotalTax'] = $this->formatCurrency($totals['tax']->getValue());
430
+ }
431
+ }
432
+
433
+ //Get The Cart Total Discount Amount
434
+ $items = $quote->getAllVisibleItems();
435
+ $itemDiscount = 0;
436
+ foreach ($items as $item) {
437
+ $itemDiscount += $item->getDiscountAmount();
438
+ }
439
+ $cartInfoArray['TotalDiscount'] = $this->formatCurrency($itemDiscount);
440
+
441
+ //Get The Delivery Cost if applicable
442
+ $shippingCost = $quote->getShippingAddress()->getShippingAmount();
443
+ $shippingCostTax = $quote->getShippingAddress()->getShippingTaxAmount();
444
+ if ($shippingCost == (float)0) {
445
+ $cartInfoArray['DeliveryCost'] = $this->formatCurrency(0);
446
+ } else {
447
+ $cartInfoArray['DeliveryCost'] = $this->formatCurrency((float)$shippingCost + (float)$shippingCostTax);
448
+ }
449
+
450
+ return $cartInfoArray;
451
+ }
452
+
453
+ /**
454
+ * Render the cart item detail
455
+ *
456
+ * @param Mage_Sales_Model_Quote $quote
457
+ *
458
+ * @return array
459
+ */
460
+ protected function renderItemsDetail($quote)
461
+ {
462
+ //Array of items
463
+ $itemsArray = array();
464
+ if (!$quote) {
465
+ return false;
466
+ }
467
+
468
+ $items = $quote->getAllVisibleItems();
469
+
470
+ /** @var $item Mage_Sales_Model_Quote_Item */
471
+ foreach ($items as $item) {
472
+ //Declare an array to store item information
473
+ $itemInfo = array();
474
+ /** @var $itemProduct Mage_Catalog_Model_Product */
475
+ $itemProduct = $item->getProduct();
476
+
477
+ $itemInfo['title'] = $item->getName();
478
+ $itemInfo['sku'] = $item->getSku();
479
+ $itemInfo['qty'] = intval($item->getQty());
480
+ //Get the item Product Object
481
+ $product = $item->getProduct();
482
+ //Get the original price for item product
483
+ $itemInfo['price'] = $this->formatCurrency($product->getPrice());
484
+ //Get the sale price
485
+ $itemInfo['sale_price'] = $this->formatCurrency($item->getPriceInclTax());
486
+
487
+ $itemInfo['item_url'] = $this->getItemUrl($item);
488
+ $itemInfo['remove_url'] = Mage::getUrl('checkout/cart/delete/', array('id' => $item->getId()));
489
+ $itemInfo['image_url'] = Mage::getModel('catalog/product_media_config')->getMediaUrl(
490
+ $itemProduct->getThumbnail()
491
+ );
492
+
493
+ $itemsArray[] = $itemInfo;
494
+ }
495
+
496
+ return $itemsArray;
497
+ }
498
+
499
+ /**
500
+ * Get the item url
501
+ *
502
+ * @param $item Mage_Sales_Model_Quote_Item
503
+ *
504
+ * @return string
505
+ */
506
+ public function getItemUrl($item)
507
+ {
508
+ if ($item->getRedirectUrl()) {
509
+ return $item->getRedirectUrl();
510
+ }
511
+
512
+ $product = $item->getProduct();
513
+ $option = $item->getOptionByCode('product_type');
514
+ if ($option) {
515
+ $product = $option->getProduct();
516
+ }
517
+
518
+ return $product->getUrlModel()->getUrl($product);
519
+ }
520
+
521
+ /**
522
+ * Render the JSONP object for SLI
523
+ *
524
+ * @param Mage_Sales_Model_Quote $quote
525
+ *
526
+ * @return string
527
+ */
528
+ public function getCartJSONP($quote)
529
+ {
530
+ $keyValues['form_key'] = Mage::getSingleton('core/session')->getFormKey();
531
+ $keyValues['logged_in'] = Mage::getSingleton('customer/session')->isLoggedIn();
532
+ $keyValues['user_name'] = $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName());
533
+
534
+ $cart = $this->renderCartTotal($quote);
535
+ $items['items'] = $this->renderItemsDetail($quote);
536
+
537
+ $result = array_merge($keyValues, $cart, $items);
538
+ $jsonResult = json_encode($result);
539
+ //Wrap up as jsonp object
540
+ $jsonpResult = "sliCartRequest($jsonResult)";
541
+
542
+ return $jsonpResult;
543
+ }
544
+
545
+ /**
546
+ * Return whether an email should be sent or not
547
+ *
548
+ * @param $error
549
+ *
550
+ * @return bool
551
+ */
552
+ public function sendEmail($error)
553
+ {
554
+
555
+ $emailLevel = $this->getEmailSetting();
556
+ if ($emailLevel == SLI_Search_Model_System_Config_Source_Emailsetting::ALL) {
557
+ return true;
558
+ } else {
559
+ if ($emailLevel == SLI_Search_Model_System_Config_Source_Emailsetting::FAILURES_ONLY && isset($error) && $error) {
560
+ return true;
561
+ } else {
562
+ return false;
563
+ }
564
+ }
565
+ }
566
+
567
+ /**
568
+ * Currency formatting
569
+ *
570
+ * @param $val
571
+ *
572
+ * @return string
573
+ */
574
+ public function formatCurrency($val)
575
+ {
576
+ return Mage::helper('checkout')->getQuote()->getStore()->formatPrice($val, false);
577
+ }
578
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/SLI/Search/Helper/Feed.php ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license � please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Feed helper for multifunctional feed related utilities
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Helper_Feed
32
+ {
33
+ const AJAX_NOTICE = "Currently generating feeds...";
34
+
35
+ protected $feedFilePath = null;
36
+
37
+ /**
38
+ * These attributes should always be added to the collection
39
+ *
40
+ * @var array
41
+ */
42
+ protected $defaultRequiredAttributes
43
+ = array(
44
+ 'product_id',
45
+ 'sku',
46
+ 'name',
47
+ 'type_id',
48
+ 'is_salable',
49
+ 'url_path',
50
+ 'url_key',
51
+ 'product_id',
52
+ 'special_from_date',
53
+ 'special_price',
54
+ 'special_to_date',
55
+ 'category_ids',
56
+ 'visibility',
57
+ );
58
+
59
+ /**
60
+ * Get ajax message.
61
+ *
62
+ * @return string
63
+ */
64
+ public function getAjaxNotice()
65
+ {
66
+ return static::AJAX_NOTICE;
67
+ }
68
+
69
+ /**
70
+ * Returns the feed file path
71
+ *
72
+ * @return string
73
+ */
74
+ public function getFeedFilePath()
75
+ {
76
+ if ($this->feedFilePath === null) {
77
+ $this->feedFilePath = $this->makeVarPath(array('sli', 'feeds'));
78
+ }
79
+
80
+ return $this->feedFilePath;
81
+ }
82
+
83
+ /**
84
+ * Returns the feed file name for the given store id and type.
85
+ *
86
+ * @param $storeId
87
+ *
88
+ * @return string
89
+ */
90
+ public function getFeedFileName($storeId)
91
+ {
92
+ return "sliCatalogFeed_{$storeId}.xml";
93
+ }
94
+
95
+ /**
96
+ * Returns the full/absolute feed file name for the given store id and type.
97
+ *
98
+ * @param $storeId
99
+ *
100
+ * @return string
101
+ */
102
+ public function getFeedFile($storeId)
103
+ {
104
+ return $this->getFeedFilePath() . DS . $this->getFeedFileName($storeId);
105
+ }
106
+
107
+ /**
108
+ * Create path within var folder if necessary given an array
109
+ * of directory names
110
+ *
111
+ * @param array $directories
112
+ *
113
+ * @return string
114
+ */
115
+ public function makeVarPath($directories)
116
+ {
117
+ $path = Mage::getBaseDir('var');
118
+ foreach ($directories as $dir) {
119
+ $path .= DS . $dir;
120
+ if (!is_dir($path)) {
121
+ mkdir($path);
122
+ chmod($path, 0777);
123
+ }
124
+ }
125
+
126
+ return $path;
127
+ }
128
+
129
+ /**
130
+ * Checks whether or not there are feed generation locks currently in place.
131
+ *
132
+ * @return boolean
133
+ */
134
+ public function feedLocksExist()
135
+ {
136
+ $path = $this->getFeedFilePath();
137
+ foreach (scandir($path) as $fileName) {
138
+ $file = $path . DS . $fileName;
139
+ if (is_file($file) && !is_dir($file) && false !== strpos($fileName, '.lock')) {
140
+ $modificationTime = filemtime($file);
141
+ if (!$modificationTime) {
142
+ return true;
143
+ } else {
144
+ if ((time() - filemtime($file)) > (24 * 60 * 60)) { // Check if older than 1 day
145
+ unlink($file); // Lock file older than a day so remove it
146
+
147
+ return false;
148
+ }
149
+
150
+ return true;
151
+ }
152
+ }
153
+ }
154
+
155
+ return false;
156
+ }
157
+
158
+ /**
159
+ * Lock feed processing.
160
+ *
161
+ * @param int $storeId
162
+ *
163
+ * @return string
164
+ */
165
+ public function lockFeedProcessing($storeId = 0)
166
+ {
167
+ $lockFile = $this->getFeedFile($storeId);
168
+ file_put_contents($lockFile . ".lock", 'locked');
169
+ @chmod($lockFile, 0666);
170
+ }
171
+
172
+ /**
173
+ * Unlock feed processing.
174
+ */
175
+ public function unlockFeedGeneration()
176
+ {
177
+ $path = $this->getFeedFilePath();
178
+ foreach (scandir($path) as $fileName) {
179
+ $file = $path . DS . $fileName;
180
+ if (is_file($file) && !is_dir($file) && false !== strpos($fileName, '.lock')) {
181
+ unlink($file);
182
+ }
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Checks write permissions on feed files that exist and
188
+ * the permissions on the folder that they are located in
189
+ *
190
+ * @throws SLI_Search_Exception
191
+ */
192
+ public function checkWritePermissions()
193
+ {
194
+ $path = $this->getFeedFilePath();
195
+
196
+ if (!(is_writable($path))) {
197
+ throw new SLI_Search_Exception("Unable to write feed location: " . $path);
198
+ }
199
+
200
+ foreach (scandir($path) as $fileName) {
201
+ $file = $path . DS . $fileName;
202
+ if (is_file($file) && !(is_writable($file))) {
203
+ throw new SLI_Search_Exception("Unable to write/update feed file: " . $file);
204
+ }
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Back ups previous feeds for a given store id.
210
+ *
211
+ * Back up previous feed into backup directory, previous backup
212
+ * into archive, and remove the last archive.
213
+ *
214
+ * @param $storeId
215
+ */
216
+ public function backUpFeeds($storeId)
217
+ {
218
+ /** @var $dataHelper SLI_Search_Helper_Data */
219
+ $dataHelper = Mage::helper('sli_search/data');
220
+
221
+ if (!$dataHelper->isBackupFeed()) {
222
+ return;
223
+ }
224
+
225
+ $file = $this->getFeedFileName($storeId);
226
+ $backupTwo = $this->makeVarPath(array('sli', 'backups', 'bak.bak'));
227
+ $backupOne = $this->makeVarPath(array('sli', 'backups', 'bak'));
228
+ $path = $this->getFeedFilePath();
229
+
230
+ if (is_file($backupTwo . DS . $file)) {
231
+ unlink($backupTwo . DS . $file);
232
+ }
233
+ if (is_file($backupOne . DS . $file)) {
234
+ rename($backupOne . DS . $file, $backupTwo . DS . $file);
235
+ chmod($backupTwo . DS . $file, 0666);
236
+ }
237
+ if (is_file($path . DS . $file)) {
238
+ copy($path . DS . $file, $backupOne . DS . $file);
239
+ chmod($backupOne . DS . $file, 0666);
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Returns a list of default attributes.
245
+ *
246
+ * @return array
247
+ */
248
+ public function getDefaultRequiredAttributes()
249
+ {
250
+ return $this->defaultRequiredAttributes;
251
+ }
252
+
253
+ /**
254
+ * Returns array of attribute names.
255
+ *
256
+ * @return array
257
+ */
258
+ public function getExtraAttributes()
259
+ {
260
+ $attributes = $this->getDefaultRequiredAttributes();
261
+
262
+ /** @var $dataHelper SLI_Search_Helper_Data */
263
+ $dataHelper = Mage::helper('sli_search/data');
264
+
265
+ $attributeLines = $dataHelper->getAttributes();
266
+ foreach ($attributeLines as $attributeLine) {
267
+ if (isset($attributeLine['attribute']) && !in_array($attributeLine['attribute'], $attributes)) {
268
+ // just attribute names
269
+ $attributes[] = $attributeLine['attribute'];
270
+ }
271
+ }
272
+
273
+ return array_unique($attributes);
274
+ }
275
+ }
app/code/community/SLI/Search/Helper/FeedLogger.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Feed logger
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Helper_FeedLogger
32
+ {
33
+ const ERROR = 1;
34
+ const TRACE = 2;
35
+ const DEBUG = 3;
36
+
37
+ const LOGGING_ENABLED = true;
38
+ const WARNING_MEMORY_LIMIT = 75;
39
+ const ERROR_MEMORY_LIMIT = 90;
40
+
41
+ protected $startTime;
42
+ protected $memoryLimit = null;
43
+ protected $warningMemoryLimit = null;
44
+ protected $errorMemoryLimit = null;
45
+
46
+ protected $storeId = null;
47
+ protected $logFile = null;
48
+
49
+ /**
50
+ *
51
+ */
52
+ public function __construct()
53
+ {
54
+ /** @var $dataHelper SLI_Search_Helper_Data */
55
+ $dataHelper = Mage::helper('sli_search/data');
56
+ $this->startTime = $dataHelper->mtime();
57
+ $this->setupMemoryLimits();
58
+ }
59
+
60
+ /**
61
+ * Set store id
62
+ *
63
+ * @param $storeId
64
+ */
65
+ public function setStoreId($storeId)
66
+ {
67
+ $this->storeId = $storeId;
68
+ $this->logFile = null;
69
+ }
70
+
71
+ /**
72
+ * Error
73
+ *
74
+ * @param $message
75
+ * @param array $args
76
+ */
77
+ public function error($message, array $args = array())
78
+ {
79
+ $this->log($message, $args, self::ERROR);
80
+ }
81
+
82
+ /**
83
+ * Trace
84
+ *
85
+ * @param $message
86
+ * @param array $args
87
+ */
88
+ public function trace($message, array $args = array())
89
+ {
90
+ $this->log($message, $args, self::TRACE);
91
+ }
92
+
93
+ /**
94
+ * Debug
95
+ *
96
+ * @param $message
97
+ * @param array $args
98
+ */
99
+ public function debug($message, array $args = array())
100
+ {
101
+ $this->log($message, $args, self::DEBUG);
102
+ }
103
+
104
+ /**
105
+ * Logs a message to the store log file with current execution time and memory usage
106
+ *
107
+ * Log level is an integer that specifies the type of logging message.
108
+ * 1 is Error, higher levels are for debugging and tracing
109
+ *
110
+ * @param string $msg
111
+ * @param array $args
112
+ * @param int $logLevel
113
+ *
114
+ */
115
+ protected function log($msg, array $args = array(), $logLevel = self::DEBUG)
116
+ {
117
+ /** @var $dataHelper SLI_Search_Helper_Data */
118
+ $dataHelper = Mage::helper('sli_search/data');
119
+ $storeLogLevel = $dataHelper->getLogLevel($this->storeId);
120
+ if ($logLevel && $storeLogLevel && $logLevel > $storeLogLevel) {
121
+ return;
122
+ }
123
+
124
+ if (null === $this->logFile) {
125
+ /** @var $feedHelper SLI_Search_Helper_Feed */
126
+ $feedHelper = Mage::helper('sli_search/feed');
127
+ $feedHelper->makeVarPath(array('log', 'sli'));
128
+ $this->logFile = "sli" . DS . "sliFeedGen_{$this->storeId}.log";
129
+ }
130
+
131
+ $memoryUsage = memory_get_usage(true);
132
+ $memoryUsageFormatted = $memoryUsage / 1024 / 1024 . "M";
133
+ $percentage = "";
134
+ $warningMessage = "";
135
+ $memoryLimit = $this->memoryLimit;
136
+ if ($memoryLimit != "-1") {
137
+ $percentage = sprintf("%.0f", (($memoryUsage / $memoryLimit) * 100)) . "%";
138
+ $warningMessage = $this->checkMemoryUsage($memoryUsage);
139
+ }
140
+ $time = sprintf("%.4fs", $dataHelper->mtime() - $this->startTime);
141
+ Mage::log(
142
+ "$time : $memoryUsageFormatted : $percentage $warningMessage-=- $msg", null, $this->logFile,
143
+ static::LOGGING_ENABLED
144
+ );
145
+ }
146
+
147
+ /**
148
+ * Function to check what the memory usage is currently and how it is compared
149
+ * to the set limits
150
+ *
151
+ * @param $currentUsage
152
+ *
153
+ * @return string
154
+ */
155
+ protected function checkMemoryUsage($currentUsage)
156
+ {
157
+ $message = '';
158
+ if ($currentUsage > $this->warningMemoryLimit) {
159
+ $message = "Warning - Using over " . self::WARNING_MEMORY_LIMIT . "% of php memory";
160
+ if ($currentUsage > $this->errorMemoryLimit) {
161
+ $message = "Error - Using over " . self::ERROR_MEMORY_LIMIT . "% of php memory: ";
162
+ }
163
+ }
164
+
165
+ return $message;
166
+ }
167
+
168
+ /**
169
+ * Setup the max php memory limit
170
+ */
171
+ protected function setupMemoryLimits()
172
+ {
173
+ $this->memoryLimit = ini_get('memory_limit');
174
+ if (substr($this->memoryLimit, -1) == 'K') {
175
+ $this->memoryLimit = str_replace('K', '', $this->memoryLimit) * 1024;
176
+ } else {
177
+ if (substr($this->memoryLimit, -1) == 'M') {
178
+ $this->memoryLimit = str_replace('M', '', $this->memoryLimit) * 1024 * 1024;
179
+ } else {
180
+ if (substr($this->memoryLimit, -1) == 'G') {
181
+ $this->memoryLimit = str_replace('G', '', $this->memoryLimit) * 1024 * 1024 * 1024;
182
+ }
183
+ }
184
+ }
185
+ $this->warningMemoryLimit = $this->memoryLimit * (self::WARNING_MEMORY_LIMIT / 100);
186
+ $this->errorMemoryLimit = $this->memoryLimit * (self::ERROR_MEMORY_LIMIT / 100);
187
+ }
188
+ }
app/code/community/SLI/Search/Helper/XmlWriter.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license � please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Class XmlWriter
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Helper_XmlWriter extends \XMLWriter
32
+ {
33
+ /**
34
+ * Open a feed for writing.
35
+ *
36
+ * @param $filename
37
+ * @param string $startElement
38
+ */
39
+ public function openFeed($filename, $startElement = 'catalog')
40
+ {
41
+ $this->openUri($filename);
42
+ $this->startDocument('1.0', 'UTF-8');
43
+ $this->setIndent(true);
44
+ $this->setIndentString(' ');
45
+ // start catalog
46
+ $this->startElement($startElement);
47
+ @chmod($filename, 0666);
48
+ }
49
+
50
+ /**
51
+ * Write a value of multiple types to a xml at a fixed level.
52
+ *
53
+ * @param mixed $value - array, bool or string
54
+ * @param int $level
55
+ */
56
+ public function writeValue($value, $level)
57
+ {
58
+ if (is_array($value)) {
59
+ foreach ($value as $v) {
60
+ $this->startElement('value_' . $level);
61
+ $this->writeValue($v, $level + 1);
62
+ $this->endElement();
63
+ }
64
+ } elseif (is_bool($value)) {
65
+ $this->text($value ? 'true' : 'false');
66
+ } elseif (is_string($value)) {
67
+ $this->text($value);
68
+ } elseif (is_numeric($value)) {
69
+ $this->text($value);
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Write a key value pair as XML.
75
+ *
76
+ * @param string $name
77
+ * @param mixed $value - array, bool or string.
78
+ */
79
+ public function writeNode($name, $value)
80
+ {
81
+ if (null === $value) {
82
+ // no point writing an empty node
83
+ return;
84
+ }
85
+
86
+ $this->startElement($name);
87
+ $this->writeValue($value, 1);
88
+ $this->endElement();
89
+ }
90
+
91
+ /**
92
+ * @param array $attributes
93
+ */
94
+ public function writeAttributes(array $attributes)
95
+ {
96
+ foreach ($attributes as $attributeKey => $attributeValues) {
97
+ $this->startElement('attribute');
98
+
99
+ $this->startElement('key');
100
+ $this->text($attributeKey);
101
+ $this->endElement();
102
+
103
+ foreach ($attributeValues as $attributeValueKey => $attributeValue) {
104
+ $this->startElement('attributeValue');
105
+ $this->startElement('key');
106
+ $this->text($attributeValueKey);
107
+ $this->endElement();
108
+
109
+ $this->startElement('value');
110
+ $this->text($attributeValue);
111
+ $this->endElement();
112
+ $this->endElement();
113
+ }
114
+ $this->endElement();
115
+ }
116
+ }
117
+
118
+ /**
119
+ *
120
+ */
121
+ public function closeFeed()
122
+ {
123
+ // main tag
124
+ $this->endElement();
125
+
126
+ $this->endDocument();
127
+ $this->flush();
128
+ }
129
+ }
app/code/community/SLI/Search/Model/Cron.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Cron activities for the sli feed generation
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_Cron
32
+ {
33
+ // matching config.xml job code
34
+ const JOB_CODE_GENERATE_FEEDS = 'sli_search';
35
+ // matching config.xml path for model + cron_expr
36
+ const CRON_GENERATE_FEEDS_SCHEDULE_EXPR_PATH = 'crontab/jobs/sli_search/schedule/cron_expr';
37
+ const CRON_GENERATE_FEEDS_MODEL_RUN_PATH = 'crontab/jobs/sli_search/run/model';
38
+
39
+ /**
40
+ * Generates the feeds and sends email of status when done
41
+ */
42
+ public function generateFeeds()
43
+ {
44
+ /** @var $dataHelper SLI_Search_Helper_Data */
45
+ $dataHelper = Mage::helper('sli_search/data');
46
+ if ($dataHelper->isCronEnabled()) {
47
+ try {
48
+ /** @var $feedManager SLI_Search_Model_FeedManager */
49
+ $feedManager = Mage::getModel('sli_search/FeedManager');
50
+ $msg = $feedManager->generateFeedForStores();
51
+ } catch (SLI_Search_Exception $e) {
52
+ $msg = array('messages' => array('Error' => $e->getMessage()));
53
+ } catch (Exception $e) {
54
+ $msg = array(
55
+ 'messages' => array(
56
+ 'Unknown Error' => "{$e->getMessage()} in {$e->getFile()} on line {$e->getLine()}."
57
+ . "Please contact your SLI provider."
58
+ )
59
+ );
60
+ }
61
+
62
+ $this->sendEmail($msg);
63
+
64
+ return true;
65
+ }
66
+
67
+ return false;
68
+ }
69
+
70
+ /**
71
+ * If there is a system config email set, send out the cron notification email.
72
+ *
73
+ * @param string $msg
74
+ */
75
+ protected function sendEmail($msg)
76
+ {
77
+ /** @var $dataHelper SLI_Search_Helper_Data */
78
+ $dataHelper = Mage::helper('sli_search/data');
79
+ if ($cronEmail = $dataHelper->getCronEmail()) {
80
+ Mage::getModel('sli_search/email')
81
+ ->setData('msg', $msg['messages'])
82
+ ->setData('subject', 'Scheduled feed generation')
83
+ ->setData('email', $cronEmail)
84
+ ->send();
85
+ }
86
+ }
87
+ }
app/code/community/SLI/Search/Model/Email.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Feed generation email
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_Email extends Varien_Object
32
+ {
33
+ const DEFAULT_STORE_ID = 0;
34
+ const SLI_FEED_EMAIL_TEMPLATE = 'sli_feed_email_template';
35
+
36
+ /**
37
+ * Send feed notification email.
38
+ */
39
+ public function send()
40
+ {
41
+ if ($toEmail = $this->getData('email')) {
42
+ /** @var $mailer Mage_Core_Model_Email_Template_Mailer */
43
+ $mailer = Mage::getModel('core/email_template_mailer');
44
+ /** @var $emailInfo Mage_Core_Model_Email_Info */
45
+ $emailInfo = Mage::getModel('core/email_info');
46
+
47
+ $emailInfo->addTo($toEmail);
48
+ $mailer->addEmailInfo($emailInfo);
49
+
50
+ // Set all required params and send emails
51
+ $mailer->setSender('general');
52
+ $mailer->setStoreId(self::DEFAULT_STORE_ID);
53
+ $mailer->setTemplateId(self::SLI_FEED_EMAIL_TEMPLATE);
54
+ $mailer->setTemplateParams(
55
+ array(
56
+ 'subject' => $this->getData('subject'),
57
+ 'messages' => (array)$this->getData('msg'),
58
+ )
59
+ );
60
+ $mailer->send();
61
+ }
62
+ }
63
+ }
app/code/community/SLI/Search/Model/FeedGenerator.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Generates feed file based on store
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_FeedGenerator
32
+ {
33
+ /**
34
+ * Generate feed(s) for the given store id.
35
+ *
36
+ * @param int $storeId
37
+ * @param SLI_Search_Helper_FeedLogger $logger
38
+ *
39
+ * @return array List of stati for each feed file.
40
+ */
41
+ public function generateForStoreId($storeId, SLI_Search_Helper_FeedLogger $logger)
42
+ {
43
+ // just to be safe
44
+ Mage::app()->setCurrentStore($storeId);
45
+
46
+ /** @var SLI_Search_Helper_Feed $feedHelper */
47
+ $feedHelper = Mage::helper('sli_search/feed');
48
+ /** @var SLI_Search_Helper_Data $dataHelper */
49
+ $dataHelper = Mage::helper('sli_search/data');
50
+
51
+ /** @var $xmlWriter SLI_Search_Helper_XmlWriter */
52
+ $xmlWriter = Mage::helper('sli_search/xmlWriter');
53
+
54
+ /** @var SLI_Search_Model_Generators_GeneratorContext $generatorContext */
55
+ $generatorContext = Mage::getModel('sli_search/generators_GeneratorContext');
56
+ $generatorContext->init($xmlWriter, $logger, $dataHelper->getWriteBatch());
57
+
58
+ $generators = array(
59
+ Mage::getModel('sli_search/generators_MetaGenerator'),
60
+ Mage::getModel('sli_search/generators_ProductGenerator'),
61
+ Mage::getModel('sli_search/generators_AttributeGenerator'),
62
+ Mage::getModel('sli_search/generators_CategoryGenerator'),
63
+ Mage::getModel('sli_search/generators_PriceGenerator'),
64
+ );
65
+
66
+ $logger->trace("Creating catalog feed.....");
67
+
68
+ $feedFilename = $feedHelper->getFeedFile($storeId);
69
+ $xmlWriter->openFeed($feedFilename);
70
+
71
+ /** @var $generator SLI_Search_Model_Generators_GeneratorInterface */
72
+ foreach ($generators as $generator) {
73
+ $generator->generateForStoreId($storeId, $generatorContext);
74
+ }
75
+
76
+ $xmlWriter->closeFeed();
77
+
78
+ $logger->trace("Finished creating catalog feed");
79
+
80
+ return true;
81
+ }
82
+ }
app/code/community/SLI/Search/Model/FeedManager.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Feed generation manager.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_FeedManager
32
+ {
33
+ const DEMO = false;
34
+ const FEED_MESSAGE_KEY_FORMAT = 'Feed %s';
35
+
36
+ /**
37
+ * Starts feed generation (and upload) for the given stores (default is all)
38
+ *
39
+ * @param array $storeIds
40
+ *
41
+ * @return array
42
+ * @throws SLI_Search_Exception
43
+ */
44
+ public function generateFeedForStores(array $storeIds = array())
45
+ {
46
+ /** @var $feedHelper SLI_Search_Helper_Feed */
47
+ $feedHelper = Mage::helper('sli_search/feed');
48
+ /** @var $dataHelper SLI_Search_Helper_Data */
49
+ $dataHelper = Mage::helper('sli_search/data');
50
+
51
+ if ($feedHelper->feedLocksExist()) {
52
+ throw new SLI_Search_Exception("One or more feeds are being generated. Generation temporarily locked.");
53
+ }
54
+
55
+ $feedHelper->checkWritePermissions();
56
+
57
+ // ok, lets lock things
58
+ $feedHelper->lockFeedProcessing();
59
+
60
+ $feedStatus = array('error' => false);
61
+
62
+ /** @var $feedGenerator SLI_Search_Model_FeedGenerator */
63
+ $feedGenerator = Mage::getModel('sli_search/FeedGenerator');
64
+
65
+ /** @var $stores Mage_Core_Model_Resource_Store_Collection */
66
+ $stores = Mage::app()->getStores();
67
+
68
+ $messages = array();
69
+ /** @var $store Mage_Core_Model_Store */
70
+ foreach ($stores as $store) {
71
+ $storeId = $store->getId();
72
+ if ($storeIds && !in_array($storeId, $storeIds)) {
73
+ // skip not specified stores
74
+ continue;
75
+ }
76
+
77
+ // set store context as $dataHelper (and others) depend on it - yay!
78
+ Mage::app()->setCurrentStore($storeId);
79
+
80
+ /** @var $logger SLI_Search_Helper_FeedLogger */
81
+ $logger = Mage::helper('sli_search/feedLogger');
82
+ $logger->setStoreId($storeId);
83
+
84
+ if (!$dataHelper->isFeedEnabled($storeId)) {
85
+ $logger->debug("Catalog Feed " . $storeId . " disabled");
86
+ $messages[sprintf(self::FEED_MESSAGE_KEY_FORMAT, $storeId)] = "Disabled";
87
+ continue;
88
+ }
89
+
90
+ $this->logSystemSettings($logger);
91
+
92
+ // backup feed files per store
93
+ $feedHelper->backUpFeeds($storeId);
94
+
95
+ try {
96
+ $feedGenerator->generateForStoreId($storeId, $logger);
97
+ $message = 'Success';
98
+ if (!self::DEMO && $dataHelper->isUseFtp()) {
99
+ $this->uploadFeed($storeId, $logger);
100
+ $message .= '; upload(FTP) OK.';
101
+ } else {
102
+ $message .= '; upload(FTP) disabled.';
103
+ }
104
+
105
+ $messages[sprintf(self::FEED_MESSAGE_KEY_FORMAT, $storeId)] = $message;
106
+ } catch (Exception $e) {
107
+ Mage::logException($e);
108
+ $message = "Exception generating catalog feed $storeId -> " . $e->getMessage();
109
+ $logger->error($message, array('exception' => $e));
110
+ $feedStatus['error'] = true;
111
+ $messages[sprintf(self::FEED_MESSAGE_KEY_FORMAT, $storeId)] = $message;
112
+ }
113
+ }
114
+ $feedStatus['messages'] = $messages;
115
+
116
+ $feedHelper->unlockFeedGeneration();
117
+
118
+ return $feedStatus;
119
+ }
120
+
121
+ /**
122
+ * Sends the feed file using ftp to system configured location
123
+ *
124
+ * @param int $storeId
125
+ * @param SLI_Search_Helper_FeedLogger $logger
126
+ *
127
+ * @throws SLI_Search_Exception
128
+ * @throws Varien_Io_Exception
129
+ */
130
+ protected function uploadFeed($storeId, SLI_Search_Helper_FeedLogger $logger)
131
+ {
132
+ /** @var $feedHelper SLI_Search_Helper_Feed */
133
+ $feedHelper = Mage::helper('sli_search/feed');
134
+ /** @var $dataHelper SLI_Search_Helper_Data */
135
+ $dataHelper = Mage::helper('sli_search/data');
136
+
137
+ $logger->trace("Sending Feed...");
138
+ $transport = new Varien_Io_Ftp();
139
+ $transport->open(
140
+ array(
141
+ 'host' => $dataHelper->getFtpHost(),
142
+ 'user' => $dataHelper->getFtpUser(),
143
+ 'password' => $dataHelper->getFtpPass(),
144
+ 'path' => $dataHelper->getFtpPath(),
145
+ 'passive' => 'true',
146
+ )
147
+ );
148
+ $pathToFeedFile = $feedHelper->getFeedFile($storeId);
149
+ $result = $transport->write($feedHelper->getFeedFileName($storeId), $pathToFeedFile);
150
+ if ($result) {
151
+ $logger->error("Feed Sent: $pathToFeedFile");
152
+ } else {
153
+ $logger->error("Feed Failed to Uploaded to FTP: $pathToFeedFile");
154
+ throw new SLI_Search_Exception("Feed Failed to Uploaded to FTP.}");
155
+ }
156
+ }
157
+
158
+ /**
159
+ * @param SLI_Search_Helper_FeedLogger $logger
160
+ */
161
+ protected function logSystemSettings(SLI_Search_Helper_FeedLogger $logger)
162
+ {
163
+ $resourceManager = Mage::getResourceModel('sli_search/feedManager');
164
+
165
+
166
+ $variables = $resourceManager->getSystemSettings();
167
+
168
+ $logger->debug('============================================================================');
169
+ $logger->debug('DB Settings:');
170
+ if (!empty($variables)) {
171
+ foreach ($variables as $result) {
172
+ $logger->debug(sprintf(' %s: %s', $result['Variable_name'], $result['Value']));
173
+ }
174
+ }
175
+
176
+ $logger->debug('PHP Settings:');
177
+ foreach (array('memory_limit', 'max_execution_time') as $key) {
178
+ $logger->debug(sprintf(' %s: %s', $key, ini_get($key)));
179
+ }
180
+ }
181
+ }
app/code/community/SLI/Search/Model/Generators/AttributeGenerator.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Generates feed attribute data.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_Generators_AttributeGenerator implements SLI_Search_Model_Generators_GeneratorInterface
32
+ {
33
+ //TODO: what is this supposed to do?
34
+ protected $indexValueAttributes = array();
35
+ protected $attributeValues = array();
36
+
37
+ /**
38
+ * {@inheritdoc}
39
+ */
40
+ public function generateForStoreId($storeId, SLI_Search_Model_Generators_GeneratorContext $generatorContext)
41
+ {
42
+ $logger = $generatorContext->getLogger();
43
+ $xmlWriter = $generatorContext->getXmlWriter();
44
+
45
+ $logger->debug(sprintf('[%s] Starting attribute XML generation', $storeId));
46
+
47
+ $this->initAttributes($storeId, $logger);
48
+
49
+ $xmlWriter->startElement('attributes');
50
+
51
+ if ($this->attributeValues) {
52
+ $xmlWriter->writeAttributes($this->attributeValues);
53
+ }
54
+
55
+ // attributes
56
+ $xmlWriter->endElement();
57
+
58
+ $logger->debug(sprintf('[%s] Finished writing attributes', $storeId));
59
+
60
+ return true;
61
+ }
62
+
63
+ /**
64
+ * Create the attribute values for a store
65
+ *
66
+ * @param int $storeId
67
+ * @param SLI_Search_Helper_FeedLogger $logger
68
+ */
69
+ protected function initAttributes($storeId, SLI_Search_Helper_FeedLogger $logger)
70
+ {
71
+ /** @var $feedHelper SLI_Search_Helper_Feed */
72
+ $feedHelper = Mage::helper('sli_search/feed');
73
+ $extraAttributes = $feedHelper->getExtraAttributes();
74
+
75
+ /** @var $attributeCollection Mage_Catalog_Model_Resource_Product_Attribute_Collection */
76
+ $attributeCollection = Mage::getResourceModel('catalog/product_attribute_collection');
77
+ $attributeCollection->addStoreLabel($storeId);
78
+
79
+ /** @var $attribute Mage_Eav_Model_Entity_Attribute */
80
+ foreach ($attributeCollection as $attribute) {
81
+ $attributeCode = $attribute->getAttributeCode();
82
+ // Only add the options that we require
83
+ if (in_array($attributeCode, $extraAttributes)) {
84
+ $attributeOptions = $this->getAttributeOptions($attribute, $storeId, $logger);
85
+ // Only add the attributes that have options
86
+ if ($attributeOptions) {
87
+ $this->attributeValues[$attributeCode] = $attributeOptions;
88
+ }
89
+ }
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
95
+ *
96
+ * @param Mage_Eav_Model_Entity_Attribute $attribute
97
+ * @param $storeId
98
+ * @param SLI_Search_Helper_FeedLogger $logger
99
+ *
100
+ * @return array
101
+ */
102
+ protected function getAttributeOptions($attribute, $storeId, SLI_Search_Helper_FeedLogger $logger)
103
+ {
104
+ $options = array();
105
+
106
+ if ($attribute->usesSource()) {
107
+ // should attribute have index (option value) instead of a label?
108
+ $index = in_array($attribute->getAttributeCode(), $this->indexValueAttributes) ? 'value' : 'label';
109
+
110
+ try {
111
+ foreach ($attribute->getSource()->getAllOptions() as $option) {
112
+ foreach (is_array($option['value']) ? $option['value'] : array($option) as $innerOption) {
113
+ if (strlen($innerOption['value'])) {
114
+ // skip ' -- Please Select -- ' option
115
+ $options[$innerOption['value']] = $innerOption[$index];
116
+ }
117
+ }
118
+ }
119
+ } catch (\Exception $e) {
120
+ // ignore exceptions connected with source models
121
+ $logger->trace(
122
+ sprintf(
123
+ '[%s] Failed to get attribute options: %s',
124
+ $storeId, $e->getMessage()
125
+ ),
126
+ array('exception' => $e)
127
+ );
128
+ }
129
+ }
130
+
131
+ return $options;
132
+ }
133
+ }
app/code/community/SLI/Search/Model/Generators/CategoryGenerator.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Generates feed category data.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_Generators_CategoryGenerator implements SLI_Search_Model_Generators_GeneratorInterface
32
+ {
33
+ /**
34
+ * {@inheritdoc}
35
+ */
36
+ public function generateForStoreId($storeId, SLI_Search_Model_Generators_GeneratorContext $generatorContext)
37
+ {
38
+ $logger = $generatorContext->getLogger();
39
+ $xmlWriter = $generatorContext->getXmlWriter();
40
+
41
+ $logger->debug(sprintf('[%s] Starting category XML generation', $storeId));
42
+
43
+ $rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
44
+ $xmlWriter->startElement('categories');
45
+ $xmlWriter->writeAttribute('root', $rootCategoryId);
46
+
47
+ $processed = 0;
48
+
49
+ $recursionLevel = 0;
50
+ $sorted = false;
51
+ $toLoad = false;
52
+ $onlyActiveCategories = false;
53
+
54
+ // Could not use the helper as we need the disabled categories
55
+ $tree = Mage::getResourceModel('catalog/category_tree');
56
+ /* @var $tree Mage_Catalog_Model_Resource_Category_Tree */
57
+ $tree->loadNode($rootCategoryId)
58
+ ->loadChildren($recursionLevel)
59
+ ->getChildren();
60
+
61
+ $tree->addCollectionData(null, $sorted, $rootCategoryId, $toLoad, $onlyActiveCategories);
62
+
63
+ foreach ($tree->getCollection() as $category) {
64
+ $this->writeCategory($xmlWriter, $category);
65
+ ++$processed;
66
+ }
67
+
68
+ // categories
69
+ $xmlWriter->endElement();
70
+
71
+ $logger->debug(sprintf('[%s] Finished category attributes; processed items: %s', $storeId, $processed));
72
+
73
+ return true;
74
+ }
75
+
76
+ /**
77
+ * Write a single category
78
+ *
79
+ * @param SLI_Search_Helper_XmlWriter|XmlWriter $xmlWriter
80
+ * @param Mage_Catalog_Model_Category $category
81
+ */
82
+ protected function writeCategory(SLI_Search_Helper_XmlWriter $xmlWriter, Mage_Catalog_Model_Category $category)
83
+ {
84
+ $xmlWriter->startElement('category');
85
+
86
+ $xmlWriter->writeAttribute('id', $category->getId());
87
+ $xmlWriter->writeAttribute('name', $category->getName());
88
+ $isActive = $category->getData('is_active');
89
+ $xmlWriter->writeAttribute('active', (empty($isActive) || '1' != $isActive) ? '0' : '1');
90
+ $xmlWriter->writeAttribute('parent', $category->getParentId());
91
+
92
+ $xmlWriter->endElement();
93
+ }
94
+ }
app/code/community/SLI/Search/Model/Generators/DemoGenerator.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Generates feed demo data.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_Generators_DemoGenerator implements SLI_Search_Model_Generators_GeneratorInterface
32
+ {
33
+ /**
34
+ * {@inheritdoc}
35
+ */
36
+ public function generateForStoreId($storeId, SLI_Search_Model_Generators_GeneratorContext $generatorContext)
37
+ {
38
+ $logger = $generatorContext->getLogger();
39
+ $xmlWriter = $generatorContext->getXmlWriter();
40
+
41
+ $logger->debug(sprintf('[%s] Starting product demo XML generation', $storeId));
42
+
43
+ $xmlWriter->startElement('products');
44
+
45
+ $demoProduct = <<<EOS
46
+
47
+ <product id="558" sku="hbm005">
48
+ <entity_id>558</entity_id>
49
+ <entity_type_id>4</entity_type_id>
50
+ <attribute_set_id>10</attribute_set_id>
51
+ <type_id>downloadable</type_id>
52
+ <sku>hbm005</sku>
53
+ <has_options>1</has_options>
54
+ <required_options>0</required_options>
55
+ <created_at>2013-03-25 19:06:32</created_at>
56
+ <updated_at>2013-05-14 18:49:42</updated_at>
57
+ <status>1</status>
58
+ <price>2.0000</price>
59
+ <tax_class_id>0</tax_class_id>
60
+ <final_price>2.0000</final_price>
61
+ <minimal_price>2.0000</minimal_price>
62
+ <min_price>2.0000</min_price>
63
+ <max_price>2.0000</max_price>
64
+ <tier_price/>
65
+ <inventory_in_stock>1</inventory_in_stock>
66
+ <name>Falling by I Am Not Lefthanded</name>
67
+ <url_path>falling-by-i-am-not-lefthanded.html</url_path>
68
+ <url_key>falling-by-i-am-not-lefthanded</url_key>
69
+ <visibility>4</visibility>
70
+ <is_salable>1</is_salable>
71
+ <is_in_stock>1</is_in_stock>
72
+ <category_ids>
73
+ <value_1>22</value_1>
74
+ </category_ids>
75
+ <related_products/>
76
+ <related_product_ids/>
77
+ </product>
78
+
79
+ EOS;
80
+
81
+ $xmlWriter->writeRaw($demoProduct);
82
+
83
+ $xmlWriter->endElement();
84
+
85
+ $logger->debug(sprintf('[%s] Finished writing product demo', $storeId));
86
+
87
+ return true;
88
+ }
89
+ }
app/code/community/SLI/Search/Model/Generators/GeneratorContext.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Generator context.
27
+ * This is the place to share things between generators.
28
+ *
29
+ * @package SLI
30
+ * @subpackage Search
31
+ */
32
+ class SLI_Search_Model_Generators_GeneratorContext
33
+ {
34
+ /** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
35
+ protected $productCollection;
36
+ /** @var SLI_Search_Helper_FeedLogger $logger */
37
+ protected $logger;
38
+ /** @var SLI_Search_Helper_XmlWriter $xmlWriter */
39
+ protected $xmlWriter;
40
+ protected $pageSize;
41
+
42
+ /**
43
+ * Create new instance.
44
+ */
45
+ public function __construct()
46
+ {
47
+ $this->productCollection = null;
48
+ }
49
+
50
+ /**
51
+ * Init.
52
+ *
53
+ * @param SLI_Search_Helper_XmlWriter $xmlWriter
54
+ * @param SLI_Search_Helper_FeedLogger $logger
55
+ * @param int $pageSize
56
+ */
57
+ public function init(SLI_Search_Helper_XmlWriter $xmlWriter, SLI_Search_Helper_FeedLogger $logger, $pageSize)
58
+ {
59
+ $this->logger = $logger;
60
+ $this->xmlWriter = $xmlWriter;
61
+ $this->pageSize = $pageSize;
62
+ }
63
+
64
+ /**
65
+ * @return SLI_Search_Helper_FeedLogger
66
+ */
67
+ public function getLogger()
68
+ {
69
+ return $this->logger;
70
+ }
71
+
72
+ /**
73
+ * @return SLI_Search_Helper_XmlWriter
74
+ */
75
+ public function getXmlWriter()
76
+ {
77
+ return $this->xmlWriter;
78
+ }
79
+
80
+ /**
81
+ * @return int
82
+ */
83
+ public function getPageSize()
84
+ {
85
+ return $this->pageSize;
86
+ }
87
+
88
+ /**
89
+ * Get the product collection.
90
+ *
91
+ * The collection will be set up with the widest required set of attributes/prices/etc.
92
+ * That means if there are new, feature-flagged options this is the place to change things.
93
+ *
94
+ * @param $storeId
95
+ *
96
+ * @return Mage_Catalog_Model_Resource_Product_Collection
97
+ */
98
+ public function getProductCollection($storeId)
99
+ {
100
+ $logger = $this->logger;
101
+
102
+ /** @var $dataHelper SLI_Search_Helper_Data */
103
+ $dataHelper = Mage::helper('sli_search/data');
104
+
105
+ $page = 1;
106
+ $pageSize = $this->pageSize;
107
+
108
+ // keep at most one collection at a time as we do iterate over stores and do not need them any more
109
+ if ($this->productCollection && $this->productCollection->getStoreId() == $storeId) {
110
+ $logger->debug("Recycling product collection with page size: $pageSize...");
111
+ $this->productCollection->setPage($page, $pageSize);
112
+ $this->productCollection->clear();
113
+
114
+ return $this->productCollection;
115
+ }
116
+
117
+ $logger->debug(sprintf('[%s] Creating context product collection with page size: %s...', $storeId, $pageSize));
118
+
119
+ /** @var $entityCollection Mage_Catalog_Model_Resource_Product_Collection */
120
+ $this->productCollection = $this->getRawProductCollection($storeId);
121
+ // add price data only here as otherwise the raw collection will not see out of stock items
122
+ $this->productCollection
123
+ ->addPriceData();
124
+
125
+ // these are handled in the product generator as adding price data will drop them from the collection
126
+ if (!$dataHelper->isIncludeOutOfStockItems($storeId)) {
127
+ // lets still add this here in case Magentos (internal) behaviour changes in the future
128
+ $logger->debug(sprintf('[%s] Exclude out of stock items', $storeId));
129
+ /** @var Mage_CatalogInventory_Model_Stock $stockHelper */
130
+ $stockHelper = Mage::getModel('cataloginventory/stock');
131
+ $stockHelper->addInStockFilterToCollection($this->productCollection);
132
+ } else {
133
+ $logger->debug(sprintf('[%s] Include out of stock items', $storeId));
134
+ }
135
+
136
+ if ($dataHelper->isPriceFeedEnabled($storeId)) {
137
+ $logger->debug("Adding tier price data...");
138
+ $this->productCollection
139
+ ->addTierPriceData();
140
+ }
141
+
142
+ $logger->debug("Finished creating collection; select: " . $this->productCollection->getSelect()->__toString());
143
+
144
+ return $this->productCollection;
145
+ }
146
+
147
+ /**
148
+ * This is not cached and will create a new collection on each call.
149
+ *
150
+ * @param int $storeId
151
+ *
152
+ * @return Mage_Catalog_Model_Resource_Product_Collection
153
+ */
154
+ public function getRawProductCollection($storeId)
155
+ {
156
+ $logger = $this->logger;
157
+
158
+ $page = 1;
159
+ $pageSize = $this->pageSize;
160
+
161
+ $logger->debug("Creating raw product collection with page size: $pageSize...");
162
+
163
+ /** @var $feedHelper SLI_Search_Helper_Feed */
164
+ $feedHelper = Mage::helper('sli_search/feed');
165
+ $extraAttributes = $feedHelper->getExtraAttributes();
166
+
167
+ /** @var $entityCollection Mage_Catalog_Model_Resource_Product_Collection */
168
+ $productCollection = Mage::getResourceModel('catalog/product_collection');
169
+
170
+ $logger->debug("Adding product attributes: " . implode(',', $extraAttributes));
171
+ $productCollection
172
+ ->setPage($page, $pageSize)
173
+ ->addAttributeToSelect($extraAttributes)
174
+ ->addAttributeToFilter('status', 1);
175
+ $productCollection
176
+ ->addStoreFilter($storeId);
177
+
178
+ return $productCollection;
179
+ }
180
+ }
app/code/community/SLI/Search/Model/Generators/GeneratorInterface.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Generator interface.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ interface SLI_Search_Model_Generators_GeneratorInterface
32
+ {
33
+ /**
34
+ * @param int $storeId
35
+ * @param SLI_Search_Model_Generators_GeneratorContext $generatorContext
36
+ *
37
+ * @return bool
38
+ */
39
+ public function generateForStoreId($storeId, SLI_Search_Model_Generators_GeneratorContext $generatorContext);
40
+ }
app/code/community/SLI/Search/Model/Generators/MetaGenerator.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Generates feed meta data.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_Generators_MetaGenerator implements SLI_Search_Model_Generators_GeneratorInterface
32
+ {
33
+ /**
34
+ * {@inheritdoc}
35
+ */
36
+ public function generateForStoreId($storeId, SLI_Search_Model_Generators_GeneratorContext $generatorContext)
37
+ {
38
+ $logger = $generatorContext->getLogger();
39
+ $xmlWriter = $generatorContext->getXmlWriter();
40
+
41
+ $logger->debug(sprintf('[%s] Starting meta XML generation', $storeId));
42
+
43
+ $xmlWriter->startElement('meta');
44
+ $xmlWriter->writeAttribute('storeId', $storeId);
45
+
46
+ $modules = Mage::getConfig()->getNode('modules')->children();
47
+ $moduleInfo = $modules->SLI_Search->asArray();
48
+ $lscVersion = isset($moduleInfo['version']) ? $moduleInfo['version'] : 'UNKNOWN';
49
+ $magentoVersion = Mage::getVersion();
50
+
51
+ $xmlWriter->writeElement('lscVersion', $lscVersion);
52
+ $xmlWriter->writeElement('magentoVersion', $magentoVersion);
53
+ $xmlWriter->writeElement('context', 'cli' == php_sapi_name() ? 'CLI' : 'UI');
54
+ $xmlWriter->writeElement('baseUrl', Mage::getBaseUrl());
55
+
56
+ $created = new DateTime();
57
+ $xmlWriter->writeElement('created', $created->format(DateTime::ISO8601));
58
+
59
+ /** @var $feedHelper SLI_Search_Helper_Feed */
60
+ $feedHelper = Mage::helper('sli_search/feed');
61
+ $extraAttributes = $feedHelper->getExtraAttributes();
62
+ $xmlWriter->writeElement('extraAttributes', implode(', ', array_values($extraAttributes)));
63
+
64
+ // meta
65
+ $xmlWriter->endElement();
66
+
67
+ $logger->debug(sprintf('[%s] Finished writing meta', $storeId));
68
+
69
+ return true;
70
+ }
71
+ }
app/code/community/SLI/Search/Model/Generators/PriceGenerator.php ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license � please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Generates feed price data.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_Generators_PriceGenerator implements SLI_Search_Model_Generators_GeneratorInterface
32
+ {
33
+ protected $customerGroupMap;
34
+
35
+ /**
36
+ * {@inheritdoc}
37
+ */
38
+ public function generateForStoreId($storeId, SLI_Search_Model_Generators_GeneratorContext $generatorContext)
39
+ {
40
+ $logger = $generatorContext->getLogger();
41
+ $xmlWriter = $generatorContext->getXmlWriter();
42
+
43
+ /** @var $dataHelper SLI_Search_Helper_Data */
44
+ $dataHelper = Mage::helper('sli_search/data');
45
+
46
+ if (!$dataHelper->isPriceFeedEnabled($storeId)) {
47
+ $logger->debug(sprintf('[%s] Price XML generation disabled', $storeId));
48
+
49
+ return false;
50
+ }
51
+
52
+ $logger->debug(sprintf('[%s] Starting price XML generation', $storeId));
53
+
54
+ $xmlWriter->startElement('advanced_pricing');
55
+
56
+ $this->addPricesToFeed($storeId, $generatorContext);
57
+ // pricing
58
+ $xmlWriter->endElement();
59
+
60
+ $logger->debug(sprintf('[%s] Finished writing pricing', $storeId));
61
+
62
+ return true;
63
+ }
64
+
65
+ /**
66
+ * Add the stores product prices to the feed
67
+ *
68
+ * @param int $storeId
69
+ * @param SLI_Search_Model_Generators_GeneratorContext $generatorContext
70
+ */
71
+ protected function addPricesToFeed($storeId, SLI_Search_Model_Generators_GeneratorContext $generatorContext)
72
+ {
73
+ $logger = $generatorContext->getLogger();
74
+ $xmlWriter = $generatorContext->getXmlWriter();
75
+
76
+ $logger->trace("Adding Advanced Pricing");
77
+
78
+ // Create a map of Customer Group id > Name.
79
+ $this->customerGroupMap = Mage::getResourceModel('customer/group_collection')->toOptionHash();
80
+
81
+ $page = 1;
82
+ $processed = 0;
83
+ $pageSize = $generatorContext->getPageSize();
84
+
85
+ /** @var $entityCollection Mage_Catalog_Model_Resource_Product_Collection */
86
+ $entityCollection = $generatorContext->getProductCollection($storeId);
87
+
88
+ // Loop over each page of the collections
89
+ while ($products = $entityCollection->getItems()) {
90
+ $logger->debug("Writing product price data...");
91
+
92
+ /** @var $product Mage_Catalog_Model_Product */
93
+ foreach ($products as $product) {
94
+ $this->writeProductPriceData($product, $xmlWriter);
95
+ ++$processed;
96
+ }
97
+ $logger->debug("Finished processing page: $page");
98
+
99
+ //Break out when the number of products is less than the pagesize
100
+ if (count($products) < $pageSize) {
101
+ break;
102
+ }
103
+ $entityCollection->setPage(++$page, $pageSize);
104
+ $entityCollection->clear();
105
+ }
106
+
107
+ $logger->debug("Finished adding prices for $processed products");
108
+ }
109
+
110
+ /**
111
+ * Write the individual product price to the price feed.
112
+ *
113
+ * @param Mage_Catalog_Model_Product $product
114
+ * @param SLI_Search_Helper_XmlWriter $xmlWriter
115
+ */
116
+ protected function writeProductPriceData(
117
+ Mage_Catalog_Model_Product $product,
118
+ SLI_Search_Helper_XmlWriter $xmlWriter
119
+ ) {
120
+ $catalogPriceData = $this->getCatalogPriceRulesData($product);
121
+ $groupPrice = $this->getPriceByType($product, 'group_price');
122
+ $tierPrice = $this->getPriceByType($product, 'tier_price');
123
+
124
+ if ($this->hasAdvancedPricing($catalogPriceData, $groupPrice, $tierPrice)) {
125
+ $xmlWriter->startElement('product_pricing');
126
+ $xmlWriter->writeNode('id', $product->getId());
127
+ $this->writePriceData('catalog_price_rules', $catalogPriceData, $xmlWriter);
128
+ $this->writePriceData('group_prices', $groupPrice, $xmlWriter);
129
+ $this->writePriceData('tier_prices', $tierPrice, $xmlWriter);
130
+
131
+ // product
132
+ $xmlWriter->endElement();
133
+ }
134
+ }
135
+
136
+ /**
137
+ * @param Mage_Catalog_Model_Product $product
138
+ * @param $priceString string to be found in the product getData call.
139
+ * - Only accepts group_price and tier_price as strings.
140
+ *
141
+ * @return array of tiered and grouped prices.
142
+ */
143
+ protected function getPriceByType(Mage_Catalog_Model_Product $product, $priceString)
144
+ {
145
+
146
+ $prices = $product->getData($priceString);
147
+ if (null === $prices) {
148
+ // Live product load - possible performance implication.
149
+ $attribute = $product->getResource()->getAttribute($priceString);
150
+ if ($attribute) {
151
+ $attribute->getBackend()->afterLoad($product);
152
+ $prices = $product->getData($priceString);
153
+ }
154
+ }
155
+
156
+ // Return empty array if there are no prices.
157
+ if (!$prices || !is_array($prices)) {
158
+ return array();
159
+ }
160
+
161
+ foreach ($prices as &$price) { // & means Array passed by reference to allow editing.
162
+ foreach ($price as $key => $value) {
163
+ // Add customer group name to node.
164
+ if (strcmp($key, 'cust_group') === 0) {
165
+ if (isset($this->customerGroupMap[$value])) {
166
+ $price['cust_name'] = $this->customerGroupMap[$value];
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ return $prices;
173
+ }
174
+
175
+ /**
176
+ * Gets the Catalog Price Rules (CPR) for a product
177
+ *
178
+ * @param Mage_Catalog_Model_Product $product
179
+ *
180
+ * @return array catalog price rule data about the product if it's effected by a rule.
181
+ */
182
+ private function getCatalogPriceRulesData(Mage_Catalog_Model_Product $product)
183
+ {
184
+ /* @var $catalogRuleModel Mage_CatalogRule_Model_Rule */
185
+ $catalogRuleModel = Mage::getModel('catalogrule/rule');
186
+
187
+ $prices = array();
188
+ foreach ($this->customerGroupMap as $customerGroupId => $name) {
189
+ /* @var $session Mage_Customer_Model_Session */
190
+ $session = Mage::getSingleton('customer/session');
191
+ $session->setCustomerGroupId($customerGroupId);
192
+
193
+ $finalPrice = $catalogRuleModel->calcProductPriceRule($product, $product->getPrice());
194
+
195
+ if (!empty($finalPrice)) {
196
+ $priceInfo = array();
197
+ $priceInfo['final_price'] = $finalPrice;
198
+ $priceInfo['customer_name'] = $name;
199
+ $priceInfo['price'] = $product->getPrice();
200
+ $prices[] = $priceInfo;
201
+ }
202
+ }
203
+
204
+ return $prices;
205
+ }
206
+
207
+ /**
208
+ * Were any of arrays set, and thus there is advanced pricing to apply in the export.
209
+ *
210
+ * @param array $catalogPriceData
211
+ * @param array $groupPrice
212
+ * @param array $tierPrice
213
+ *
214
+ * @return bool if any of the arrays are set
215
+ */
216
+ protected function hasAdvancedPricing($catalogPriceData, $groupPrice, $tierPrice)
217
+ {
218
+ return count($catalogPriceData) > 0 || count($groupPrice) > 0 || count($tierPrice) > 0;
219
+ }
220
+
221
+ /**
222
+ * @param string $priceType name of the advanced pricing node eg 'group_prices'
223
+ * @param array $priceData the actual data to output. Must be of format:
224
+ * array (
225
+ * array ( key => value ),
226
+ * ...
227
+ * array ( key => value )
228
+ * )
229
+ * @param SLI_Search_Helper_XmlWriter $xmlWriter
230
+ */
231
+ protected function writePriceData($priceType, $priceData, $xmlWriter)
232
+ {
233
+ if (!$priceData || !is_array($priceData)) {
234
+ return;
235
+ }
236
+
237
+ $xmlWriter->startElement($priceType);
238
+ foreach ($priceData as $price) {
239
+ $xmlWriter->startElement("price");
240
+ foreach ($price as $key => $value) {
241
+ $xmlWriter->writeNode($key, $value);
242
+ }
243
+ $xmlWriter->endElement();
244
+ }
245
+ $xmlWriter->endElement();
246
+ }
247
+ }
app/code/community/SLI/Search/Model/Generators/ProductGenerator.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Generates feed product data.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_Generators_ProductGenerator implements SLI_Search_Model_Generators_GeneratorInterface
32
+ {
33
+ /**
34
+ * {@inheritdoc}
35
+ */
36
+ public function generateForStoreId($storeId, SLI_Search_Model_Generators_GeneratorContext $generatorContext)
37
+ {
38
+ $logger = $generatorContext->getLogger();
39
+ $xmlWriter = $generatorContext->getXmlWriter();
40
+
41
+ $logger->debug(sprintf('[%s] Starting product XML generation', $storeId));
42
+
43
+ $xmlWriter->startElement('products');
44
+
45
+ // Disables Catalog Flat Table for LSC process.
46
+ // Allows all attributes to be obtained from EAV directly as they are not all stored in Flat Tables.
47
+ Mage::app()->getStore()->setConfig('catalog/frontend/flat_catalog_product', 0);
48
+
49
+ $this->addProductsToFeed($storeId, $generatorContext);
50
+
51
+ $xmlWriter->endElement();
52
+
53
+ $logger->debug(sprintf('[%s] Finished writing products', $storeId));
54
+
55
+ return true;
56
+ }
57
+
58
+ /**
59
+ * Add the stores products to the feed with the selected attributes
60
+ *
61
+ * @param int $storeId
62
+ * @param SLI_Search_Model_Generators_GeneratorContext $generatorContext
63
+ */
64
+ protected function addProductsToFeed(
65
+ $storeId,
66
+ SLI_Search_Model_Generators_GeneratorContext $generatorContext
67
+ ) {
68
+ $logger = $generatorContext->getLogger();
69
+ $xmlWriter = $generatorContext->getXmlWriter();
70
+
71
+ $logger->trace("Adding products");
72
+
73
+ /** @var $feedHelper SLI_Search_Helper_Feed */
74
+ $feedHelper = Mage::helper('sli_search/feed');
75
+ $extraAttributes = $feedHelper->getExtraAttributes();
76
+
77
+ $page = 1;
78
+ $processed = 0;
79
+ $pageSize = $generatorContext->getPageSize();
80
+
81
+ // might need to iterate over more than one product collection...
82
+ $productCollections = array(
83
+ 'mainProducts' => array(
84
+ 'collection' => $generatorContext->getProductCollection($storeId),
85
+ 'filters' => array(),
86
+ )
87
+ );
88
+ /** @var $dataHelper SLI_Search_Helper_Data */
89
+ $dataHelper = Mage::helper('sli_search/data');
90
+
91
+ if ($dataHelper->isIncludeOutOfStockItems($storeId)) {
92
+ /** @var Mage_Catalog_Model_Resource_Product_Collection $outOfStockProductsCollections */
93
+ $outOfStockProductsCollection = $generatorContext->getRawProductCollection($storeId);
94
+ $productCollections['outOfStockProducts'] = array(
95
+ 'collection' => $outOfStockProductsCollection,
96
+ 'filters' => array(
97
+ function ($product) {
98
+ /** @var Mage_Catalog_Model_Product $product */
99
+ /** @var Varien_Object $value */
100
+ $value = $product->getData('stock_item');
101
+
102
+ return (bool)!$value->getData('is_in_stock');
103
+ }
104
+ )
105
+ );
106
+ }
107
+
108
+ // Add in the rating data if one of the attributes is selected
109
+ $reviewAttributes = array('review_reviews_count', 'review_rating_summary');
110
+ /** @var $review Mage_Review_Model_Review */
111
+ $review = array_intersect($reviewAttributes, $extraAttributes) ? Mage::getModel('review/review') : null;
112
+
113
+ foreach ($productCollections as $collectionKey => $productCollectionDetails) {
114
+ /** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
115
+ $productCollection = $productCollectionDetails['collection'];
116
+ $productFilters = $productCollectionDetails['filters'];
117
+
118
+ $logger->debug(sprintf('Writing products for collection %s...', $collectionKey));
119
+
120
+ while ($products = $productCollection->getItems()) {
121
+ if ($review) {
122
+ $logger->debug("Adding review data for page: $page");
123
+ $review->appendSummary($productCollection);
124
+ }
125
+
126
+ // apply include filters
127
+ $filteredProducts = array_filter($products, function ($product) use ($productFilters) {
128
+ if (!$productFilters) {
129
+ // no filter - use all
130
+ return true;
131
+ }
132
+
133
+ // got filters, so lets see if at least one wants the product...
134
+ foreach ($productFilters as $includeFilter) {
135
+ if ($includeFilter($product)) {
136
+ return true;
137
+ }
138
+ }
139
+
140
+ return false;
141
+ });
142
+
143
+ /** @var $product Mage_Catalog_Model_Product */
144
+ foreach ($filteredProducts as $product) {
145
+ // load category_ids into product _data
146
+ $product->getCategoryIds();
147
+ $this->addProductRelationshipData($product, $extraAttributes);
148
+ $this->writeProductData($product, $xmlWriter);
149
+ ++$processed;
150
+ }
151
+ $logger->debug(sprintf('Finished processing product page %s for collection %s', $page,
152
+ $collectionKey));
153
+
154
+ // break out when we get less than a full page
155
+ if (count($products) < $pageSize) {
156
+ break;
157
+ }
158
+
159
+ $productCollection->setPage(++$page, $pageSize);
160
+ $productCollection->clear();
161
+ }
162
+ }
163
+
164
+ $logger->debug("Finished adding $processed products");
165
+ }
166
+
167
+ /**
168
+ * Write the individual product to the feed.
169
+ *
170
+ * @param Mage_Catalog_Model_Product $product
171
+ * @param SLI_Search_Helper_XmlWriter $xmlWriter
172
+ */
173
+ protected function writeProductData(Mage_Catalog_Model_Product $product, SLI_Search_Helper_XmlWriter $xmlWriter)
174
+ {
175
+ $xmlWriter->startElement('product');
176
+ $xmlWriter->writeAttribute('id', $product->getId());
177
+ $xmlWriter->writeAttribute('sku', $product->getSku());
178
+
179
+ foreach ($product->getData() as $name => $value) {
180
+ if ('rating_summary' == $name) {
181
+ // Always add all review data if it is in the collection
182
+ /** @var $value Mage_Review_Model_Review_Summary */
183
+ $xmlWriter->startElement('reviews');
184
+ $xmlWriter->writeAttribute('count', $value->getData('reviews_count'));
185
+ $xmlWriter->writeAttribute('summary', $value->getData('rating_summary'));
186
+ $xmlWriter->endElement();
187
+ } else {
188
+ if ('stock_item' == $name) {
189
+ /** @var $value Varien_Object */
190
+ $xmlWriter->writeNode('is_in_stock', $value->getData('is_in_stock'));
191
+ } else {
192
+ $xmlWriter->writeNode($name, $value);
193
+ }
194
+ }
195
+ }
196
+
197
+ $type = $product->getTypeInstance();
198
+ if ($childrenIds = $type->getChildrenIds($product->getId(), true)) {
199
+ // Add the children to the feed. Grouped product required items are in the different groups.
200
+ // See getChildrenIds
201
+ foreach ($childrenIds as $group => $groupIdChildren) {
202
+ $xmlWriter->startElement('child_ids');
203
+ $xmlWriter->writeAttribute('group', $group);
204
+ foreach ($groupIdChildren as $childId) {
205
+ $xmlWriter->writeElement('id', $childId);
206
+ }
207
+ $xmlWriter->endElement();
208
+ }
209
+ }
210
+
211
+ // product
212
+ $xmlWriter->endElement();
213
+ }
214
+
215
+ /**
216
+ * Adds the id's for inter product linking based on up sells, cross sells or related products
217
+ * Only doing so if they are added as extra attributes
218
+ *
219
+ * @param Mage_Catalog_Model_Product $product
220
+ * @param string $extraAttributes
221
+ */
222
+ protected function addProductRelationshipData($product, $extraAttributes)
223
+ {
224
+ // Array of XML Node Name => Product Object function call which obtains the ids for each relationship type.
225
+ $linkedAttributesFunctionMap = array(
226
+ 'linked_related' => 'getRelatedProductIds',
227
+ 'linked_upsell' => 'getUpsellProductIds',
228
+ 'linked_crosssell' => 'getCrossSellProductIds'
229
+ );
230
+
231
+ foreach ($linkedAttributesFunctionMap as $label => $method) {
232
+ if (in_array($label, $extraAttributes)) {
233
+ $product->{$method}();
234
+ }
235
+ }
236
+ }
237
+ }
app/code/community/SLI/Search/Model/Resource/FeedManager.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
4
+ * Reserved
5
+ * This file is part of Learning Search Connect.
6
+ * Learning Search Connect is distributed under a limited and restricted
7
+ * license - please visit www.sli-systems.com/LSC for full license details.
8
+ *
9
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
10
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
11
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
12
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
13
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
14
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
15
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
16
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
17
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
18
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
19
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
20
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
21
+ * POSSIBILITY OF SUCH DAMAGES.
22
+ */
23
+
24
+ /**
25
+ * Feed Resource used to grab MYSQL settings
26
+ *
27
+ * @package SLI
28
+ * @subpackage Search
29
+ */
30
+ class SLI_Search_Model_Resource_FeedManager extends Mage_Core_Model_Resource_Db_Abstract
31
+ {
32
+ /** @var $connection Varien_Db_Adapter_Pdo_Mysql */
33
+ protected $connection = null;
34
+
35
+ /**
36
+ * Resource initialization
37
+ */
38
+ protected function _construct()
39
+ {
40
+ $this->connection = Mage::getSingleton('core/resource')
41
+ ->getConnection(Mage_Core_Model_Resource::DEFAULT_READ_RESOURCE);
42
+ }
43
+
44
+ /**
45
+ * Get a key value array of the system settings for output
46
+ *
47
+ * @return Zend_Db_Statement_Pdo
48
+ */
49
+ public function getSystemSettings()
50
+ {
51
+ $query
52
+ = "SHOW VARIABLES where
53
+ Variable_name = 'max_allowed_packet'
54
+ OR Variable_name = 'wait_timeout'
55
+ OR Variable_name = 'connect_timeout'
56
+ OR Variable_name = 'innodb_buffer_pool_size'";
57
+
58
+ /* @var $result Zend_Db_Statement_Pdo */
59
+ try {
60
+ $result = $this->connection->query($query);
61
+ } catch (Exception $e) {
62
+ Mage::throwException(Mage::helper('sli_search')->__('Unable to log Mysql settings'));
63
+ }
64
+
65
+ return $result;
66
+ }
67
+
68
+
69
+ }
app/code/community/SLI/Search/Model/System/Config/Backend/Cron.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * System configuration backend model for the cron frequency system configuration
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_System_Config_Backend_Cron extends Mage_Core_Model_Config_Data
32
+ {
33
+ /**
34
+ * When frequency system configuration saves, save the values from the frequency
35
+ * and time as a cron line that Magento cron will use.
36
+ */
37
+ protected function _afterSave()
38
+ {
39
+ /** @var $dataHelper SLI_Search_Helper_Data */
40
+ $dataHelper = Mage::helper('sli_search/data');
41
+
42
+ // get UI values
43
+ $frequency = $this->getData('groups/cron/fields/frequency/value');
44
+ $time = $this->getData('groups/cron/fields/time/value');
45
+
46
+ $cronTab = $dataHelper->getCronTimeAsCrontab($frequency, $time);
47
+ try {
48
+ $this->saveCronTab($cronTab);
49
+ } catch (Exception $e) {
50
+ Mage::throwException(Mage::helper('cron')->__('Unable to save the cron expression.'));
51
+ }
52
+
53
+ return parent::_afterSave();
54
+ }
55
+
56
+ /**
57
+ * Save crontab line for feed generation cron job.
58
+ *
59
+ * @param string $cronTab The crontab line.
60
+ * @param string $model
61
+ */
62
+ public function saveCronTab($cronTab, $model = null)
63
+ {
64
+ Mage::getModel('core/config_data')
65
+ ->load(SLI_Search_Model_Cron::CRON_GENERATE_FEEDS_SCHEDULE_EXPR_PATH, 'path')
66
+ ->setValue($cronTab)
67
+ ->setPath(SLI_Search_Model_Cron::CRON_GENERATE_FEEDS_SCHEDULE_EXPR_PATH)
68
+ ->save();
69
+
70
+ if ($model) {
71
+ // install only
72
+ Mage::getModel('core/config_data')
73
+ ->load(SLI_Search_Model_Cron::CRON_GENERATE_FEEDS_MODEL_RUN_PATH, 'path')
74
+ ->setValue($model)
75
+ ->setPath(SLI_Search_Model_Cron::CRON_GENERATE_FEEDS_MODEL_RUN_PATH)
76
+ ->save();
77
+ }
78
+ }
79
+ }
app/code/community/SLI/Search/Model/System/Config/Backend/Loglevel.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Log level.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_System_Config_Backend_Loglevel
32
+ {
33
+ /**
34
+ * Options getter
35
+ *
36
+ * @return array
37
+ */
38
+ public function toOptionArray()
39
+ {
40
+ return array(
41
+ array('value' => 1, 'label' => Mage::helper('sli_search')->__('Error')),
42
+ array('value' => 2, 'label' => Mage::helper('sli_search')->__('Debug')),
43
+ array('value' => 3, 'label' => Mage::helper('sli_search')->__('Trace')),
44
+ );
45
+ }
46
+
47
+ /**
48
+ * Get options in "key-value" format
49
+ *
50
+ * @return array
51
+ */
52
+ public function toArray()
53
+ {
54
+ return array(
55
+ 1 => Mage::helper('sli_search')->__('Error'),
56
+ 2 => Mage::helper('sli_search')->__('Debug'),
57
+ 3 => Mage::helper('sli_search')->__('Trace'),
58
+ );
59
+ }
60
+ }
app/code/{local → community}/SLI/Search/Model/System/Config/Backend/Minigrid.php RENAMED
@@ -1,79 +1,94 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Minigrid backend model
14
- * Serializes and unserializes the grid data to
15
- * the config data
16
- *
17
- * @package SLI
18
- * @subpackage Search
19
- */
20
-
21
- class SLI_Search_Model_System_Config_Backend_Minigrid extends Mage_Core_Model_Config_Data {
22
-
23
- /**
24
- * In the event of a minigrid with file, get the local tmp location of the
25
- * image file that was uploaded by the font minigrid
26
- *
27
- * @return string|false
28
- */
29
- protected function _getTmpFileNames() {
30
- if (isset($_FILES['groups']['tmp_name']) && is_array($_FILES['groups']['tmp_name'])) {
31
- if (isset($_FILES['groups']['tmp_name']["{$this->getGroupId()}"])) {
32
- $field = $_FILES['groups']['tmp_name']["{$this->getGroupId()}"]['fields'][$this->getField()];
33
- if (isset($field['value'])) {
34
- return $field['value'];
35
- }
36
- }
37
- }
38
- return false;
39
- }
40
-
41
- /**
42
- * In the event that a file was uploaded,
43
- * this array will contain the filenames as they appear
44
- * on the uploaded file.
45
- *
46
- * @return array
47
- */
48
- protected function _getFileNames() {
49
- $groups = $this->getData('groups');
50
- $values = $groups["{$this->getGroupId()}"]['fields'][$this->getField()]['value'];
51
-
52
- return $values;
53
- }
54
-
55
- /**
56
- * Serialize
57
- */
58
- protected function _beforeSave() {
59
- parent::_beforeSave();
60
- $groups = $this->getData('groups');
61
- $values = $groups["{$this->getGroupId()}"]['fields'][$this->getField()]['value'];
62
-
63
- if (is_array($values)) {
64
- $this->setValue(serialize(array_values($values)));
65
- }
66
- else {
67
- $this->setValue(serialize($values));
68
- }
69
- }
70
-
71
- /**
72
- * Unserialize
73
- */
74
- protected function _afterLoad() {
75
- parent::_afterLoad();
76
- $this->setValue(unserialize($this->getValue()));
77
- }
78
-
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Minigrid backend model
27
+ * Serializes and unserializes the grid data to
28
+ * the config data
29
+ *
30
+ * @package SLI
31
+ * @subpackage Search
32
+ */
33
+ class SLI_Search_Model_System_Config_Backend_Minigrid extends Mage_Core_Model_Config_Data
34
+ {
35
+ /**
36
+ * In the event of a minigrid with file, get the community tmp location of the
37
+ * image file that was uploaded by the font minigrid
38
+ *
39
+ * @return string|false
40
+ */
41
+ protected function _getTmpFileNames()
42
+ {
43
+ if (isset($_FILES['groups']['tmp_name']) && is_array($_FILES['groups']['tmp_name'])) {
44
+ if (isset($_FILES['groups']['tmp_name']["{$this->getGroupId()}"])) {
45
+ $field = $_FILES['groups']['tmp_name']["{$this->getGroupId()}"]['fields'][$this->getField()];
46
+ if (isset($field['value'])) {
47
+ return $field['value'];
48
+ }
49
+ }
50
+ }
51
+
52
+ return false;
53
+ }
54
+
55
+ /**
56
+ * In the event that a file was uploaded,
57
+ * this array will contain the filenames as they appear
58
+ * on the uploaded file.
59
+ *
60
+ * @return array
61
+ */
62
+ protected function _getFileNames()
63
+ {
64
+ $groups = $this->getData('groups');
65
+ $values = $groups["{$this->getGroupId()}"]['fields'][$this->getField()]['value'];
66
+
67
+ return $values;
68
+ }
69
+
70
+ /**
71
+ * Serialize
72
+ */
73
+ protected function _beforeSave()
74
+ {
75
+ parent::_beforeSave();
76
+ $groups = $this->getData('groups');
77
+ $values = $groups["{$this->getGroupId()}"]['fields'][$this->getField()]['value'];
78
+
79
+ if (is_array($values)) {
80
+ $this->setValue(serialize(array_values($values)));
81
+ } else {
82
+ $this->setValue(serialize($values));
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Unserialize
88
+ */
89
+ protected function _afterLoad()
90
+ {
91
+ parent::_afterLoad();
92
+ $this->setValue(unserialize($this->getValue()));
93
+ }
94
+ }
app/code/community/SLI/Search/Model/System/Config/Source/Attributes.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Source renderer for product attributes data.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_System_Config_Source_Attributes
32
+ {
33
+ /**
34
+ * Remove attributes that do not need to be included in the feed or cause issues
35
+ * in feed generation when selected.
36
+ * This should be done in Feed::$defaultRequiredAttributes; not sure about this one so we'll leave it for now
37
+ *
38
+ * @var array
39
+ */
40
+ protected $blockedAttributes = array('category_id');
41
+
42
+ /**
43
+ * We want these attributes to appear in the drop down configuration menu, but they are not included in the
44
+ * EAV selection. We must add them in individually.
45
+ * If a key exists for a value, that key will be used as the label instead of the prefixed value
46
+ *
47
+ * @var array
48
+ */
49
+ protected $nonEavAttributes
50
+ = array(
51
+ 'max_price',
52
+ 'min_price',
53
+ 'related_products' => 'linked_related',
54
+ 'upsell_products' => 'linked_upsell',
55
+ 'crosssell_products' => 'linked_crosssell'
56
+ );
57
+
58
+ /**
59
+ * Prefix to use in the dropdown to differentiate the inventory attributes
60
+ */
61
+ const LINKED_PRODUCTS_PREFIX = 'linked';
62
+
63
+ /**
64
+ * Prefix to use in the dropdown to differentiate the inventory attributes
65
+ */
66
+ const INVENTORY_ATTRIBUTES_PREFIX = 'inventory';
67
+
68
+ /**
69
+ * Attributes from the flat inventory table that we will use for the feed
70
+ * if a key exists for a value, that key will be used as the label instead of the prefixed value
71
+ *
72
+ * @var array
73
+ */
74
+ protected $_inventoryAttributes
75
+ = array(
76
+ 'qty',
77
+ 'is_in_stock',
78
+ 'manage_stock',
79
+ 'backorders',
80
+ );
81
+
82
+ /**
83
+ * Prefix to use in the dropdown to differentiate the review attributes
84
+ */
85
+ const REVIEW_ATTRIBUTES_PREFIX = 'review';
86
+
87
+ /**
88
+ * Attributes from customer review that we will use for the feed
89
+ * if a key exists for a value, that key will be used as the label instead of the prefixed value
90
+ *
91
+ * @var array
92
+ */
93
+ protected $reviewAttributes
94
+ = array(
95
+ 'reviews_count' => 'reviews_count',
96
+ 'rating_summary',
97
+ );
98
+
99
+ /**
100
+ * Returns code => code pairs of attributes for all product attributes
101
+ *
102
+ * @return array
103
+ */
104
+ public function toOptionArray()
105
+ {
106
+ /** @var SLI_Search_Helper_Feed $feedHelper */
107
+ $feedHelper = Mage::helper('sli_search/feed');
108
+ $defaultRequiredAttributes = $feedHelper->getDefaultRequiredAttributes();
109
+
110
+ $productEntityId = Mage::getModel('catalog/product')->getResource()->getTypeId();
111
+
112
+ /** @var $attributes Mage_Eav_Model_Entity_Collection * */
113
+ $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
114
+ ->setEntityTypeFilter($productEntityId);
115
+
116
+ $attributes->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns(array("code" => 'attribute_code'));
117
+ $attributes->addFieldToFilter('attribute_code',
118
+ array('nin' => array_merge($defaultRequiredAttributes, $this->blockedAttributes)));
119
+
120
+ $options = array();
121
+
122
+ foreach ($attributes as $attribute) {
123
+ $options[$attribute['code']] = $attribute['code'];
124
+ }
125
+
126
+ // We want some non-eav attributes to be added to this dropdown as well
127
+ foreach ($this->nonEavAttributes as $label => $attributeCode) {
128
+ $label = is_string($label) ? $label : $attributeCode;
129
+ $options[$attributeCode] = $label;
130
+ }
131
+
132
+ // Add the inventory attributes
133
+ foreach ($this->_inventoryAttributes as $label => $attributeCode) {
134
+ $code = self::INVENTORY_ATTRIBUTES_PREFIX . "_" . $attributeCode;
135
+ $label = is_string($label) ? $label : self::INVENTORY_ATTRIBUTES_PREFIX . "_" . $attributeCode;
136
+ $options[$code] = $label;
137
+ }
138
+
139
+ // Add the review attributes
140
+ foreach ($this->reviewAttributes as $label => $attributeCode) {
141
+ $code = self::REVIEW_ATTRIBUTES_PREFIX . "_" . $attributeCode;
142
+ $label = is_string($label) ? $label : self::REVIEW_ATTRIBUTES_PREFIX . "_" . $attributeCode;
143
+ $options[$code] = $label;
144
+ }
145
+
146
+ // Sort the array to account for the non-eav attrs being added in
147
+ asort($options);
148
+
149
+ return $options;
150
+ }
151
+ }
app/code/community/SLI/Search/Model/System/Config/Source/Cron/Frequency.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Cron Frequency Model
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_System_Config_Source_Cron_Frequency
32
+ {
33
+ const CRON_EVERY_HOUR = '1H';
34
+ const CRON_3_HOURLY = '3H';
35
+ const CRON_6_HOURLY = '6H';
36
+ const CRON_12_HOURLY = '12H';
37
+ const CRON_DAILY = 'D';
38
+
39
+ protected static $OPTIONS;
40
+
41
+ /**
42
+ * @return array
43
+ */
44
+ public function toOptionArray()
45
+ {
46
+ if (!self::$OPTIONS) {
47
+ self::$OPTIONS = array(
48
+ array(
49
+ 'label' => Mage::helper('cron')->__('Every Hour'),
50
+ 'value' => self::CRON_EVERY_HOUR,
51
+ ),
52
+ array(
53
+ 'label' => Mage::helper('cron')->__('3 Hourly'),
54
+ 'value' => self::CRON_3_HOURLY,
55
+ ),
56
+ array(
57
+ 'label' => Mage::helper('cron')->__('6 Hourly'),
58
+ 'value' => self::CRON_6_HOURLY,
59
+ ),
60
+ array(
61
+ 'label' => Mage::helper('cron')->__('12 Hourly'),
62
+ 'value' => self::CRON_12_HOURLY,
63
+ ),
64
+ array(
65
+ 'label' => Mage::helper('cron')->__('Daily'),
66
+ 'value' => self::CRON_DAILY,
67
+ ),
68
+ );
69
+ }
70
+
71
+ return self::$OPTIONS;
72
+ }
73
+ }
74
+
app/code/community/SLI/Search/Model/System/Config/Source/Emailsetting.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * @package SLI
27
+ * @subpackage Search
28
+ */
29
+ class SLI_Search_Model_System_Config_Source_Emailsetting
30
+ {
31
+ const DISABLED = 1;
32
+ const FAILURES_ONLY = 2;
33
+ const ALL = 3;
34
+
35
+ /**
36
+ * Options getter
37
+ *
38
+ * @return array
39
+ */
40
+ public function toOptionArray()
41
+ {
42
+ return array(
43
+ array('value' => self::DISABLED, 'label' => Mage::helper('sli_search')->__('Disabled')),
44
+ array('value' => self::FAILURES_ONLY, 'label' => Mage::helper('sli_search')->__('Failures Only')),
45
+ array('value' => self::ALL, 'label' => Mage::helper('sli_search')->__('All Failures and Successes')),
46
+ );
47
+ }
48
+
49
+ /**
50
+ * Get options in "key-value" format
51
+ *
52
+ * @return array
53
+ */
54
+ public function toArray()
55
+ {
56
+ return array(
57
+ self::DISABLED => Mage::helper('sli_search')->__('Disabled'),
58
+ self::FAILURES_ONLY => Mage::helper('sli_search')->__('Failures Only'),
59
+ self::ALL => Mage::helper('sli_search')->__('All Failures and Successes'),
60
+ );
61
+ }
62
+ }
app/code/community/SLI/Search/Model/System/Config/Source/Minigrid/Abstract.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Minigrid system config field type source model abstract
27
+ * Provides base functionality for minigrid source models
28
+ * as the toOptionArray is specialized to the minigrid type
29
+ *
30
+ * @package SLI
31
+ * @subpackage Search
32
+ */
33
+ abstract class SLI_Search_Model_System_Config_Source_Minigrid_Abstract
34
+ {
35
+ /**
36
+ * Default values of field array. Field array defines
37
+ * the fields on the grid.
38
+ *
39
+ * @return array
40
+ */
41
+ abstract protected function _getFields();
42
+
43
+ /**
44
+ * Add the additional grid type as a viable type on the form
45
+ *
46
+ * Note: Have to add value and label to each field array because
47
+ * the frontend renderer requires value and label to be set
48
+ * when under score scope.
49
+ *
50
+ * @return array
51
+ */
52
+ public function toOptionArray()
53
+ {
54
+ $fields = $this->_getFields();
55
+ foreach ($fields as $key => $field) {
56
+ $fields[$key]['value'] = 1;
57
+ $fields[$key]['label'] = 1;
58
+ }
59
+
60
+ return $fields;
61
+ }
62
+ }
app/code/community/SLI/Search/Model/System/Config/Source/Minigrid/Attributes.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Attributes MiniGrid source model
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Model_System_Config_Source_Minigrid_Attributes
32
+ extends SLI_Search_Model_System_Config_Source_Minigrid_Abstract
33
+ {
34
+ /**
35
+ * Minigrid field source. One column with a list of product attributes
36
+ *
37
+ * @return array
38
+ */
39
+ protected function _getFields()
40
+ {
41
+ return array(
42
+ "attribute" => array(
43
+ "width" => "100%",
44
+ "type" => "select",
45
+ "options" => Mage::getModel('sli_search/system_config_source_attributes')->toOptionArray()
46
+ )
47
+ );
48
+ }
49
+ }
app/code/community/SLI/Search/NotificationException.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * To be used when you a stores feed needs to stop, but other stores can continue
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_NotificationException extends SLI_Search_Exception
32
+ {
33
+
34
+ }
app/code/community/SLI/Search/controllers/Adminhtml/SliController.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Trigger feed generation.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_Adminhtml_SliController extends Mage_Adminhtml_Controller_Action
32
+ {
33
+ /**
34
+ * {@inheritdoc}
35
+ */
36
+ protected function _isAllowed()
37
+ {
38
+ return Mage::getSingleton('admin/session')
39
+ ->isAllowed('system/config/sli_search/manual_feed');
40
+ }
41
+
42
+ /**
43
+ * Feed generation action, linked to from the admin UI
44
+ * uri: /admin/sli/generateFeeds
45
+ */
46
+ public function generateFeedsAction()
47
+ {
48
+ $response = array();
49
+
50
+ $storeIds = array();
51
+ if ($storeId = $this->getRequest()->getParam("storeId")) {
52
+ $storeIds[] = $storeId;
53
+ }
54
+
55
+ /** @var $dataHelper SLI_Search_Helper_Data */
56
+ $dataHelper = Mage::helper('sli_search/data');
57
+
58
+ try {
59
+ /** @var $feedManager SLI_Search_Model_FeedManager */
60
+ $feedManager = Mage::getModel('sli_search/FeedManager');
61
+ $response = $feedManager->generateFeedForStores($storeIds);
62
+ } catch (SLI_Search_Exception $e) {
63
+ $response['messages'] = array("Error" => $e->getMessage());
64
+ $response['error'] = true;
65
+ } catch (Exception $e) {
66
+ Mage::logException($e);
67
+ $response['messages'] = array("Error" => "An unknown error occurred. Please contact your SLI provider");;
68
+ $response['error'] = true;
69
+ }
70
+
71
+ // email results
72
+ if ($dataHelper->sendEmail($response['error'])) {
73
+ Mage::getModel('sli_search/email')
74
+ ->setData('msg', $response['messages'])
75
+ ->setData('subject', 'Manual Feed Generation')
76
+ ->setData('email', $dataHelper->getFeedEmail())
77
+ ->send();
78
+ }
79
+
80
+ $this->getResponse()
81
+ ->setHeader("Content-Type", "application/json")
82
+ ->setBody(json_encode($response));
83
+ }
84
+ }
app/code/community/SLI/Search/controllers/ApiController.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Provide the URL for SLI to retrieve the current shopping cart items and all relative information
27
+ * An JSON file will be passed back
28
+ *
29
+ * @package SLI
30
+ * @subpackage Search
31
+ */
32
+ class SLI_Search_ApiController extends Mage_Core_Controller_Front_Action
33
+ {
34
+ // Declare the quote
35
+ private $quote = null;
36
+
37
+ /**
38
+ * Load the quote
39
+ *
40
+ * @return Mage_Sales_Model_Quote
41
+ */
42
+ protected function getQuote()
43
+ {
44
+ if ($this->quote) {
45
+ return $this->quote;
46
+ } else {
47
+ return Mage::getSingleton('checkout/session')->getQuote();
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Allow SLI to call this url to get the cart jsonp object
53
+ * uri: /sli/api/cart
54
+ */
55
+ public function cartAction()
56
+ {
57
+ $jsonpResult = Mage::helper('sli_search')->getCartJSONP(
58
+ $this->getQuote()
59
+ );
60
+
61
+ if ($jsonpResult) {
62
+ $this->getResponse()->setBody($jsonpResult);
63
+ }
64
+ }
65
+ }
app/code/community/SLI/Search/controllers/SearchController.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Provides the frontend capabilities of the SLI Search integration.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ class SLI_Search_SearchController extends Mage_Core_Controller_Front_Action
32
+ {
33
+ /**
34
+ * Renders a standard frontend page using just the default handles.
35
+ * Nothing is defined in the layout for this page and it should have an empty
36
+ * content.
37
+ *
38
+ * SLI uses this page as a template for their hosted search solution.
39
+ * uri: /sli/search/template
40
+ */
41
+ public function templateAction()
42
+ {
43
+ $this->loadLayout();
44
+ $this->renderLayout();
45
+ }
46
+ }
app/code/community/SLI/Search/etc/adminhtml.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Systems configurations for SLI Systems Search
27
+ * Includes General, Feed Settings, FTP Settings, Javascript, Cron Settings,
28
+ * Product Attributes, and other settings.
29
+ *
30
+ * @package SLI
31
+ * @subpackage Search
32
+ */
33
+ -->
34
+ <config>
35
+ <acl>
36
+ <resources>
37
+ <admin>
38
+ <children>
39
+ <system>
40
+ <children>
41
+ <config>
42
+ <children>
43
+ <sli_search translate="title" module="sli_search">
44
+ <title>SLI Learning Search Connect</title>
45
+ <children>
46
+ <manual_feed translate="title" module="sli_search">
47
+ <title>Manual Feed Generation</title>
48
+ </manual_feed>
49
+ </children>
50
+ </sli_search>
51
+ </children>
52
+ </config>
53
+ </children>
54
+ </system>
55
+ </children>
56
+ </admin>
57
+ </resources>
58
+ </acl>
59
+ </config>
app/code/{local → community}/SLI/Search/etc/config.xml RENAMED
@@ -1,133 +1,164 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
5
- * This file is part of Learning Search Connect.
6
- * Learning Search Connect is distribute under license,
7
- * go to www.sli-systems.com/LSC for full license details.
8
- *
9
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
10
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
11
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
12
- * PARTICULAR PURPOSE.
13
- *
14
- * SLI Systems Search integration.
15
- *
16
- * @package SLI
17
- * @subpackage Search
18
- */
19
- -->
20
- <config>
21
- <modules>
22
- <SLI_Search>
23
- <version>2.1.4</version>
24
- </SLI_Search>
25
- </modules>
26
- <global>
27
- <blocks>
28
- <sli_search>
29
- <class>SLI_Search_Block</class>
30
- </sli_search>
31
- <adminhtml>
32
- <rewrite>
33
- <system_config_form>SLI_Search_Block_System_Config_Form</system_config_form>
34
- </rewrite>
35
- </adminhtml>
36
- </blocks>
37
- <helpers>
38
- <sli_search>
39
- <class>SLI_Search_Helper</class>
40
- </sli_search>
41
- </helpers>
42
- <models>
43
- <sli_search>
44
- <class>SLI_Search_Model</class>
45
- </sli_search>
46
- </models>
47
- <resources>
48
- <sli_search_setup>
49
- <setup>
50
- <module>SLI_Search</module>
51
- </setup>
52
- </sli_search_setup>
53
- </resources>
54
- </global>
55
- <frontend>
56
- <routers>
57
- <sli_search>
58
- <use>standard</use>
59
- <args>
60
- <module>SLI_Search</module>
61
- <frontName>sli</frontName>
62
- </args>
63
- </sli_search>
64
- </routers>
65
- <layout>
66
- <updates>
67
- <sli_search module="SLI_Search">
68
- <file>sli/search.xml</file>
69
- </sli_search>
70
- </updates>
71
- </layout>
72
- </frontend>
73
- <default>
74
- <sli_search>
75
- <general>
76
- <form_enabled>0</form_enabled>
77
- <feed_enabled>1</feed_enabled>
78
- <price_feed>0</price_feed>
79
- <log_level>1</log_level>
80
- </general>
81
- <feed>
82
- <backup>1</backup>
83
- <submittal/>
84
- <stockstatus>1</stockstatus>
85
- <categorystatus>0</categorystatus>
86
- <email_setting>1</email_setting>
87
- <emailto/>
88
- <generate/>
89
- <write_batch>10000</write_batch>
90
- </feed>
91
- <ftp>
92
- <enabled>1</enabled>
93
- <user/>
94
- <pass backend_model="adminhtml/system_config_backend_encrypted"/>
95
- <path/>
96
- </ftp>
97
- <form>
98
- <customform>0</customform>
99
- <formcode>&lt;!-- Please get configuration from SLI Systems !--&gt;</formcode>
100
- </form>
101
- <js>
102
- <header>&lt;!-- Please get configuration from SLI Systems !--&gt;</header>
103
- <footer/>
104
- <autocomplete/>
105
- <domain/>
106
- </js>
107
- <cron>
108
- <email/>
109
- <frequency backend_model="sli_search/system_config_backend_cron">D</frequency>
110
- <time>2,00,00</time>
111
- <disabled>0</disabled>
112
- </cron>
113
- <attributes>
114
- <attributes backend_model="sli_search/system_config_backend_minigrid" />
115
- </attributes>
116
- <default_attributes>
117
- <attributes>name,url_path,product_id<!--sku,short_description,description,meta_description,price,special_price,special_from_date,special_to_date,news_to_date,news_from_date,image,small_image,product_id,type_id--></attributes>
118
- </default_attributes>
119
- </sli_search>
120
- </default>
121
- <crontab>
122
- <sli_search>
123
- <job_code>sli_feed_generate</job_code>
124
- </sli_search>
125
- <jobs>
126
- <sli_search>
127
- <run>
128
- <model>sli_search/cron::generateFeeds</model>
129
- </run>
130
- </sli_search>
131
- </jobs>
132
- </crontab>
133
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * SLI Systems Search integration.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ -->
32
+ <config>
33
+ <modules>
34
+ <SLI_Search>
35
+ <version>3.0.5</version>
36
+ </SLI_Search>
37
+ </modules>
38
+ <global>
39
+ <blocks>
40
+ <sli_search>
41
+ <class>SLI_Search_Block</class>
42
+ </sli_search>
43
+ <adminhtml>
44
+ <rewrite>
45
+ <system_config_form>SLI_Search_Block_System_Config_Form</system_config_form>
46
+ </rewrite>
47
+ </adminhtml>
48
+ </blocks>
49
+ <helpers>
50
+ <sli_search>
51
+ <class>SLI_Search_Helper</class>
52
+ </sli_search>
53
+ </helpers>
54
+ <models>
55
+ <sli_search>
56
+ <class>SLI_Search_Model</class>
57
+ <resourceModel>sli_search_resource</resourceModel>
58
+ </sli_search>
59
+ <sli_search_resource>
60
+ <class>SLI_Search_Model_Resource</class>
61
+ </sli_search_resource>
62
+ </models>
63
+ <resources>
64
+ <sli_search_setup>
65
+ <setup>
66
+ <module>SLI_Search</module>
67
+ </setup>
68
+ </sli_search_setup>
69
+ </resources>
70
+ <template>
71
+ <email>
72
+ <sli_feed_email_template translate="label" module="adminhtml">
73
+ <label>SLI Feed Notification</label>
74
+ <file>sli/feed_email_template.html</file>
75
+ <type>html</type>
76
+ </sli_feed_email_template>
77
+ </email>
78
+ </template>
79
+ </global>
80
+ <frontend>
81
+ <routers>
82
+ <sli_search>
83
+ <use>standard</use>
84
+ <args>
85
+ <module>SLI_Search</module>
86
+ <frontName>sli</frontName>
87
+ </args>
88
+ </sli_search>
89
+ </routers>
90
+ <layout>
91
+ <updates>
92
+ <sli_search module="SLI_Search">
93
+ <file>sli/search.xml</file>
94
+ </sli_search>
95
+ </updates>
96
+ </layout>
97
+ </frontend>
98
+ <admin>
99
+ <routers>
100
+ <adminhtml>
101
+ <args>
102
+ <modules>
103
+ <frontName>sli</frontName>
104
+ <SLI_Search before="Mage_Adminhtml">SLI_Search_Adminhtml</SLI_Search>
105
+ </modules>
106
+ </args>
107
+ </adminhtml>
108
+ </routers>
109
+ </admin>
110
+ <default>
111
+ <sli_search>
112
+ <general>
113
+ <form_enabled>0</form_enabled>
114
+ <feed_enabled>1</feed_enabled>
115
+ <price_feed>0</price_feed>
116
+ <log_level>1</log_level>
117
+ </general>
118
+ <feed>
119
+ <backup>1</backup>
120
+ <submittal/>
121
+ <stockstatus>1</stockstatus>
122
+ <email_setting>1</email_setting>
123
+ <emailto/>
124
+ <generate/>
125
+ <write_batch>1000</write_batch>
126
+ </feed>
127
+ <ftp>
128
+ <enabled>1</enabled>
129
+ <user/>
130
+ <pass backend_model="adminhtml/system_config_backend_encrypted"/>
131
+ <path/>
132
+ </ftp>
133
+ <form>
134
+ <formcode>&lt;!-- Please get configuration from SLI Systems !--&gt;</formcode>
135
+ </form>
136
+ <js>
137
+ <header>&lt;!-- Please get configuration from SLI Systems !--&gt;</header>
138
+ <footer>&lt;!-- Please get configuration from SLI Systems !--&gt;</footer>
139
+ </js>
140
+ <cron>
141
+ <email/>
142
+ <frequency backend_model="sli_search/system_config_backend_cron">D</frequency>
143
+ <time>2,0</time>
144
+ <disabled>0</disabled>
145
+ </cron>
146
+ <attributes>
147
+ <attributes backend_model="sli_search/system_config_backend_minigrid"/>
148
+ </attributes>
149
+ </sli_search>
150
+ </default>
151
+ <crontab>
152
+ <jobs>
153
+ <!-- job code: SLI_Search_Model_Cron::JOB_CODE_GENERATE_FEEDS -->
154
+ <sli_search>
155
+ <schedule>
156
+ <cron_expr>0 2 * * *</cron_expr>
157
+ </schedule>
158
+ <run>
159
+ <model>sli_search/cron::generateFeeds</model>
160
+ </run>
161
+ </sli_search>
162
+ </jobs>
163
+ </crontab>
164
+ </config>
app/code/{local → community}/SLI/Search/etc/system.xml RENAMED
@@ -1,390 +1,373 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
5
- * This file is part of Learning Search Connect.
6
- * Learning Search Connect is distribute under license,
7
- * go to www.sli-systems.com/LSC for full license details.
8
- *
9
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
10
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
11
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
12
- * PARTICULAR PURPOSE.
13
- *
14
- * Systems configurations for SLI Systems Search
15
- * Includes General, Feed Settings, FTP Settings, Javascript, Cron Settings,
16
- * Product Attributes, and other settings.
17
- *
18
- * @package SLI
19
- * @subpackage Search
20
- */
21
- -->
22
- <config>
23
- <tabs>
24
- <sli translate="label" module="sli_search">
25
- <label>SLI</label>
26
- <sort_order>200</sort_order>
27
- </sli>
28
- </tabs>
29
- <sections>
30
- <sli_search translate="label" module="sli_search">
31
- <label>SLI Settings</label>
32
- <tab>sli</tab>
33
- <frontend_type>text</frontend_type>
34
- <sort_order>100</sort_order>
35
- <show_in_default>1</show_in_default>
36
- <show_in_website>1</show_in_website>
37
- <show_in_store>1</show_in_store>
38
- <groups>
39
- <general translate="label" module="sli_search">
40
- <label>General</label>
41
- <frontend_type>text</frontend_type>
42
- <sort_order>1</sort_order>
43
- <show_in_default>1</show_in_default>
44
- <show_in_website>1</show_in_website>
45
- <show_in_store>1</show_in_store>
46
- <fields>
47
- <form_enabled translate="label">
48
- <label>SLI Search Form</label>
49
- <frontend_type>select</frontend_type>
50
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
51
- <sort_order>1</sort_order>
52
- <show_in_default>1</show_in_default>
53
- <show_in_website>1</show_in_website>
54
- <show_in_store>1</show_in_store>
55
- </form_enabled>
56
- <feed_enabled translate="label">
57
- <label>Feed Generation</label>
58
- <frontend_type>select</frontend_type>
59
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
60
- <sort_order>1</sort_order>
61
- <show_in_default>1</show_in_default>
62
- <show_in_website>1</show_in_website>
63
- <show_in_store>1</show_in_store>
64
- </feed_enabled>
65
- <price_feed>
66
- <label>Price Feed</label>
67
- <frontend_type>select</frontend_type>
68
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
69
- <depends><feed_enabled>1</feed_enabled></depends>
70
- <sort_order>5</sort_order>
71
- <show_in_default>1</show_in_default>
72
- <show_in_website>1</show_in_website>
73
- <show_in_store>1</show_in_store>
74
- </price_feed>
75
- <log_level>
76
- <label>Log Level</label>
77
- <frontend_type>select</frontend_type>
78
- <source_model>sli_search/system_config_backend_loglevel</source_model>
79
- <comment>Please set to "Trace" if SLI support is required.</comment>
80
- <sort_order>10</sort_order>
81
- <show_in_default>1</show_in_default>
82
- <show_in_website>1</show_in_website>
83
- <show_in_store>1</show_in_store>
84
- </log_level>
85
- </fields>
86
- </general>
87
- <feed translate="label" module="sli_search">
88
- <label>Feed Settings</label>
89
- <frontend_type>text</frontend_type>
90
- <sort_order>100</sort_order>
91
- <show_in_default>1</show_in_default>
92
- <show_in_website>1</show_in_website>
93
- <show_in_store>1</show_in_store>
94
- <fields>
95
- <backup translate="label">
96
- <label>Backup Feed?</label>
97
- <frontend_type>select</frontend_type>
98
- <source_model>adminhtml/system_config_source_yesno</source_model>
99
- <sort_order>1</sort_order>
100
- <show_in_default>1</show_in_default>
101
- <show_in_website>0</show_in_website>
102
- <show_in_store>0</show_in_store>
103
- </backup>
104
- <write_batch translate="label">
105
- <label>Batch Count</label>
106
- <frontend_type>text</frontend_type>
107
- <comment>Please only change the pre-populated value in consultation with SLI. The lower the number, the slower the feed generation.</comment>
108
- <sort_order>10</sort_order>
109
- <show_in_default>1</show_in_default>
110
- <show_in_website>0</show_in_website>
111
- <show_in_store>0</show_in_store>
112
- </write_batch>
113
- <submittal translate="label">
114
- <label>Next Automatic Feed Generation</label>
115
- <frontend_type>text</frontend_type>
116
- <frontend_model>sli_search/system_config_frontend_feed_next</frontend_model>
117
- <sort_order>100</sort_order>
118
- <show_in_default>1</show_in_default>
119
- <show_in_website>0</show_in_website>
120
- <show_in_store>0</show_in_store>
121
- </submittal>
122
- <stockstatus translate="label">
123
- <label>Include Out of Stock Items</label>
124
- <frontend_type>select</frontend_type>
125
- <source_model>adminhtml/system_config_source_yesno</source_model>
126
- <sort_order>150</sort_order>
127
- <show_in_default>1</show_in_default>
128
- <show_in_website>1</show_in_website>
129
- <show_in_store>1</show_in_store>
130
- </stockstatus>
131
- <categorystatus>
132
- <label>Include Disabled Categories</label>
133
- <frontend_type>select</frontend_type>
134
- <source_model>adminhtml/system_config_source_yesno</source_model>
135
- <sort_order>175</sort_order>
136
- <show_in_default>1</show_in_default>
137
- <show_in_website>1</show_in_website>
138
- <show_in_store>1</show_in_store>
139
- </categorystatus>
140
- <email_setting>
141
- <label>Email Results</label>
142
- <frontend_type>select</frontend_type>
143
- <source_model>sli_search/system_config_source_emailsetting</source_model>
144
- <sort_order>180</sort_order>
145
- <show_in_default>1</show_in_default>
146
- <show_in_website>0</show_in_website>
147
- <show_in_store>0</show_in_store>
148
- </email_setting>
149
- <emailto>
150
- <label>Email Address</label>
151
- <frontend_type>text</frontend_type>
152
- <sort_order>190</sort_order>
153
- <show_in_default>1</show_in_default>
154
- <show_in_website>0</show_in_website>
155
- <show_in_store>0</show_in_store>
156
- </emailto>
157
- <generate translate="label">
158
- <label>Generate Feed</label>
159
- <frontend_type>button</frontend_type>
160
- <frontend_model>sli_search/system_config_frontend_feed_generate</frontend_model>
161
- <comment>Manually generates feed. If FTP is enabled, also sends the feed.</comment>
162
- <sort_order>200</sort_order>
163
- <show_in_default>1</show_in_default>
164
- <show_in_website>0</show_in_website>
165
- <show_in_store>0</show_in_store>
166
- </generate>
167
- </fields>
168
- </feed>
169
- <ftp translate="label" module="sli_search">
170
- <label>FTP Settings</label>
171
- <frontend_type>text</frontend_type>
172
- <sort_order>200</sort_order>
173
- <show_in_default>1</show_in_default>
174
- <show_in_website>1</show_in_website>
175
- <show_in_store>1</show_in_store>
176
- <fields>
177
- <enabled translate="label">
178
- <label>Enabled</label>
179
- <frontend_type>select</frontend_type>
180
- <source_model>adminhtml/system_config_source_yesno</source_model>
181
- <sort_order>1</sort_order>
182
- <show_in_default>1</show_in_default>
183
- <show_in_website>1</show_in_website>
184
- <show_in_store>1</show_in_store>
185
- </enabled>
186
- <user translate="label">
187
- <label>FTP User</label>
188
- <frontend_type>text</frontend_type>
189
- <comment>Provided by SLI.</comment>
190
- <sort_order>100</sort_order>
191
- <show_in_default>1</show_in_default>
192
- <show_in_website>1</show_in_website>
193
- <show_in_store>1</show_in_store>
194
- </user>
195
- <pass translate="label">
196
- <label>FTP Password</label>
197
- <frontend_type>obscure</frontend_type>
198
- <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
199
- <comment>Provided by SLI.</comment>
200
- <sort_order>200</sort_order>
201
- <show_in_default>1</show_in_default>
202
- <show_in_website>1</show_in_website>
203
- <show_in_store>1</show_in_store>
204
- </pass>
205
- <host translate="label">
206
- <label>FTP Host</label>
207
- <frontend_type>text</frontend_type>
208
- <comment>Provided by SLI.</comment>
209
- <sort_order>300</sort_order>
210
- <show_in_default>1</show_in_default>
211
- <show_in_website>1</show_in_website>
212
- <show_in_store>1</show_in_store>
213
- </host>
214
- <path translate="label">
215
- <label>FTP Upload Path</label>
216
- <frontend_type>text</frontend_type>
217
- <comment>Provided by SLI.</comment>
218
- <sort_order>400</sort_order>
219
- <show_in_default>1</show_in_default>
220
- <show_in_website>1</show_in_website>
221
- <show_in_store>1</show_in_store>
222
- </path>
223
- </fields>
224
- </ftp>
225
- <form translate="label" module="sli_search">
226
- <label>Search Form Code</label>
227
- <frontend_type>text</frontend_type>
228
- <sort_order>250</sort_order>
229
- <show_in_default>1</show_in_default>
230
- <show_in_website>1</show_in_website>
231
- <show_in_store>1</show_in_store>
232
- <fields>
233
- <customform translate="label">
234
- <label>Use Custom Search Form Code</label>
235
- <comment>Enable use of a custom form rather than default form.mini.phtml</comment>
236
- <source_model>adminhtml/system_config_source_yesno</source_model>
237
- <frontend_type>select</frontend_type>
238
- <sort_order>1</sort_order>
239
- <show_in_default>1</show_in_default>
240
- <show_in_website>1</show_in_website>
241
- <show_in_store>1</show_in_store>
242
- </customform>
243
- <formcode translate="label">
244
- <label>Custom Form Code</label>
245
- <comment>Provided by SLI.</comment>
246
- <frontend_type>textarea</frontend_type>
247
- <sort_order>2</sort_order>
248
- <show_in_default>1</show_in_default>
249
- <show_in_website>1</show_in_website>
250
- <show_in_store>1</show_in_store>
251
- <depends><customform>1</customform></depends>
252
- </formcode>
253
- </fields>
254
- </form>
255
- <js translate="label" module="sli_search">
256
- <label>JavaScript</label>
257
- <frontend_type>text</frontend_type>
258
- <sort_order>300</sort_order>
259
- <show_in_default>1</show_in_default>
260
- <show_in_website>1</show_in_website>
261
- <show_in_store>1</show_in_store>
262
- <fields>
263
- <header translate="label">
264
- <label>Header</label>
265
- <comment>Provided by SLI.</comment>
266
- <frontend_type>textarea</frontend_type>
267
- <sort_order>1</sort_order>
268
- <show_in_default>1</show_in_default>
269
- <show_in_website>1</show_in_website>
270
- <show_in_store>1</show_in_store>
271
- </header>
272
- <footer translate="label">
273
- <label>Footer</label>
274
- <comment>Provided by SLI.</comment>
275
- <frontend_type>textarea</frontend_type>
276
- <sort_order>100</sort_order>
277
- <show_in_default>1</show_in_default>
278
- <show_in_website>1</show_in_website>
279
- <show_in_store>1</show_in_store>
280
- </footer>
281
- <autocomplete translate="label">
282
- <label>Auto Complete</label>
283
- <frontend_type>textarea</frontend_type>
284
- <sort_order>200</sort_order>
285
- <show_in_default>1</show_in_default>
286
- <show_in_website>1</show_in_website>
287
- <show_in_store>1</show_in_store>
288
- </autocomplete>
289
- <domain translate="label">
290
- <label>Search Domain</label>
291
- <comment>Provided by SLI.</comment>
292
- <frontend_type>text</frontend_type>
293
- <sort_order>300</sort_order>
294
- <show_in_default>1</show_in_default>
295
- <show_in_website>1</show_in_website>
296
- <show_in_store>1</show_in_store>
297
- </domain>
298
- </fields>
299
- </js>
300
- <cron translate="label" module="sli_search">
301
- <label>Cron Settings</label>
302
- <frontend_type>text</frontend_type>
303
- <sort_order>400</sort_order>
304
- <show_in_default>1</show_in_default>
305
- <show_in_website>0</show_in_website>
306
- <show_in_store>0</show_in_store>
307
- <fields>
308
- <email translate="label">
309
- <label>Cron Email</label>
310
- <comment>When cron runs, email to send notification to.</comment>
311
- <frontend_type>text</frontend_type>
312
- <sort_order>1</sort_order>
313
- <show_in_default>1</show_in_default>
314
- <show_in_website>1</show_in_website>
315
- <show_in_store>1</show_in_store>
316
- </email>
317
- <frequency translate="label">
318
- <label>Frequency</label>
319
- <comment>Hourly times from 12:00AM</comment>
320
- <frontend_type>select</frontend_type>
321
- <source_model>sli_search/system_config_source_cron_frequency</source_model>
322
- <backend_model>sli_search/system_config_backend_cron</backend_model>
323
- <sort_order>100</sort_order>
324
- <show_in_default>1</show_in_default>
325
- <show_in_website>1</show_in_website>
326
- <show_in_store>1</show_in_store>
327
- </frequency>
328
- <time translate="label">
329
- <label>Start Time</label>
330
- <comment>Only used when set to Daily, Weekly or Monthly</comment>
331
- <frontend_type>time</frontend_type>
332
- <sort_order>200</sort_order>
333
- <show_in_default>1</show_in_default>
334
- <show_in_website>1</show_in_website>
335
- <show_in_store>1</show_in_store>
336
- </time>
337
- <disabled translate="label">
338
- <label>Disabled</label>
339
- <frontend_type>select</frontend_type>
340
- <source_model>adminhtml/system_config_source_yesno</source_model>
341
- <sort_order>300</sort_order>
342
- <show_in_default>1</show_in_default>
343
- <show_in_website>1</show_in_website>
344
- <show_in_store>1</show_in_store>
345
- </disabled>
346
- </fields>
347
- </cron>
348
- <attributes translate="label" module="sli_search">
349
- <label>Product Attributes</label>
350
- <frontend_type>text</frontend_type>
351
- <sort_order>500</sort_order>
352
- <show_in_default>1</show_in_default>
353
- <show_in_website>1</show_in_website>
354
- <show_in_store>1</show_in_store>
355
- <fields>
356
- <attributes translate="label">
357
- <label>Attributes to include</label>
358
- <comment>The following attributes are automatically added to the feed: Name, URL, Children Ids, Categories and Product Ids.</comment>
359
- <frontend_type>minigrid</frontend_type>
360
- <source_model>sli_search/system_config_source_minigrid_attributes</source_model>
361
- <backend_model>sli_search/system_config_backend_minigrid</backend_model>
362
- <sort_order>1</sort_order>
363
- <show_in_default>1</show_in_default>
364
- <show_in_website>1</show_in_website>
365
- <show_in_store>1</show_in_store>
366
- </attributes>
367
- </fields>
368
- </attributes>
369
- <version translate="label" module="sli_search">
370
- <label>Version Information</label>
371
- <frontend_type>text</frontend_type>
372
- <sort_order>600</sort_order>
373
- <show_in_default>1</show_in_default>
374
- <show_in_website>1</show_in_website>
375
- <show_in_store>1</show_in_store>
376
- <fields>
377
- <version translate="label">
378
- <label>Version</label>
379
- <frontend_type>version</frontend_type>
380
- <sort_order>100</sort_order>
381
- <show_in_default>1</show_in_default>
382
- <show_in_website>1</show_in_website>
383
- <show_in_store>1</show_in_store>
384
- </version>
385
- </fields>
386
- </version>
387
- </groups>
388
- </sli_search>
389
- </sections>
390
- </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Systems configurations for SLI Systems Search
27
+ * Includes General, Feed Settings, FTP Settings, Javascript, Cron Settings,
28
+ * Product Attributes, and other settings.
29
+ *
30
+ * @package SLI
31
+ * @subpackage Search
32
+ */
33
+ -->
34
+ <config>
35
+ <tabs>
36
+ <sli translate="label" module="sli_search">
37
+ <label>SLI Systems</label>
38
+ <sort_order>200</sort_order>
39
+ </sli>
40
+ </tabs>
41
+ <sections>
42
+ <sli_search translate="label" module="sli_search">
43
+ <label>Learning Search Connect</label>
44
+ <tab>sli</tab>
45
+ <frontend_type>text</frontend_type>
46
+ <sort_order>100</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ <groups>
51
+ <general translate="label" module="sli_search">
52
+ <label>General</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>1</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ <fields>
59
+ <form_enabled translate="label">
60
+ <label>SLI Search Form</label>
61
+ <frontend_type>select</frontend_type>
62
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
63
+ <sort_order>1</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ </form_enabled>
68
+ <feed_enabled translate="label">
69
+ <label>Feed Generation</label>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
72
+ <sort_order>1</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </feed_enabled>
77
+ <price_feed>
78
+ <label>Price Feed</label>
79
+ <frontend_type>select</frontend_type>
80
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
81
+ <depends>
82
+ <feed_enabled>1</feed_enabled>
83
+ </depends>
84
+ <sort_order>5</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </price_feed>
89
+ <log_level>
90
+ <label>Log Level</label>
91
+ <frontend_type>select</frontend_type>
92
+ <source_model>sli_search/system_config_backend_loglevel</source_model>
93
+ <comment>Please set to "Trace" if SLI support is required.</comment>
94
+ <sort_order>10</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ </log_level>
99
+ </fields>
100
+ </general>
101
+ <feed translate="label" module="sli_search">
102
+ <label>Feed Settings</label>
103
+ <frontend_type>text</frontend_type>
104
+ <sort_order>100</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ <fields>
109
+ <backup translate="label">
110
+ <label>Backup Feed?</label>
111
+ <frontend_type>select</frontend_type>
112
+ <source_model>adminhtml/system_config_source_yesno</source_model>
113
+ <sort_order>1</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>0</show_in_website>
116
+ <show_in_store>0</show_in_store>
117
+ </backup>
118
+ <write_batch translate="label">
119
+ <label>Batch Count</label>
120
+ <frontend_type>text</frontend_type>
121
+ <comment>Please only change the pre-populated value in consultation with SLI. The lower the
122
+ number, the slower the feed generation.
123
+ </comment>
124
+ <sort_order>10</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>0</show_in_website>
127
+ <show_in_store>0</show_in_store>
128
+ </write_batch>
129
+ <submittal translate="label">
130
+ <label>Next Automatic Feed Generation</label>
131
+ <frontend_type>text</frontend_type>
132
+ <frontend_model>sli_search/system_config_frontend_feed_next</frontend_model>
133
+ <sort_order>100</sort_order>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>0</show_in_website>
136
+ <show_in_store>0</show_in_store>
137
+ </submittal>
138
+ <stockstatus translate="label">
139
+ <label>Include Out of Stock Items</label>
140
+ <frontend_type>select</frontend_type>
141
+ <source_model>adminhtml/system_config_source_yesno</source_model>
142
+ <sort_order>150</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ </stockstatus>
147
+ <email_setting>
148
+ <label>Email Results</label>
149
+ <frontend_type>select</frontend_type>
150
+ <source_model>sli_search/system_config_source_emailsetting</source_model>
151
+ <sort_order>180</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>0</show_in_website>
154
+ <show_in_store>0</show_in_store>
155
+ </email_setting>
156
+ <emailto>
157
+ <label>Email Address</label>
158
+ <frontend_type>text</frontend_type>
159
+ <sort_order>190</sort_order>
160
+ <show_in_default>1</show_in_default>
161
+ <show_in_website>0</show_in_website>
162
+ <show_in_store>0</show_in_store>
163
+ </emailto>
164
+ <generate translate="label">
165
+ <label>Generate Feed</label>
166
+ <frontend_type>button</frontend_type>
167
+ <frontend_model>sli_search/system_config_frontend_feed_generate</frontend_model>
168
+ <comment>Manually generates feed. If FTP is enabled, also sends the feed.</comment>
169
+ <sort_order>200</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>0</show_in_website>
172
+ <show_in_store>0</show_in_store>
173
+ </generate>
174
+ </fields>
175
+ </feed>
176
+ <ftp translate="label" module="sli_search">
177
+ <label>FTP Settings</label>
178
+ <frontend_type>text</frontend_type>
179
+ <sort_order>200</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <show_in_store>1</show_in_store>
183
+ <fields>
184
+ <enabled translate="label">
185
+ <label>Enabled</label>
186
+ <frontend_type>select</frontend_type>
187
+ <source_model>adminhtml/system_config_source_yesno</source_model>
188
+ <sort_order>1</sort_order>
189
+ <show_in_default>1</show_in_default>
190
+ <show_in_website>1</show_in_website>
191
+ <show_in_store>1</show_in_store>
192
+ </enabled>
193
+ <user translate="label">
194
+ <label>FTP User</label>
195
+ <frontend_type>text</frontend_type>
196
+ <comment>Provided by SLI.</comment>
197
+ <sort_order>100</sort_order>
198
+ <show_in_default>1</show_in_default>
199
+ <show_in_website>1</show_in_website>
200
+ <show_in_store>1</show_in_store>
201
+ </user>
202
+ <pass translate="label">
203
+ <label>FTP Password</label>
204
+ <frontend_type>obscure</frontend_type>
205
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
206
+ <comment>Provided by SLI.</comment>
207
+ <sort_order>200</sort_order>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ </pass>
212
+ <host translate="label">
213
+ <label>FTP Host</label>
214
+ <frontend_type>text</frontend_type>
215
+ <comment>Provided by SLI.</comment>
216
+ <sort_order>300</sort_order>
217
+ <show_in_default>1</show_in_default>
218
+ <show_in_website>1</show_in_website>
219
+ <show_in_store>1</show_in_store>
220
+ </host>
221
+ <path translate="label">
222
+ <label>FTP Upload Path</label>
223
+ <frontend_type>text</frontend_type>
224
+ <comment>Provided by SLI.</comment>
225
+ <sort_order>400</sort_order>
226
+ <show_in_default>1</show_in_default>
227
+ <show_in_website>1</show_in_website>
228
+ <show_in_store>1</show_in_store>
229
+ </path>
230
+ </fields>
231
+ </ftp>
232
+ <form translate="label" module="sli_search">
233
+ <label>Search Form Code</label>
234
+ <frontend_type>text</frontend_type>
235
+ <sort_order>250</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>1</show_in_store>
239
+ <fields>
240
+ <formcode translate="label">
241
+ <label>Custom Form Code</label>
242
+ <comment>Provided by SLI.</comment>
243
+ <frontend_type>textarea</frontend_type>
244
+ <sort_order>2</sort_order>
245
+ <show_in_default>1</show_in_default>
246
+ <show_in_website>1</show_in_website>
247
+ <show_in_store>1</show_in_store>
248
+ </formcode>
249
+ </fields>
250
+ </form>
251
+ <js translate="label" module="sli_search">
252
+ <label>JavaScript</label>
253
+ <frontend_type>text</frontend_type>
254
+ <sort_order>300</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>1</show_in_store>
258
+ <fields>
259
+ <header translate="label">
260
+ <label>Header</label>
261
+ <comment>Provided by SLI.</comment>
262
+ <frontend_type>textarea</frontend_type>
263
+ <sort_order>1</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <show_in_store>1</show_in_store>
267
+ </header>
268
+ <footer translate="label">
269
+ <label>Footer</label>
270
+ <comment>Provided by SLI.</comment>
271
+ <frontend_type>textarea</frontend_type>
272
+ <sort_order>100</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <show_in_store>1</show_in_store>
276
+ </footer>
277
+ </fields>
278
+ </js>
279
+ <cron translate="label" module="sli_search">
280
+ <label>Cron Settings</label>
281
+ <frontend_type>text</frontend_type>
282
+ <sort_order>400</sort_order>
283
+ <show_in_default>1</show_in_default>
284
+ <show_in_website>0</show_in_website>
285
+ <show_in_store>0</show_in_store>
286
+ <fields>
287
+ <email translate="label">
288
+ <label>Cron Email</label>
289
+ <comment>When cron runs, email to send notification to.</comment>
290
+ <frontend_type>text</frontend_type>
291
+ <sort_order>1</sort_order>
292
+ <show_in_default>1</show_in_default>
293
+ <show_in_website>0</show_in_website>
294
+ <show_in_store>0</show_in_store>
295
+ </email>
296
+ <frequency translate="label">
297
+ <label>Frequency</label>
298
+ <comment>Hourly times from 12:00AM</comment>
299
+ <frontend_type>select</frontend_type>
300
+ <source_model>sli_search/system_config_source_cron_frequency</source_model>
301
+ <backend_model>sli_search/system_config_backend_cron</backend_model>
302
+ <sort_order>100</sort_order>
303
+ <show_in_default>1</show_in_default>
304
+ <show_in_website>0</show_in_website>
305
+ <show_in_store>0</show_in_store>
306
+ </frequency>
307
+ <time translate="label">
308
+ <label>Start Time</label>
309
+ <comment>Only used when set to Daily or Weekly (Seconds do not apply to any cron
310
+ configuration)
311
+ </comment>
312
+ <frontend_type>time</frontend_type>
313
+ <sort_order>200</sort_order>
314
+ <show_in_default>1</show_in_default>
315
+ <show_in_website>0</show_in_website>
316
+ <show_in_store>0</show_in_store>
317
+ </time>
318
+ <disabled translate="label">
319
+ <label>Disabled</label>
320
+ <frontend_type>select</frontend_type>
321
+ <source_model>adminhtml/system_config_source_yesno</source_model>
322
+ <sort_order>300</sort_order>
323
+ <show_in_default>1</show_in_default>
324
+ <show_in_website>0</show_in_website>
325
+ <show_in_store>0</show_in_store>
326
+ </disabled>
327
+ </fields>
328
+ </cron>
329
+ <attributes translate="label" module="sli_search">
330
+ <label>Product Attributes</label>
331
+ <frontend_type>text</frontend_type>
332
+ <sort_order>500</sort_order>
333
+ <show_in_default>1</show_in_default>
334
+ <show_in_website>1</show_in_website>
335
+ <show_in_store>1</show_in_store>
336
+ <fields>
337
+ <attributes translate="label">
338
+ <label>Attributes to include</label>
339
+ <comment>The following attributes are automatically added to the feed: Name, URL, Children
340
+ Ids, Categories and Product Ids.
341
+ </comment>
342
+ <frontend_type>minigrid</frontend_type>
343
+ <source_model>sli_search/system_config_source_minigrid_attributes</source_model>
344
+ <backend_model>sli_search/system_config_backend_minigrid</backend_model>
345
+ <sort_order>1</sort_order>
346
+ <show_in_default>1</show_in_default>
347
+ <show_in_website>1</show_in_website>
348
+ <show_in_store>1</show_in_store>
349
+ </attributes>
350
+ </fields>
351
+ </attributes>
352
+ <version translate="label" module="sli_search">
353
+ <label>Version Information</label>
354
+ <frontend_type>text</frontend_type>
355
+ <sort_order>600</sort_order>
356
+ <show_in_default>1</show_in_default>
357
+ <show_in_website>1</show_in_website>
358
+ <show_in_store>1</show_in_store>
359
+ <fields>
360
+ <version translate="label">
361
+ <label>Version</label>
362
+ <frontend_type>version</frontend_type>
363
+ <sort_order>100</sort_order>
364
+ <show_in_default>1</show_in_default>
365
+ <show_in_website>1</show_in_website>
366
+ <show_in_store>1</show_in_store>
367
+ </version>
368
+ </fields>
369
+ </version>
370
+ </groups>
371
+ </sli_search>
372
+ </sections>
373
+ </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/SLI/Search/sql/sli_search_setup/install-1.0.0.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Install script for version 1.0.0
27
+ * Sets defaults into system config data table
28
+ *
29
+ * @package SLI
30
+ * @subpackage Search
31
+ */
32
+
33
+ // save out the cron job to the core config data table
34
+ $frequency = Mage::getConfig()->getNode('default/sli_search/cron/frequency');
35
+ $time = explode(',', Mage::getConfig()->getNode('default/sli_search/cron/time'));
36
+
37
+ /** @var SLI_Search_Helper_Data $dataHelper */
38
+ $dataHelper = Mage::helper('sli_search/data');
39
+
40
+ $cronTab = $dataHelper->getCronTimeAsCrontab($frequency, $time);
41
+ $model = Mage::getConfig()->getNode(SLI_Search_Model_Cron::CRON_GENERATE_FEEDS_MODEL_RUN_PATH);
42
+
43
+ /** @var SLI_Search_Model_System_Config_Backend_Cron $backendCron */
44
+ $backendCron = Mage::getModel('sli_search/system_config_backend_cron');
45
+ $backendCron->saveCronTab($cronTab, $model);
app/code/local/SLI/Search/Block/Search/Form/Mini.php DELETED
@@ -1,71 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Search Mini Form block.
14
- * Provides rendering abilities for SLI version of the form.mini.phtml that
15
- * replaces the search url with an external url to an SLI hosted search page.
16
- * Provides an inline search autocomplete feature as well.
17
- *
18
- * @package SLI
19
- * @subpackage Search
20
- */
21
-
22
- class SLI_Search_Block_Search_Form_Mini extends Mage_Core_Block_Template {
23
-
24
- /**
25
- * Returns SLI provided auto complete javascript.
26
- *
27
- * @return string
28
- */
29
- public function getInlineAutocompleteJs() {
30
- return Mage::helper('sli_search')->getAutocompleteJs();
31
- }
32
-
33
- /**
34
- * Returns External search domain to the search page hosted by SLI.
35
- *
36
- * @return string
37
- */
38
- public function getSearchUrl() {
39
- $url = Mage::helper('sli_search')->getSearchDomain();
40
- $scheme = parse_url($url, PHP_URL_SCHEME);
41
-
42
- if (!$scheme) {
43
- $url = "http://".$url;
44
- }
45
-
46
- return $url;
47
- }
48
-
49
- /**
50
- * Retrieve the form code from the database for this site
51
- *
52
- * @return string
53
- */
54
- public function getFormData() {
55
- return $data = Mage::helper('sli_search')->getFormData();
56
- }
57
-
58
- /**
59
- * Use the default SLI layout or the custom layout from the DB
60
- *
61
- * @return string
62
- */
63
- protected function _toHtml() {
64
- if(Mage::helper('sli_search')->useCustomForm()) {
65
- return $this->getFormData();
66
- }else {
67
- $this->setTemplate('sli/search/form.mini.phtml');
68
- }
69
- return parent::_toHtml();
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Block/Search/Js/Bottom.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Bottom javascript block for before body end. Includes javascript from
14
- * system configuration
15
- *
16
- * @package SLI
17
- * @subpackage Search
18
- */
19
-
20
- class SLI_Search_Block_Search_JS_Bottom extends Mage_Core_Block_Text {
21
-
22
- /**
23
- * Set text to be javascript from system configuration
24
- */
25
- protected function _construct() {
26
- parent::_construct();
27
- $helper = Mage::helper('sli_search');
28
- if ($helper->isFormEnabled(Mage::app()->getStore()->getId())) {
29
- $this->addText($helper->getFooterJs());
30
- }
31
- }
32
-
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Block/Search/Js/Top.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Top javascript included in head block
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Block_Search_JS_Top extends Mage_Core_Block_Text {
20
-
21
- /**
22
- * Set text to be javascript from system configuration
23
- */
24
- protected function _construct() {
25
- parent::_construct();
26
- $helper = Mage::helper('sli_search');
27
- if ($helper->isFormEnabled(Mage::app()->getStore()->getId())) {
28
- $this->addText($helper->getSLIDomainJs());
29
- $this->addText($helper->getHeaderJs());
30
- }
31
- }
32
-
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Block/System/Config/Form/Field/Minigrid.php DELETED
@@ -1,134 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Minigrid system config field element type
14
- * Displays the minigid in a usable backend fashion. Requires a source
15
- * model to properly display;
16
- *
17
- * @package SLI
18
- * @subpackage Search
19
- */
20
-
21
- class SLI_Search_Block_System_Config_Form_Field_Minigrid extends Varien_Data_Form_Element_Abstract {
22
-
23
- /**
24
- * Add the js block which contains the js that makes
25
- * the mini grids work only once to the admin js
26
- * block
27
- */
28
- protected function _addJsIfNecessary() {
29
- $alias = 'ba.mini.grid.js';
30
- $block = Mage::app()->getLayout()->createBlock("sli_search/System_Config_Form_Field_Minigrid_Js", $alias);
31
-
32
- $js = Mage::app()->getLayout()->getBlock('js');
33
- if (!$js->getChild($alias)) {
34
- Mage::app()->getLayout()->getBlock('js')->append($block, $alias);
35
- }
36
- }
37
-
38
- /**
39
- * Default values of field array. Field array defines
40
- * the fields on the grid.
41
- *
42
- * @return array
43
- */
44
- protected function _getDefaultSourceValues() {
45
- return array(
46
- "{$this->getLabel()}" => array("width" => "98%", "type" => "text"),
47
- );
48
- }
49
-
50
- /**
51
- * Element rendererd html. Called by getDefaultHtml which combines
52
- * the label html with this html to render the full element. Specifically,
53
- * this is the html to render the field input
54
- *
55
- * @var $fields Fields is the array of minigrid columns and fields
56
- * Fields is represented by $this->getValues()
57
- * @var $rowData The row data is an array of values of already existant
58
- * grid rows. Row data is represented with $this->getValue();
59
- *
60
- * NOTE: We are breaking php runtime to fall into html directly
61
- * in this function instead of using a template to keep this module
62
- * succinct, contained, and to avoid rendering html/js via strings
63
- * as is the convention for form and form element renderers.
64
- *
65
- * Providing optional parameters for required inputs if this block is being
66
- * used outside of its normal use case (such as outside of system config)
67
- *
68
- * @param string $label
69
- * @param string $tableId
70
- * @param string $fieldName
71
- * @param array $fields
72
- * @param array $rowData
73
- *
74
- * @return string
75
- */
76
- public function getElementHtml($tableId = null, $fieldName = null, $fields = array(), $rowData = array()) {
77
-
78
- $this->_addJsIfNecessary();
79
-
80
- $label = $this->getLabel();
81
- $tableId = ($tableId) ? $tableId : $this->getHtmlId();
82
- $fieldName = ($fieldName) ? $fieldName : $this->getName();
83
-
84
- $fields = (empty($fields)) ? $this->getValues() : $fields;
85
- if (!$fields) {
86
- $fields = $this->_getDefaultSourceValues();
87
- }
88
- $rowData = (empty($rowData)) ? $this->getValue() : $rowData;
89
- if (!is_array($rowData)) {
90
- $rowData = array();
91
- }
92
-
93
- ob_start();
94
- ?>
95
- <div class="grid">
96
- <table id="ba-<?php echo $tableId?>-table" class="option-header" cellpadding="0" cellspacing="0">
97
- <thead>
98
- <tr class="headings">
99
- <?php foreach($fields as $header => $def) :?>
100
- <th style="width:<?php echo $def['width']?>"><?php echo ucwords(str_replace("_"," ",$header))?></th>
101
- <?php endforeach;?>
102
- <th style="width:30px">Remove</th>
103
- </tr>
104
- </thead>
105
- <tbody id="ba-<?php echo $tableId?>">
106
- </tbody>
107
- <tfoot>
108
- <tr>
109
- <td colspan="<?php echo count($fields) + 1?>" class="a-right">
110
- <button id="ba-add-<?php echo $tableId?>" class="scalable add" type="button"><span>Add <?php echo ucwords($label)?></span></button>
111
- </td>
112
- </tr>
113
- </tfoot>
114
- </table>
115
- <input type="text" class="validate-minigrid-attributes" style="opacity:0" value="">
116
- </div>
117
- <style>
118
- select.validation-failed {
119
- border: 1px solid red;
120
- }
121
- </style>
122
- <script type="text/javascript">
123
- Event.observe(window,'load', function(){
124
- (new baMiniGrid()).init($("ba-<?php echo $tableId?>"),
125
- $('ba-add-<?php echo $tableId?>'),
126
- "<?php echo $fieldName?>",
127
- <?php echo json_encode($rowData)?>,
128
- <?php echo json_encode($fields)?>);
129
- });
130
- </script>
131
- <?php
132
- return ob_get_clean();
133
- }
134
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Block/System/Config/Form/Field/Minigrid/Js.php DELETED
@@ -1,211 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Minigrid form field js
14
- * Javascript that controls the forms
15
- *
16
- * @package SLI
17
- * @subpackage Search
18
- */
19
-
20
- class SLI_Search_Block_System_Config_Form_Field_Minigrid_Js extends Mage_Core_Block_Text {
21
-
22
-
23
- /**
24
- * Output the JS that controls the minigrids
25
- *
26
- * NOTE: We are breaking php runtime to fall into html directly
27
- * in this function instead of using a template to keep this module
28
- * succinct, contained, and to avoid rendering html/js via strings
29
- * as is the convention for form and form element renderers.
30
- *
31
- * @use (new baMiniGrid()).init(tbody, addRowButton, rowName, collectionData, rowData);
32
- * @return string
33
- */
34
- protected function _toHtml() {
35
-
36
- $html = parent::_toHtml();
37
- $successIcon = $this->getSkinUrl('images/success_msg_icon.gif');
38
- ob_start();
39
- ?>
40
- <script type="text/javascript">
41
-
42
- function baMiniGrid() {
43
- return {
44
- /**
45
- * @param tbody Body tag of grid table to insert rows into
46
- * @param addRowButton Button that adds rows to grid
47
- * @param rowName Unique name to give the grid rows. Used in name attribute
48
- * @param collectionData Object that has info on all prexisting grid rows
49
- * @param rowData Object containing the schema of the columns in each row
50
- */
51
- init : function(tbody, addRowButton, rowName, collectionData, rowData) {
52
- this.tbody = tbody;
53
- this.addRowButton = addRowButton;
54
- this.collectionData = collectionData;
55
- this.rowData = rowData;
56
- this.rowName = rowName;
57
-
58
- this.initRows();
59
- this.observeAddRowButton();
60
- },
61
- observeAddRowButton : function () {
62
- this.addRowButton.observe('click', function(ev){
63
- ev.stop();
64
- this.addRow();
65
- }.bind(this));
66
- },
67
- getNewRowId : function () {
68
- if (typeof this.rowId == "undefined") {
69
- this.rowId = 0;
70
- }
71
- return this.tbody.id+"-row-id-"+this.rowId++;
72
- },
73
- initRows : function () {
74
- if (!this.collectionData.length || this.collectionData.length < 1) {
75
- return;
76
- }
77
- this.collectionData.each(function(rowValues) {
78
- var row = this.getNewRow(rowValues);
79
- this.addRow(row);
80
- }.bind(this));
81
- },
82
- getNewRow : function (rowValues) {
83
- var rowId = this.getNewRowId();
84
- var rowName = this.rowName;
85
-
86
- var tr = new Element('tr', {id: rowId});
87
- var td, input;
88
- for (var field in this.rowData) {
89
- td = new Element('td');
90
- input = this.getInputTag(field, rowName, rowId);
91
- if (rowValues && typeof rowValues[field] != 'undefined') {
92
- try {
93
- input.value = rowValues[field];
94
- delete rowValues[field];
95
- }
96
- catch (e) {
97
- if (input.type == "file") {
98
- var fileUploaded = new Element('div', {style:"float:left; width:16px; height:16px; background: url('<?php echo $successIcon ?>') no-repeat 0 0;"});
99
- var uploaded = new Element('p', {style:"float:left; margin:0 0 0 5px"}).update("File Uploaded.");
100
- Element.insert(td, {bottom: fileUploaded});
101
- Element.insert(td, {bottom: uploaded});
102
- td.setAttribute("title", "File: " + rowValues[field]);
103
- }
104
- }
105
- }
106
-
107
- Element.insert(td, {bottom: input});
108
- Element.insert(tr, {bottom: td});
109
- }
110
-
111
- if (rowValues && typeof rowValues != 'undefined') {
112
- for (var field in rowValues) {
113
- Element.insert(tr, {top: new Element('input', {name:this.rowName + "["+rowId+"]["+field+"]", type:"hidden", value:rowValues[field]})})
114
- }
115
- }
116
-
117
- var button = new Element('button', {type: 'button', style: 'width:50px;', title: 'Delete'}).update("<span>Delete</span>");
118
- button.className = "scalable delete icon-btn";
119
- button.observe('click', function(ev) {
120
- ev.stop();
121
- this.removeRow(rowId);
122
- }.bind(this));
123
-
124
- var buttonTd = new Element('td');
125
- Element.insert(buttonTd, {bottom: button});
126
- Element.insert(tr, {bottom: buttonTd});
127
- return tr;
128
- },
129
- getInputTag : function (field, rowName, rowId) {
130
- var input;
131
- if (this.rowData[field]['type'] == 'textarea' || this.rowData[field]['type'] == "select") {
132
- input = new Element(this.rowData[field]['type'], {style:"width:98%;",name: rowName + "["+rowId+"][" +field + "]"});
133
- input.addClassName("minigrid-field");
134
- input.addClassName("minigrid-field-" + field);
135
- input.addClassName("validate-minigrid-attribute");
136
-
137
- if (typeof this.rowData[field]['options'] != 'undefined') {
138
- var options = this.rowData[field]['options'];
139
- if (Object.isArray(options)) {
140
- options.each(function(value,opt){
141
- var option = new Element('option', {value: opt}).update(value);
142
- Element.insert(input, {bottom: option});
143
- }.bind(this));
144
- }
145
- else {
146
- for (var opt in options) {
147
- var option = new Element('option', {value: opt}).update(options[opt]);
148
- Element.insert(input, {bottom: option});
149
- }
150
- }
151
- }
152
- }
153
- else {
154
- input = new Element('input', {style:"width:" + this.rowData[field]['width'],type: this.rowData[field]['type'], name: rowName + "["+rowId+"][" +field + "]"});
155
- input.addClassName("minigrid-field");
156
- input.addClassName("minigrid-field-" + field);
157
- }
158
- return input;
159
- },
160
- addRow : function (row) {
161
- row = row || this.getNewRow();
162
- if (typeof this.allRemoved != 'undefined' && this.allRemoved) {
163
- this.allRemoved.remove();
164
- delete this.allRemoved;
165
- }
166
- Element.insert(this.tbody, {bottom: row});
167
- },
168
- removeRow : function (rowId) {
169
- var row = $(rowId);
170
- if (typeof row != "undefined" && row) {
171
- row.remove();
172
- if (this.tbody.children.length == 0 ) {
173
- this.allRemoved = new Element('input', {type:'hidden', name: this.rowName, value:''});
174
- Element.insert(this.tbody, {bottom: this.allRemoved});
175
- }
176
- }
177
- return 1;
178
- }
179
- }
180
- }
181
-
182
- Validation.add('validate-minigrid-attributes', 'Please remove duplicate attributes.', function (v) {
183
- var selectedAttributes = document.getElementsByClassName("validate-minigrid-attribute");
184
-
185
- var hasDuplicates = false;
186
- for(var i = 0; i < selectedAttributes.length; i++)
187
- {
188
- var occurrences = 1;
189
- var icurrent = selectedAttributes.item(i).value;
190
- for(var j = i+1; j < selectedAttributes.length; j++) {
191
- var jcurrent = selectedAttributes.item(j).value;
192
- if (icurrent == jcurrent) {
193
- occurrences++;
194
- if(occurrences > 1){
195
- selectedAttributes.item(i).addClassName('validation-failed');
196
- selectedAttributes.item(j).addClassName('validation-failed');
197
- }
198
- }
199
- }
200
- if(occurrences > 1) hasDuplicates = true;
201
- }
202
- if(hasDuplicates == true) return false;
203
- else return true;
204
- });
205
-
206
-
207
- </script>
208
- <?php
209
- return $html . ob_get_clean();
210
- }
211
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Block/System/Config/Form/Field/Version.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Custom field to display the version number of the SLI module in the system configuration
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Block_System_Config_Form_Field_Version extends Varien_Data_Form_Element_Abstract
20
- {
21
-
22
- public function getElementHtml() {
23
- /* @var $modules Mage_Core_Model_Config_Element */
24
-
25
- $modules = Mage::getConfig()->getNode('modules')->children();
26
- $info = $modules->SLI_Search->asArray();
27
-
28
- return isset($info['version']) ? $info['version'] : '';
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Generate.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Source renderer for product attributes data.
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Block_System_Config_Frontend_Feed_Generate extends Mage_Adminhtml_Block_System_Config_Form_Field {
20
-
21
- protected $_buttonId = "generate_feed_button";
22
-
23
- /**
24
- * Programmatically include the generate feed javascript in the adminhtml
25
- * JS block.
26
- *
27
- * @return <type>
28
- */
29
- protected function _prepareLayout() {
30
- $block = $this->getLayout()->createBlock("sli_search/system_config_frontend_feed_generate_js");
31
- $block->setData("button_id", $this->_buttonId);
32
-
33
- $this->getLayout()->getBlock('js')->append($block);
34
- return parent::_prepareLayout();
35
- }
36
-
37
- /**
38
- * Return element html
39
- *
40
- * @param Varien_Data_Form_Element_Abstract $element
41
- * @return string
42
- */
43
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
44
- $button = $this->getButtonHtml();
45
-
46
- $notice = "";
47
- if ($this->_feedGenIsLocked()) {
48
- $notice = "<p id='sli_display_msg' class='note'>".Mage::getModel("sli_search/feed")->getAjaxNotice()."</p>";
49
- }
50
- return $button.$notice;
51
- }
52
-
53
- /**
54
- * Generate button html for the feed button
55
- *
56
- * @return string
57
- */
58
- public function getButtonHtml() {
59
- $button = $this->getLayout()->createBlock('adminhtml/widget_button')
60
- ->setData(array(
61
- 'id' => $this->_buttonId,
62
- 'label' => $this->helper('sli_search')->__('Generate Feed'),
63
- 'onclick' => 'javascript:sliSearch.generateFeed(); return false;'
64
- ));
65
-
66
- if ($this->_feedGenIsLocked()) {
67
- $button->setData('class', 'disabled');
68
- }
69
-
70
- return $button->toHtml();
71
- }
72
-
73
- /**
74
- * Check to see if there are any locks for any feeds at the moment
75
- *
76
- * @return boolean
77
- */
78
- protected function _feedGenIsLocked() {
79
- return Mage::helper('sli_search/feed')->thereAreFeedLocks();
80
- }
81
-
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Generate/Js.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Javascript block for adminhtml JS text_list block to add functionality to the
14
- * generate feed button on the system configuration for Feed Settings.
15
- *
16
- * @package SLI
17
- * @subpackage Search
18
- */
19
-
20
- class SLI_Search_Block_System_Config_Frontend_Feed_Generate_Js extends Mage_Adminhtml_Block_Template {
21
-
22
- /**
23
- * Sets javascript template to be included in the adminhtml js text_list block
24
- */
25
- protected function _construct() {
26
- parent::_construct();
27
- $this->setTemplate('sli/search/sysconfig/generate/js.phtml');
28
- }
29
-
30
- /**
31
- * Returns the run all feeds async url
32
- *
33
- * @return string
34
- */
35
- public function getGenerateUrl() {
36
- $curStore = Mage::app()->getStore();
37
- Mage::app()->setCurrentStore(1); //default store number...always 1
38
- $myUrl = Mage::getUrl('sli_search/search/runFeedGeneration', array('_secure' => Mage::app()->getStore()->isCurrentlySecure()));
39
- Mage::app()->setCurrentStore($curStore);
40
- return $myUrl;
41
- }
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Next.php DELETED
@@ -1,57 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Determines next time the cron will run on the feeds.
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Block_System_Config_Frontend_Feed_Next extends Mage_Adminhtml_Block_System_Config_Form_Field {
20
-
21
- /**
22
- * Returns the config xml set job code for the sli cron job
23
- *
24
- * @return string
25
- */
26
- protected function _getSliCronJobCode() {
27
- $jobCode = Mage::getConfig()->getNode('crontab/sli_search/job_code');
28
-
29
- if (!$jobCode) {
30
- Mage::throwException("No cron job code set for sli_search cron job in config xml.");
31
- }
32
- return $jobCode;
33
- }
34
-
35
- /**
36
- * Renders the next scheduled cron time first from the cron table and then
37
- * from the set cron time if Magento hasnt scheduled it.
38
- *
39
- * @param Varien_Data_Form_Element_Abstract $element
40
- * @return <type>
41
- */
42
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
43
- $crons = Mage::getResourceModel('cron/schedule_collection')
44
- ->addFieldToFilter("job_code", $this->_getSliCronJobCode());
45
- $crons->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns(array("scheduled_at" => 'max(scheduled_at)'));
46
-
47
- $scheduledAt = $crons->getFirstItem()->getData('scheduled_at');
48
-
49
- if (!$scheduledAt) {
50
- $helper = Mage::helper('sli_search');
51
- $scheduledAt = $helper->getNextRunDateFromCronTime();
52
- }
53
-
54
- return $scheduledAt;
55
- }
56
-
57
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Block/Widget/Minigrid/Form.php DELETED
@@ -1,153 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Form that utilizes a minigrid. Good as an alternative
14
- * to a grid
15
- *
16
- * NOTE: Not used with SLI Search
17
- *
18
- * @package SLI
19
- * @subpackage Search
20
- */
21
-
22
- class SLI_Search_Block_Widget_Minigrid_Form extends Mage_Adminhtml_Block_Abstract {
23
-
24
- protected $_formId = "ba-minigrid-form";
25
- protected $_formClass = "";
26
- protected $_formAction = "";
27
- protected $_gridFields = array();
28
- protected $_gridRowData = array();
29
-
30
- /**
31
- * It was decided to use the overwritable _toHtml instead of a template
32
- * to be consistent with magento renderers and to increase portability
33
- *
34
- * @return string
35
- */
36
- protected function _toHtml() {
37
- $html = parent::_toHtml();
38
- $html .= "<form id='{$this->getFormId()}' action='{$this->getFormAction()}' method='post' class='{$this->getFormClass()}' enctype='multipart/form-data'>";
39
- $minigrid = new SLI_Search_Block_System_Config_Form_Field_Minigrid();
40
- $html .= $minigrid->getElementHtml("ba-minigrid-form-grid", $this->getFieldName(), $this->getGridFields(), $this->getGridRowData());
41
- $html .= "
42
- </form>
43
- <script type='text/javascript'>
44
- function submitMinigridForm() {
45
- $('{$this->getFormId()}').submit();
46
- }
47
- </script>
48
-
49
- ";
50
- return $html;
51
- }
52
-
53
-
54
- /**
55
- * Public return for form id
56
- *
57
- * @return string
58
- */
59
- public function getFormId() {
60
- return $this->_formId;
61
- }
62
-
63
- /**
64
- * Public set for form id
65
- *
66
- * @param string $formId
67
- * @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
68
- */
69
- public function setFormId($formId) {
70
- $this->_formId = $formId;
71
- return $this;
72
- }
73
-
74
- /**
75
- * Public return for form class
76
- *
77
- * @return string
78
- */
79
- public function getFormClass() {
80
- return $this->_formClass;
81
- }
82
-
83
- /**
84
- * Public set for form class
85
- *
86
- * @param string $formClass
87
- * @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
88
- */
89
- public function setFormClass($formClass) {
90
- $this->_formClass = $formClass;
91
- return $this;
92
- }
93
- /**
94
- * Public return for form class
95
- *
96
- * @return string
97
- */
98
- public function getFormAction() {
99
- return $this->_formAction;
100
- }
101
-
102
- /**
103
- * Public set for form class
104
- *
105
- * @param string $url
106
- * @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
107
- */
108
- public function setFormAction($url) {
109
- $this->_formAction = $url;
110
- return $this;
111
- }
112
-
113
- /**
114
- * Public return for grid fields
115
- *
116
- * @return string
117
- */
118
- public function getGridFields() {
119
- return $this->_gridFields;
120
- }
121
-
122
- /**
123
- * Public set for grid fields
124
- *
125
- * @param array $gridFields
126
- * @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
127
- */
128
- public function setGridFields($gridFields) {
129
- $this->_gridFields = $gridFields;
130
- return $this;
131
- }
132
-
133
- /**
134
- * Public return for grid row data
135
- *
136
- * @return string
137
- */
138
- public function getGridRowData() {
139
- return $this->_gridRowData;
140
- }
141
-
142
- /**
143
- * Public set for grid row data
144
- *
145
- * @param array $gridRowData
146
- * @return Blueacorn_Minigrid_Block_Widget_Minigrid_Form
147
- */
148
- public function setGridRowData($gridRowData) {
149
- $this->_gridRowData = $gridRowData;
150
- return $this;
151
- }
152
-
153
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Exception.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Namespaced exception for the SLI Search
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
- class SLI_Search_Exception extends Exception{
19
-
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Helper/Feed.php DELETED
@@ -1,169 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Feed helper for multifunctional feed related utilities
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Helper_Feed {
20
-
21
- protected $_feedFilePath = null;
22
-
23
- /**
24
- * Open socket to feed generation url with store id as passed parameter.
25
- *
26
- *
27
- * @deprecated
28
- * @param Mage_Core_Model_Store $store
29
- * @param array $urlParts
30
- * @throws Mage_Core_Exception
31
- * @throws SLI_Search_Exception
32
- */
33
- public function postToGenerateFeed($store, $urlParts) {
34
- $feedSocket = @fsockopen($urlParts['host'], 80, $errNo, $errStr, 10);
35
-
36
- if (!$feedSocket) {
37
- throw new SLI_Search_Exception("Err. #$errNo: Cannot access feed generation uri.");
38
- }
39
-
40
- $storeParam = "storeId={$store->getId()}";
41
- $storeParamLen = strlen($storeParam);
42
-
43
- $EOL = "\r\n";
44
- $request = "POST {$urlParts['path']} HTTP/1.1$EOL";
45
- $request .= "HOST: {$urlParts['host']}$EOL";
46
- $request .= "Content-Length: $storeParamLen$EOL";
47
- $request .= "Content-Type: application/x-www-form-urlencoded$EOL";
48
- $request .= "Connection: Close$EOL$EOL";
49
- $request .= "$storeParam";
50
-
51
- $result = fwrite($feedSocket, $request);
52
-
53
- if (!$result) {
54
- throw new SLI_Search_Exception("Error writing to feed generation uri.");
55
- }
56
- fclose($feedSocket);
57
- }
58
-
59
- /**
60
- * Returns url that controls feed generation
61
- *
62
- * @return string
63
- */
64
- public function getGenerateFeedUrl() {
65
- $curStore = Mage::app()->getStore();
66
- Mage::app()->setCurrentStore(1); //default store number...always 1
67
- $myUrl = Mage::getUrl('sli_search/search/generateFeed');
68
- Mage::app()->setCurrentStore($curStore);
69
- return $myUrl;
70
- }
71
-
72
- /**
73
- * Starts a feed generation for each store
74
- * @return array
75
- * @throws SLI_Search_Exception
76
- */
77
- public function generateFeedsForAllStores() {
78
- if ($this->thereAreFeedLocks()) {
79
- throw new SLI_Search_Exception("One or more feeds are being generated. Generation temporarily locked.");
80
- }
81
-
82
- $toReturn = array();
83
- $messages = array();
84
- $toReturn['error'] = false;
85
-
86
- /** @var $stores Mage_Core_Model_Resource_Store_Collection */
87
- $stores = Mage::getResourceModel('core/store_collection');
88
-
89
- foreach($stores as $store){
90
- $storeId = $store->getId();
91
- try {
92
- $productFeedStatus = Mage::getModel('sli_search/feed')->setData('store_id', $storeId)->generateFeed();
93
- if (true === $productFeedStatus) {
94
- $messages["Product Feed " . $storeId ] = "Success";
95
- } else {
96
- $messages["Product Feed " . $storeId ] = $productFeedStatus;
97
- }
98
- $priceFeedStatus = Mage::getModel('sli_search/feed')->setData('store_id', $storeId)->generateFeed(true);
99
- if (true === $priceFeedStatus) {
100
- $messages["Price Feed " . $storeId] = "Success";
101
- } else {
102
- $messages["Price Feed " . $storeId] = $priceFeedStatus;
103
- }
104
- }catch (Exception $e) {
105
- Mage::logException($e);
106
- $toReturn['error'] = true;
107
- $messages["Feed " .$storeId] = "Exception generating feed $storeId -> " . $e->getMessage();
108
- }
109
- }
110
- $toReturn['messages'] = $messages;
111
- return $toReturn;
112
- }
113
-
114
- /**
115
- * Returns the feed file path
116
- *
117
- * @return string
118
- */
119
- public function getFeedFilePath() {
120
- if ($this->_feedFilePath === null) {
121
- $this->_feedFilePath = $this->makeVarPath(array('sli', 'feeds'));
122
- }
123
- return $this->_feedFilePath;
124
- }
125
-
126
- /**
127
- * Create path within var folder if necessary given an array
128
- * of directory names
129
- *
130
- * @param array $directories
131
- * @return string
132
- */
133
- public function makeVarPath($directories) {
134
- $path = Mage::getBaseDir('var');
135
- foreach ($directories as $dir) {
136
- $path .= DS . $dir;
137
- if (!is_dir($path)) {
138
- @mkdir($path, 0777);
139
- }
140
- }
141
- return $path;
142
- }
143
-
144
- /**
145
- * Whether or not there are feed generation locks currently in place
146
- *
147
- * @return boolean
148
- */
149
- public function thereAreFeedLocks() {
150
- $path = $this->getFeedFilePath();
151
- foreach (scandir($path) as $file) {
152
- $fullFile = $path.DS.$file;
153
- if (is_file($fullFile) && !is_dir($fullFile) && is_numeric(strpos($file, '.lock'))) {
154
- $modification_time = filemtime($fullFile);
155
- if(!$modification_time) {
156
- return true;
157
- }else {
158
- if ((time() - filemtime($fullFile)) > (24 * 60 * 60)) { // Check if older than 1 day
159
- unlink($fullFile); // Lock file older than a day so remove it
160
- return false;
161
- }
162
- return true;
163
- }
164
- }
165
- }
166
- return false;
167
- }
168
-
169
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/Cron.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Cron activities for the sli feed generation
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
- class SLI_Search_Model_Cron {
19
-
20
- /**
21
- * Generates the feeds and sends email of status when done
22
- */
23
- public function generateFeeds() {
24
- if(!Mage::getStoreConfig('sli_search/cron/disabled'))
25
- {
26
- try {
27
- /** @var $helper SLI_Search_Helper_Feed */
28
- $helper = Mage::helper('sli_search/feed');
29
- $msg = $helper->generateFeedsForAllStores();
30
- }
31
- catch (SLI_Search_Exception $e) {
32
- $msg = $e->getMessage();
33
- }
34
- catch (Exception $e) {
35
- $msg = "Unknown Error: {$e->getMessage()} in {$e->getFile()} on line {$e->getLine()}. Please contact your sli provider.";
36
- }
37
-
38
- $this->_sendEmail($msg);
39
- }
40
- }
41
-
42
- /**
43
- * If there is a system config email set, send out the cron notification
44
- * email.
45
- *
46
- * @param $msg String
47
- */
48
- protected function _sendEmail($msg) {
49
- $sliHelper = Mage::helper('sli_search');
50
- Mage::getModel('sli_search/email')
51
- ->setData('msg', $sliHelper->formatEmailOutput($msg['messages']))
52
- ->setData('subject', 'SLI Scheduled Feed Generation')
53
- ->setData('email', Mage::helper('sli_search')->getCronEmail())
54
- ->send();
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/Email.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Feed generation email
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Model_Email extends Mage_Core_Model_Abstract {
20
-
21
- /**
22
- * Set up some default variables that can be set from sys config
23
- */
24
- public function __construct() {
25
- $this->setFromName(Mage::getStoreConfig('trans_email/ident_general/name'));
26
- $this->setFromEmail(Mage::getStoreConfig('trans_email/ident_general/email'));
27
- $this->setType('text');
28
- }
29
-
30
- /**
31
- * SLI feed generation email subject
32
- *
33
- * @return string
34
- */
35
- public function getSubject() {
36
- return $this->getData('subject');
37
- }
38
-
39
- public function getEmail(){
40
- return $this->getData('email');
41
- }
42
- /**
43
- * SLI feed generation email body
44
- *
45
- * @return string
46
- */
47
- public function getBody() {
48
- return <<<BODY
49
- Status:
50
- {$this->getData('msg')}
51
-
52
- Please check the sli log files for further information.
53
-
54
- BODY;
55
- }
56
-
57
- public function send() {
58
- $email = $this->getEmail();
59
- if ($email) {
60
- mail($email, $this->getSubject(), $this->getBody(), "From: {$this->getFromName()} <{$this->getFromEmail()}>\r\nReply-To: {$this->getFromEmail()}");
61
- }
62
- }
63
-
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/Feed.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
5
- * This file is part of Learning Search Connect.
6
- * Learning Search Connect is distribute under license,
7
- * go to www.sli-systems.com/LSC for full license details.
8
- *
9
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
10
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
11
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
12
- * PARTICULAR PURPOSE.
13
- *
14
- * Generates feed file based on store
15
- *
16
- * @package SLI
17
- * @subpackage Search
18
- */
19
- class SLI_Search_Model_Feed extends Mage_Core_Model_Abstract {
20
-
21
- protected $_ajaxNotice = "Currently generating feeds...";
22
- protected $_dbConnection = null;
23
-
24
- protected $_totalProductCount = null;
25
-
26
- /**
27
- * Generate feed based on store and returns success
28
- *
29
- * @return boolean
30
- */
31
- public function generateFeed($price_feed = false) {
32
- try {
33
- if (!$price_feed) {
34
- return PHP_EOL."If you had the full version of Learning Search Connect, this would have created a feed containing up to {$this->_getProductCount()} products.".PHP_EOL."Please Contact SLI to receive the full version. Call us toll free in the US: (866) 240-2812 or send us an email to sales@sli-systems.com".PHP_EOL.PHP_EOL;
35
- }
36
- } catch (Exception $e) {
37
- Mage::log("Exception: {$e->getMessage()}");
38
- }
39
- }
40
-
41
- /**
42
- * Returns the total number of products in the store catalog
43
- *
44
- * @return int
45
- */
46
- protected function _getProductCount() {
47
- if ($this->_totalProductCount === null) {
48
- $count = $this->_getConnection()->query("select count(entity_id) from ".Mage::getSingleton('core/resource')->getTableName('catalog/product'));
49
- $this->_totalProductCount = ($count) ? $count->fetch(PDO::FETCH_COLUMN) : 0;
50
- }
51
- return $this->_totalProductCount;
52
- }
53
-
54
- /**
55
- * Returns the database connection used by the feed
56
- *
57
- * @return PDO
58
- */
59
- protected function _getConnection() {
60
- if (!$this->_dbConnection) {
61
- $connection = Mage::getConfig()->getNode('global/resources/default_setup/connection');
62
- $name = $connection->dbname;
63
- $host = $connection->host;
64
- $user = $connection->username;
65
- $pass = $connection->password;
66
-
67
- $this->_dbConnection = new PDO("mysql:dbname=$name;host=$host", $user, $pass);
68
- }
69
- $this->_dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
70
-
71
- return $this->_dbConnection;
72
- }
73
-
74
- public function getAjaxNotice() {
75
- $this->_ajaxNotice = "<p style='color:red'>If you had the full version of Learning Search Connect, this would have created a feed containing up to {$this->_getProductCount()} products. Please Contact SLI to receive the full version. Call us toll free in the US: (866) 240-2812 or send us an email to sales@sli-systems.com</p>";
76
- return $this->_ajaxNotice;
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/System/Config/Backend/Cron.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * System configuration backend model for the cron frequency system configuration
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Model_System_Config_Backend_Cron extends Mage_Core_Model_Config_Data {
20
-
21
- const CRON_STRING_PATH = 'crontab/jobs/sli_search/schedule/cron_expr';
22
- const CRON_MODEL_PATH = 'crontab/jobs/sli_search/run/model';
23
-
24
- /**
25
- * When frequency system configuration saves, save the values from the frequency
26
- * and time as a cron string to a parsable path that the crontab will pick up
27
- */
28
- protected function _afterSave() {
29
- $isEnabled = Mage::helper('sli_search')->isFeedEnabled();
30
-
31
- $frequency = $this->getData('groups/cron/fields/frequency/value');
32
- $time = $this->getData('groups/cron/fields/time/value');
33
-
34
- if ($isEnabled) {
35
- $cronTab = Mage::helper('sli_search')->getCronTimeAsCrontab($frequency, $time);
36
-
37
- try {
38
- $this->saveCronTab($cronTab);
39
- } catch (Exception $e) {
40
- throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
41
- }
42
- }
43
- }
44
-
45
- /**
46
- * Saves the necessary core config data entries for the cron
47
- * to pull them from the database
48
- */
49
- public function saveCronTab($cronTab) {
50
- Mage::getModel('core/config_data')
51
- ->load(self::CRON_STRING_PATH, 'path')
52
- ->setValue($cronTab)
53
- ->setPath(self::CRON_STRING_PATH)
54
- ->save();
55
- Mage::getModel('core/config_data')
56
- ->load(self::CRON_MODEL_PATH, 'path')
57
- ->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
58
- ->setPath(self::CRON_MODEL_PATH)
59
- ->save();
60
- }
61
-
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/System/Config/Backend/Enabledsetting.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- */
14
-
15
- class SLI_Search_Model_System_Config_Backend_Enabledsetting {
16
- /**
17
- * Options getter
18
- *
19
- * @return array
20
- */
21
- public function toOptionArray()
22
- {
23
- return array(
24
- array('value' => 1, 'label'=>Mage::helper('sli_search')->__('Enabled')),
25
- array('value' => 2, 'label'=>Mage::helper('sli_search')->__('Disabled')),
26
- array('value' => 3, 'label'=>Mage::helper('sli_search')->__('Only Feed Enabled')),
27
- );
28
- }
29
-
30
- /**
31
- * Get options in "key-value" format
32
- *
33
- * @return array
34
- */
35
- public function toArray()
36
- {
37
- return array(
38
- 1 => Mage::helper('sli_search')->__('Enabled'),
39
- 2 => Mage::helper('sli_search')->__('Disabled'),
40
- 3 => Mage::helper('sli_search')->__('Only Feed Enabled'),
41
- );
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/System/Config/Backend/Loglevel.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- */
14
-
15
- class SLI_Search_Model_System_Config_Backend_Loglevel {
16
- /**
17
- * Options getter
18
- *
19
- * @return array
20
- */
21
- public function toOptionArray()
22
- {
23
- return array(
24
- array('value' => 1, 'label'=>Mage::helper('sli_search')->__('Error')),
25
- array('value' => 2, 'label'=>Mage::helper('sli_search')->__('Debug')),
26
- array('value' => 3, 'label'=>Mage::helper('sli_search')->__('Trace')),
27
- );
28
- }
29
-
30
- /**
31
- * Get options in "key-value" format
32
- *
33
- * @return array
34
- */
35
- public function toArray()
36
- {
37
- return array(
38
- 1 => Mage::helper('sli_search')->__('Error'),
39
- 2 => Mage::helper('sli_search')->__('Debug'),
40
- 3 => Mage::helper('sli_search')->__('Trace'),
41
- );
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/System/Config/Source/Attributes.php DELETED
@@ -1,132 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Source renderer for product attributes data.
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Model_System_Config_Source_Attributes {
20
-
21
-
22
- //These attributes are automatically included in the feed and thus dont need
23
- //to be selectable on the configuration
24
- protected $_automaticAttributes = array('name', 'url_path', 'status', 'type_id','product_id');
25
-
26
- //Remove attributes that do not need to be included in the feed or cause issues
27
- //in feed generation when selected.
28
- protected $_blockedAttributes = array('category_id','category_ids');
29
-
30
- /**
31
- * We want these attributes to appear in the drop down configuration menu, but they are not included in the
32
- * EAV selection. We must add them in individually.
33
- * if a key exists for a value, that key will be used as the label instead of the prefixed value
34
- *
35
- * @var array
36
- */
37
- protected $_nonEavAttributes = array(
38
- 'product_id',
39
- 'type_id',
40
- 'max_price',
41
- 'min_price',
42
- 'parent_ids' => 'parent_id',
43
- 'related_products' => 'linked_related',
44
- 'upsell_products' => 'linked_upsell',
45
- 'crosssell_products' => 'linked_crosssell'
46
- );
47
-
48
- /**
49
- * Prefix to use in the dropdown to differentiate the inventory attributes
50
- */
51
- const LINKED_PRODUCTS_PREFIX = 'linked';
52
-
53
- /**
54
- * Prefix to use in the dropdown to differentiate the inventory attributes
55
- */
56
- const INVENTORY_ATTRIBUTES_PREFIX = 'inventory';
57
-
58
- /**
59
- * Attributes from the flat inventory table that we will use for the feed
60
- * if a key exists for a value, that key will be used as the label instead of the prefixed value
61
- *
62
- * @var array
63
- */
64
- protected $_inventoryAttributes = array(
65
- 'qty',
66
- 'is_in_stock',
67
- 'manage_stock',
68
- 'backorders',
69
- );
70
-
71
- /**
72
- * Prefix to use in the dropdown to differentiate the review attributes
73
- */
74
- const REVIEW_ATTRIBUTES_PREFIX = 'review';
75
-
76
- /**
77
- * Attributes from customer review that we will use for the feed
78
- * if a key exists for a value, that key will be used as the label instead of the prefixed value
79
- *
80
- * @var array
81
- */
82
- protected $_reviewAttributes = array(
83
- 'reviews_count' => 'reviews_count',
84
- 'rating_summary',
85
- );
86
-
87
- /**
88
- * Returns code => code pairs of attributes for all product attributes
89
- *
90
- * @return array
91
- */
92
- public function toOptionArray() {
93
- $productEntityId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getId();
94
-
95
- $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
96
- ->setEntityTypeFilter($productEntityId);
97
- $attributes->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns(array("code" => 'attribute_code'));
98
-
99
- foreach ($attributes as $attribute) {
100
- $code = $attribute['code'];
101
- if (!in_array($attribute['code'], $this->_automaticAttributes) &&
102
- !in_array($attribute['code'], $this->_blockedAttributes)) {
103
- $options[$code] = $code;
104
- }
105
- }
106
-
107
- // We want some non-eav attributes to be added to this dropdown as well
108
- foreach ($this->_nonEavAttributes as $label => $attributeCode) {
109
- $label = is_string($label) ? $label : $attributeCode;
110
- $options[$attributeCode] = $label;
111
- }
112
-
113
- // Add the inventory attributes
114
- foreach ($this->_inventoryAttributes as $label => $attributeCode) {
115
- $code = self::INVENTORY_ATTRIBUTES_PREFIX . "_" . $attributeCode;
116
- $label = is_string($label) ? $label : self::INVENTORY_ATTRIBUTES_PREFIX . "_" . $attributeCode;
117
- $options[$code] = $label;
118
- }
119
-
120
- // Add the review attributes
121
- foreach ($this->_reviewAttributes as $label => $attributeCode) {
122
- $code = self::REVIEW_ATTRIBUTES_PREFIX . "_" . $attributeCode;
123
- $label = is_string($label) ? $label : self::REVIEW_ATTRIBUTES_PREFIX . "_" . $attributeCode;
124
- $options[$code] = $label;
125
- }
126
-
127
- // Sort the array to account for the non-eav attrs being added in
128
- asort($options);
129
-
130
- return $options;
131
- }
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/System/Config/Source/Cron/Frequency.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Cron Frequency Model
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Model_System_Config_Source_Cron_Frequency {
20
-
21
- protected static $_options;
22
-
23
- const CRON_3_HOURLY = '3H';
24
- const CRON_6_HOURLY = '6H';
25
- const CRON_12_HOURLY = '12H';
26
- const CRON_DAILY = 'D';
27
- const CRON_WEEKLY = 'W';
28
- const CRON_MONTHLY = 'M';
29
-
30
- public function toOptionArray()
31
- {
32
- if (!self::$_options) {
33
- self::$_options = array(
34
- array(
35
- 'label' => Mage::helper('cron')->__('3 Hourly'),
36
- 'value' => self::CRON_3_HOURLY,
37
- ),
38
- array(
39
- 'label' => Mage::helper('cron')->__('6 Hourly'),
40
- 'value' => self::CRON_6_HOURLY,
41
- ),
42
- array(
43
- 'label' => Mage::helper('cron')->__('12 Hourly'),
44
- 'value' => self::CRON_12_HOURLY,
45
- ),
46
- array(
47
- 'label' => Mage::helper('cron')->__('Daily'),
48
- 'value' => self::CRON_DAILY,
49
- ),
50
- array(
51
- 'label' => Mage::helper('cron')->__('Weekly'),
52
- 'value' => self::CRON_WEEKLY,
53
- ),
54
- array(
55
- 'label' => Mage::helper('cron')->__('Monthly'),
56
- 'value' => self::CRON_MONTHLY,
57
- ),
58
-
59
- );
60
- }
61
- return self::$_options;
62
- }
63
- }
64
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/System/Config/Source/Emailsetting.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
5
- * This file is part of Learning Search Connect.
6
- * Learning Search Connect is distribute under license,
7
- * go to www.sli-systems.com/LSC for full license details.
8
- *
9
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
10
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
11
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
12
- * PARTICULAR PURPOSE.
13
- *
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- *
18
- *
19
- */
20
- class SLI_Search_Model_System_Config_Source_Emailsetting {
21
- /**
22
- * Options getter
23
- *
24
- * @return array
25
- */
26
- public function toOptionArray()
27
- {
28
- return array(
29
- array('value' => 1, 'label'=>Mage::helper('sli_search')->__('Disabled')),
30
- array('value' => 2, 'label'=>Mage::helper('sli_search')->__('Failures Only')),
31
- array('value' => 3, 'label'=>Mage::helper('sli_search')->__('All Failures and Successes')),
32
- );
33
- }
34
-
35
- /**
36
- * Get options in "key-value" format
37
- *
38
- * @return array
39
- */
40
- public function toArray()
41
- {
42
- return array(
43
- 1 => Mage::helper('sli_search')->__('Disabled'),
44
- 2 => Mage::helper('sli_search')->__('Failures Only'),
45
- 3 => Mage::helper('sli_search')->__('All Failures and Successes'),
46
- );
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/System/Config/Source/Minigrid/Abstract.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Minigrid system config field type source model abstract
14
- * Provides base functionality for minigrid source models
15
- * as the toOptionArray is specialized to the minigrid type
16
- *
17
- * @package SLI
18
- * @subpackage Search
19
- */
20
-
21
- abstract class SLI_Search_Model_System_Config_Source_Minigrid_Abstract {
22
-
23
- /**
24
- * Default values of field array. Field array defines
25
- * the fields on the grid.
26
- *
27
- * @return array
28
- */
29
- abstract protected function _getFields();
30
-
31
- /**
32
- * Add the additional grid type as a viable type on the form
33
- *
34
- * Note: Have to add value and label to each field array because
35
- * the frontend renderer requires value and label to be set
36
- * when under score scope.
37
- *
38
- * @return array
39
- */
40
- public function toOptionArray() {
41
- $fields = $this->_getFields();
42
- foreach($fields as $key => $field) {
43
- $fields[$key]['value'] = 1;
44
- $fields[$key]['label'] = 1;
45
- }
46
-
47
- return $fields;
48
- }
49
-
50
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/Model/System/Config/Source/Minigrid/Attributes.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Attributes MiniGrid source model
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- */
18
-
19
- class SLI_Search_Model_System_Config_Source_Minigrid_Attributes extends SLI_Search_Model_System_Config_Source_Minigrid_Abstract {
20
-
21
- /**
22
- * Minigrid field source. One column with a list of product attributes
23
- *
24
- * @return array
25
- */
26
- protected function _getFields() {
27
- return array(
28
- "attribute" => array(
29
- "width" => "100%",
30
- "type" => "select",
31
- "options" => Mage::getModel('sli_search/system_config_source_attributes')->toOptionArray()
32
- )
33
- );
34
- }
35
-
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/NotificationException.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * This will cause the current feed that is being generated to stop, but will allow the next feeds to continue generating.
14
- *
15
- * To be used when you a stores feed needs to stop, but other stores can continue
16
- *
17
- *
18
- * @package SLI
19
- * @subpackage Search
20
- */
21
- class SLI_Search_NotificationException extends SLI_Search_Exception{
22
-
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/controllers/ApiController.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
5
- * This file is part of Learning Search Connect.
6
- * Learning Search Connect is distribute under license,
7
- * go to www.sli-systems.com/LSC for full license details.
8
- *
9
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
10
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
11
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
12
- * PARTICULAR PURPOSE.
13
- *
14
- *
15
- * @package SLI
16
- * @subpackage Search
17
- *
18
- * Provide the URL for SLI to retrieve the current shopping cart items and all relative information
19
- * An JSON file will be passedback
20
- *
21
- */
22
- class SLI_Search_ApiController extends Mage_Core_Controller_Front_Action
23
- {
24
- //Decare the quote
25
- private $_quote = NULL;
26
-
27
- /**
28
- * Load the quote by passing the quote id
29
- *
30
- * @param int $quoteId
31
- * @return Mage_Sales_Model_Quote
32
- */
33
- private function _getQuote()
34
- {
35
- if( $this->_quote ) return $this->_quote;
36
- else return Mage::getSingleton('checkout/session')->getQuote();
37
- }
38
-
39
- /**
40
- * Allow SLI to call this url to get the cart jsonp object
41
- *
42
- */
43
- public function cartAction()
44
- {
45
- $jsonpResult = Mage::helper( 'sli_search' )->getCartJSONP( $this->_getQuote() );
46
-
47
- if( $jsonpResult )
48
- $this->getResponse()->setBody( $jsonpResult );
49
- }
50
-
51
-
52
-
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/controllers/SearchController.php DELETED
@@ -1,103 +0,0 @@
1
- <?php
2
- /**
3
- * Controller than provides the frontend capabilities of the SLI Search integration.
4
- *
5
- * @package SLI
6
- * @subpackage Search
7
- * @author Blue Acorn: Brys Sepulveda
8
- */
9
-
10
- class SLI_Search_SearchController extends Mage_Core_Controller_Front_Action {
11
-
12
- /**
13
- * Renders a standard frontend page using just the default handles.
14
- * Nothing is defined in the layout for this page and it should have an empty
15
- * content.
16
- *
17
- * SLI uses this page as a template for their hosted search solution
18
- */
19
- public function templateAction() {
20
- $this->loadLayout();
21
- $this->renderLayout();
22
- }
23
-
24
- /**
25
- * Feed generation action, linked to from the admin UI
26
- */
27
- public function runFeedGenerationAction() {
28
- $response = array();
29
-
30
- /** @var $sliFeedHelper SLI_Search_Helper_Feed */
31
- $sliFeedHelper = Mage::helper('sli_search/feed');
32
- /** @var $sliHelper SLI_Search_Helper_Data */
33
- $sliHelper = Mage::helper('sli_search');
34
-
35
- try {
36
- $response = $sliFeedHelper->generateFeedsForAllStores();
37
- }
38
- catch (SLI_Search_Exception $e) {
39
- $response['messages'] = array("Error" => $e->getMessage());
40
- $response['error'] = true;
41
- }
42
- catch (Exception $e) {
43
- Mage::logException($e);
44
- $response['messages'] = array("Error" => "An unknown error occurred. Please contact your SLI provider");;
45
- $response['error'] = true;
46
- }
47
-
48
- //Email results
49
- if($sliHelper->sendEmail($response['error'])) {
50
- Mage::getModel('sli_search/email')
51
- ->setData('msg', $sliHelper->formatEmailOutput($response['messages']))
52
- ->setData('subject', 'Manual Feed Generation')
53
- ->setData('email' , $sliHelper->getFeedEmail())
54
- ->send();
55
- }
56
- $this->getResponse()
57
- ->setHeader("Content-Type", "application/json")
58
- ->setBody(json_encode($response));
59
- }
60
-
61
- /**
62
- * Generates a feed based on passed in store id. Defaults store id to
63
- * default store
64
- */
65
- public function generateFeedAction() {
66
- $response = "";
67
- $error = false;
68
- try {
69
- $storeId = $this->getRequest()->getParam("storeId");
70
-
71
- if (!$storeId) {
72
- $storeId = Mage::app()->getDefaultStoreView()->getId();
73
- }
74
-
75
- $productFeed = Mage::getModel('sli_search/feed')->setData('store_id', $storeId)->generateFeed();
76
- $priceFeed = Mage::getModel('sli_search/feed')->setData('store_id', $storeId)->generateFeed(true);
77
- if($productFeed && $priceFeed) {
78
- $response = "Feed generated successfully for store {$storeId}";
79
- }else {
80
- $response = "Error occurred during feed generation for store {$storeId}";
81
- $error = true;
82
- }
83
- }
84
- catch (SLI_Search_Exception $e) {
85
- $response = $e->getMessage();
86
- $error = true;
87
- }
88
- catch (Exception $e) {
89
- Mage::logException($e);
90
- $response = "An unknown error occurred. Please contact your SLI provider";
91
- $error = true;
92
- }
93
- $sliHelper = Mage::helper('sli_search');
94
- if($sliHelper->sendEmail($error)) {
95
- Mage::getModel('sli_search/email')
96
- ->setData('msg', $response)
97
- ->setData('subject', 'Manual Feed Generation')
98
- ->setData('email', $sliHelper->getFeedEmail())
99
- ->send();
100
- }
101
- $this->getResponse()->setBody($response);
102
- }
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/doc/changelog.txt DELETED
@@ -1,2 +0,0 @@
1
- 1.0.0
2
- Initial Module
 
 
app/code/local/SLI/Search/doc/design.txt DELETED
@@ -1,84 +0,0 @@
1
- /**
2
- * The SLI Search module integrates with SLI Systems Search and provides
3
- * an outstanding level of search customizability.
4
- *
5
- * @todo Extend cron functionalities to smaller than daily frequency
6
- * @todo Have separate crons for each store feed (job code by store id)
7
- * @todo May need to pass some variable to the template page to make it store specific
8
- * @todo Make sending emails on cron an optional thing with a yes/no in sys config
9
- *
10
- * @package SLI
11
- * @subpackage Search
12
- * @author Blue Acorn: Brys Sepulveda
13
- */
14
-
15
- Overview:
16
- This module provides the sitewide javascript necessary for SLI to integrate properly
17
- with Magento. It redirects the search functionality (through the form.mini.search)
18
- to a new url (provided by SLI) which SLI hosts that serves search results. This SLI
19
- hosted page gets its styling from a special Magento hosted template page that this
20
- module creates as sli/search/template. SLI will use that page to template their own
21
- page. SLI learns about Magento's products from a feed that is generated for each
22
- Magento store and sent to SLI through FTP. If FTP is not enabled, then the feed will
23
- have to be manually sent.
24
-
25
- MiniGrid:
26
- Any mention of the MiniGrid within this module is reference to the base module that
27
- this search module is built on. The BlueAcorn_MiniGrid module provides a mini
28
- grid in an easy to use system configuration frontend type. The frontend type creates
29
- a grid with the level of customization of normal Magento grids with column renderers.
30
- The MiniGrid provides the flexability of inline editing in the same vein as the Magento native
31
- grids you see on things like tier pricing on product pages.
32
-
33
- Sli_Search_Template:
34
- This page provides the template by which SLI generates its search page. SLI hits
35
- this page to pull designs off of it so that their externally hosted search page
36
- has the latest Magento design.
37
-
38
- Feed Backup:
39
- When a feed generation occurs, all feeds created during the generation can be backed
40
- up into an archive. The archive keeps track of the last two generations at a time in
41
- order to be efficient about space. Once a generation happens, the oldest archive
42
- is destroyed, the next archive is made the oldest, and then the new generation is
43
- archived. These archives are found in var/sli/backups/bak/ and
44
- var/sli/backups/bak.bak. Feed back up can be turned on and off in the system config.
45
-
46
- Manual Feed Generation:
47
- The system configuration provides a Feed Generation button under the feed section. The
48
- manual feed button will start the generation for all stores. If the generation is already
49
- happening then the generation will not occur.
50
-
51
- Scheduled Feed Generation:
52
- The feed generation can be set on a schedule which is settable under the Cron section
53
- of the system configurations. The frequency (daily, weekly, monthly) and the exact
54
- time of day can be set. The default is daily at 2 in the morning.The next time the
55
- feed will run is displayed on the Feed section.
56
-
57
- CLI Feed Generation:
58
- The feeds can be generated from the command line as well. the script is located under
59
- shell/sli/feed.php. The script has one command which is 'build' and can take 0 or 1 parameter.
60
- With 0 parameters, all feeds are built. The 1 parameter it takes is --store with the store
61
- id as a value. With that parameter set, the feed for the store id will be created.
62
-
63
- Feed Generation Logging:
64
- The generation of the feed is logged to a specific log file for the feed. In this way,
65
- there will be a different log file for each feed. The logs are located under var/log/sli/
66
- and are named accordingly. There are three levels of logging, Error, Debug, and Trace.
67
-
68
- FTP:
69
- The SLI Search module will send the product feed to SLI if the settings are correct.
70
- SLI will provide an ftp user, password, host, and path where the feeds can be uploaded.
71
- These will need to be set up as part of set up for the module.
72
-
73
- Search Mini Form:
74
- The search mini form, which is the search box in the header, has been overwritten in
75
- this module to link to the external SLI hosted search page. This page will be provided
76
- by SLI in your setup of the module and will need to be configured under the javascript
77
- section of the system configurations under Search Domain. The search also comes with an
78
- autocomplete script which will need to be configured in the same area under the
79
- javascript section under Auto Complete.
80
-
81
- Javascript:
82
- The top and bottom javascripts appear on each page and will be provided by SLI to
83
- set up this module. The javascript will need to be pasted directly into the system
84
- configurations under the javascript section under Header and Footer.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/doc/makeTar.txt DELETED
@@ -1,18 +0,0 @@
1
- tar \
2
- -czvf \
3
- slisearch.tar.gz \
4
- app/code/local/SLI/Search/ \
5
- app/etc/modules/SLI_Search.xml \
6
- app/design/adminhtml/default/default/template/sli/search/ \
7
- app/design/frontend/base/default/template/sli/search/ \
8
- app/design/frontend/base/default/layout/sli/search.xml \
9
- shell/sli/
10
-
11
- tar -czvf \
12
- slisearch2_0_4.tar.gz \
13
- app/code/local/SLI/Search/ \
14
- app/design/adminhtml/default/default/template/sli/search/ \
15
- app/design/frontend/base/default/layout/sli/search.xml \
16
- app/design/frontend/base/default/template/sli/search/ \
17
- app/etc/modules/SLI_Search.xml \
18
- shell/sli/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/dropdown.sql DELETED
@@ -1,59 +0,0 @@
1
- SELECT `e`.`entity_id`
2
- AS
3
- `product_id`,
4
- IF(at_name.value_id > 0, at_name.value, at_name_default.value)
5
- AS `name`,
6
- IF(at_url_path.value_id > 0, at_url_path.value,
7
- at_url_path_default.value) AS
8
- `url_path`,
9
- IF(at_somethingspecial.value_id > 0, at_somethingspecial.value,
10
- at_somethingspecial_default.value)
11
- AS `somethingspecial`,
12
- Group_concat(DISTINCT opt_somethingspecial.value SEPARATOR '|')
13
- AS
14
- `option_somethingspecial`
15
- FROM `catalog_product_entity` AS `e`
16
- INNER JOIN `catalog_product_entity_int` AS `at_status_default`
17
- ON ( `at_status_default`.`entity_id` = `e`.`entity_id` )
18
- AND ( `at_status_default`.`attribute_id` = '273' )
19
- AND `at_status_default`.`store_id` = 0
20
- LEFT JOIN `catalog_product_entity_int` AS `at_status`
21
- ON ( `at_status`.`entity_id` = `e`.`entity_id` )
22
- AND ( `at_status`.`attribute_id` = '273' )
23
- AND ( `at_status`.`store_id` = 2 )
24
- INNER JOIN `catalog_product_website` AS `product_website`
25
- ON product_website.product_id = e.entity_id
26
- AND product_website.website_id = '1'
27
- LEFT JOIN `catalog_product_entity_varchar` AS `at_name_default`
28
- ON ( `at_name_default`.`entity_id` = `e`.`entity_id` )
29
- AND ( `at_name_default`.`attribute_id` = '96' )
30
- AND `at_name_default`.`store_id` = 0
31
- LEFT JOIN `catalog_product_entity_varchar` AS `at_name`
32
- ON ( `at_name`.`entity_id` = `e`.`entity_id` )
33
- AND ( `at_name`.`attribute_id` = '96' )
34
- AND ( `at_name`.`store_id` = '2 OR `at_name`.`store_id` = 1' )
35
- LEFT JOIN `catalog_product_entity_varchar` AS `at_url_path_default`
36
- ON ( `at_url_path_default`.`entity_id` = `e`.`entity_id` )
37
- AND ( `at_url_path_default`.`attribute_id` = '570' )
38
- AND `at_url_path_default`.`store_id` = 0
39
- LEFT JOIN `catalog_product_entity_varchar` AS `at_url_path`
40
- ON ( `at_url_path`.`entity_id` = `e`.`entity_id` )
41
- AND ( `at_url_path`.`attribute_id` = '570' )
42
- AND ( `at_url_path`.`store_id` =
43
- '2 OR `at_url_path`.`store_id` = 1' )
44
- LEFT JOIN `catalog_product_entity_int` AS `at_somethingspecial_default`
45
- ON ( `at_somethingspecial_default`.`entity_id` = `e`.`entity_id` )
46
- AND ( `at_somethingspecial_default`.`attribute_id` = '1004' )
47
- AND `at_somethingspecial_default`.`store_id` = 0
48
- LEFT JOIN `catalog_product_entity_int` AS `at_somethingspecial`
49
- ON ( `at_somethingspecial`.`entity_id` = `e`.`entity_id` )
50
- AND ( `at_somethingspecial`.`attribute_id` = '1004' )
51
- AND ( `at_somethingspecial`.`store_id` =
52
- '1 OR `at_somethingspecial`.`store_id` = 1'
53
- )
54
- LEFT JOIN `eav_attribute_option_value` AS `opt_somethingspecial`
55
- ON Concat(',', at_somethingspecial.value, ',') LIKE
56
- Concat('%,', opt_somethingspecial.option_id, ',%')
57
- WHERE ( IF(at_status.value_id > 0, at_status.value, at_status_default.value) =
58
- '1' )
59
- GROUP BY e.entity_id having e.entity_id = 168;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/etc/adminhtml.xml DELETED
@@ -1,42 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
5
- * This file is part of Learning Search Connect.
6
- * Learning Search Connect is distribute under license,
7
- * go to www.sli-systems.com/LSC for full license details.
8
- *
9
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
10
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
11
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
12
- * PARTICULAR PURPOSE.
13
- *
14
- * Systems configurations for SLI Systems Search
15
- * Includes General, Feed Settings, FTP Settings, Javascript, Cron Settings,
16
- * Product Attributes, and other settings.
17
- *
18
- * @package SLI
19
- * @subpackage Search
20
- */
21
- -->
22
- <config>
23
- <acl>
24
- <resources>
25
- <admin>
26
- <children>
27
- <system>
28
- <children>
29
- <config>
30
- <children>
31
- <sli_search translate="title" module="sli_search">
32
- <title>SLI Search Section</title>
33
- </sli_search>
34
- </children>
35
- </config>
36
- </children>
37
- </system>
38
- </children>
39
- </admin>
40
- </resources>
41
- </acl>
42
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/SLI/Search/sql/sli_search_setup/install-1.0.0.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Install script for version 1.0.0
14
- * Sets defaults into system config data table
15
- *
16
- * @package SLI
17
- * @subpackage Search
18
- */
19
-
20
- // This function will be used to sort the attributes array
21
- function cmp($attr1, $attr2) {
22
- return strcmp($attr1['attribute'], $attr2['attribute']) > 0 ? 1 : -1;
23
- }
24
-
25
- //Save out the default attributes to the core config data table
26
- $defaultAttributes = Mage::getConfig()->getNode('default/sli_search/default_attributes')->asArray();
27
-
28
- $productEntityType = Mage::getModel('eav/entity_type')->loadByCode('catalog_product');
29
- $attributeCollection = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($productEntityType->getId());
30
-
31
- $attributes = array();
32
- foreach($attributeCollection as $attribute) {
33
- $code = $attribute->getAttributeCode();
34
- if (isset($defaultAttributes[$code])) {
35
- $attributes[]['attribute'] = $attribute->getAttributeCode();
36
- unset($defaultAttributes[$code]);
37
- }
38
- }
39
-
40
- // The attributes left in the array are non-eav
41
- foreach ($defaultAttributes as $attributeCode => $val) {
42
- $attributes[]['attribute'] = $attributeCode;
43
- }
44
-
45
- usort($attributes, "cmp");
46
-
47
- Mage::getModel('core/config_data')
48
- ->setPath('sli_search/attributes/attributes')
49
- ->setScope('default')
50
- ->setScopeId(0)
51
- ->setValue(serialize($attributes))
52
- ->save();
53
-
54
-
55
- //Save out the cron job to the core config data table
56
- $frequency = Mage::getConfig()->getNode('default/sli_search/cron/frequency');
57
- $time = explode(",", Mage::getConfig()->getNode('default/sli_search/cron/time'));
58
-
59
- $cronTab = Mage::helper('sli_search')->getCronTimeAsCrontab($frequency, $time);
60
-
61
- Mage::getModel("sli_search/system_config_backend_cron")->saveCronTab($cronTab);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/sli/search/email/messages.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Javascript that provides functionality to run the SLI feed generator using
27
+ * ajax.
28
+ *
29
+ * @package SLI
30
+ * @subpackage Search
31
+ */
32
+ ?>
33
+ <table style="margin:3px;">
34
+ <?php foreach ($this->getMessages() as $key => $message): ?>
35
+ <tr>
36
+ <td style="margin:3px;"><b><?php echo $key ?></b></td>
37
+ <td style="margin:3px;"><?php echo $message ?></td>
38
+ </tr>
39
+ <?php endforeach; ?>
40
+ </table>
app/design/adminhtml/default/default/template/sli/search/sysconfig/ba_minigrid_js.phtml ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * Minigrid form field js
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ ?>
32
+ <script type="text/javascript">
33
+ function baMiniGrid() {
34
+ return {
35
+ /**
36
+ * @param tbody Body tag of grid table to insert rows into
37
+ * @param addRowButton Button that adds rows to grid
38
+ * @param rowName Unique name to give the grid rows. Used in name attribute
39
+ * @param collectionData Object that has info on all prexisting grid rows
40
+ * @param rowData Object containing the schema of the columns in each row
41
+ */
42
+ init: function (tbody, addRowButton, rowName, collectionData, rowData) {
43
+ this.tbody = tbody;
44
+ this.addRowButton = addRowButton;
45
+ this.collectionData = collectionData;
46
+ this.rowData = rowData;
47
+ this.rowName = rowName;
48
+
49
+ this.initRows();
50
+ this.observeAddRowButton();
51
+ this.initAttributeValidation();
52
+ },
53
+ observeAddRowButton: function () {
54
+ this.addRowButton.observe('click', function (ev) {
55
+ ev.stop();
56
+ this.addRow();
57
+ }.bind(this));
58
+ },
59
+ getNewRowId: function () {
60
+ if (typeof this.rowId == "undefined") {
61
+ this.rowId = 0;
62
+ }
63
+ return this.tbody.id + "-row-id-" + this.rowId++;
64
+ },
65
+ initRows: function () {
66
+ if (!this.collectionData.length || this.collectionData.length < 1) {
67
+ return;
68
+ }
69
+ this.collectionData.each(function (rowValues) {
70
+ var row = this.getNewRow(rowValues);
71
+ this.addRow(row);
72
+ }.bind(this));
73
+ },
74
+ getNewRow: function (rowValues) {
75
+ var rowId = this.getNewRowId();
76
+ var rowName = this.rowName;
77
+
78
+ var tr = new Element('tr', {id: rowId});
79
+ var td, input;
80
+ for (var field in this.rowData) {
81
+ td = new Element('td');
82
+ input = this.getInputTag(field, rowName, rowId);
83
+ if (rowValues && typeof rowValues[field] != 'undefined') {
84
+ try {
85
+ input.value = rowValues[field];
86
+ delete rowValues[field];
87
+ }
88
+ catch (e) {
89
+ if (input.type == "file") {
90
+ var bgStyle = "background: url('<?php echo Mage::getDesign()->getSkinUrl('images/success_msg_icon.gif') ?>') no-repeat 0 0;";
91
+ var fileUploaded = new Element('div', {
92
+ style: "float:left; width:16px; height:16px; " + bgStyle
93
+ });
94
+ var uploaded = new Element('p', {
95
+ style: "float:left; margin:0 0 0 5px"
96
+ }).update("File Uploaded.");
97
+ Element.insert(td, {bottom: fileUploaded});
98
+ Element.insert(td, {bottom: uploaded});
99
+ td.setAttribute("title", "File: " + rowValues[field]);
100
+ }
101
+ }
102
+ }
103
+
104
+ Element.insert(td, {bottom: input});
105
+ Element.insert(tr, {bottom: td});
106
+ }
107
+
108
+ if (rowValues && typeof rowValues != 'undefined') {
109
+ for (var field in rowValues) {
110
+ Element.insert(tr, {
111
+ top: new Element('input', {
112
+ name: this.rowName + "[" + rowId + "][" + field + "]",
113
+ type: "hidden",
114
+ value: rowValues[field]
115
+ })
116
+ })
117
+ }
118
+ }
119
+
120
+ var button = new Element('button', {
121
+ type: 'button',
122
+ style: 'width:50px;',
123
+ title: 'Delete'
124
+ }).update("<span>Delete</span>");
125
+ button.className = "scalable delete icon-btn";
126
+ button.observe('click', function (ev) {
127
+ ev.stop();
128
+ this.removeRow(rowId);
129
+ }.bind(this));
130
+
131
+ var buttonTd = new Element('td');
132
+ Element.insert(buttonTd, {bottom: button});
133
+ Element.insert(tr, {bottom: buttonTd});
134
+ return tr;
135
+ },
136
+ getInputTag: function (field, rowName, rowId) {
137
+ var input;
138
+ if (this.rowData[field]['type'] == 'textarea' || this.rowData[field]['type'] == "select") {
139
+ input = new Element(this.rowData[field]['type'], {
140
+ style: "width:98%;",
141
+ name: rowName + "[" + rowId + "][" + field + "]"
142
+ });
143
+ input.addClassName("minigrid-field");
144
+ input.addClassName("minigrid-field-" + field);
145
+ input.addClassName("validate-minigrid-attribute");
146
+
147
+ if (typeof this.rowData[field]['options'] != 'undefined') {
148
+ var options = this.rowData[field]['options'];
149
+ if (Object.isArray(options)) {
150
+ options.each(function (value, opt) {
151
+ var option = new Element('option', {value: opt}).update(value);
152
+ Element.insert(input, {bottom: option});
153
+ }.bind(this));
154
+ }
155
+ else {
156
+ for (var opt in options) {
157
+ var option = new Element('option', {value: opt}).update(options[opt]);
158
+ Element.insert(input, {bottom: option});
159
+ }
160
+ }
161
+ }
162
+ }
163
+ else {
164
+ input = new Element('input', {
165
+ style: "width:" + this.rowData[field]['width'],
166
+ type: this.rowData[field]['type'],
167
+ name: rowName + "[" + rowId + "][" + field + "]"
168
+ });
169
+ input.addClassName("minigrid-field");
170
+ input.addClassName("minigrid-field-" + field);
171
+ }
172
+ return input;
173
+ },
174
+ addRow: function (row) {
175
+ row = row || this.getNewRow();
176
+ if (typeof this.allRemoved != 'undefined' && this.allRemoved) {
177
+ this.allRemoved.remove();
178
+ delete this.allRemoved;
179
+ }
180
+ Element.insert(this.tbody, {bottom: row});
181
+ },
182
+ removeRow: function (rowId) {
183
+ var row = $(rowId);
184
+ if (typeof row != "undefined" && row) {
185
+ row.remove();
186
+ if (this.tbody.children.length == 0) {
187
+ this.allRemoved = new Element('input', {type: 'hidden', name: this.rowName, value: ''});
188
+ Element.insert(this.tbody, {bottom: this.allRemoved});
189
+ }
190
+ }
191
+ return 1;
192
+ },
193
+ initAttributeValidation: function () {
194
+ Validation.add('validate-minigrid-attributes', 'Please remove duplicate attributes.', function (v) {
195
+ var selectedAttributes = document.getElementsByClassName("validate-minigrid-attribute");
196
+
197
+ var hasDuplicates = false;
198
+ for (var i = 0; i < selectedAttributes.length; i++) {
199
+ var occurrences = 1;
200
+ var icurrent = selectedAttributes.item(i).value;
201
+ for (var j = i + 1; j < selectedAttributes.length; j++) {
202
+ var jcurrent = selectedAttributes.item(j).value;
203
+ if (icurrent == jcurrent) {
204
+ occurrences++;
205
+ if (occurrences > 1) {
206
+ selectedAttributes.item(i).addClassName('validation-failed');
207
+ selectedAttributes.item(j).addClassName('validation-failed');
208
+ }
209
+ }
210
+ }
211
+ if (occurrences > 1) hasDuplicates = true;
212
+ }
213
+ if (hasDuplicates == true) return false;
214
+ else return true;
215
+ });
216
+ }
217
+ }
218
+ }
219
+ </script>
app/design/adminhtml/default/default/template/sli/search/sysconfig/generate/js.phtml CHANGED
@@ -1,55 +1,89 @@
1
  <?php
 
2
  /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
 
4
  * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
  *
8
  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
  * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
 
 
 
 
 
 
 
 
 
 
 
13
  * Javascript that provides functionality to run the SLI feed generator using
14
  * ajax.
15
  *
16
- * @package SLI
17
  * @subpackage Search
18
  */
19
  ?>
20
  <script type="text/javascript">
21
- //<![CDATA[
22
 
23
  var sliSearch = {
24
- isInit : false,
25
- buttonId : null,
26
- init : function() {
27
  this.url = '<?php echo $this->getGenerateUrl() ?>';
28
  this.buttonId = '<?php echo $this->getButtonId()?>';
29
  this.displayId = "sli_display_msg";
30
  this.isInit = true;
31
  },
32
- generateFeed : function() {
33
  if (!this.isInit) {
34
  this.init();
35
  }
36
  new Ajax.Request(this.url, {
37
- onSuccess: function(transport) {
38
  var response = transport.responseText.evalJSON();
39
  this.displayResults(response);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }.bind(this)
41
  });
42
  },
43
- displayResults : function(response) {
44
  var responseEl = $(this.displayId);
45
  if (responseEl == null) {
46
- var responseEl = new Element('p', {id : this.displayId}).addClassName('note');
47
- Element.insert($(this.buttonId) , {after: responseEl});
48
  }
49
- if(response.messages) {
 
50
  responseEl.innerHTML = '';
51
- for(var message in response.messages) {
52
- responseEl.appendChild( new Element('p').update('<b>' + message + ':</b> ' + response.messages[message]));
 
 
 
 
53
  }
54
  return responseEl;
55
  }
@@ -58,9 +92,9 @@
58
  }
59
  $(this.buttonId).disabled = true;
60
  $(this.buttonId).addClassName("disabled");
61
- return responseEl.innerHTML = "<?php echo Mage::getModel('sli_search/feed')->getAjaxNotice(); ?>";
62
  }
63
- }
64
 
65
- //]]>
66
- </script>
1
  <?php
2
+
3
  /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
  * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
  *
10
  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
  * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
  * Javascript that provides functionality to run the SLI feed generator using
27
  * ajax.
28
  *
29
+ * @package SLI
30
  * @subpackage Search
31
  */
32
  ?>
33
  <script type="text/javascript">
34
+ //<![CDATA[
35
 
36
  var sliSearch = {
37
+ isInit: false,
38
+ buttonId: null,
39
+ init: function () {
40
  this.url = '<?php echo $this->getGenerateUrl() ?>';
41
  this.buttonId = '<?php echo $this->getButtonId()?>';
42
  this.displayId = "sli_display_msg";
43
  this.isInit = true;
44
  },
45
+ generateFeed: function () {
46
  if (!this.isInit) {
47
  this.init();
48
  }
49
  new Ajax.Request(this.url, {
50
+ onSuccess: function (transport) {
51
  var response = transport.responseText.evalJSON();
52
  this.displayResults(response);
53
+ }.bind(this),
54
+ onFailure: function (transport) {
55
+ if (403 == transport.status) {
56
+ this.displayResults({
57
+ "messages": {
58
+ 'Error': 'Your role does not have permission for "Manual Feed Generation". '
59
+ + 'Please contact your system administrator.'
60
+ },
61
+ "error": true
62
+ });
63
+ } else {
64
+ this.displayResults({
65
+ "messages": {'Error': 'Generation failed! Status: ' + transport.status},
66
+ "error": true
67
+ });
68
+ }
69
  }.bind(this)
70
  });
71
  },
72
+ displayResults: function (response) {
73
  var responseEl = $(this.displayId);
74
  if (responseEl == null) {
75
+ var responseEl = new Element('p', {id: this.displayId}).addClassName('note');
76
+ Element.insert($(this.buttonId), {after: responseEl});
77
  }
78
+ if (response.messages) {
79
+ var style = response.error ? ' style="color:red;"' : '';
80
  responseEl.innerHTML = '';
81
+ for (var message in response.messages) {
82
+ responseEl.appendChild(
83
+ new Element('p').update(
84
+ '<span' + style + '><b>' + message + ':</b> ' + response.messages[message] + '</span>'
85
+ )
86
+ );
87
  }
88
  return responseEl;
89
  }
92
  }
93
  $(this.buttonId).disabled = true;
94
  $(this.buttonId).addClassName("disabled");
95
+ return responseEl.innerHTML = "<?php echo Mage::helper('sli_search/feed')->getAjaxNotice(); ?>";
96
  }
97
+ };
98
 
99
+ //]]>
100
+ </script>
app/design/frontend/base/default/layout/sli/search.xml CHANGED
@@ -1,51 +1,65 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
5
- * This file is part of Learning Search Connect.
6
- * Learning Search Connect is distribute under license,
7
- * go to www.sli-systems.com/LSC for full license details.
8
- *
9
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
10
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
11
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
12
- * PARTICULAR PURPOSE.
13
- *
14
- * Layout xml to change out the search mini form with the SLI one, add the SLI
15
- * header and footer javascript to all pages, and format the special SLI search
16
- * template that they hit for design updates.
17
- *
18
- * @package SLI
19
- * @subpackage Search
20
- */
21
- -->
22
- <layout version="0.1.0">
23
- <default>
24
- <reference name="before_body_end">
25
- <block type="sli_search/search_js_bottom" name="sli_search_bottom_js" />
26
- </reference>
27
- <reference name="head">
28
- <block type="sli_search/search_js_top" name="sli_search_top_js" />
29
- </reference>
30
- <reference name="header">
31
- <action method="unsetChild" ifconfig="sli_search/general/form_enabled">
32
- <name>topSearch</name>
33
- </action>
34
- <block name="sliSearch" type="sli_search/search_form_mini" template="sli/search/form.mini.phtml"/>
35
- <action method="append" ifconfig="sli_search/general/form_enabled">
36
- <block>sliSearch</block>
37
- <alias>topSearch</alias>
38
- </action>
39
- </reference>
40
- </default>
41
- <sli_search_search_template>
42
- <reference name="root">
43
- <action method="setTemplate"><template>page/1column.phtml</template></action>
44
- </reference>
45
- <reference name="content">
46
- <block type="core/text" name="sli_tags">
47
- <action method="setText" module="sli_search"><text><![CDATA[ <!--SLIContent--><!--EndSLIContent--> ]]></text></action>
48
- </block>
49
- </reference>
50
- </sli_search_search_template>
51
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license – please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ /**
26
+ * SLI Systems Search integration.
27
+ *
28
+ * @package SLI
29
+ * @subpackage Search
30
+ */
31
+ -->
32
+ <layout version="0.1.0">
33
+ <default>
34
+ <reference name="before_body_end">
35
+ <block type="sli_search/search_js_bottom" name="sli_search_bottom_js"/>
36
+ </reference>
37
+ <reference name="head">
38
+ <block type="sli_search/search_js_top" name="sli_search_top_js"/>
39
+ </reference>
40
+ <reference name="header">
41
+ <action method="unsetChild" ifconfig="sli_search/general/form_enabled">
42
+ <name>topSearch</name>
43
+ </action>
44
+ <block name="sliSearch" type="sli_search/search_form_mini"/>
45
+ <action method="append" ifconfig="sli_search/general/form_enabled">
46
+ <block>sliSearch</block>
47
+ <alias>topSearch</alias>
48
+ </action>
49
+ </reference>
50
+ </default>
51
+ <sli_search_search_template>
52
+ <reference name="root">
53
+ <action method="setTemplate">
54
+ <template>page/1column.phtml</template>
55
+ </action>
56
+ </reference>
57
+ <reference name="content">
58
+ <block type="core/text" name="sli_tags">
59
+ <action method="setText" module="sli_search">
60
+ <text><![CDATA[ <!--SLIContent--><!--EndSLIContent--> ]]></text>
61
+ </action>
62
+ </block>
63
+ </reference>
64
+ </sli_search_search_template>
65
+ </layout>
app/design/frontend/base/default/template/sli/search/form.mini.phtml DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- * Search Mini Form for SLI.
14
- * Provides search url to SLI hosted search solution and SLI provided autocomplete
15
- * feature.
16
- *
17
- * @package SLI
18
- * @subpackage Search
19
- */
20
- ?>
21
- <form name="searchform" action="<?php echo $this->getSearchUrl() ?>" method="get" id="SliSearchProductForm" onsubmit="ajaxsearchsubmit(this);return false;">
22
- <div class="form-search">
23
- <label for="sli_search_1">Search:</label>
24
- <input type="text" name="w" id="sli_search_1" class="input-text" autocomplete="off" data-provide="rac" />
25
- <button type="submit" title="<?php echo $this->__('Search') ?>" class="button"><span><span><?php echo $this->__('Search') ?></span></span></button>
26
- </div>
27
- <script type="text/javascript">
28
- //<![CDATA[
29
- var searchForm = new Varien.searchForm('SliSearchProductForm', 'sli_search_1', '<?php echo $this->__('Search entire store here...') ?>');
30
- //]]>
31
- </script>
32
- </form>
33
- <?php echo $this->getInlineAutocompleteJs(); ?>
34
- <script type="text/javascript">
35
- function ajaxsearchsubmit(form){
36
- var search = encodeURIComponent(form.w.value);
37
- if (typeof ajaxsearch !== 'undefined' && ajaxsearch) {
38
- window.location=slibaseurlsearch+"#w="+search
39
- } else {
40
- window.location=slibaseurlsearch+"?w="+search;
41
- }
42
- return false;
43
- }
44
- </script>
45
-
46
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/SLI_Search.xml CHANGED
@@ -1,13 +1,13 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <SLI_Search>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- <depends>
8
- <Mage_CatalogSearch/>
9
- <Mage_Catalog />
10
- </depends>
11
- </SLI_Search>
12
- </modules>
13
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <SLI_Search>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_CatalogSearch/>
9
+ <Mage_Catalog/>
10
+ </depends>
11
+ </SLI_Search>
12
+ </modules>
13
+ </config>
app/locale/en_US/template/email/sli/feed_email_template.html ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject SLI Learning Search Connect: {{var subject}} @-->
2
+ <!--@vars
3
+ {
4
+ "var logo_url":"Email Logo Image Url",
5
+ "var logo_alt":"Email Logo Image Alt"
6
+ }
7
+ @-->
8
+
9
+ <!--@styles
10
+ @-->
11
+
12
+ {{template config_path="design/email/header"}}
13
+ {{inlinecss file="email-inline.css"}}
14
+
15
+ <table cellpadding="0" cellspacing="0" border="0">
16
+ <tr>
17
+ <td class="action-content">
18
+ <h2>SLI Learning Search Connect feed status:</h2>
19
+ {{block type='core/template' area='adminhtml' template='sli/search/email/messages.phtml'
20
+ messages=$messages}}
21
+ <p>Please check the sli log files for further information. These are on your servers file system in "&lt;magento
22
+ base&gt;/var/log/sli".</p>
23
+ </td>
24
+ </tr>
25
+ </table>
26
+
27
+ {{template config_path="design/email/footer"}}
package.xml CHANGED
@@ -1,22 +1,27 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>slisearch</name>
4
- <version>2.1.4</version>
5
  <stability>stable</stability>
6
- <license uri="http://www.sli-systems.com/lsc">SLI Feed Generation</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>LSC integrates Magento with SLI's SaaS based Learning Search, Learning Navigation and user based SEO products.</summary>
10
  <description>Learning Search Connect (LSC) produces data feeds out of current Magento Community and Enterprise editions. The feeds are created and then sent to SLI's FTP servers for further processing.</description>
11
  <notes>Changes since last release:&#xD;
12
- * Added ability to disable/enable the feed generation and the search form separately&#xD;
13
- * Updated ability to send feed generation success/failure notifications&#xD;
14
- * Fixed issue with the pricing for configurable products whose children are out of stock&#xD;
15
- * Fixed issue with the price feed in multiple stores</notes>
16
- <authors><author><name>Platform Support</name><user>SLI-Systems</user><email>support@sli-systems.com</email></author></authors>
17
- <date>2015-06-16</date>
18
- <time>05:45:43</time>
19
- <contents><target name="magelocal"><dir name="SLI"><dir name="Search"><dir name="Block"><dir name="Search"><dir name="Form"><file name="Mini.php" hash="3604db79a2b2f26b45805b9cb2ad2a3e"/></dir><dir name="Js"><file name="Bottom.php" hash="0a692390e55bb4023949fa031e3d4e70"/><file name="Top.php" hash="aea872cd49aa8e354e676633542aea94"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><dir name="Minigrid"><file name="Js.php" hash="e5073c787a85d065029b210a347b8009"/></dir><file name="Minigrid.php" hash="fa2e4dec779179aae10e9bdd678429cc"/><file name="Version.php" hash="72bcde22f1eaa0e2f8fafd3e00d717e4"/></dir></dir><file name="Form.php" hash="4a1551d259ef3510cb803cb02a026083"/><dir name="Frontend"><dir name="Feed"><dir name="Generate"><file name="Js.php" hash="c7a4f7c7cbd83c3479d8bf2cfc360597"/></dir><file name="Generate.php" hash="3ad8446e6650c5d3562574f294b4bcef"/><file name="Next.php" hash="008c3d9351c50712ea4d2b76531e0bb4"/></dir></dir></dir></dir><dir name="Widget"><dir name="Minigrid"><file name="Form.php" hash="014ef14b01cbafc9cd305e9a1caf82ae"/></dir></dir></dir><file name="Exception.php" hash="6a8fc0cab1826df68df2e447d2152e58"/><dir name="Helper"><file name="Data.php" hash="93b201c553af72dcc023f702d35f18b6"/><file name="Feed.php" hash="29a34ecb802155308cd3dc023c11827b"/></dir><dir name="Model"><file name="Cron.php" hash="afb9440de8054fc20db834e7d7fb7889"/><file name="Email.php" hash="db28fb33aaf2f32ae0dbf1ceb13761e3"/><file name="Feed.php" hash="2e46a4651ffa8f13309a7a8225ad156d"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Cron.php" hash="ae282d6bfc5e22e7c3320d581465f24d"/><file name="Enabledsetting.php" hash="059ac548a388b8ca02147d0d317f7bb5"/><file name="Loglevel.php" hash="31b58bfdf479b9de2380f3d741bd3175"/><file name="Minigrid.php" hash="afc9bff695c0b3b933340c4dcb2837ad"/></dir><dir name="Source"><file name="Attributes.php" hash="e777863deb4e2e17574a833202911f38"/><dir name="Cron"><file name="Frequency.php" hash="882dade19aec9b2bddf1cdb611be018c"/></dir><file name="Emailsetting.php" hash="a5776ec69c7a1413c87d3290530741af"/><dir name="Minigrid"><file name="Abstract.php" hash="3f65ae2dd959bb8583cfcffb0109cffa"/><file name="Attributes.php" hash="7a97225139a38a4a0576538293980187"/></dir></dir></dir></dir></dir><file name="NotificationException.php" hash="79982dffb46f3e0468bc5f38d22e322e"/><dir name="controllers"><file name="ApiController.php" hash="b2e138b49dc29b4a17836ab3436beaba"/><file name="SearchController.php" hash="7403ba2b0f1223f48fe3a982d0066042"/></dir><dir name="doc"><file name="changelog.txt" hash="93ac6e72c6dbfb91e3ee2f2c2701d865"/><file name="design.txt" hash="ff939b286de699aed45c6d6ad103cd5c"/><file name="makeTar.txt" hash="ef75554f12dde147891fea285a7f6bc0"/></dir><file name="dropdown.sql" hash="dc15502900071cb30caa144ddeb21a0d"/><dir name="etc"><file name="adminhtml.xml" hash="868b799465f118e2212bcff9048994bb"/><file name="config.xml" hash="907a1309543293c61015b62c775b5a06"/><file name="system.xml" hash="603c5b3af3f8cd2fa5803764b74f1b9e"/></dir><dir name="sql"><dir name="sli_search_setup"><file name="install-1.0.0.php" hash="8b5dd72380e039eb124b804657086f77"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="sli"><dir name="search"><dir name="sysconfig"><dir name="generate"><file name="js.phtml" hash="9797355ec3189a3c37933a21f7351a18"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="sli"><file name="search.xml" hash="06a16a544602d34c2b4fb0fa45257941"/></dir></dir><dir name="template"><dir name="sli"><dir name="search"><file name="form.mini.phtml" hash="57c4a3ea68c2ba0678ded7949c0661a4"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SLI_Search.xml" hash="56554dd94200e574eb398c59a437af4c"/></dir></target><target name="mage"><dir name="shell"><dir name="sli"><file name="feed.php" hash="daaf2fdb80f6cc72ddf5b35709822416"/></dir></dir></target></contents>
 
 
 
 
 
20
  <compatible/>
21
  <dependencies><required><php><min>5.3.19</min><max>5.5.0</max></php></required></dependencies>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>slisearch</name>
4
+ <version>3.0.5</version>
5
  <stability>stable</stability>
6
+ <license uri="http://sli-systems.com/lsc">SLI Feed Generation</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>LSC integrates Magento with SLI's SaaS based Learning Search, Learning Navigation and user based SEO products.</summary>
10
  <description>Learning Search Connect (LSC) produces data feeds out of current Magento Community and Enterprise editions. The feeds are created and then sent to SLI's FTP servers for further processing.</description>
11
  <notes>Changes since last release:&#xD;
12
+ * Fixed issues related to cron job creation&#xD;
13
+ * Improved format of exported feed&#xD;
14
+ * Smarter feed encoding capability&#xD;
15
+ * Optimized feed processing&#xD;
16
+ * Fixed potential security issue&#xD;
17
+ * Improved email notification format&#xD;
18
+ * Improved support for tiered and group pricing&#xD;
19
+ * Better support for required attributes&#xD;
20
+ * Improved logging capability</notes>
21
+ <authors><author><name>Platform support</name><user>SLI-Systems</user><email>support@sli-system.com</email></author></authors>
22
+ <date>2016-05-03</date>
23
+ <time>02:40:12</time>
24
+ <contents><target name="magecommunity"><dir name="SLI"><dir name="Search"><dir name="Block"><dir name="Search"><dir name="Form"><file name="Mini.php" hash="bf98fdd4a73b0536cf6fd0f7bd15f7cd"/></dir><dir name="Js"><file name="Bottom.php" hash="448c67f3ea49538b522eec5fb67ad6ec"/><file name="Top.php" hash="48a2ef9314240ae7f2a7b137073cfead"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Minigrid.php" hash="211b3ed2e02da5fd7514eb998d24ecea"/><file name="Version.php" hash="6c21b8393c4840337989ed43c6d9a9eb"/></dir></dir><file name="Form.php" hash="08e1291b012bff41bc8f3df6644fc763"/><dir name="Frontend"><dir name="Feed"><dir name="Generate"><file name="Js.php" hash="5b2d825f90faaf56b3eb4a1a052eb927"/></dir><file name="Generate.php" hash="87cfb67934be30bcfbd208f99839c16c"/><file name="Next.php" hash="6270ea4de96286999eefbe8843b2c391"/></dir></dir></dir></dir></dir><file name="Exception.php" hash="5ccdacc40bd1fa4e0bff9e1052135ed7"/><dir name="Helper"><file name="Data.php" hash="3525ed62c3a40e8dc7e902b85bd45e2f"/><file name="Feed.php" hash="ecb22065ed034a81f04b588373579681"/><file name="FeedLogger.php" hash="78ab2597e31741ba19734d8fc636621d"/><file name="XmlWriter.php" hash="26d623c550f00c6a94ab1187f00b024c"/></dir><dir name="Model"><file name="Cron.php" hash="c62a9de1e84322674e6f1fac0f4c7a2d"/><file name="Email.php" hash="d19ecbae60401f770518e28c70aed151"/><file name="FeedGenerator.php" hash="22cf795739ca52a0e316e9b60b125e48"/><file name="FeedManager.php" hash="8fa1be3c21d30e5d36b2cc5a7344fd0b"/><dir name="Generators"><file name="AttributeGenerator.php" hash="b5fe82bc890d59e1fbe51d15c66e6429"/><file name="CategoryGenerator.php" hash="93fa6b7f3b3d06e06390888681eba94d"/><file name="DemoGenerator.php" hash="b6e0612249d5ac460bd8f5d3a478fa03"/><file name="GeneratorContext.php" hash="65e0ca2c7bb9e7e971e5ce70f60db639"/><file name="GeneratorInterface.php" hash="8429040b4a235f3d036c6e05c74da945"/><file name="MetaGenerator.php" hash="1fc2d82062353e32aa9cd0b5a3e4cf92"/><file name="PriceGenerator.php" hash="5e3aa9b3ab28f0fab46bfe222ab46ef8"/><file name="ProductGenerator.php" hash="ae7290603cd00c415508516a4c5cf240"/></dir><dir name="Resource"><file name="FeedManager.php" hash="1aaf710eb3a2a0faf9975e04751a0ffe"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Cron.php" hash="65cc33439803b330a1edc63a7e157aeb"/><file name="Loglevel.php" hash="d6f55cdf860f3a04a4cc66e9d07f2690"/><file name="Minigrid.php" hash="d22a3dac552aa9702d6dd78914908157"/></dir><dir name="Source"><file name="Attributes.php" hash="3ef527a83eab735a4d96efd7c8b4abab"/><dir name="Cron"><file name="Frequency.php" hash="813fa35468c79ab091222bfdacaac10c"/></dir><file name="Emailsetting.php" hash="05381cab1a6cbfa927bf057738ecde36"/><dir name="Minigrid"><file name="Abstract.php" hash="bea6e5915b98615f23a14e7b9ba47e26"/><file name="Attributes.php" hash="7cdaeac2ec3af87c646c1f19230bd61d"/></dir></dir></dir></dir></dir><file name="NotificationException.php" hash="f9b2751fe6b842b0f478e6af315c3504"/><dir name="controllers"><dir name="Adminhtml"><file name="SliController.php" hash="4e1aa872aefda9d14bdc0c2e161720eb"/></dir><file name="ApiController.php" hash="6bea6fe1136126cb87fc7510e9f6f789"/><file name="SearchController.php" hash="59ed22f3094a50e58e4db51ad885ff78"/></dir><dir name="etc"><file name="adminhtml.xml" hash="9dc07e335dcc973c32e06252d1706475"/><file name="config.xml" hash="4f7c9b84a94649999ae42ea3d98c1dba"/><file name="system.xml" hash="87fd41109a5f19fa247793757ec112b0"/></dir><dir name="sql"><dir name="sli_search_setup"><file name="install-1.0.0.php" hash="93ed7171c20b348ada1911bda071a3f3"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="sli"><dir name="search"><dir name="email"><file name="messages.phtml" hash="a1c625234e566d8c3b8e38eae87ef771"/></dir><dir name="sysconfig"><file name="ba_minigrid_js.phtml" hash="77fb2709cc3d8887c688581872315993"/><dir name="generate"><file name="js.phtml" hash="ba33a2176318c8639d8627b051beb949"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="sli"><file name="search.xml" hash="3b30097cb35b8887c19d5da934dd8ce5"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SLI_Search.xml" hash="6c577c136e2170969e0b3afba1a7b426"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="sli"><file name="feed_email_template.html" hash="41f77fe9e8525320c954ad7afbeff584"/></dir></dir></dir></dir></target><target name="mage"><dir name="shell"><dir name="sli"><file name="feed.php" hash="80d7556f6f026ab7bd56cdbfed9c4b97"/></dir></dir></target></contents>
25
  <compatible/>
26
  <dependencies><required><php><min>5.3.19</min><max>5.5.0</max></php></required></dependencies>
27
  </package>
shell/sli/feed.php CHANGED
@@ -1,74 +1,102 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights Reserved
4
- * This file is part of Learning Search Connect.
5
- * Learning Search Connect is distribute under license,
6
- * go to www.sli-systems.com/LSC for full license details.
7
- *
8
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
9
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
10
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
11
- * PARTICULAR PURPOSE.
12
- *
13
- *
14
- * @package SLI
15
- * @subpackage Search
16
- */
17
-
18
- require_once('../abstract.php');
19
-
20
- class SLI_Search_Shell_Feed extends Mage_Shell_Abstract {
21
-
22
- /**
23
- *
24
- *
25
- * @return boolean
26
- */
27
- public function run() {
28
- if ($this->getArg('build')) {
29
- try {
30
- $id = $this->getArg('store');
31
- if (!is_bool($id)) {
32
- Mage::getModel('sli_search/feed')->setData('store_id', $id)->generateFeed(); //Standard feed
33
- echo "Feed generated for store $id.\n";
34
- return true;
35
- }
36
- else if (count($this->_args) == 1){
37
- Mage::getModel('sli_search/feed')->setData('store_id', 1)->generateFeed(); //Standard feed
38
- echo "Feed generated for store 1.\n";
39
- return true;
40
- }
41
- }
42
- catch (SLI_Search_Exception $e) {
43
- echo "{$e->getMessage()}\n";
44
- return false;
45
- }
46
- catch (Exception $e) {
47
- Mage::logException($e);
48
- echo "An unknown error occurred. Please contact your SLI provider. {$e->getMessage()}\n";
49
- return false;
50
- }
51
- }
52
- echo $this->usageHelp();
53
- return false;
54
- }
55
-
56
- /**
57
- * Retrieve Usage Help Message
58
- *
59
- */
60
- public function usageHelp()
61
- {
62
- return <<<USAGE
63
- Usage: php -f feed.php -- [options]
64
-
65
- build Builds Feeds For All Stores
66
- build --store [#] Builds Feed For Specific Store
67
-
68
- USAGE;
69
- }
70
-
71
- }
72
-
73
- $sliSearchFeed = new SLI_Search_Shell_Feed();
74
- $sliSearchFeed->run();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (c) 2015 S.L.I. Systems, Inc. (www.sli-systems.com) - All Rights
5
+ * Reserved
6
+ * This file is part of Learning Search Connect.
7
+ * Learning Search Connect is distributed under a limited and restricted
8
+ * license - please visit www.sli-systems.com/LSC for full license details.
9
+ *
10
+ * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13
+ * PARTICULAR PURPOSE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO
14
+ * EVENT WILL SLI BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY GENERAL, DIRECT,
15
+ * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL LOSS OR DAMAGES OF ANY
16
+ * CHARACTER ARISING OUT OF THE USE OF THE CODE AND/OR THE LICENSE INCLUDING
17
+ * BUT NOT LIMITED TO PERSONAL INJURY, LOSS OF DATA, LOSS OF PROFITS, LOSS OF
18
+ * ASSIGNMENTS, DATA OR OUTPUT FROM THE SERVICE BEING RENDERED INACCURATE,
19
+ * FAILURE OF CODE, SERVER DOWN TIME, DAMAGES FOR LOSS OF GOODWILL, BUSINESS
20
+ * INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES
21
+ * OR LOSSES OF WHATEVER NATURE, EVEN IF SLI HAS BEEN INFORMED OF THE
22
+ * POSSIBILITY OF SUCH DAMAGES.
23
+ */
24
+
25
+ require_once(__DIR__ . '/../abstract.php');
26
+
27
+ /**
28
+ * LSC CLI interface.
29
+ *
30
+ * @package SLI
31
+ * @subpackage Search
32
+ */
33
+ class SLI_Search_Shell_Feed extends Mage_Shell_Abstract
34
+ {
35
+ /**
36
+ *
37
+ * @return boolean
38
+ */
39
+ public function run()
40
+ {
41
+ try {
42
+ /** @var $feedManager SLI_Search_Model_FeedManager */
43
+ $feedManager = Mage::getModel('sli_search/FeedManager');
44
+
45
+ if ($this->getArg('build')) {
46
+ $id = $this->getArg('store');
47
+ if (!is_bool($id)) {
48
+ $feedManager->generateFeedForStores(array($id));
49
+ echo "Feed generated for store $id.\n";
50
+
51
+ return true;
52
+ } else {
53
+ if (count($this->_args) == 1) {
54
+ $feedManager->generateFeedForStores();
55
+ echo "Generating feeds for all stores.\n";
56
+
57
+ return true;
58
+ }
59
+ }
60
+ } elseif ($this->getArg('cron')) {
61
+ /** @var $cron SLI_Search_Model_Cron */
62
+ $cron = Mage::getModel('sli_search/cron');
63
+ $cron->generateFeeds();
64
+
65
+ return true;
66
+ }
67
+ } catch (SLI_Search_Exception $e) {
68
+ echo "{$e->getMessage()}\n";
69
+
70
+ return false;
71
+ } catch (Exception $e) {
72
+ Mage::logException($e);
73
+ echo "An unknown error occurred. Please contact your SLI provider. {$e->getMessage()}\n";
74
+
75
+ return false;
76
+ }
77
+
78
+ echo $this->usageHelp();
79
+
80
+ return false;
81
+ }
82
+
83
+ /**
84
+ * Retrieve Usage Help Message
85
+ *
86
+ */
87
+ public function usageHelp()
88
+ {
89
+ return <<<USAGE
90
+ Usage: php -f feed.php -- [options]
91
+
92
+ build Builds Feeds For All Stores
93
+ build --store [#] Builds Feed For Specific Store
94
+ cron Execute Feed cron
95
+
96
+ USAGE;
97
+ }
98
+ }
99
+
100
+ // run
101
+ $sliSearchFeed = new SLI_Search_Shell_Feed();
102
+ $sliSearchFeed->run();