slisearch - Version 1.8.6

Version Notes

first release for Magento Connect

Download this release

Release Info

Developer SLI-Systems
Extension slisearch
Version 1.8.6
Comparing to
See all releases


Version 1.8.6

Files changed (35) hide show
  1. app/code/local/SLI/Search/Block/Search/Form/Mini.php +60 -0
  2. app/code/local/SLI/Search/Block/Search/Js/Bottom.php +33 -0
  3. app/code/local/SLI/Search/Block/Search/Js/Top.php +33 -0
  4. app/code/local/SLI/Search/Block/System/Config/Form.php +27 -0
  5. app/code/local/SLI/Search/Block/System/Config/Form/Field/Minigrid.php +129 -0
  6. app/code/local/SLI/Search/Block/System/Config/Form/Field/Minigrid/Js.php +183 -0
  7. app/code/local/SLI/Search/Block/System/Config/Form/Field/Version.php +30 -0
  8. app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Generate.php +82 -0
  9. app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Generate/Js.php +42 -0
  10. app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Next.php +57 -0
  11. app/code/local/SLI/Search/Block/Widget/Minigrid/Form.php +153 -0
  12. app/code/local/SLI/Search/Exception.php +20 -0
  13. app/code/local/SLI/Search/Helper/Data.php +326 -0
  14. app/code/local/SLI/Search/Helper/Feed.php +131 -0
  15. app/code/local/SLI/Search/Model/Cron.php +45 -0
  16. app/code/local/SLI/Search/Model/Email.php +60 -0
  17. app/code/local/SLI/Search/Model/Feed.php +78 -0
  18. app/code/local/SLI/Search/Model/System/Config/Backend/Cron.php +62 -0
  19. app/code/local/SLI/Search/Model/System/Config/Backend/Loglevel.php +43 -0
  20. app/code/local/SLI/Search/Model/System/Config/Backend/Minigrid.php +79 -0
  21. app/code/local/SLI/Search/Model/System/Config/Source/Attributes.php +120 -0
  22. app/code/local/SLI/Search/Model/System/Config/Source/Minigrid/Abstract.php +50 -0
  23. app/code/local/SLI/Search/Model/System/Config/Source/Minigrid/Attributes.php +36 -0
  24. app/code/local/SLI/Search/controllers/SearchController.php +71 -0
  25. app/code/local/SLI/Search/doc/changelog.txt +2 -0
  26. app/code/local/SLI/Search/doc/design.txt +84 -0
  27. app/code/local/SLI/Search/doc/makeTar.txt +9 -0
  28. app/code/local/SLI/Search/etc/adminhtml.xml +42 -0
  29. app/code/local/SLI/Search/etc/config.xml +149 -0
  30. app/code/local/SLI/Search/etc/system.xml +322 -0
  31. app/code/local/SLI/Search/sql/sli_search_setup/install-1.0.0.php +61 -0
  32. app/design/adminhtml/default/default/template/sli/search/sysconfig/generate/js.phtml +59 -0
  33. app/etc/modules/SLI_Search.xml +12 -0
  34. package.xml +132 -0
  35. shell/sli/feed.php +74 -0
app/code/local/SLI/Search/Block/Search/Form/Mini.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Switch out the default form mini template for the sli version
51
+ *
52
+ * @return string
53
+ */
54
+ protected function _toHtml() {
55
+ if (Mage::helper('sli_search')->isEnabled(Mage::app()->getStore()->getId())) {
56
+ $this->setTemplate('sli/search/form.mini.phtml');
57
+ }
58
+ return parent::_toHtml();
59
+ }
60
+ }
app/code/local/SLI/Search/Block/Search/Js/Bottom.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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->isEnabled()) {
29
+ $this->addText($helper->getFooterJs());
30
+ }
31
+ }
32
+
33
+ }
app/code/local/SLI/Search/Block/Search/Js/Top.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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->isEnabled()) {
28
+ $this->addText($helper->getSLIDomainJs());
29
+ $this->addText($helper->getHeaderJs());
30
+ }
31
+ }
32
+
33
+ }
app/code/local/SLI/Search/Block/System/Config/Form.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
app/code/local/SLI/Search/Block/System/Config/Form/Field/Minigrid.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ </div>
116
+
117
+ <script type="text/javascript">
118
+ Event.observe(window,'load', function(){
119
+ (new baMiniGrid()).init($("ba-<?php echo $tableId?>"),
120
+ $('ba-add-<?php echo $tableId?>'),
121
+ "<?php echo $fieldName?>",
122
+ <?php echo json_encode($rowData)?>,
123
+ <?php echo json_encode($fields)?>);
124
+ });
125
+ </script>
126
+ <?php
127
+ return ob_get_clean();
128
+ }
129
+ }
app/code/local/SLI/Search/Block/System/Config/Form/Field/Minigrid/Js.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if (typeof this.rowData[field]['options'] != 'undefined') {
136
+ var options = this.rowData[field]['options'];
137
+ if (Object.isArray(options)) {
138
+ options.each(function(value,opt){
139
+ var option = new Element('option', {value: opt}).update(value);
140
+ Element.insert(input, {bottom: option});
141
+ }.bind(this));
142
+ }
143
+ else {
144
+ for (var opt in options) {
145
+ var option = new Element('option', {value: opt}).update(options[opt]);
146
+ Element.insert(input, {bottom: option});
147
+ }
148
+ }
149
+ }
150
+ }
151
+ else {
152
+ input = new Element('input', {style:"width:" + this.rowData[field]['width'],type: this.rowData[field]['type'], name: rowName + "["+rowId+"][" +field + "]"});
153
+ input.addClassName("minigrid-field");
154
+ input.addClassName("minigrid-field-" + field);
155
+ }
156
+ return input;
157
+ },
158
+ addRow : function (row) {
159
+ row = row || this.getNewRow();
160
+ if (typeof this.allRemoved != 'undefined' && this.allRemoved) {
161
+ this.allRemoved.remove();
162
+ delete this.allRemoved;
163
+ }
164
+ Element.insert(this.tbody, {bottom: row});
165
+ },
166
+ removeRow : function (rowId) {
167
+ var row = $(rowId);
168
+ if (typeof row != "undefined" && row) {
169
+ row.remove();
170
+ if (this.tbody.children.length == 0 ) {
171
+ this.allRemoved = new Element('input', {type:'hidden', name: this.rowName, value:''});
172
+ Element.insert(this.tbody, {bottom: this.allRemoved});
173
+ }
174
+ }
175
+ return 1;
176
+ }
177
+ }
178
+ }
179
+ </script>
180
+ <?php
181
+ return $html . ob_get_clean();
182
+ }
183
+ }
app/code/local/SLI/Search/Block/System/Config/Form/Field/Version.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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');
39
+ Mage::app()->setCurrentStore($curStore);
40
+ return $myUrl;
41
+ }
42
+ }
app/code/local/SLI/Search/Block/System/Config/Frontend/Feed/Next.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/Data.php ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 JS_GROUP = "js/";
26
+ const CRON_GROUP = "cron/";
27
+ const ATTR_GROUP = "attributes/";
28
+ const DEFAULT_ATTRS = "default_attributes/";
29
+
30
+ /**
31
+ * Returns true/false on whether or not the module is enabled
32
+ *
33
+ * @return boolean
34
+ */
35
+ public function isEnabled($store_id = 0) {
36
+ return (bool) Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::GENERAL_GROUP . 'enabled');
37
+ }
38
+
39
+ /**
40
+ * Returns true/false on whether or not the price feed is enabled
41
+ *
42
+ * @return boolean
43
+ */
44
+ public function isPriceFeedEnabled($store_id = 0) {
45
+ return (bool) Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::GENERAL_GROUP . 'price_feed');
46
+ }
47
+
48
+ /**
49
+ * Returns an integer which is the log level
50
+ *
51
+ * @return int
52
+ */
53
+ public function getLogLevel($store_id = 0) {
54
+ return (int) Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::GENERAL_GROUP . 'log_level');
55
+ }
56
+
57
+ /**
58
+ * Returns true/false on whether or not we should backup feeds
59
+ *
60
+ * @return boolean
61
+ */
62
+ public function isBackupFeed() {
63
+ return (bool) Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "backup");
64
+ }
65
+
66
+ /**
67
+ * Returns true/false on whether or not we should drop tables
68
+ *
69
+ * @return boolean
70
+ */
71
+ public function isDataPersistent() {
72
+ return (bool) Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "persistent_data");
73
+ }
74
+
75
+ /**
76
+ * Returns true/false on whether or not to include out of stock items in feed
77
+ *
78
+ * @return boolean
79
+ */
80
+ public function isIncludeOutOfStockItems($store_id = 0) {
81
+ return (bool) Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::FEED_GROUP . "stockstatus");
82
+ }
83
+
84
+ /**
85
+ * Returns true/false on whether or not to include disabled categories in feed
86
+ *
87
+ * @return boolean
88
+ */
89
+ public function isIncludeDisabledCategories($store_id = 0) {
90
+ return (bool) Mage::app()->getStore($store_id)->getConfig(self::SECTION . self::FEED_GROUP . "categorystatus");
91
+ }
92
+
93
+ /**
94
+ * Returns true/false on whether or not we should drop tables;
95
+ *
96
+ * @return int
97
+ */
98
+ public function getWriteBatch() {
99
+ return (int) Mage::getStoreConfig(self::SECTION . self::FEED_GROUP . "write_batch");
100
+ }
101
+
102
+ /**
103
+ * Returns true/false on whether or not we should use ftp on feed generation
104
+ *
105
+ * @return boolean
106
+ */
107
+ public function isUseFtp() {
108
+ return (bool) Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "enabled");
109
+ }
110
+
111
+ /**
112
+ * Returns the user by which to log into the ftp server
113
+ *
114
+ * @return string
115
+ */
116
+ public function getFtpUser() {
117
+ return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "user");
118
+ }
119
+
120
+ /**
121
+ * Returns the password for the user to log into the ftp server
122
+ *
123
+ * @return string
124
+ */
125
+ public function getFtpPass() {
126
+ return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "pass");
127
+ }
128
+
129
+ /**
130
+ * Returns the host that we will log into via ftp
131
+ *
132
+ * @return string
133
+ */
134
+ public function getFtpHost() {
135
+ return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "host");
136
+ }
137
+
138
+ /**
139
+ * Returns the path on the ftp server that we will drop the feed into
140
+ *
141
+ * @return string
142
+ */
143
+ public function getFtpPath() {
144
+ return Mage::getStoreConfig(self::SECTION . self::FTP_GROUP . "path");
145
+ }
146
+
147
+ /**
148
+ * Returns the javascript that goes into the html head block
149
+ *
150
+ * @return string
151
+ */
152
+ public function getHeaderJs() {
153
+ return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "header");
154
+ }
155
+
156
+ /**
157
+ * Returns the javascript that goes into the before_body_end
158
+ *
159
+ * @return string
160
+ */
161
+ public function getFooterJs() {
162
+ return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "footer");
163
+ }
164
+
165
+ /**
166
+ * Returns the javascript that goes under the mini search form to provide
167
+ * autocomplete features from SLI
168
+ *
169
+ * @return string
170
+ */
171
+ public function getAutocompleteJs() {
172
+ return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "autocomplete");
173
+ }
174
+
175
+ /**
176
+ * Returns the external search domain to the SLI externally hosted search page
177
+ *
178
+ * @return string
179
+ */
180
+ public function getSearchDomain() {
181
+ return Mage::getStoreConfig(self::SECTION . self::JS_GROUP . "domain");
182
+ }
183
+
184
+ /**
185
+ * Returns the email to send notifications to when the cron runs
186
+ *
187
+ * @return string
188
+ */
189
+ public function getCronEmail() {
190
+ return Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "email");
191
+ }
192
+
193
+ /**
194
+ * Returns the frequency that the cron should run.
195
+ *
196
+ * @return string
197
+ */
198
+ public function getCronFrequency() {
199
+ return Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "frequency");
200
+ }
201
+
202
+ /**
203
+ * Returns the time of day that the cron should run at.
204
+ *
205
+ * @return string
206
+ */
207
+ public function getCronTime() {
208
+ return Mage::getStoreConfig(self::SECTION . self::CRON_GROUP . "time");
209
+ }
210
+
211
+ /**
212
+ * Returns an array of attributes to be included in the feed
213
+ *
214
+ * @return array
215
+ */
216
+ public function getAttributes() {
217
+ $attrs = Mage::getStoreConfig(self::SECTION . self::ATTR_GROUP . "attributes");
218
+ $default_attributes = Mage::getStoreConfig(self::SECTION . self::DEFAULT_ATTRS . "attributes");
219
+ $defaults = array();
220
+ foreach(explode(',',$default_attributes) as $attr) {
221
+ if($attr && trim($attr) != '') $defaults[] = array('attribute'=>trim($attr));
222
+ }
223
+ $arr = array_merge_recursive($defaults, $attrs);
224
+ return array_merge_recursive($defaults, $attrs);
225
+ }
226
+
227
+
228
+ /**
229
+ * Return crontab formatted time for cron set time.
230
+ *
231
+ * @param string $frequency
232
+ * @param array $time
233
+ * @return string
234
+ */
235
+ public function getCronTimeAsCrontab($frequency, $time) {
236
+ list($hours, $minutes, $seconds) = $time;
237
+
238
+ $cron = array("*", "*", "*", "*", "*");
239
+
240
+ //Parse through time
241
+ if ($minutes) {
242
+ $cron[0] = $minutes;
243
+ }
244
+
245
+ if ($hours) {
246
+ $cron[1] = $hours;
247
+ }
248
+
249
+ //Parse through frequencies
250
+ switch ($frequency) {
251
+ case "W":
252
+ $cron[4] = 0;
253
+ break;
254
+ case "M":
255
+ $cron[2] = 1;
256
+ break;
257
+ }
258
+
259
+ return implode(" ", $cron);
260
+ }
261
+
262
+ /**
263
+ * Gets the next run date based on cron settings.
264
+ *
265
+ * @return Zend_Date
266
+ */
267
+ public function getNextRunDateFromCronTime() {
268
+ $now = Mage::app()->getLocale()->date();
269
+ $frequency = $this->getCronFrequency();
270
+ list($hours, $minutes, $seconds) = explode(',', $this->getCronTime());
271
+
272
+ $time = Mage::app()->getLocale()->date();
273
+ $time->setHour($hours)->setMinute($minutes)->setSecond($seconds);
274
+
275
+ //Parse through frequencies
276
+ switch ($frequency) {
277
+ case "D":
278
+ if ($time->compare($now) == -1) {
279
+ $time->addDay(1);
280
+ }
281
+ break;
282
+ case "W":
283
+ $time->setWeekday(7);
284
+ if ($time->compare($now) == -1) {
285
+ $time->addWeek(1);
286
+ }
287
+ break;
288
+ case "M":
289
+ $time->setDay(1);
290
+ if ($time->compare($now) == -1) {
291
+ $time->addMonth(1);
292
+ }
293
+ break;
294
+ }
295
+
296
+ return $time;
297
+ }
298
+
299
+ function mtime() {
300
+ list($usec, $sec) = explode(" ", microtime());
301
+ return ((float) $usec + (float) $sec);
302
+ }
303
+
304
+ /**
305
+ * Returns domain(s) as a js var
306
+ *
307
+ * @return url
308
+ */
309
+ public function getSLIDomainJs() {
310
+ $searchURL = $this->getSearchDomain();
311
+ $scheme = parse_url($searchURL, PHP_URL_SCHEME);
312
+ if (!$scheme) {
313
+ $searchURL = "http://".$searchURL;
314
+ }
315
+ preg_match('/http(s|):\/\/(.+?)\//',$searchURL,$matches);
316
+ $searchURLBase = $searchURL;
317
+ if (isset($matches[2])) {
318
+ $searchURLBase = $matches[2];
319
+ }
320
+ $returnJS = "\n<script type=\"text/javascript\">\nvar slibaseurlsearch = '" . $searchURL ."';\nvar slibaseurl = '" . $searchURLBase . "';\n</script>\n";
321
+
322
+ return $returnJS;
323
+ }
324
+
325
+
326
+ }
app/code/local/SLI/Search/Helper/Feed.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @param Mage_Core_Model_Store $store
27
+ * @param array $urlParts
28
+ * @throws Mage_Core_Exception
29
+ */
30
+ public function postToGenerateFeed($store, $urlParts) {
31
+ $feedSocket = @fsockopen($urlParts['host'], 80, $errNo, $errStr, 10);
32
+
33
+ if (!$feedSocket) {
34
+ throw new SLI_Search_Exception("Err. #$errNo: Cannot access feed generation uri.");
35
+ }
36
+
37
+ $storeParam = "storeId={$store->getId()}";
38
+ $storeParamLen = strlen($storeParam);
39
+
40
+ $EOL = "\r\n";
41
+ $request = "POST {$urlParts['path']} HTTP/1.1$EOL";
42
+ $request .= "HOST: {$urlParts['host']}$EOL";
43
+ $request .= "Content-Length: $storeParamLen$EOL";
44
+ $request .= "Content-Type: application/x-www-form-urlencoded$EOL";
45
+ $request .= "Connection: Close$EOL$EOL";
46
+ $request .= "$storeParam";
47
+
48
+ $result = fwrite($feedSocket, $request);
49
+
50
+ if (!$result) {
51
+ throw new SLI_Search_Exception("Error writing to feed generation uri.");
52
+ }
53
+ fclose($feedSocket);
54
+ }
55
+
56
+ /**
57
+ * Returns url that controls feed generation
58
+ *
59
+ * @return string
60
+ */
61
+ public function getGenerateFeedUrl() {
62
+ $curStore = Mage::app()->getStore();
63
+ Mage::app()->setCurrentStore(1); //default store number...always 1
64
+ $myUrl = Mage::getUrl('sli_search/search/generateFeed');
65
+ Mage::app()->setCurrentStore($curStore);
66
+ return $myUrl;
67
+ }
68
+
69
+ /**
70
+ * Asynchronously starts a feed generation for each store
71
+ */
72
+ public function generateFeedsForAllStores() {
73
+ if ($this->thereAreFeedLocks()) {
74
+ throw new SLI_Search_Exception("One or more feeds are being generated. Generation temporarily locked.");
75
+ }
76
+ $feedUrl = $this->getGenerateFeedUrl();
77
+ $urlParts = parse_url($feedUrl);
78
+
79
+ $stores = Mage::getResourceModel('core/store_collection');
80
+ foreach($stores as $store) {
81
+ $this->postToGenerateFeed($store, $urlParts);
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Returns the feed file path
87
+ *
88
+ * @return string
89
+ */
90
+ public function getFeedFilePath() {
91
+ if ($this->_feedFilePath === null) {
92
+ $this->_feedFilePath = $this->makeVarPath(array('sli', 'feeds'));
93
+ }
94
+ return $this->_feedFilePath;
95
+ }
96
+
97
+ /**
98
+ * Create path within var folder if necessary given an array
99
+ * of directory names
100
+ *
101
+ * @param array $directories
102
+ * @return string
103
+ */
104
+ public function makeVarPath($directories) {
105
+ $path = Mage::getBaseDir('var');
106
+ foreach ($directories as $dir) {
107
+ $path .= DS . $dir;
108
+ if (!is_dir($path)) {
109
+ mkdir($path, 0777);
110
+ }
111
+ }
112
+ return $path;
113
+ }
114
+
115
+ /**
116
+ * Whether or not there are feed generation locks currently in place
117
+ *
118
+ * @return boolean
119
+ */
120
+ public function thereAreFeedLocks() {
121
+ $path = $this->getFeedFilePath();
122
+ foreach (scandir($path) as $file) {
123
+ $fullFile = $path.DS.$file;
124
+ if (is_file($fullFile) && !is_dir($fullFile) && is_numeric(strpos($file, '.lock'))) {
125
+ return true;
126
+ }
127
+ }
128
+ return false;
129
+ }
130
+
131
+ }
app/code/local/SLI/Search/Model/Cron.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ try {
25
+ Mage::helper('sli_search/feed')->generateFeedsForAllStores();
26
+ $msg = "Feeds Generating";
27
+ }
28
+ catch (SLI_Search_Exception $e) {
29
+ $msg = $e->getMessage();
30
+ }
31
+ catch (Exception $e) {
32
+ $msg = "Unknown Error: {$e->getMessage()} in {$e->getFile()} on line {$e->getLine()}. Please contact your sli provider.";
33
+ }
34
+
35
+ $this->_sendEmail($msg);
36
+ }
37
+
38
+ /**
39
+ * If there is a system config email set, send out the cron notification
40
+ * email.
41
+ */
42
+ protected function _sendEmail($msg) {
43
+ Mage::getModel('sli_search/email')->setData('msg', "test")->send();
44
+ }
45
+ }
app/code/local/SLI/Search/Model/Email.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 "SLI Scheduled Feed Generation";
37
+ }
38
+
39
+ /**
40
+ * SLI feed generation email body
41
+ *
42
+ * @return string
43
+ */
44
+ public function getBody() {
45
+ return <<<BODY
46
+ Status: {$this->getData('msg')}
47
+
48
+ Please check the sli log files for further information.
49
+
50
+ BODY;
51
+ }
52
+
53
+ public function send() {
54
+ $email = Mage::helper('sli_search')->getCronEmail();
55
+ if ($email) {
56
+ mail($email, $this->getSubject(), $this->getBody(), "From: {$this->getFromName()} <{$this->getFromEmail()}>\r\nReply-To: {$this->getFromEmail()}");
57
+ }
58
+ }
59
+
60
+ }
app/code/local/SLI/Search/Model/Feed.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ echo PHP_EOL."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 discovery@sli-systems.com ".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.<br> Please Contact SLI to receive the full version. <br>Call us toll free in the US: (866) 240-2812 or send us an email to discovery@sli-systems.com </p>";
76
+ return $this->_ajaxNotice;
77
+ }
78
+ }
app/code/local/SLI/Search/Model/System/Config/Backend/Cron.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = $this->getData('groups/general/fields/enabled/value');
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/Loglevel.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/Backend/Minigrid.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
app/code/local/SLI/Search/Model/System/Config/Source/Attributes.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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');
25
+
26
+ /**
27
+ * We want these attributes to appear in the drop down configuration menu, but they are not included in the
28
+ * EAV selection. We must add them in individually.
29
+ * if a key exists for a value, that key will be used as the label instead of the prefixed value
30
+ *
31
+ * @var array
32
+ */
33
+ protected $_nonEavAttributes = array(
34
+ 'product_id',
35
+ 'type_id',
36
+ 'max_price',
37
+ 'min_price',
38
+ 'parent_ids' => 'parent_id',
39
+ );
40
+
41
+ /**
42
+ * Prefix to use in the dropdown to differentiate the inventory attributes
43
+ */
44
+ const INVENTORY_ATTRIBUTES_PREFIX = 'inventory';
45
+
46
+ /**
47
+ * Attributes from the flat inventory table that we will use for the feed
48
+ * if a key exists for a value, that key will be used as the label instead of the prefixed value
49
+ *
50
+ * @var array
51
+ */
52
+ protected $_inventoryAttributes = array(
53
+ 'qty',
54
+ 'is_in_stock',
55
+ 'manage_stock',
56
+ 'backorders',
57
+ );
58
+
59
+ /**
60
+ * Prefix to use in the dropdown to differentiate the review attributes
61
+ */
62
+ const REVIEW_ATTRIBUTES_PREFIX = 'review';
63
+
64
+ /**
65
+ * Attributes from customer review that we will use for the feed
66
+ * if a key exists for a value, that key will be used as the label instead of the prefixed value
67
+ *
68
+ * @var array
69
+ */
70
+ protected $_reviewAttributes = array(
71
+ 'reviews_count' => 'reviews_count',
72
+ 'rating_summary',
73
+ );
74
+
75
+ /**
76
+ * Returns code => code pairs of attributes for all product attributes
77
+ *
78
+ * @return array
79
+ */
80
+ public function toOptionArray() {
81
+ $productEntityId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getId();
82
+
83
+ $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
84
+ ->setEntityTypeFilter($productEntityId);
85
+ $attributes->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns(array("code" => 'attribute_code'));
86
+
87
+ foreach ($attributes as $attribute) {
88
+ $code = $attribute['code'];
89
+ if (!in_array($attribute['code'], $this->_automaticAttributes)) {
90
+ $options[$code] = $code;
91
+ }
92
+ }
93
+
94
+ // We want some non-eav attributes to be added to this dropdown as well
95
+ foreach ($this->_nonEavAttributes as $label => $attributeCode) {
96
+ $label = is_string($label) ? $label : $attributeCode;
97
+ $options[$attributeCode] = $label;
98
+ }
99
+
100
+ // Add the inventory attributes
101
+ foreach ($this->_inventoryAttributes as $label => $attributeCode) {
102
+ $code = self::INVENTORY_ATTRIBUTES_PREFIX . "_" . $attributeCode;
103
+ $label = is_string($label) ? $label : self::INVENTORY_ATTRIBUTES_PREFIX . "_" . $attributeCode;
104
+ $options[$code] = $label;
105
+ }
106
+
107
+ // Add the review attributes
108
+ foreach ($this->_reviewAttributes as $label => $attributeCode) {
109
+ $code = self::REVIEW_ATTRIBUTES_PREFIX . "_" . $attributeCode;
110
+ $label = is_string($label) ? $label : self::REVIEW_ATTRIBUTES_PREFIX . "_" . $attributeCode;
111
+ $options[$code] = $label;
112
+ }
113
+
114
+ // Sort the array to account for the non-eav attrs being added in
115
+ asort($options);
116
+
117
+ unset($options['price']); //remove price from multiselect since it will be included regardless
118
+ return $options;
119
+ }
120
+ }
app/code/local/SLI/Search/Model/System/Config/Source/Minigrid/Abstract.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/controllers/SearchController.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Asynchronous posting to feed generation url for each store.
26
+ */
27
+ public function runFeedGenerationAction() {
28
+ $response = array("error" => false);
29
+
30
+ try {
31
+ Mage::helper('sli_search/feed')->generateFeedsForAllStores();
32
+ }
33
+ catch (SLI_Search_Exception $e) {
34
+ $response['error'] = $e->getMessage();
35
+ }
36
+ catch (Exception $e) {
37
+ Mage::logException($e);
38
+ $response['error'] = "An unknown error occurred. Please contact your SLI provider";
39
+ }
40
+ $this->getResponse()
41
+ ->setHeader("Content-Type", "application/json")
42
+ ->setBody(json_encode($response));
43
+ }
44
+
45
+ /**
46
+ * Generates a feed based on passed in store id. Defaults store id to
47
+ * default store
48
+ */
49
+ public function generateFeedAction() {
50
+ $response = "";
51
+ try {
52
+ $storeId = $this->getRequest()->getParam("storeId");
53
+
54
+ if (!$storeId) {
55
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
56
+ }
57
+
58
+ Mage::getModel('sli_search/feed')->setData('store_id', $storeId)->generateFeed();
59
+ Mage::getModel('sli_search/feed')->setData('store_id', $storeId)->generateFeed(true);
60
+ }
61
+ catch (SLI_Search_Exception $e) {
62
+ $response = $e->getMessage();
63
+ }
64
+ catch (Exception $e) {
65
+ Mage::logException($e);
66
+ $response = "An unknown error occurred. Please contact your SLI provider";
67
+ //@TODO Send a magento message of feed failure
68
+ }
69
+ $this->getResponse()->setBody($response);
70
+ }
71
+ }
app/code/local/SLI/Search/doc/changelog.txt ADDED
@@ -0,0 +1,2 @@
 
 
1
+ 1.0.0
2
+ Initial Module
app/code/local/SLI/Search/doc/design.txt ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
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/
app/code/local/SLI/Search/etc/adminhtml.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/etc/config.xml ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>1.8.6</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
+ <sli_search>
55
+ <default_attributes>
56
+ <sku/>
57
+ <short_description/>
58
+ <description/>
59
+ <meta_description/>
60
+ <price/>
61
+ <special_price/>
62
+ <special_from_date/>
63
+ <special_to_date/>
64
+ <news_to_date/>
65
+ <news_from_date/>
66
+ <image/>
67
+ <small_image/>
68
+ <product_id />
69
+ <type_id />
70
+ </default_attributes>
71
+ </sli_search>
72
+ </global>
73
+ <frontend>
74
+ <routers>
75
+ <sli_search>
76
+ <use>standard</use>
77
+ <args>
78
+ <module>SLI_Search</module>
79
+ <frontName>sli</frontName>
80
+ </args>
81
+ </sli_search>
82
+ </routers>
83
+ <layout>
84
+ <updates>
85
+ <sli_search module="SLI_Search">
86
+ <file>sli/search.xml</file>
87
+ </sli_search>
88
+ </updates>
89
+ </layout>
90
+ </frontend>
91
+ <default>
92
+ <sli_search>
93
+ <general>
94
+ <enabled>1</enabled>
95
+ <log_level>1</log_level>
96
+ <price_feed>0</price_feed>
97
+ </general>
98
+ <feed>
99
+ <backup>1</backup>
100
+ <submittal></submittal>
101
+ <stockstatus>1</stockstatus>
102
+ <categorystatus>0</categorystatus>
103
+ <generate></generate>
104
+ <write_batch>10000</write_batch>
105
+ </feed>
106
+ <ftp>
107
+ <enabled>1</enabled>
108
+ <user></user>
109
+ <pass backend_model="adminhtml/system_config_backend_encrypted"></pass>
110
+ <path></path>
111
+ </ftp>
112
+ <js>
113
+ <header>&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
114
+ var sliJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://&quot; : &quot;http://&quot;);
115
+ document.write(unescape('%3Clink rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;' + sliJsHost + 'assets.resultspage.com/js/rac/sli-rac.0.3.css&quot; /%3E'));
116
+ document.write(unescape('%3Clink rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;' + sliJsHost + slibaseurl + '/rac/sli-rac.css&quot; /%3E'));
117
+ &lt;/script&gt;</header>
118
+ <footer>&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
119
+ document.write(unescape('%3Cscript src=&quot;' + sliJsHost + slibaseurl + '/rac/sli-rac.config.js&quot; type=&quot;text/javascript&quot;%3E%3C/script%3E'));
120
+ &lt;/script&gt;</footer>
121
+ <autocomplete></autocomplete>
122
+ <domain>client.resultspage.com/search</domain>
123
+ </js>
124
+ <cron>
125
+ <email></email>
126
+ <frequency backend_model="adminhtml/system_config_backend_product_alert_cron">D</frequency>
127
+ <time>2,00,00</time>
128
+ </cron>
129
+ <attributes>
130
+ <attributes backend_model="sli_search/system_config_backend_minigrid" />
131
+ </attributes>
132
+ <default_attributes>
133
+ <attributes>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>
134
+ </default_attributes>
135
+ </sli_search>
136
+ </default>
137
+ <crontab>
138
+ <sli_search>
139
+ <job_code>sli_feed_generate</job_code>
140
+ </sli_search>
141
+ <jobs>
142
+ <sli_search>
143
+ <run>
144
+ <model>sli_search/cron::generateFeeds</model>
145
+ </run>
146
+ </sli_search>
147
+ </jobs>
148
+ </crontab>
149
+ </config>
app/code/local/SLI/Search/etc/system.xml ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <enabled translate="label">
48
+ <label>Enabled</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_yesno</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
+ </enabled>
56
+ <price_feed>
57
+ <label>Price Feed</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>adminhtml/system_config_source_yesno</source_model>
60
+ <comment>This feature is only functional in Enterprise Edition.</comment>
61
+ <sort_order>5</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </price_feed>
66
+ <log_level>
67
+ <label>Log Level</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>sli_search/system_config_backend_loglevel</source_model>
70
+ <sort_order>10</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
+ </log_level>
75
+ </fields>
76
+ </general>
77
+ <feed translate="label" module="sli_search">
78
+ <label>Feed Settings</label>
79
+ <frontend_type>text</frontend_type>
80
+ <sort_order>100</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
+ <fields>
85
+ <backup translate="label">
86
+ <label>Backup Feed?</label>
87
+ <frontend_type>select</frontend_type>
88
+ <source_model>adminhtml/system_config_source_yesno</source_model>
89
+ <sort_order>1</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>0</show_in_website>
92
+ <show_in_store>0</show_in_store>
93
+ </backup>
94
+ <write_batch translate="label">
95
+ <label>Batch Count</label>
96
+ <frontend_type>text</frontend_type>
97
+ <comment>Please only change the pre-populated value in consultation with SLI. The lower the number, the slower the feed generation.</comment>
98
+ <sort_order>10</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>0</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </write_batch>
103
+ <submittal translate="label">
104
+ <label>Next Automatic Feed Generation</label>
105
+ <frontend_type>text</frontend_type>
106
+ <frontend_model>sli_search/system_config_frontend_feed_next</frontend_model>
107
+ <sort_order>100</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>0</show_in_website>
110
+ <show_in_store>0</show_in_store>
111
+ </submittal>
112
+ <stockstatus translate="label">
113
+ <label>Include Out of Stock Items</label>
114
+ <frontend_type>select</frontend_type>
115
+ <source_model>adminhtml/system_config_source_yesno</source_model>
116
+ <sort_order>150</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </stockstatus>
121
+ <categorystatus>
122
+ <label>Include Disabled Categories</label>
123
+ <frontend_type>select</frontend_type>
124
+ <source_model>adminhtml/system_config_source_yesno</source_model>
125
+ <sort_order>175</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
+ </categorystatus>
130
+ <generate translate="label">
131
+ <label>Generate Feed</label>
132
+ <frontend_type>button</frontend_type>
133
+ <frontend_model>sli_search/system_config_frontend_feed_generate</frontend_model>
134
+ <comment>Manually generates feed. If FTP is enabled, also sends the feed.</comment>
135
+ <sort_order>200</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>0</show_in_website>
138
+ <show_in_store>0</show_in_store>
139
+ </generate>
140
+ </fields>
141
+ </feed>
142
+ <ftp translate="label" module="sli_search">
143
+ <label>FTP Settings</label>
144
+ <frontend_type>text</frontend_type>
145
+ <sort_order>200</sort_order>
146
+ <show_in_default>1</show_in_default>
147
+ <show_in_website>1</show_in_website>
148
+ <show_in_store>1</show_in_store>
149
+ <fields>
150
+ <enabled translate="label">
151
+ <label>Enabled</label>
152
+ <frontend_type>select</frontend_type>
153
+ <source_model>adminhtml/system_config_source_yesno</source_model>
154
+ <sort_order>1</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>1</show_in_store>
158
+ </enabled>
159
+ <user translate="label">
160
+ <label>FTP User</label>
161
+ <frontend_type>text</frontend_type>
162
+ <comment>Provided by SLI.</comment>
163
+ <sort_order>100</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ </user>
168
+ <pass translate="label">
169
+ <label>FTP Password</label>
170
+ <frontend_type>obscure</frontend_type>
171
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
172
+ <comment>Provided by SLI.</comment>
173
+ <sort_order>200</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ </pass>
178
+ <host translate="label">
179
+ <label>FTP Host</label>
180
+ <frontend_type>text</frontend_type>
181
+ <comment>Provided by SLI.</comment>
182
+ <sort_order>300</sort_order>
183
+ <show_in_default>1</show_in_default>
184
+ <show_in_website>1</show_in_website>
185
+ <show_in_store>1</show_in_store>
186
+ </host>
187
+ <path translate="label">
188
+ <label>FTP Upload Path</label>
189
+ <frontend_type>text</frontend_type>
190
+ <comment>Provided by SLI.</comment>
191
+ <sort_order>400</sort_order>
192
+ <show_in_default>1</show_in_default>
193
+ <show_in_website>1</show_in_website>
194
+ <show_in_store>1</show_in_store>
195
+ </path>
196
+ </fields>
197
+ </ftp>
198
+ <js translate="label" module="sli_search">
199
+ <label>JavaScript</label>
200
+ <frontend_type>text</frontend_type>
201
+ <sort_order>300</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>1</show_in_store>
205
+ <fields>
206
+ <header translate="label">
207
+ <label>Header</label>
208
+ <comment>Provided by SLI.</comment>
209
+ <frontend_type>textarea</frontend_type>
210
+ <sort_order>1</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>1</show_in_store>
214
+ </header>
215
+ <footer translate="label">
216
+ <label>Footer</label>
217
+ <comment>Provided by SLI.</comment>
218
+ <frontend_type>textarea</frontend_type>
219
+ <sort_order>100</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>1</show_in_website>
222
+ <show_in_store>1</show_in_store>
223
+ </footer>
224
+ <autocomplete translate="label">
225
+ <label>Auto Complete</label>
226
+ <frontend_type>textarea</frontend_type>
227
+ <sort_order>200</sort_order>
228
+ <show_in_default>1</show_in_default>
229
+ <show_in_website>1</show_in_website>
230
+ <show_in_store>1</show_in_store>
231
+ </autocomplete>
232
+ <domain translate="label">
233
+ <label>Search Domain</label>
234
+ <comment>Provided by SLI.</comment>
235
+ <frontend_type>text</frontend_type>
236
+ <sort_order>300</sort_order>
237
+ <show_in_default>1</show_in_default>
238
+ <show_in_website>1</show_in_website>
239
+ <show_in_store>1</show_in_store>
240
+ </domain>
241
+ </fields>
242
+ </js>
243
+ <cron translate="label" module="sli_search">
244
+ <label>Cron Settings</label>
245
+ <frontend_type>text</frontend_type>
246
+ <sort_order>400</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>0</show_in_website>
249
+ <show_in_store>0</show_in_store>
250
+ <fields>
251
+ <email translate="label">
252
+ <label>Cron Email</label>
253
+ <comment>When cron runs, email to send notification to.</comment>
254
+ <frontend_type>text</frontend_type>
255
+ <sort_order>1</sort_order>
256
+ <show_in_default>1</show_in_default>
257
+ <show_in_website>0</show_in_website>
258
+ <show_in_store>0</show_in_store>
259
+ </email>
260
+ <frequency translate="label">
261
+ <label>Frequency</label>
262
+ <frontend_type>select</frontend_type>
263
+ <source_model>adminhtml/system_config_source_cron_frequency</source_model>
264
+ <backend_model>sli_search/system_config_backend_cron</backend_model>
265
+ <sort_order>100</sort_order>
266
+ <show_in_default>1</show_in_default>
267
+ <show_in_website>0</show_in_website>
268
+ <show_in_store>0</show_in_store>
269
+ </frequency>
270
+ <time translate="label">
271
+ <label>Start Time</label>
272
+ <frontend_type>time</frontend_type>
273
+ <sort_order>200</sort_order>
274
+ <show_in_default>1</show_in_default>
275
+ <show_in_website>0</show_in_website>
276
+ <show_in_store>0</show_in_store>
277
+ </time>
278
+ </fields>
279
+ </cron>
280
+ <attributes translate="label" module="sli_search">
281
+ <label>Product Attributes</label>
282
+ <frontend_type>text</frontend_type>
283
+ <sort_order>500</sort_order>
284
+ <show_in_default>1</show_in_default>
285
+ <show_in_website>0</show_in_website>
286
+ <show_in_store>0</show_in_store>
287
+ <fields>
288
+ <attributes translate="label">
289
+ <label>Attributes to include</label>
290
+ <comment>The following attributes are automatically added to the feed: Name, Price, URL, Children Ids, and Categories.</comment>
291
+ <frontend_type>minigrid</frontend_type>
292
+ <source_model>sli_search/system_config_source_minigrid_attributes</source_model>
293
+ <backend_model>sli_search/system_config_backend_minigrid</backend_model>
294
+ <sort_order>1</sort_order>
295
+ <show_in_default>1</show_in_default>
296
+ <show_in_website>0</show_in_website>
297
+ <show_in_store>0</show_in_store>
298
+ </attributes>
299
+ </fields>
300
+ </attributes>
301
+ <version translate="label" module="sli_search">
302
+ <label>Version Information</label>
303
+ <frontend_type>text</frontend_type>
304
+ <sort_order>600</sort_order>
305
+ <show_in_default>1</show_in_default>
306
+ <show_in_website>1</show_in_website>
307
+ <show_in_store>1</show_in_store>
308
+ <fields>
309
+ <version translate="label">
310
+ <label>Version</label>
311
+ <frontend_type>version</frontend_type>
312
+ <sort_order>100</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
+ </version>
317
+ </fields>
318
+ </version>
319
+ </groups>
320
+ </sli_search>
321
+ </sections>
322
+ </config>
app/code/local/SLI/Search/sql/sli_search_setup/install-1.0.0.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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('global/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/sysconfig/generate/js.phtml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.error) {
50
+ return responseEl.innerHTML = response.error;
51
+ }
52
+ $(this.buttonId).disabled = true;
53
+ $(this.buttonId).addClassName("disabled");
54
+ return responseEl.innerHTML = "<?php echo Mage::getModel('sli_search/feed')->getAjaxNotice(); ?>";
55
+ }
56
+ }
57
+
58
+ //]]>
59
+ </script>
app/etc/modules/SLI_Search.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
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
+ </depends>
10
+ </SLI_Search>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>slisearch</name>
4
+ <version>1.8.6</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>&lt;p&gt;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.&lt;/p&gt;&#xD;
11
+ &lt;p&gt;Any information required to power SLI's SaaS based product family is contained in the feed.&lt;/p&gt;&#xD;
12
+ &lt;p&gt;Other than feed creation LSC provides the following features:&#xD;
13
+ &lt;li&gt;When active it replaces the Magento built in Catalog Search with SLI-Systems' award winning Learning Search. Your site visitors on entering search terms will be served search results that were created by SLI-Systems.&lt;/li&gt;&#xD;
14
+ &lt;li&gt;It exposes a URL to the Magento site's template page so that SLI's search results page can be styled to exactly match your Magento implementation's look and feel.&lt;/li&gt;&#xD;
15
+ &lt;/p&gt;&#xD;
16
+ &#xD;
17
+ &#xD;
18
+ The data in the feed can be used for the following SLI products and services:&#xD;
19
+ &lt;li&gt;&#xD;
20
+ &lt;a href="http://www.sli-systems.com/solutions/site-search"&gt;Learning Search for eCommerce Retail Sites&lt;/a&gt;&#xD;
21
+ &lt;/li&gt;&#xD;
22
+ &lt;li&gt;&#xD;
23
+ &lt;a href="http://www.sli-systems.com/solutions/navigation"&gt;Learning Navigation for eCommerce Retail Sites&lt;/a&gt;&#xD;
24
+ &lt;/li&gt;&#xD;
25
+ &lt;li&gt;&#xD;
26
+ &lt;a href="http://www.sli-systems.com/solutions/site-champion"&gt;Site Champion: User-Generated SEO&lt;/a&gt;&#xD;
27
+ &lt;/li&gt;&#xD;
28
+ &lt;li&gt;&#xD;
29
+ &lt;a href="http://www.sli-systems.com/solutions/mobile-site-search"&gt;Site Search for Mobile Devices&lt;/a&gt;&#xD;
30
+ &lt;/li&gt;&#xD;
31
+ &lt;li&gt;24x7 support&#xA0;&lt;/li&gt;&#xD;
32
+ &lt;li&gt;Other features include:&#xD;
33
+ &lt;ul&gt;&#xD;
34
+ &lt;li&gt;&#xD;
35
+ &lt;a href="http://www.sli-systems.com/solutions/merchandising"&gt;SLI Merchandising&lt;/a&gt;&#xD;
36
+ &lt;/li&gt;&#xD;
37
+ &lt;li&gt;&#xD;
38
+ &lt;a href="http://www.sli-systems.com/solutions/multivariate-testing"&gt;Conversion Optimizer for A/B and Multivariate Testing&lt;/a&gt;&#xD;
39
+ &lt;/li&gt;&#xD;
40
+ &lt;li&gt;Comprehensive reporting system&lt;/li&gt;&#xD;
41
+ &lt;li&gt;Rich Auto Complete&lt;/li&gt;&#xD;
42
+ &lt;li&gt;AJAX search&lt;/li&gt;&#xD;
43
+ &lt;/ul&gt;&#xD;
44
+ &lt;/li&gt;&#xD;
45
+ &#xD;
46
+ &#xD;
47
+ &#xD;
48
+ Learning Search Connect has the following capabilities&#xD;
49
+ &lt;div&gt;&#xD;
50
+ &lt;ul&gt;&#xD;
51
+ &lt;li&gt;Store specific feeds&lt;/li&gt;&#xD;
52
+ &lt;li&gt;Optional separate price feed in case advanced price finding mechanisms (such as catalog price rules) are used in the implementation&lt;/li&gt;&#xD;
53
+ &lt;li&gt;Replacement of the Magento built in catalogsearch form with the SLI search form&lt;/li&gt;&#xD;
54
+ &lt;li&gt;&#xD;
55
+ &lt;span&gt;Very fast generation of feeds&lt;/span&gt;&#xD;
56
+ &lt;/li&gt;&#xD;
57
+ &lt;li&gt;Optional backup of feeds&lt;/li&gt;&#xD;
58
+ &lt;li&gt;Optional FTP&lt;/li&gt;&#xD;
59
+ &lt;li&gt;Scheduling of feed generation&lt;/li&gt;&#xD;
60
+ &lt;li&gt;Triggering of feed generation via command line interface&lt;/li&gt;&#xD;
61
+ &lt;li&gt;Support for Parent Child relationships (via associated products and super attributes)&lt;/li&gt;&#xD;
62
+ &lt;li&gt;Price Ranges on the parent product&lt;/li&gt;&#xD;
63
+ &lt;li&gt;Inventory information&lt;/li&gt;&#xD;
64
+ &lt;li&gt;Stock information&lt;/li&gt;&#xD;
65
+ &lt;li&gt;Multiple, tiered categories per feed&lt;/li&gt;&#xD;
66
+ &lt;li&gt;Support for advanced price finding mechanisms:&#xD;
67
+ &lt;ul&gt;&#xD;
68
+ &lt;li&gt;Price range on parent products&lt;/li&gt;&#xD;
69
+ &lt;li&gt;special price with date range&lt;/li&gt;&#xD;
70
+ &lt;li&gt;Catalog Price Rules (full support, including customer group specific prices)&lt;/li&gt;&#xD;
71
+ &lt;li&gt;Tiered prices&lt;/li&gt;&#xD;
72
+ &lt;li&gt;Group/Bundle prices&lt;/li&gt;&#xD;
73
+ &lt;/ul&gt;&#xD;
74
+ &lt;/li&gt;&#xD;
75
+ &lt;li&gt;Configurable list of attributes to be added into the feed&lt;/li&gt;&#xD;
76
+ &lt;/ul&gt;&#xD;
77
+ Request a Demo&#xD;
78
+ &lt;/div&gt;&#xD;
79
+ &lt;div&gt;&#xD;
80
+ &lt;div class="lpeCElement Rich_Text_2"&gt;&#xD;
81
+ &lt;span&gt;See a live demo and find out how SLI can help you with easy to use site search and merchandising. Discover why others make the switch and use powerful technology that continuously "learns" from past site search activity by tracking visitors' aggregate search queries and click-throughs.&#xA0;&lt;/span&gt;&#xD;
82
+ &lt;/div&gt;&#xD;
83
+ &lt;div&gt;&#xD;
84
+ &lt;p&gt;You can request a demo by clicking on this link:&#xA0;&lt;a href="http://sitesearch.sli-systems.com/Request-Demo.html"&gt;Request a Demo&lt;/a&gt;&#xD;
85
+ &lt;/p&gt;&#xD;
86
+ &lt;/div&gt;&#xD;
87
+ &lt;/div&gt;&#xD;
88
+ &lt;div&gt;&#xD;
89
+ &lt;div class="lpeCElement Rich_Text_1"&gt;&#xD;
90
+ &#xD;
91
+ &lt;span&gt;&#xD;
92
+ &lt;a href="mailto:discovery@sli-systems.com" title="Send us an e-mail"&gt;&#xD;
93
+ &lt;span style="color: rgb(0,0,0);"&gt;Send us an e-mail&lt;/span&gt;&#xD;
94
+ &lt;/a&gt;&#xD;
95
+ &lt;/span&gt;&#xD;
96
+ &#xD;
97
+ &lt;p&gt;&#xD;
98
+ &lt;span&gt;&#xD;
99
+ &lt;span style="color: rgb(0,0,0);"&gt;&#xD;
100
+ &lt;a href="mailto:discovery@sli-systems.com"&gt;discovery@sli-systems.com&lt;/a&gt;&#xD;
101
+ &lt;/span&gt;&#xD;
102
+ &lt;/span&gt;&#xD;
103
+ &lt;/p&gt;&#xD;
104
+ &#xD;
105
+ &lt;span&gt;&#xD;
106
+ &lt;span style="color: rgb(0,0,0);"&gt;Call us&lt;/span&gt;&#xD;
107
+ &lt;/span&gt;&#xD;
108
+ &#xD;
109
+ &lt;/div&gt;&#xD;
110
+ &lt;div&gt;&#xD;
111
+ &lt;p&gt;&#xD;
112
+ &lt;strong&gt;USA -&#xA0;&lt;/strong&gt;Toll Free: (866) 240-2812&lt;/p&gt;&#xD;
113
+ &lt;p&gt;&#xD;
114
+ &lt;strong&gt;United Kingdom -&#xA0;&lt;/strong&gt;&#xD;
115
+ &lt;span&gt;Toll Free: 0800 032 4783&lt;/span&gt;&#xD;
116
+ &lt;/p&gt;&#xD;
117
+ &lt;p&gt;&#xD;
118
+ &lt;strong&gt;Australia -&#xA0;&lt;/strong&gt;Toll Free: 1800 139 190&lt;/p&gt;&#xD;
119
+ &lt;p&gt;&#xD;
120
+ &lt;strong&gt;New Zealand -&#xA0;&lt;/strong&gt;Toll Free: 0800 SLI SYS (0800 754 797)&lt;/p&gt;&#xD;
121
+ Important Notice:&#xD;
122
+ &lt;p&gt;Please be aware that the extension provided here is reduced in functionality. This extension will allow you to replace the Magento Built in Catalog Search with Search hosted by SLI. It will expose the Magento site template URL. However feed creation is limited to determining the number of products that would be in the feed if the full version was used. Please contact us for the full version of LSC.&lt;/p&gt;&#xD;
123
+ &lt;/div&gt;&#xD;
124
+ &lt;/div&gt;</description>
125
+ <notes>first release for Magento Connect</notes>
126
+ <authors><author><name>SLI-Systems</name><user>SLISystems</user><email>support@sli-systems.com</email></author></authors>
127
+ <date>2013-04-05</date>
128
+ <time>01:11:45</time>
129
+ <contents><target name="magelocal"><dir name="SLI"><dir name="Search"><dir name="Block"><dir name="Search"><dir name="Form"><file name="Mini.php" hash="7abb2d4708fae5018a214c3c04c626bf"/></dir><dir name="Js"><file name="Bottom.php" hash="702dd219952b047ba47c4931f3e12344"/><file name="Top.php" hash="be80119d48facedc599fadb7f15738a7"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><dir name="Minigrid"><file name="Js.php" hash="1a9a5a3c880c11f6e99ba53956ec7101"/></dir><file name="Minigrid.php" hash="3f0810444f875bf8502ef79742a314e4"/><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="3ba76026119adb36aed4d1d052eb464c"/></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="75bb23d837ca9d31ff8a73df9b2d72a1"/><file name="Feed.php" hash="35e3ad19541c3126d89e0060fbc02a10"/></dir><dir name="Model"><file name="Cron.php" hash="6ad84c367fed231a29cb255b8d9b7a4c"/><file name="Email.php" hash="701049238dca1a452e67d7bcc0d77f00"/><file name="Feed.php" hash="0f4e8087b212101d8316c3220a8ecb49"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Cron.php" hash="320f7eb3a1be3e309b2ded0bfe0b7c5e"/><file name="Loglevel.php" hash="31b58bfdf479b9de2380f3d741bd3175"/><file name="Minigrid.php" hash="a899cfbc25c573846b735e1170970c99"/></dir><dir name="Source"><file name="Attributes.php" hash="41beacfb8b3da59bf32f635377d57e0c"/><dir name="Minigrid"><file name="Abstract.php" hash="3f65ae2dd959bb8583cfcffb0109cffa"/><file name="Attributes.php" hash="7a97225139a38a4a0576538293980187"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="SearchController.php" hash="44422b8daf76199590dd0d7cbfb4a76c"/></dir><dir name="doc"><file name="changelog.txt" hash="93ac6e72c6dbfb91e3ee2f2c2701d865"/><file name="design.txt" hash="ff939b286de699aed45c6d6ad103cd5c"/><file name="makeTar.txt" hash="b444856b2a42685832bd37715bb4bac1"/></dir><dir name="etc"><file name="adminhtml.xml" hash="868b799465f118e2212bcff9048994bb"/><file name="config.xml" hash="f08fa08bcaff2f2c033b52d2898f826d"/><file name="system.xml" hash="bae33054840aa6302b11fb458981a4f4"/></dir><dir name="sql"><dir name="sli_search_setup"><file name="install-1.0.0.php" hash="fd2393d9d3c3e104f0ab09a1e626dace"/></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=""/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SLI_Search.xml" hash=""/></dir></target><target name="mage"><dir name="shell"><dir name="sli"><file name="feed.php" hash=""/></dir></dir></target></contents>
130
+ <compatible/>
131
+ <dependencies><required><php><min>5.3.19</min><max>5.5.0</max></php></required></dependencies>
132
+ </package>
shell/sli/feed.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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();