Doofinder_Feed - Version 1.8.11

Version Notes

Code standards.

Download this release

Release Info

Developer Carlos Escribano Rey
Extension Doofinder_Feed
Version 1.8.11
Comparing to
See all releases


Code changes from version 1.8.10 to 1.8.11

Files changed (65) hide show
  1. app/code/community/Doofinder/Feed/Block/Adminhtml/Log/View.php +44 -27
  2. app/code/community/Doofinder/Feed/Block/Adminhtml/Map/Additional.php +37 -24
  3. app/code/community/Doofinder/Feed/Block/Integration.php +8 -4
  4. app/code/community/Doofinder/Feed/Block/Settings/Buttons/Generate.php +6 -2
  5. app/code/community/Doofinder/Feed/Block/Settings/Buttons/ViewLog.php +3 -2
  6. app/code/community/Doofinder/Feed/Block/Settings/Locks.php +10 -7
  7. app/code/community/Doofinder/Feed/Block/Settings/Panel/AtomicUpdates.php +15 -4
  8. app/code/community/Doofinder/Feed/Block/Settings/Panel/Crondescription.php +6 -2
  9. app/code/community/Doofinder/Feed/Block/Settings/Panel/Datetime.php +10 -5
  10. app/code/community/Doofinder/Feed/Block/Settings/Panel/Description.php +7 -8
  11. app/code/community/Doofinder/Feed/Block/Settings/Panel/DynamicFeedUrl.php +7 -3
  12. app/code/community/Doofinder/Feed/Block/Settings/Panel/File.php +35 -14
  13. app/code/community/Doofinder/Feed/Block/Settings/Panel/Hashdescription.php +4 -2
  14. app/code/community/Doofinder/Feed/Block/Settings/Panel/Layerdescription.php +5 -3
  15. app/code/community/Doofinder/Feed/Block/Settings/Panel/Message.php +7 -5
  16. app/code/community/Doofinder/Feed/Helper/Data.php +53 -59
  17. app/code/community/Doofinder/Feed/Helper/Log.php +10 -10
  18. app/code/community/Doofinder/Feed/Helper/Search.php +11 -6
  19. app/code/community/Doofinder/Feed/Helper/Tax.php +2 -1
  20. app/code/community/Doofinder/Feed/Model/Adminhtml/System/Config/Backend/Cron.php +9 -10
  21. app/code/community/Doofinder/Feed/Model/Adminhtml/System/Config/Validation/Hashid.php +10 -4
  22. app/code/community/Doofinder/Feed/Model/CatalogSearch/Resource/Fulltext.php +30 -20
  23. app/code/community/Doofinder/Feed/Model/Config.php +27 -74
  24. app/code/community/Doofinder/Feed/Model/Cron.php +9 -6
  25. app/code/community/Doofinder/Feed/Model/Generator.php +149 -150
  26. app/code/community/Doofinder/Feed/Model/Log.php +5 -4
  27. app/code/community/Doofinder/Feed/Model/Map/Product/Abstract.php +66 -134
  28. app/code/community/Doofinder/Feed/Model/Map/Product/Associated.php +17 -25
  29. app/code/community/Doofinder/Feed/Model/Map/Product/Bundle.php +15 -13
  30. app/code/community/Doofinder/Feed/Model/Map/Product/Configurable.php +32 -36
  31. app/code/community/Doofinder/Feed/Model/Map/Product/Downloadable.php +6 -3
  32. app/code/community/Doofinder/Feed/Model/Map/Product/Grouped.php +7 -9
  33. app/code/community/Doofinder/Feed/Model/Map/Product/Simple.php +6 -3
  34. app/code/community/Doofinder/Feed/Model/Map/Product/Virtual.php +6 -3
  35. app/code/community/Doofinder/Feed/Model/Mysql4/Cron.php +7 -5
  36. app/code/community/Doofinder/Feed/Model/Mysql4/Cron/Collection.php +5 -3
  37. app/code/community/Doofinder/Feed/Model/Mysql4/Log.php +7 -5
  38. app/code/community/Doofinder/Feed/Model/Mysql4/Log/Collection.php +3 -2
  39. app/code/community/Doofinder/Feed/Model/Observers/Feed.php +150 -71
  40. app/code/community/Doofinder/Feed/Model/Observers/Logs.php +9 -3
  41. app/code/community/Doofinder/Feed/Model/Observers/Schedule.php +63 -35
  42. app/code/community/Doofinder/Feed/Model/Resource/Mysql4/Setup.php +5 -4
  43. app/code/community/Doofinder/Feed/Model/System/Config/Backend/Map/Additional.php +3 -2
  44. app/code/community/Doofinder/Feed/Model/System/Config/Backend/Password.php +7 -4
  45. app/code/community/Doofinder/Feed/Model/System/Config/Backend/Total/Limit.php +3 -3
  46. app/code/community/Doofinder/Feed/Model/System/Config/Reset.php +1 -1
  47. app/code/community/Doofinder/Feed/Model/System/Config/Source/Feed/Pricetaxmode.php +6 -6
  48. app/code/community/Doofinder/Feed/Model/System/Config/Source/Product/Attributes.php +1 -1
  49. app/code/community/Doofinder/Feed/Model/Tools.php +219 -119
  50. app/code/community/Doofinder/Feed/Test/Controller/Index.php +0 -4
  51. app/code/community/Doofinder/Feed/Test/Controller/Index/fixtures/testFeed.yaml +0 -3
  52. app/code/community/Doofinder/Feed/Test/Controller/Index/providers/testFeed.yaml +0 -1
  53. app/code/community/Doofinder/Feed/Test/Model/Product.php +8 -18
  54. app/code/community/Doofinder/Feed/controllers/DoofinderFeedFeedController.php +12 -3
  55. app/code/community/Doofinder/Feed/controllers/DoofinderFeedLogController.php +9 -1
  56. app/code/community/Doofinder/Feed/controllers/FeedController.php +33 -102
  57. app/code/community/Doofinder/Feed/controllers/IndexController.php +9 -3
  58. app/code/community/Doofinder/Feed/etc/config.xml +1 -1
  59. app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-install-1.5.4.php +104 -41
  60. app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-install-1.5.7.php +172 -101
  61. app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-upgrade-1.5.4-1.5.5.php +6 -9
  62. app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-upgrade-1.5.5-1.5.6.php +72 -48
  63. app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-upgrade-1.5.6-1.5.7.php +2 -0
  64. package.xml +5 -5
  65. skin/adminhtml/default/default/doofinder/styles.css +5 -5
app/code/community/Doofinder/Feed/Block/Adminhtml/Log/View.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Adminhtml_Log_View extends Mage_Adminhtml_Block_Widget_Grid
@@ -28,7 +28,9 @@ class Doofinder_Feed_Block_Adminhtml_Log_View extends Mage_Adminhtml_Block_Widge
28
  $collection = Mage::getResourceModel('doofinder_feed/log_collection');
29
 
30
  if ($this->_processId) {
 
31
  $collection->getSelect()->where("process_id = $this->_processId");
 
32
  }
33
 
34
  $this->setCollection($collection);
@@ -38,38 +40,53 @@ class Doofinder_Feed_Block_Adminhtml_Log_View extends Mage_Adminhtml_Block_Widge
38
 
39
  protected function _prepareColumns()
40
  {
41
- $this->addColumn('id', array(
42
- 'header' => Mage::helper('doofinder_feed')->__('ID'),
43
- 'index' => 'id',
44
- 'type' => 'number',
45
- ));
 
 
 
46
 
47
  if (!$this->_processId) {
48
- $this->addColumn('process_id', array(
49
- 'header' => Mage::helper('doofinder_feed')->__('Process ID'),
50
- 'index' => 'process_id',
51
- 'type' => 'number',
52
- ));
 
 
 
53
  }
54
 
55
- $this->addColumn('time', array(
56
- 'header' => Mage::helper('doofinder_feed')->__('Time'),
57
- 'index' => 'time',
58
- 'type' => 'datetime',
59
- ));
 
 
 
60
 
61
- $this->addColumn('type', array(
62
- 'header' => Mage::helper('doofinder_feed')->__('Type'),
63
- 'index' => 'type',
64
- 'type' => 'options',
65
- 'options' => Mage::helper('doofinder_feed/log')->listLogTypes(),
66
- ));
 
 
 
67
 
68
- $this->addColumn('message', array(
69
- 'header' => Mage::helper('doofinder_feed')->__('Message'),
70
- 'index' => 'message',
71
- 'type' => 'text',
72
- ));
 
 
 
73
 
74
  return parent::_prepareColumns();
75
  }
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Adminhtml_Log_View extends Mage_Adminhtml_Block_Widget_Grid
28
  $collection = Mage::getResourceModel('doofinder_feed/log_collection');
29
 
30
  if ($this->_processId) {
31
+ // @codingStandardsIgnoreStart
32
  $collection->getSelect()->where("process_id = $this->_processId");
33
+ // @codingStandardsIgnoreEnd
34
  }
35
 
36
  $this->setCollection($collection);
40
 
41
  protected function _prepareColumns()
42
  {
43
+ $this->addColumn(
44
+ 'id',
45
+ array(
46
+ 'header' => Mage::helper('doofinder_feed')->__('ID'),
47
+ 'index' => 'id',
48
+ 'type' => 'number',
49
+ )
50
+ );
51
 
52
  if (!$this->_processId) {
53
+ $this->addColumn(
54
+ 'process_id',
55
+ array(
56
+ 'header' => Mage::helper('doofinder_feed')->__('Process ID'),
57
+ 'index' => 'process_id',
58
+ 'type' => 'number',
59
+ )
60
+ );
61
  }
62
 
63
+ $this->addColumn(
64
+ 'time',
65
+ array(
66
+ 'header' => Mage::helper('doofinder_feed')->__('Time'),
67
+ 'index' => 'time',
68
+ 'type' => 'datetime',
69
+ )
70
+ );
71
 
72
+ $this->addColumn(
73
+ 'type',
74
+ array(
75
+ 'header' => Mage::helper('doofinder_feed')->__('Type'),
76
+ 'index' => 'type',
77
+ 'type' => 'options',
78
+ 'options' => Mage::helper('doofinder_feed/log')->listLogTypes(),
79
+ )
80
+ );
81
 
82
+ $this->addColumn(
83
+ 'message',
84
+ array(
85
+ 'header' => Mage::helper('doofinder_feed')->__('Message'),
86
+ 'index' => 'message',
87
+ 'type' => 'text',
88
+ )
89
+ );
90
 
91
  return parent::_prepareColumns();
92
  }
app/code/community/Doofinder/Feed/Block/Adminhtml/Map/Additional.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -32,13 +32,14 @@ class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block
32
 
33
  $html .= '<table>';
34
  $html .= '<thead><tr>';
35
- $html .= '<th>' . $this->__('Label') . '</th><th>' . $this->__('Field') . '</th><th>' . $this->__('Attribute') . '</th>';
 
36
  $html .= '</tr></thead>';
37
  $html .= '<tbody id="doofinder_feed_additional_mapping_container">';
38
 
39
  $count = 0;
40
  if ($this->_getValue('additional_mapping')) {
41
- foreach ($this->_getValue('additional_mapping') as $i => $f) {
42
  $html .= $this->_getRowTemplateHtml($count++);
43
  }
44
  }
@@ -46,23 +47,25 @@ class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block
46
  $html .= '</tbody></table>';
47
  $html .= $this->_getAddRowButtonHtml();
48
 
49
- $html .= '<script type="text/javascript">';
50
- ob_start();
51
- ?>
52
- var DoofinderFeedMapAdditionalRowGenerator = function() {
53
- this.count = <?php print $count; ?>;
54
- };
55
-
56
- DoofinderFeedMapAdditionalRowGenerator.prototype.add = function() {
57
- var html = $('doofinder_feed_additional_mapping_template').innerHTML;
58
- html = html.replace(/\[additional_mapping\]\[-1\]/g, '[additional_mapping][' + (this.count++) + ']');
59
- Element.insert($('doofinder_feed_additional_mapping_container'), {bottom: html});
60
- };
61
-
62
- var doofinderFeedMapAdditionalRowGenerator = new DoofinderFeedMapAdditionalRowGenerator();
63
- <?php
64
- $html .= ob_get_clean();
65
- $html .= '</script>';
 
 
66
 
67
  return $html;
68
  }
@@ -88,11 +91,17 @@ class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block
88
  . $this->getElement()->getName() . '[additional_mapping][' . $rowIndex . '][field]" value="'
89
  . $value['field'] . '" ' . $this->_getDisabled() . '/> ';
90
  $html .= '</td><td>';
91
- $html .= '<select name="'
92
- . $this->getElement()->getName() . '[additional_mapping][' . $rowIndex . '][attribute]" ' . $this->_getDisabled() . '>';
93
- foreach (Mage::getSingleton('doofinder_feed/system_config_source_product_attributes')->toOptionArray() as $key => $label) {
94
- $html .= '<option value="' . $key . '"'. ($value['attribute'] == $key ? 'selected="selected"' : '') . '>' . $label . '</option>';
 
 
 
 
 
95
  }
 
96
  $html .= '</select> ';
97
  $html .= '</td><td>';
98
  $html .= $this->_getRemoveRowButtonHtml();
@@ -136,13 +145,16 @@ class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block
136
  ->setDisabled($this->_getDisabled())
137
  ->toHtml();
138
  }
 
139
  return $this->_addRowButtonHtml[$container];
140
  }
141
 
142
  protected function _getRemoveRowButtonHtml()
143
  {
144
  if (!$this->_removeRowButtonHtml) {
 
145
  $_cssClass = 'delete v-middle';
 
146
 
147
  if (version_compare(Mage::getVersion(), '1.6', '<')) {
148
  $_cssClass .= ' ' . $this->_getDisabled();
@@ -156,6 +168,7 @@ class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block
156
  ->setDisabled($this->_getDisabled())
157
  ->toHtml();
158
  }
 
159
  return $this->_removeRowButtonHtml;
160
  }
161
  }
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block_System_Config_Form_Field
32
 
33
  $html .= '<table>';
34
  $html .= '<thead><tr>';
35
+ $html .= '<th>' . $this->__('Label') . '</th>';
36
+ $html .= '<th>' . $this->__('Field') . '</th><th>' . $this->__('Attribute') . '</th>';
37
  $html .= '</tr></thead>';
38
  $html .= '<tbody id="doofinder_feed_additional_mapping_container">';
39
 
40
  $count = 0;
41
  if ($this->_getValue('additional_mapping')) {
42
+ for ($i = count($this->_getValue('additional_mapping')); $i > 0; $i--) {
43
  $html .= $this->_getRowTemplateHtml($count++);
44
  }
45
  }
47
  $html .= '</tbody></table>';
48
  $html .= $this->_getAddRowButtonHtml();
49
 
50
+ $html .= "<script type=\"text/javascript\">
51
+ var DoofinderFeedMapAdditionalRowGenerator = function() {
52
+ this.count = $count;
53
+ };
54
+
55
+ DoofinderFeedMapAdditionalRowGenerator.prototype.add = function() {
56
+ var html = $('doofinder_feed_additional_mapping_template').innerHTML;
57
+ html = html.replace(
58
+ /\[additional_mapping\]\[-1\]/g,
59
+ '[additional_mapping][' + (this.count++) + ']'
60
+ );
61
+ Element.insert(
62
+ $('doofinder_feed_additional_mapping_container'),
63
+ {bottom: html}
64
+ );
65
+ };
66
+
67
+ var doofinderFeedMapAdditionalRowGenerator = new DoofinderFeedMapAdditionalRowGenerator();
68
+ </script>";
69
 
70
  return $html;
71
  }
91
  . $this->getElement()->getName() . '[additional_mapping][' . $rowIndex . '][field]" value="'
92
  . $value['field'] . '" ' . $this->_getDisabled() . '/> ';
93
  $html .= '</td><td>';
94
+ $html .= '<select name="' . $this->getElement()->getName();
95
+ $html .= '[additional_mapping][' . $rowIndex . '][attribute]" ';
96
+ $html .= $this->_getDisabled() . '>';
97
+
98
+ $attributes = Mage::getSingleton('doofinder_feed/system_config_source_product_attributes');
99
+ foreach ($attributes->toOptionArray() as $key => $label) {
100
+ $html .= '<option value="' . $key . '"';
101
+ $html .= ($value['attribute'] == $key ? 'selected="selected"' : '');
102
+ $html .= '>' . $label . '</option>';
103
  }
104
+
105
  $html .= '</select> ';
106
  $html .= '</td><td>';
107
  $html .= $this->_getRemoveRowButtonHtml();
145
  ->setDisabled($this->_getDisabled())
146
  ->toHtml();
147
  }
148
+
149
  return $this->_addRowButtonHtml[$container];
150
  }
151
 
152
  protected function _getRemoveRowButtonHtml()
153
  {
154
  if (!$this->_removeRowButtonHtml) {
155
+ // @codingStandardsIgnoreStart
156
  $_cssClass = 'delete v-middle';
157
+ // @codingStandardsIgnoreEnd
158
 
159
  if (version_compare(Mage::getVersion(), '1.6', '<')) {
160
  $_cssClass .= ' ' . $this->_getDisabled();
168
  ->setDisabled($this->_getDisabled())
169
  ->toHtml();
170
  }
171
+
172
  return $this->_removeRowButtonHtml;
173
  }
174
  }
app/code/community/Doofinder/Feed/Block/Integration.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Integration extends Mage_Core_Block_Abstract
@@ -22,9 +22,13 @@ class Doofinder_Feed_Block_Integration extends Mage_Core_Block_Abstract
22
  $script = Mage::getStoreConfig('doofinder_search/layer_settings/script', Mage::app()->getStore());
23
 
24
  if ($enabled) {
25
- $script .= '<script type="text/javascript">';
26
- $script .= "if (typeof Varien.searchForm !== 'undefined') Varien.searchForm.prototype.initAutocomplete = function() { $('search_autocomplete').hide(); };";
27
- $script .= '</script>';
 
 
 
 
28
 
29
  return $script;
30
  } else {
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Integration extends Mage_Core_Block_Abstract
22
  $script = Mage::getStoreConfig('doofinder_search/layer_settings/script', Mage::app()->getStore());
23
 
24
  if ($enabled) {
25
+ $script .= "<script type=\"text/javascript\">
26
+ if (typeof Varien.searchForm !== 'undefined') {
27
+ Varien.searchForm.prototype.initAutocomplete = function() {
28
+ $('search_autocomplete').hide();
29
+ };
30
+ }
31
+ </script>";
32
 
33
  return $script;
34
  } else {
app/code/community/Doofinder/Feed/Block/Settings/Buttons/Generate.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Buttons_Generate extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -35,7 +35,11 @@ class Doofinder_Feed_Block_Settings_Buttons_Generate extends Mage_Adminhtml_Bloc
35
  ->setType('button')
36
  ->setClass('generate-feed')
37
  ->setLabel('Start Feed Generation Now')
38
- ->setOnClick("confirm('No changes will be saved, feed will be rescheduled (if there\'s a process running it will be stopped and the feed will be reset). Do you want to proceed?') && generateFeed()")
 
 
 
 
39
  ->setAfterHtml($script)
40
  ->toHtml();
41
  return $html;
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Buttons_Generate extends Mage_Adminhtml_Block_System_Config_Form_Field
35
  ->setType('button')
36
  ->setClass('generate-feed')
37
  ->setLabel('Start Feed Generation Now')
38
+ ->setOnClick(
39
+ "confirm('No changes will be saved, feed will be rescheduled " .
40
+ "(if there\'s a process running it will be stopped and the feed " .
41
+ "will be reset). Do you want to proceed?') && generateFeed()"
42
+ )
43
  ->setAfterHtml($script)
44
  ->toHtml();
45
  return $html;
app/code/community/Doofinder/Feed/Block/Settings/Buttons/ViewLog.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Buttons_ViewLog extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -17,7 +17,8 @@ class Doofinder_Feed_Block_Settings_Buttons_ViewLog extends Mage_Adminhtml_Block
17
  $this->setElement($element);
18
  $element->setScopeLabel('');
19
 
20
- $process = Mage::getModel('doofinder_feed/cron')->load(Mage::app()->getRequest()->getParam('store'), 'store_code');
 
21
 
22
  $url = Mage::helper("adminhtml")->getUrl('adminhtml/doofinderFeedLog/view/processId/' . $process->getId());
23
 
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Buttons_ViewLog extends Mage_Adminhtml_Block_System_Config_Form_Field
17
  $this->setElement($element);
18
  $element->setScopeLabel('');
19
 
20
+ $store = Mage::app()->getRequest()->getParam('store');
21
+ $process = Mage::getModel('doofinder_feed/cron')->load($store, 'store_code');
22
 
23
  $url = Mage::helper("adminhtml")->getUrl('adminhtml/doofinderFeedLog/view/processId/' . $process->getId());
24
 
app/code/community/Doofinder/Feed/Block/Settings/Locks.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Locks extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -22,15 +22,14 @@ class Doofinder_Feed_Block_Settings_Locks extends Mage_Adminhtml_Block_System_Co
22
  $helper = Mage::helper('doofinder_feed');
23
 
24
  $this->setElement($element);
25
- $name = $element->getName();
26
  $element->setScopeLabel('');
27
 
28
- $store_code = Mage::app()->getRequest()->getParam('store');
29
 
30
  $stores = array();
31
 
32
- if ($store_code) {
33
- $stores[$store_code] = Mage::getModel('core/store')->load($store_code);
34
  } else {
35
  foreach (Mage::app()->getStores() as $store) {
36
  if ($store->getIsActive()) {
@@ -42,12 +41,15 @@ class Doofinder_Feed_Block_Settings_Locks extends Mage_Adminhtml_Block_System_Co
42
  $locks = array();
43
 
44
  foreach ($stores as $store) {
45
- if (file_exists($helper->getFeedLockPath($store->getCode()))) {
46
  $msg = $this->getLayout()->createBlock('adminhtml/widget_button')
47
  ->setType('button')
48
  ->setClass('remove-lock')
49
  ->setLabel($helper->__('Remove lock'))
50
- ->setOnClick("confirm('Removing lock file may cause inconsistencies in generated feed. Proceed?') && removeFeedLock('" . $store->getCode() . "')")
 
 
 
51
  ->toHtml();
52
  } else {
53
  $msg = $helper->__('Lock file for store <em>%s</em> does not exist.', $store->getCode());
@@ -63,6 +65,7 @@ class Doofinder_Feed_Block_Settings_Locks extends Mage_Adminhtml_Block_System_Co
63
  foreach ($locks as $code => $file) {
64
  $html .= '<li><b>' . $stores[$code]->getName() . ':</b><div>' . $file . '</div></li>';
65
  }
 
66
  $html .= '</ul>';
67
  } else {
68
  $html .= reset($locks);
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Locks extends Mage_Adminhtml_Block_System_Config_Form_Field
22
  $helper = Mage::helper('doofinder_feed');
23
 
24
  $this->setElement($element);
 
25
  $element->setScopeLabel('');
26
 
27
+ $storeCode = Mage::app()->getRequest()->getParam('store');
28
 
29
  $stores = array();
30
 
31
+ if ($storeCode) {
32
+ $stores[$storeCode] = Mage::getModel('core/store')->load($storeCode);
33
  } else {
34
  foreach (Mage::app()->getStores() as $store) {
35
  if ($store->getIsActive()) {
41
  $locks = array();
42
 
43
  foreach ($stores as $store) {
44
+ if ((new Varien_Io_File())->fileExists($helper->getFeedLockPath($store->getCode()))) {
45
  $msg = $this->getLayout()->createBlock('adminhtml/widget_button')
46
  ->setType('button')
47
  ->setClass('remove-lock')
48
  ->setLabel($helper->__('Remove lock'))
49
+ ->setOnClick(
50
+ 'confirm(\'Removing lock file may cause inconsistencies in generated feed. Proceed?\') ' .
51
+ ' && removeFeedLock(\'' . $store->getCode() . '\')'
52
+ )
53
  ->toHtml();
54
  } else {
55
  $msg = $helper->__('Lock file for store <em>%s</em> does not exist.', $store->getCode());
65
  foreach ($locks as $code => $file) {
66
  $html .= '<li><b>' . $stores[$code]->getName() . ':</b><div>' . $file . '</div></li>';
67
  }
68
+
69
  $html .= '</ul>';
70
  } else {
71
  $html .= reset($locks);
app/code/community/Doofinder/Feed/Block/Settings/Panel/AtomicUpdates.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_AtomicUpdates extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -22,13 +22,23 @@ class Doofinder_Feed_Block_Settings_Panel_AtomicUpdates extends Mage_Adminhtml_B
22
  $messages = array();
23
  foreach (Mage::app()->getStores() as $store) {
24
  if ($store->getIsActive()) {
25
- $engineEnabled = Mage::getStoreConfig('doofinder_search/internal_settings/enable', $store->getCode());
26
- $atomicUpdatesEnabled = Mage::getStoreConfig('doofinder_cron/feed_settings/atomic_updates_enabled', $store->getCode());
 
 
 
 
 
 
27
 
28
  if (!$engineEnabled || !$atomicUpdatesEnabled) {
29
  $message = $helper->__('Atomic updates are <strong>disabled</strong>.');
30
  } else {
31
- $message = $helper->__('Atomic updates are <strong>enabled</strong>. Your products will be automatically indexed when they are created, updated or deleted.');
 
 
 
 
32
  }
33
 
34
  $messages[$store->getName()] = $message;
@@ -43,6 +53,7 @@ class Doofinder_Feed_Block_Settings_Panel_AtomicUpdates extends Mage_Adminhtml_B
43
  foreach ($messages as $name => $message) {
44
  $html .= '<li><strong>' . $name . ':</strong><p>' . $message . '</p></li>';
45
  }
 
46
  $html .= '</ul>';
47
 
48
  return $html;
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_AtomicUpdates extends Mage_Adminhtml_Block_System_Config_Form_Field
22
  $messages = array();
23
  foreach (Mage::app()->getStores() as $store) {
24
  if ($store->getIsActive()) {
25
+ $engineEnabled = Mage::getStoreConfig(
26
+ 'doofinder_search/internal_settings/enable',
27
+ $store->getCode()
28
+ );
29
+ $atomicUpdatesEnabled = Mage::getStoreConfig(
30
+ 'doofinder_cron/feed_settings/atomic_updates_enabled',
31
+ $store->getCode()
32
+ );
33
 
34
  if (!$engineEnabled || !$atomicUpdatesEnabled) {
35
  $message = $helper->__('Atomic updates are <strong>disabled</strong>.');
36
  } else {
37
+ $message = $helper->__(
38
+ 'Atomic updates are <strong>enabled</strong>. ' .
39
+ 'Your products will be automatically indexed when ' .
40
+ 'they are created, updated or deleted.'
41
+ );
42
  }
43
 
44
  $messages[$store->getName()] = $message;
53
  foreach ($messages as $name => $message) {
54
  $html .= '<li><strong>' . $name . ':</strong><p>' . $message . '</p></li>';
55
  }
56
+
57
  $html .= '</ul>';
58
 
59
  return $html;
app/code/community/Doofinder/Feed/Block/Settings/Panel/Crondescription.php CHANGED
@@ -6,10 +6,14 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_CronDescription extends Doofinder_Feed_Block_Settings_Panel_Description
13
  {
14
- protected $description = 'THIS FEATURE IS CURRENTLY IN BETA.<br>Feeds can be generated directly in your server to save computer resources. See <a href="http://www.doofinder.com/support/topics/plugins/magento">this article</a> for more information.';
 
 
 
 
15
  }
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_CronDescription extends Doofinder_Feed_Block_Settings_Panel_Description
13
  {
14
+ protected $_description = 'THIS FEATURE IS CURRENTLY IN BETA.<br>' .
15
+ 'Feeds can be generated directly in your ' .
16
+ 'server to save computer resources. ' .
17
+ 'See <a href="http://www.doofinder.com/support/topics/plugins/magento">' .
18
+ 'this article</a> for more information.';
19
  }
app/code/community/Doofinder/Feed/Block/Settings/Panel/Datetime.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Datetime extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -25,18 +25,23 @@ class Doofinder_Feed_Block_Settings_Panel_Datetime extends Mage_Adminhtml_Block_
25
  $msg = $datetime;
26
 
27
  try {
28
- $dateTimestamp = Mage::getModel('core/date')->timestamp(strtotime($datetime));
29
- $msg = Mage::helper('core')->formatDate(date('Y-m-d H:i:s', $dateTimestamp), null, true);
30
- } catch (Exception $e) {}
 
 
 
 
31
 
32
  $class = 'feed-datetime';
33
  $html = "<p class='{$class}'>{$msg}</p>";
34
  }
35
  }
 
36
  return $html;
37
  }
38
 
39
- private function _getField($name = null)
40
  {
41
  $pattern = '/groups\[panel\]\[fields\]\[([a-z_-]*)\]\[value\]/';
42
  $preg = preg_match($pattern, $name, $match);
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Datetime extends Mage_Adminhtml_Block_System_Config_Form_Field
25
  $msg = $datetime;
26
 
27
  try {
28
+ // @codingStandardsIgnoreStart
29
+ $date = Mage::getSingleton('core/date')->date(null, $datetime);
30
+ // @codingStandardsIgnoreEnd
31
+ $msg = Mage::helper('core')->formatDate($date, null, true);
32
+ } catch (Exception $e) {
33
+ Mage::logException($e);
34
+ }
35
 
36
  $class = 'feed-datetime';
37
  $html = "<p class='{$class}'>{$msg}</p>";
38
  }
39
  }
40
+
41
  return $html;
42
  }
43
 
44
+ protected function _getField($name = null)
45
  {
46
  $pattern = '/groups\[panel\]\[fields\]\[([a-z_-]*)\]\[value\]/';
47
  $preg = preg_match($pattern, $name, $match);
app/code/community/Doofinder/Feed/Block/Settings/Panel/Description.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Description extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -14,23 +14,22 @@ class Doofinder_Feed_Block_Settings_Panel_Description extends Mage_Adminhtml_Blo
14
  const INFO = 'info';
15
  const WARNING = 'warning';
16
 
17
- protected $level = self::INFO;
18
- protected $description = 'You can set the rest of the options for each store separately by modifying the Current Configuration Scope.';
 
19
 
20
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
21
  {
22
  $text = '';
23
 
24
- if (!Mage::app()->getRequest()->getParam('store'))
25
- {
26
- $text = $this->description;
27
  }
28
 
29
  $this->setElement($element);
30
- $name = $element->getName();
31
  $element->setScopeLabel('');
32
 
33
- return '<p class="doofinder-' . $this->level . '">' . $text . '</p>';
34
  }
35
 
36
  public function render(Varien_Data_Form_Element_Abstract $element)
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Description extends Mage_Adminhtml_Block_System_Config_Form_Field
14
  const INFO = 'info';
15
  const WARNING = 'warning';
16
 
17
+ protected $_level = self::INFO;
18
+ protected $_description = 'You can set the rest of the options for each store ' .
19
+ 'separately by modifying the Current Configuration Scope.';
20
 
21
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
22
  {
23
  $text = '';
24
 
25
+ if (!Mage::app()->getRequest()->getParam('store')) {
26
+ $text = $this->_description;
 
27
  }
28
 
29
  $this->setElement($element);
 
30
  $element->setScopeLabel('');
31
 
32
+ return '<p class="doofinder-' . $this->_level . '">' . $text . '</p>';
33
  }
34
 
35
  public function render(Varien_Data_Form_Element_Abstract $element)
app/code/community/Doofinder/Feed/Block/Settings/Panel/DynamicFeedUrl.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_DynamicFeedUrl extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -16,7 +16,6 @@ class Doofinder_Feed_Block_Settings_Panel_DynamicFeedUrl extends Mage_Adminhtml_
16
  $helper = Mage::helper('doofinder_feed');
17
 
18
  $this->setElement($element);
19
- $name = $element->getName();
20
  $element->setScopeLabel('');
21
 
22
  $html = '<ul>';
@@ -34,9 +33,14 @@ class Doofinder_Feed_Block_Settings_Panel_DynamicFeedUrl extends Mage_Adminhtml_
34
  $html .= '<li><strong>' . $store->getName() . ':</strong><p>' . $anchor . '</p></li>';
35
  }
36
  }
 
37
  $html .= '</ul>';
38
  $html .= '<p>';
39
- $html .= $helper->__('If cron feed doesn\'t work for you, use these URLs to dynamically index your content from Doofinder. Contact support if you need help.');
 
 
 
 
40
  $html .= '</p>';
41
 
42
  return $html;
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_DynamicFeedUrl extends Mage_Adminhtml_Block_System_Config_Form_Field
16
  $helper = Mage::helper('doofinder_feed');
17
 
18
  $this->setElement($element);
 
19
  $element->setScopeLabel('');
20
 
21
  $html = '<ul>';
33
  $html .= '<li><strong>' . $store->getName() . ':</strong><p>' . $anchor . '</p></li>';
34
  }
35
  }
36
+
37
  $html .= '</ul>';
38
  $html .= '<p>';
39
+ $html .= $helper->__(
40
+ 'If cron feed doesn\'t work for you, use these URLs to ' .
41
+ 'dynamically index your content from Doofinder. ' .
42
+ 'Contact support if you need help.'
43
+ );
44
  $html .= '</p>';
45
 
46
  return $html;
app/code/community/Doofinder/Feed/Block/Settings/Panel/File.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -24,29 +24,43 @@ class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_Syst
24
  {
25
  $lastSchedule = Mage::getModel('cron/schedule')->getCollection()
26
  ->setOrder('finished_at', 'desc')
27
- ->getFirstItem();
 
 
 
 
28
 
29
  $message = '';
30
- if ($lastSchedule && count($lastSchedule->getData()) > 0) {
31
  $scheduleTime = strtotime($lastSchedule->getFinishedAt());
32
- $currentTime = time();
33
 
34
  // Difference in seconds
35
  $dif = ($currentTime - $scheduleTime);
36
 
37
  // If difference is bigger than allowed, display message
38
  if ($dif > self::ALLOWED_TIME) {
39
-
40
- $message = sprintf('Cron was run for the last time at %s. Taking into account the settings of the step delay option, there might be problems with the cron\'s configuration.', $lastSchedule->getFinishedAt());
 
 
 
 
41
  Mage::helper('doofinder_feed')->__($message);
42
  }
43
  } else {
44
- $message = Mage::helper('doofinder_feed')->__('There are no registered cron tasks. Please, check your system\'s crontab configuration.');
 
 
 
45
  }
46
 
47
  return '<p class="error">' . $message . '</p>';
48
  }
49
 
 
 
 
50
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
51
  {
52
  $helper = Mage::helper('doofinder_feed');
@@ -54,12 +68,12 @@ class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_Syst
54
  $this->setElement($element);
55
  $name = $element->getName();
56
  $element->setScopeLabel('');
57
- $store_code = Mage::app()->getRequest()->getParam('store');
58
 
59
  $stores = array();
60
 
61
- if ($store_code) {
62
- $stores[$store_code] = Mage::getModel('core/store')->load($store_code);
63
  } else {
64
  foreach (Mage::app()->getStores() as $store) {
65
  if ($store->getIsActive()) {
@@ -76,24 +90,30 @@ class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_Syst
76
  $message = $helper->__('Cron-based feed generation is <strong>disabled</strong>.');
77
  } else {
78
  $enabled = true;
 
79
  $process = Mage::getModel('doofinder_feed/cron')->load($store->getCode(), 'store_code');
 
80
  $lastGeneratedName = $process->getLastFeedName();
81
 
82
  $fileUrl = Mage::getBaseUrl('media').'doofinder'.DS.$lastGeneratedName;
83
  $fileDir = Mage::getBaseDir('media').DS.'doofinder'.DS.$lastGeneratedName;
84
 
85
- if ($lastGeneratedName && file_exists($fileDir)) {
86
  $message = '<p><a href=' . $fileUrl . ' target="_blank">';
87
- $message .= count($stores) > 1 ? $fileUrl : $helper->__('Get %s', $lastGeneratedName);
88
  $message .= '</a></p>';
89
  } else {
90
  $message = '<p>' . $helper->__('Currently there is no file to preview.') . '</p>';
91
  }
92
 
93
  $time = explode(',', Mage::getStoreConfig('doofinder_cron/schedule_settings/time', $store->getCode()));
94
- $frequency = Mage::getStoreConfig('doofinder_cron/schedule_settings/frequency', $store->getCode());
95
  $message .= '<p>';
96
- $message .= $helper->__('Cron-based feed generation is <strong>enabled</strong>. Feed generation is being scheduled at %s:%s.', $time[0], $time[1]);
 
 
 
 
 
97
  $message .= '</p>';
98
  }
99
 
@@ -114,6 +134,7 @@ class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_Syst
114
  foreach ($messages as $name => $message) {
115
  $html .= '<li><strong>' . $name . ':</strong><p>' . $message . '</p></li>';
116
  }
 
117
  $html .= '</ul>';
118
 
119
  return $html;
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_System_Config_Form_Field
24
  {
25
  $lastSchedule = Mage::getModel('cron/schedule')->getCollection()
26
  ->setOrder('finished_at', 'desc')
27
+ ->setPageSize(1)
28
+ ->getItems();
29
+
30
+ $lastSchedule = $lastSchedule ? current($lastSchedule) : null;
31
+ $lastScheduleData = $lastSchedule ? $lastSchedule->getData() : array();
32
 
33
  $message = '';
34
+ if ($lastSchedule && !empty($lastScheduleData)) {
35
  $scheduleTime = strtotime($lastSchedule->getFinishedAt());
36
+ $currentTime = Mage::getSingleton('core/date')->timestamp();
37
 
38
  // Difference in seconds
39
  $dif = ($currentTime - $scheduleTime);
40
 
41
  // If difference is bigger than allowed, display message
42
  if ($dif > self::ALLOWED_TIME) {
43
+ $message = sprintf(
44
+ 'Cron was run for the last time at %s. ' .
45
+ 'Taking into account the settings of the step delay option, ' .
46
+ 'there might be problems with the cron\'s configuration.',
47
+ $lastSchedule->getFinishedAt()
48
+ );
49
  Mage::helper('doofinder_feed')->__($message);
50
  }
51
  } else {
52
+ $message = Mage::helper('doofinder_feed')->__(
53
+ 'There are no registered cron tasks. ' .
54
+ 'Please, check your system\'s crontab configuration.'
55
+ );
56
  }
57
 
58
  return '<p class="error">' . $message . '</p>';
59
  }
60
 
61
+ /**
62
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
63
+ */
64
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
65
  {
66
  $helper = Mage::helper('doofinder_feed');
68
  $this->setElement($element);
69
  $name = $element->getName();
70
  $element->setScopeLabel('');
71
+ $storeCode = Mage::app()->getRequest()->getParam('store');
72
 
73
  $stores = array();
74
 
75
+ if ($storeCode) {
76
+ $stores[$storeCode] = Mage::getModel('core/store')->load($storeCode);
77
  } else {
78
  foreach (Mage::app()->getStores() as $store) {
79
  if ($store->getIsActive()) {
90
  $message = $helper->__('Cron-based feed generation is <strong>disabled</strong>.');
91
  } else {
92
  $enabled = true;
93
+ // @codingStandardsIgnoreStart
94
  $process = Mage::getModel('doofinder_feed/cron')->load($store->getCode(), 'store_code');
95
+ // @codingStandardsIgnoreEnd
96
  $lastGeneratedName = $process->getLastFeedName();
97
 
98
  $fileUrl = Mage::getBaseUrl('media').'doofinder'.DS.$lastGeneratedName;
99
  $fileDir = Mage::getBaseDir('media').DS.'doofinder'.DS.$lastGeneratedName;
100
 
101
+ if ($lastGeneratedName && (new Varien_Io_File())->fileExists($fileDir)) {
102
  $message = '<p><a href=' . $fileUrl . ' target="_blank">';
103
+ $message .= !empty($stores) ? $fileUrl : $helper->__('Get %s', $lastGeneratedName);
104
  $message .= '</a></p>';
105
  } else {
106
  $message = '<p>' . $helper->__('Currently there is no file to preview.') . '</p>';
107
  }
108
 
109
  $time = explode(',', Mage::getStoreConfig('doofinder_cron/schedule_settings/time', $store->getCode()));
 
110
  $message .= '<p>';
111
+ $message .= $helper->__(
112
+ 'Cron-based feed generation is <strong>enabled</strong>. ' .
113
+ 'Feed generation is being scheduled at %s:%s.',
114
+ $time[0],
115
+ $time[1]
116
+ );
117
  $message .= '</p>';
118
  }
119
 
134
  foreach ($messages as $name => $message) {
135
  $html .= '<li><strong>' . $name . ':</strong><p>' . $message . '</p></li>';
136
  }
137
+
138
  $html .= '</ul>';
139
 
140
  return $html;
app/code/community/Doofinder/Feed/Block/Settings/Panel/Hashdescription.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
  class Doofinder_Feed_Block_Settings_Panel_HashDescription extends Doofinder_Feed_Block_Settings_Panel_Description
3
  {
4
- protected $level = self::WARNING;
5
- protected $description = '<b>IMPORTANT:</b> You must configure a "hashid" for each store view. Use the "Current Configuration Scope" selector at the top left side of the page to choose a store view.';
 
 
6
  }
1
  <?php
2
  class Doofinder_Feed_Block_Settings_Panel_HashDescription extends Doofinder_Feed_Block_Settings_Panel_Description
3
  {
4
+ protected $_level = self::WARNING;
5
+ protected $_description = '<strong>IMPORTANT:</strong> You must configure a "hashid" ' .
6
+ 'for each store view. Use the "Current Configuration Scope" ' .
7
+ 'selector at the top left side of the page to choose a store view.';
8
  }
app/code/community/Doofinder/Feed/Block/Settings/Panel/Layerdescription.php CHANGED
@@ -6,11 +6,13 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_LayerDescription extends Doofinder_Feed_Block_Settings_Panel_Description
13
  {
14
- protected $level = self::WARNING;
15
- protected $description = '<b>IMPORTANT:</b> You must configure a different Layer script for each store view. Use the "Current Configuration Scope" selector at the top left side of the page to choose a store view.';
 
 
16
  }
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_LayerDescription extends Doofinder_Feed_Block_Settings_Panel_Description
13
  {
14
+ protected $_level = self::WARNING;
15
+ protected $_description = '<strong>IMPORTANT:</strong> You must configure a different ' .
16
+ 'Layer script for each store view. Use the "Current Configuration Scope" ' .
17
+ 'selector at the top left side of the page to choose a store view.';
18
  }
app/code/community/Doofinder/Feed/Block/Settings/Panel/Message.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Message extends Mage_Adminhtml_Block_System_Config_Form_Field
@@ -35,13 +35,14 @@ class Doofinder_Feed_Block_Settings_Panel_Message extends Mage_Adminhtml_Block_S
35
  break;
36
 
37
  case 'message':
38
- $msg = Mage::helper('doofinder_feed')->__('Process not created yet, it will be created automatically by cron job');
 
 
39
  break;
40
 
41
  default:
42
  $msg = '';
43
  }
44
-
45
  } else {
46
  $msg = $process->getData($field);
47
  }
@@ -56,11 +57,12 @@ class Doofinder_Feed_Block_Settings_Panel_Message extends Mage_Adminhtml_Block_S
56
 
57
  $html = "<p class='{$class}'>{$msg}</p>";
58
  }
 
59
  return $html;
60
  }
61
 
62
- private function _getField($name = null) {
63
-
64
  $pattern = '/groups\[panel\]\[fields\]\[([a-z_-]*)\]\[value\]/';
65
  $preg = preg_match($pattern, $name, $match);
66
  if ($preg && isset($match[1])) {
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Message extends Mage_Adminhtml_Block_System_Config_Form_Field
35
  break;
36
 
37
  case 'message':
38
+ $msg = Mage::helper('doofinder_feed')->__(
39
+ 'Process not created yet, it will be created automatically by cron job'
40
+ );
41
  break;
42
 
43
  default:
44
  $msg = '';
45
  }
 
46
  } else {
47
  $msg = $process->getData($field);
48
  }
57
 
58
  $html = "<p class='{$class}'>{$msg}</p>";
59
  }
60
+
61
  return $html;
62
  }
63
 
64
+ protected function _getField($name = null)
65
+ {
66
  $pattern = '/groups\[panel\]\[fields\]\[([a-z_-]*)\]\[value\]/';
67
  $preg = preg_match($pattern, $name, $match);
68
  if ($preg && isset($match[1])) {
app/code/community/Doofinder/Feed/Helper/Data.php CHANGED
@@ -6,27 +6,17 @@
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  /**
13
  * Data helper for Doofinder Feed
14
  *
15
- * @version 1.8.10
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
19
  {
20
- private $store = null;
21
-
22
- private $currencyConvert = false;
23
-
24
- private $useMinimalPrice = false;
25
-
26
- private $groupConfigurables = true;
27
-
28
- private $minTierPrice = null;
29
-
30
  const CRON_DAILY = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
31
  const CRON_WEEKLY = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_WEEKLY;
32
  const CRON_MONTHLY = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;
@@ -88,7 +78,8 @@ class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
88
  * @param boolean $withPassword = true
89
  * @return array
90
  */
91
- public function getStoreConfig($storeCode = '', $withPassword = true) {
 
92
  $xmlName = Mage::getStoreConfig('doofinder_cron/schedule_settings/name', $storeCode);
93
  $config = array(
94
  'enabled' => Mage::getStoreConfig('doofinder_cron/schedule_settings/enabled', $storeCode),
@@ -113,7 +104,8 @@ class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
113
  * @param string|boolean $password = true
114
  * @return bool
115
  */
116
- private function _processXmlName($name = 'doofinder-{store_code}.xml', $code = 'default', $password = true) {
 
117
  $pattern = '/\{\s*store_code\s*\}/';
118
 
119
  if ($password === true) {
@@ -121,7 +113,7 @@ class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
121
  }
122
 
123
  $replacement = $code;
124
- if ($password && strlen($password)) {
125
  $replacement .= '-' . $password;
126
  }
127
 
@@ -136,7 +128,8 @@ class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
136
  * @param string $oldPassword
137
  * @param string $newPassword
138
  */
139
- public function changeXmlPassword($storeCode, $oldPassword, $newPassword) {
 
140
  $xmlName = Mage::getStoreConfig('doofinder_cron/schedule_settings/name', $storeCode);
141
  $dir = $this->getFeedDirectory();
142
 
@@ -144,13 +137,16 @@ class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
144
  $newFilename = $this->_processXmlName($xmlName, $storeCode, $newPassword);
145
  $newFilepath = $dir . DS . $newFilename;
146
 
147
- if (file_exists($oldFilepath)) {
148
- if (!file_exists($newFilepath) && !rename($oldFilepath, $newFilepath)) {
149
- throw new \Magento\Framework\Exception\LocalizedException(__(
150
- 'Feed file could not be renamed accordingly to new %s value because file permission issues or file with name %s already exists.',
 
 
151
  $this->getData('field_config/label'),
152
  $newFilename
153
- ));
 
154
  }
155
 
156
  $process = Mage::getModel('doofinder_feed/cron')->load($storeCode, 'store_code');
@@ -162,45 +158,33 @@ class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
162
  }
163
  }
164
 
165
- /**
166
- * Create cron expr string
167
- * @param string $time
168
- * @return mixed
169
- */
170
- private function _getCronExpr($time = null, $frequency = null) {
171
-
172
- if (!$time) return false;
173
- $time = explode(',', $time);
174
-
175
- $cronExprArray = array(
176
- intval($time[1]),
177
- intval($time[0]),
178
- ($frequency == self::CRON_MONTHLY) ? '1' : '*',
179
- '*',
180
- ($frequency == self::CRON_WEEKLY) ? '1' : '*',
181
- );
182
- $cronExprString = join(' ', $cronExprArray);
183
-
184
- return $cronExprString;
185
- }
186
-
187
  /**
188
  * Creates new schedule entry.
189
  * @param Doofinder_Feed_Model_Cron $process
190
  */
191
-
192
- public function createNewSchedule(Doofinder_Feed_Model_Cron $process) {
193
  $helper = Mage::helper('doofinder_feed');
 
194
 
195
  $config = $helper->getStoreConfig($process->getStoreCode());
196
 
197
  // Set new schedule time
198
- $delayInMin = intval($config['stepDelay']);
199
- $timescheduled = strftime("%Y-%m-%d %H:%M:%S", mktime(date("H"), date("i") + $delayInMin, date("s"), date("m"), date("d"), date("Y")));
 
 
 
 
 
 
 
 
 
 
200
 
201
  // Prepare new process data
202
  $status = $helper::STATUS_RUNNING;
203
- $nextRun = '-';
204
 
205
  // Set process data and save
206
  $process->setStatus($status)
@@ -208,14 +192,22 @@ class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
208
  ->setNextIteration($timescheduled)
209
  ->save();
210
 
211
- Mage::helper('doofinder_feed/log')->log($process, Doofinder_Feed_Helper_Log::STATUS, $helper->__('Scheduling the next step for %s', $timescheduled));
 
 
 
 
212
  }
213
 
214
- public function getScheduledAt($time = null, $frequency = null, $timezoneOffset = true) {
215
- $parts = array($time[0], $time[1], $time[2], date('m'), date('d'));
 
 
 
 
216
  $offset = $this->getTimezoneOffset();
217
 
218
- $now = time();
219
  $start = mktime($parts[0] - $offset, $parts[1], $parts[2], $parts[3], $parts[4]);
220
 
221
  if ($start < $now) {
@@ -238,15 +230,20 @@ class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
238
  $parts[0] -= $offset;
239
  }
240
 
241
- return strftime("%Y-%m-%d %H:%M:%S", mktime($parts[0], $parts[1], $parts[2], $parts[3], $parts[4]));
 
 
242
  }
243
 
244
- public function getTimezoneOffset() {
 
245
  $timezone = Mage::getStoreConfig('general/locale/timezone');
246
  $backTimezone = date_default_timezone_get();
247
  // Set relative timezone
248
  date_default_timezone_set($timezone);
249
- $offset = (date('Z') / 60 / 60);
 
 
250
  // Revoke server timezone
251
  date_default_timezone_set($backTimezone);
252
  return $offset;
@@ -303,10 +300,7 @@ class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
303
  public function createFeedDirectory()
304
  {
305
  $dir = $this->getFeedDirectory();
306
-
307
- if ((!file_exists($dir) && !mkdir($dir, 0777, true)) || !is_dir($dir)) {
308
- Mage::throwException('Could not create directory: '.$dir);
309
- }
310
 
311
  return true;
312
  }
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  /**
13
  * Data helper for Doofinder Feed
14
  *
15
+ * @version 1.8.11
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
19
  {
 
 
 
 
 
 
 
 
 
 
20
  const CRON_DAILY = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
21
  const CRON_WEEKLY = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_WEEKLY;
22
  const CRON_MONTHLY = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;
78
  * @param boolean $withPassword = true
79
  * @return array
80
  */
81
+ public function getStoreConfig($storeCode = '', $withPassword = true)
82
+ {
83
  $xmlName = Mage::getStoreConfig('doofinder_cron/schedule_settings/name', $storeCode);
84
  $config = array(
85
  'enabled' => Mage::getStoreConfig('doofinder_cron/schedule_settings/enabled', $storeCode),
104
  * @param string|boolean $password = true
105
  * @return bool
106
  */
107
+ protected function _processXmlName($name = 'doofinder-{store_code}.xml', $code = 'default', $password = true)
108
+ {
109
  $pattern = '/\{\s*store_code\s*\}/';
110
 
111
  if ($password === true) {
113
  }
114
 
115
  $replacement = $code;
116
+ if ($password) {
117
  $replacement .= '-' . $password;
118
  }
119
 
128
  * @param string $oldPassword
129
  * @param string $newPassword
130
  */
131
+ public function changeXmlPassword($storeCode, $oldPassword, $newPassword)
132
+ {
133
  $xmlName = Mage::getStoreConfig('doofinder_cron/schedule_settings/name', $storeCode);
134
  $dir = $this->getFeedDirectory();
135
 
137
  $newFilename = $this->_processXmlName($xmlName, $storeCode, $newPassword);
138
  $newFilepath = $dir . DS . $newFilename;
139
 
140
+ $fileIo = new Varien_Io_File();
141
+ if ($fileIo->fileExists($oldFilepath)) {
142
+ if (!$fileIo->fileExists($newFilepath) && !$fileIo->mv($oldFilepath, $newFilepath)) {
143
+ $msg = __(
144
+ 'Feed file could not be renamed accordingly to new %s ' .
145
+ 'value because file permission issues or file with name %s already exists.',
146
  $this->getData('field_config/label'),
147
  $newFilename
148
+ );
149
+ throw new \Magento\Framework\Exception\LocalizedException($msg);
150
  }
151
 
152
  $process = Mage::getModel('doofinder_feed/cron')->load($storeCode, 'store_code');
158
  }
159
  }
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  /**
162
  * Creates new schedule entry.
163
  * @param Doofinder_Feed_Model_Cron $process
164
  */
165
+ public function createNewSchedule(Doofinder_Feed_Model_Cron $process)
166
+ {
167
  $helper = Mage::helper('doofinder_feed');
168
+ $date = Mage::getSingleton('core/date');
169
 
170
  $config = $helper->getStoreConfig($process->getStoreCode());
171
 
172
  // Set new schedule time
173
+ $delayInMin = (int) $config['stepDelay'];
174
+ // @codingStandardsIgnoreStart
175
+ $timestamp = mktime(
176
+ $date->date("H"),
177
+ $date->date("i") + $delayInMin,
178
+ $date->date("s"),
179
+ $date->date("m"),
180
+ $date->date("d"),
181
+ $date->date("Y")
182
+ );
183
+ $timescheduled = $date->date(null, $timestamp);
184
+ // @codingStandardsIgnoreEnd
185
 
186
  // Prepare new process data
187
  $status = $helper::STATUS_RUNNING;
 
188
 
189
  // Set process data and save
190
  $process->setStatus($status)
192
  ->setNextIteration($timescheduled)
193
  ->save();
194
 
195
+ Mage::helper('doofinder_feed/log')->log(
196
+ $process,
197
+ Doofinder_Feed_Helper_Log::STATUS,
198
+ $helper->__('Scheduling the next step for %s', $timescheduled)
199
+ );
200
  }
201
 
202
+ public function getScheduledAt($time = null, $frequency = null, $timezoneOffset = true)
203
+ {
204
+ $date = Mage::getSingleton('core/date');
205
+ // @codingStandardsIgnoreStart
206
+ $parts = array($time[0], $time[1], $time[2], $date->date('m'), $date->date('d'));
207
+ // @codingStandardsIgnoreEnd
208
  $offset = $this->getTimezoneOffset();
209
 
210
+ $now = $date->timestamp();
211
  $start = mktime($parts[0] - $offset, $parts[1], $parts[2], $parts[3], $parts[4]);
212
 
213
  if ($start < $now) {
230
  $parts[0] -= $offset;
231
  }
232
 
233
+ // @codingStandardsIgnoreStart
234
+ return $date->date(null, mktime($parts[0], $parts[1], $parts[2], $parts[3], $parts[4]));
235
+ // @codingStandardsIgnoreEnd
236
  }
237
 
238
+ public function getTimezoneOffset()
239
+ {
240
  $timezone = Mage::getStoreConfig('general/locale/timezone');
241
  $backTimezone = date_default_timezone_get();
242
  // Set relative timezone
243
  date_default_timezone_set($timezone);
244
+ // @codingStandardsIgnoreStart
245
+ $offset = (Mage::getSingleton('core/date')->date('Z') / 60 / 60);
246
+ // @codingStandardsIgnoreEnd
247
  // Revoke server timezone
248
  date_default_timezone_set($backTimezone);
249
  return $offset;
300
  public function createFeedDirectory()
301
  {
302
  $dir = $this->getFeedDirectory();
303
+ (new Varien_Io_File())->checkAndCreateFolder($dir, 0777);
 
 
 
304
 
305
  return true;
306
  }
app/code/community/Doofinder/Feed/Helper/Log.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  /**
13
  * Log helper for Doofinder Feed
14
  *
15
- * @version 1.8.10
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Log extends Mage_Core_Helper_Abstract
@@ -24,14 +24,14 @@ class Doofinder_Feed_Helper_Log extends Mage_Core_Helper_Abstract
24
  /**
25
  * @var boolean
26
  */
27
- public $_debugEnabled;
28
 
29
  /**
30
  * Constructor
31
  */
32
- function __construct()
33
  {
34
- $this->_debugEnabled = Mage::getStoreConfig('doofinder_cron/feed_settings/debug', false);
35
  }
36
 
37
  /**
@@ -42,11 +42,11 @@ class Doofinder_Feed_Helper_Log extends Mage_Core_Helper_Abstract
42
  * @param string $message
43
  * @param boolean $debug Pass message to debug log
44
  */
45
- function log(Doofinder_Feed_Model_Cron $process, $type, $message, $debug = true)
46
  {
47
  $debug && $this->debug(sprintf('log(%d, %s) %s', $process->getId(), $type, $message));
48
 
49
- $entry = Mage::getModel('doofinder_feed/log')
50
  ->setProcessId($process->getId())
51
  ->setType($type)
52
  ->setMessage($message)
@@ -60,7 +60,7 @@ class Doofinder_Feed_Helper_Log extends Mage_Core_Helper_Abstract
60
  *
61
  * @return array
62
  */
63
- function listLogTypes()
64
  {
65
  return array(
66
  static::STATUS => $this->__('Status'),
@@ -74,9 +74,9 @@ class Doofinder_Feed_Helper_Log extends Mage_Core_Helper_Abstract
74
  *
75
  * @param string $msg
76
  */
77
- function debug($msg)
78
  {
79
- if (!$this->_debugEnabled) {
80
  return;
81
  }
82
 
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  /**
13
  * Log helper for Doofinder Feed
14
  *
15
+ * @version 1.8.11
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Log extends Mage_Core_Helper_Abstract
24
  /**
25
  * @var boolean
26
  */
27
+ public $debugEnabled;
28
 
29
  /**
30
  * Constructor
31
  */
32
+ public function __construct()
33
  {
34
+ $this->debugEnabled = Mage::getStoreConfig('doofinder_cron/feed_settings/debug', false);
35
  }
36
 
37
  /**
42
  * @param string $message
43
  * @param boolean $debug Pass message to debug log
44
  */
45
+ public function log(Doofinder_Feed_Model_Cron $process, $type, $message, $debug = true)
46
  {
47
  $debug && $this->debug(sprintf('log(%d, %s) %s', $process->getId(), $type, $message));
48
 
49
+ Mage::getModel('doofinder_feed/log')
50
  ->setProcessId($process->getId())
51
  ->setType($type)
52
  ->setMessage($message)
60
  *
61
  * @return array
62
  */
63
+ public function listLogTypes()
64
  {
65
  return array(
66
  static::STATUS => $this->__('Status'),
74
  *
75
  * @param string $msg
76
  */
77
+ public function debug($msg)
78
  {
79
+ if (!$this->debugEnabled) {
80
  return;
81
  }
82
 
app/code/community/Doofinder/Feed/Helper/Search.php CHANGED
@@ -64,12 +64,15 @@ class Doofinder_Feed_Helper_Search extends Mage_Core_Helper_Abstract
64
  $client = new \Doofinder\Api\Search\Client($hashId, $apiKey);
65
 
66
  try {
67
- $results = $client->query($queryText, null, ['rpp' => $limit, 'transformer' => 'onlyid', 'filter' => []]);
 
 
 
68
  } catch (\Doofinder\Api\Search\Error $e) {
69
  $results = null;
70
  Mage::logException($e);
71
  }
72
-
73
  // Store objects
74
  $this->_lastSearch = $client;
75
  $this->_lastResults = $results;
@@ -85,7 +88,7 @@ class Doofinder_Feed_Helper_Search extends Mage_Core_Helper_Abstract
85
  */
86
  protected function retrieveIds(\Doofinder\Api\Search\Results $results)
87
  {
88
- $ids = [];
89
  foreach ($results->getResults() as $result) {
90
  $ids[] = $result['id'];
91
  }
@@ -133,13 +136,13 @@ class Doofinder_Feed_Helper_Search extends Mage_Core_Helper_Abstract
133
  public function getDoofinderSearchEngine($storeCode)
134
  {
135
  if ($this->_searchEngines === null) {
136
- $this->_searchEngines = [];
137
 
138
  // Create DoofinderManagementApi instance
139
  $this->loadDoofinderLibrary();
140
- $doofinderManagementApi = new \Doofinder\Api\Management\Client($this->getApiKey($storeCode));
141
 
142
- foreach ($doofinderManagementApi->getSearchEngines() as $searchEngine) {
143
  $this->_searchEngines[$searchEngine->hashid] = $searchEngine;
144
  }
145
  }
@@ -171,8 +174,10 @@ class Doofinder_Feed_Helper_Search extends Mage_Core_Helper_Abstract
171
  $classPath = str_replace('\\', '/', substr($className, $len)) . '.php';
172
  $file = $libraryDirectory . $classPath;
173
 
 
174
  if (file_exists($file)) {
175
  require $file;
176
  }
 
177
  }
178
  }
64
  $client = new \Doofinder\Api\Search\Client($hashId, $apiKey);
65
 
66
  try {
67
+ $queryArgs = array('rpp' => $limit, 'transformer' => 'onlyid', 'filter' => array());
68
+ // @codingStandardsIgnoreStart
69
+ $results = $client->query($queryText, null, $queryArgs);
70
+ // @codingStandardsIgnoreEnd
71
  } catch (\Doofinder\Api\Search\Error $e) {
72
  $results = null;
73
  Mage::logException($e);
74
  }
75
+
76
  // Store objects
77
  $this->_lastSearch = $client;
78
  $this->_lastResults = $results;
88
  */
89
  protected function retrieveIds(\Doofinder\Api\Search\Results $results)
90
  {
91
+ $ids = array();
92
  foreach ($results->getResults() as $result) {
93
  $ids[] = $result['id'];
94
  }
136
  public function getDoofinderSearchEngine($storeCode)
137
  {
138
  if ($this->_searchEngines === null) {
139
+ $this->_searchEngines = array();
140
 
141
  // Create DoofinderManagementApi instance
142
  $this->loadDoofinderLibrary();
143
+ $api = new \Doofinder\Api\Management\Client($this->getApiKey($storeCode));
144
 
145
+ foreach ($api->getSearchEngines() as $searchEngine) {
146
  $this->_searchEngines[$searchEngine->hashid] = $searchEngine;
147
  }
148
  }
174
  $classPath = str_replace('\\', '/', substr($className, $len)) . '.php';
175
  $file = $libraryDirectory . $classPath;
176
 
177
+ // @codingStandardsIgnoreStart
178
  if (file_exists($file)) {
179
  require $file;
180
  }
181
+ // @codingStandardsIgnoreEnd
182
  }
183
  }
app/code/community/Doofinder/Feed/Helper/Tax.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  class Doofinder_Feed_Helper_Tax extends Mage_Tax_Helper_Data
@@ -19,6 +19,7 @@ class Doofinder_Feed_Helper_Tax extends Mage_Tax_Helper_Data
19
  if ($needPriceConversion !== false) {
20
  return $needPriceConversion;
21
  }
 
22
  $taxMode = Mage::getStoreConfig('doofinder_cron/feed_settings/price_tax_mode', $store);
23
  // Force price conversion only in case of 'with tax' price export mode
24
  return $taxMode == Doofinder_Feed_Model_System_Config_Source_Feed_Pricetaxmode::MODE_WITH_TAX;
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  class Doofinder_Feed_Helper_Tax extends Mage_Tax_Helper_Data
19
  if ($needPriceConversion !== false) {
20
  return $needPriceConversion;
21
  }
22
+
23
  $taxMode = Mage::getStoreConfig('doofinder_cron/feed_settings/price_tax_mode', $store);
24
  // Force price conversion only in case of 'with tax' price export mode
25
  return $taxMode == Doofinder_Feed_Model_System_Config_Source_Feed_Pricetaxmode::MODE_WITH_TAX;
app/code/community/Doofinder/Feed/Model/Adminhtml/System/Config/Backend/Cron.php CHANGED
@@ -6,25 +6,24 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
- class Doofinder_Feed_Model_Adminhtml_System_Config_Backend_Cron extends Mage_Core_Model_Config_Data {
 
13
 
14
  const CRON_STRING_PATH = 'crontab/jobs/doofinder_feed_generate/schedule/cron_expr';
15
 
16
- protected function _afterSave() {
 
17
  $time = $this->getData('groups/settings/fields/time/value');
18
  $frequency = $this->getData('groups/settings/fields/frequency/value');
19
- $frequencyDaily = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
20
  $frequencyWeekly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_WEEKLY;
21
  $frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;
22
 
23
- $cronDayOfWeek = date('N');
24
-
25
  $cronExprArray = array(
26
- intval($time[1]), # Minute
27
- intval($time[0]), # Hour
28
  ($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
29
  '*', # Month of the Year
30
  ($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
@@ -47,8 +46,8 @@ class Doofinder_Feed_Model_Adminhtml_System_Config_Backend_Cron extends Mage_Cor
47
  ->save();
48
  }
49
  catch (Exception $e) {
50
- throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
51
-
52
  }
53
  }
54
  }
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
+ class Doofinder_Feed_Model_Adminhtml_System_Config_Backend_Cron extends Mage_Core_Model_Config_Data
13
+ {
14
 
15
  const CRON_STRING_PATH = 'crontab/jobs/doofinder_feed_generate/schedule/cron_expr';
16
 
17
+ protected function _afterSave()
18
+ {
19
  $time = $this->getData('groups/settings/fields/time/value');
20
  $frequency = $this->getData('groups/settings/fields/frequency/value');
 
21
  $frequencyWeekly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_WEEKLY;
22
  $frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;
23
 
 
 
24
  $cronExprArray = array(
25
+ (int) $time[1], # Minute
26
+ (int) $time[0], # Hour
27
  ($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
28
  '*', # Month of the Year
29
  ($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
46
  ->save();
47
  }
48
  catch (Exception $e) {
49
+ $msg = Mage::helper('cron')->__('Unable to save the cron expression.');
50
+ Mage::throwException($msg);
51
  }
52
  }
53
  }
app/code/community/Doofinder/Feed/Model/Adminhtml/System/Config/Validation/Hashid.php CHANGED
@@ -1,6 +1,9 @@
1
  <?php
2
- class Doofinder_Feed_Model_Adminhtml_System_Config_Validation_Hashid extends Mage_Core_Model_Config_Data {
3
- public function save() {
 
 
 
4
  // Hash id to save
5
  $hashId = $this->getValue();
6
  $stores = Mage::app()->getStores();
@@ -10,10 +13,13 @@ class Doofinder_Feed_Model_Adminhtml_System_Config_Validation_Hashid extends Mag
10
  $code = $store->getCode();
11
  $scopeHashId = Mage::getStoreConfig('doofinder_search/internal_settings/hash_id', $code);
12
  if ($hashId !== '' && $hashId === $scopeHashId) {
13
- Mage::throwException("HashID ".$hashId." is already used in ".$code." store. It must have a unique value.");
14
- exit;
 
 
15
  }
16
  }
 
17
  return parent::save();
18
  }
19
  }
1
  <?php
2
+
3
+ class Doofinder_Feed_Model_Adminhtml_System_Config_Validation_Hashid extends Mage_Core_Model_Config_Data
4
+ {
5
+ public function save()
6
+ {
7
  // Hash id to save
8
  $hashId = $this->getValue();
9
  $stores = Mage::app()->getStores();
13
  $code = $store->getCode();
14
  $scopeHashId = Mage::getStoreConfig('doofinder_search/internal_settings/hash_id', $code);
15
  if ($hashId !== '' && $hashId === $scopeHashId) {
16
+ Mage::throwException(
17
+ 'HashID ' . $hashId . ' is already used in ' . $code . ' store. ' .
18
+ 'It must have a unique value.'
19
+ );
20
  }
21
  }
22
+
23
  return parent::save();
24
  }
25
  }
app/code/community/Doofinder/Feed/Model/CatalogSearch/Resource/Fulltext.php CHANGED
@@ -5,18 +5,20 @@ class Doofinder_Feed_Model_CatalogSearch_Resource_Fulltext extends Mage_CatalogS
5
  /**
6
  * Get stored results select
7
  *
8
- * @param int $query_id
9
  * @param int $attr
10
  * @return Varien_Db_Select
11
  */
12
- protected function getStoredResultsSelect($query_id, $attr = 'product_id')
13
  {
14
  $adapter = $this->_getReadAdapter();
15
 
 
16
  $select = $adapter->select()
17
  ->from($this->getTable('catalogsearch/result'), $attr)
18
- ->where('query_id = ?', $query_id)
19
  ->order('relevance desc');
 
20
 
21
  return $select;
22
  }
@@ -24,18 +26,22 @@ class Doofinder_Feed_Model_CatalogSearch_Resource_Fulltext extends Mage_CatalogS
24
  /**
25
  * Get stored results in CatalogSearch cache
26
  *
27
- * @param int $query_id
28
  * @param int $limit
29
  * @return array
30
  */
31
- protected function getStoredResults($query_id, $limit)
32
  {
33
  $adapter = $this->_getReadAdapter();
34
- $select = $this->getStoredResultsSelect($query_id);
 
35
  $select->limit($limit);
 
36
 
37
  $results = array();
 
38
  foreach ($adapter->fetchAll($select) as $result) {
 
39
  $results[] = $result['product_id'];
40
  }
41
 
@@ -45,13 +51,13 @@ class Doofinder_Feed_Model_CatalogSearch_Resource_Fulltext extends Mage_CatalogS
45
  /**
46
  * Get number of stored results in CatalogSearch cache
47
  *
48
- * @param int $query_id
49
  * @return array
50
  */
51
- protected function getStoredResultsCount($query_id)
52
  {
53
  $adapter = $this->_getReadAdapter();
54
- $select = $this->getStoredResultsSelect($query_id, 'COUNT(*)');
55
 
56
  return (int) $adapter->fetchOne($select);
57
  }
@@ -67,7 +73,7 @@ class Doofinder_Feed_Model_CatalogSearch_Resource_Fulltext extends Mage_CatalogS
67
  */
68
  public function prepareResult($object, $queryText, $query)
69
  {
70
- if(!Mage::getStoreConfigFlag('doofinder_search/internal_settings/enable', Mage::app()->getStore())) {
71
  return parent::prepareResult($object, $queryText, $query);
72
  }
73
 
@@ -79,27 +85,31 @@ class Doofinder_Feed_Model_CatalogSearch_Resource_Fulltext extends Mage_CatalogS
79
  $adapter = $this->_getWriteAdapter();
80
 
81
  if ($query->getIsProcessed()) {
82
- $storedResults = $this->getStoredResults($query->getId(), count($results));
83
- $maxResults = Mage::getStoreConfig('doofinder_search/internal_settings/total_limit', Mage::app()->getStore());
 
 
 
84
 
85
  // Compare results count and checksum
86
- if (min($helper->getResultsCount(), $maxResults) == $this->getStoredResultsCount($query->getId()) &&
87
- $this->calculateChecksum($results) == $this->calculateChecksum($storedResults)) {
88
-
89
  // Set search results
90
  $this->setResults($storedResults);
91
  return $this;
92
  }
93
 
94
  // Delete results
 
95
  $select = $adapter->select()
96
  ->from($this->getTable('catalogsearch/result'), 'product_id')
97
  ->where('query_id = ?', $query->getId());
98
  $adapter->query($adapter->deleteFromSelect($select, $this->getTable('catalogsearch/result')));
 
99
  }
100
 
101
  try {
102
-
103
  // Fetch all results
104
  $results = $helper->getAllResults();
105
 
@@ -115,12 +125,13 @@ class Doofinder_Feed_Model_CatalogSearch_Resource_Fulltext extends Mage_CatalogS
115
  foreach ($productCollection as $product) {
116
  $productIds[] = $product->getId();
117
  }
 
118
  $results = array_intersect($results, $productIds);
119
 
120
- foreach($results as $product_id) {
121
  $data[] = array(
122
  'query_id' => $query->getId(),
123
- 'product_id' => $product_id,
124
  'relevance' => $relevance--,
125
  );
126
  }
@@ -132,7 +143,6 @@ class Doofinder_Feed_Model_CatalogSearch_Resource_Fulltext extends Mage_CatalogS
132
  }
133
 
134
  $query->setIsProcessed(1);
135
-
136
  } catch (Exception $e) {
137
  Mage::logException($e);
138
  return parent::prepareResult($object, $queryText, $query);
@@ -151,7 +161,7 @@ class Doofinder_Feed_Model_CatalogSearch_Resource_Fulltext extends Mage_CatalogS
151
  {
152
  $data = array();
153
  $relevance = count($results);
154
-
155
  foreach ($results as $productId) {
156
  $data[$productId] = $relevance--;
157
  }
5
  /**
6
  * Get stored results select
7
  *
8
+ * @param int $queryId
9
  * @param int $attr
10
  * @return Varien_Db_Select
11
  */
12
+ protected function _getStoredResultsSelect($queryId, $attr = 'product_id')
13
  {
14
  $adapter = $this->_getReadAdapter();
15
 
16
+ // @codingStandardsIgnoreStart
17
  $select = $adapter->select()
18
  ->from($this->getTable('catalogsearch/result'), $attr)
19
+ ->where('query_id = ?', $queryId)
20
  ->order('relevance desc');
21
+ // @codingStandardsIgnoreEnd
22
 
23
  return $select;
24
  }
26
  /**
27
  * Get stored results in CatalogSearch cache
28
  *
29
+ * @param int $queryId
30
  * @param int $limit
31
  * @return array
32
  */
33
+ protected function _getStoredResults($queryId, $limit)
34
  {
35
  $adapter = $this->_getReadAdapter();
36
+ $select = $this->_getStoredResultsSelect($queryId);
37
+ // @codingStandardsIgnoreStart
38
  $select->limit($limit);
39
+ // @codingStandardsIgnoreEnd
40
 
41
  $results = array();
42
+ // @codingStandardsIgnoreStart
43
  foreach ($adapter->fetchAll($select) as $result) {
44
+ // @codingStandardsIgnoreEnd
45
  $results[] = $result['product_id'];
46
  }
47
 
51
  /**
52
  * Get number of stored results in CatalogSearch cache
53
  *
54
+ * @param int $queryId
55
  * @return array
56
  */
57
+ protected function _getStoredResultsCount($queryId)
58
  {
59
  $adapter = $this->_getReadAdapter();
60
+ $select = $this->_getStoredResultsSelect($queryId, 'COUNT(*)');
61
 
62
  return (int) $adapter->fetchOne($select);
63
  }
73
  */
74
  public function prepareResult($object, $queryText, $query)
75
  {
76
+ if (!Mage::getStoreConfigFlag('doofinder_search/internal_settings/enable', Mage::app()->getStore())) {
77
  return parent::prepareResult($object, $queryText, $query);
78
  }
79
 
85
  $adapter = $this->_getWriteAdapter();
86
 
87
  if ($query->getIsProcessed()) {
88
+ $storedResults = $this->_getStoredResults($query->getId(), count($results));
89
+ $maxResults = Mage::getStoreConfig(
90
+ 'doofinder_search/internal_settings/total_limit',
91
+ Mage::app()->getStore()
92
+ );
93
 
94
  // Compare results count and checksum
95
+ if (min($helper->getResultsCount(), $maxResults) == $this->_getStoredResultsCount($query->getId())
96
+ && $this->calculateChecksum($results) == $this->calculateChecksum($storedResults)
97
+ ) {
98
  // Set search results
99
  $this->setResults($storedResults);
100
  return $this;
101
  }
102
 
103
  // Delete results
104
+ // @codingStandardsIgnoreStart
105
  $select = $adapter->select()
106
  ->from($this->getTable('catalogsearch/result'), 'product_id')
107
  ->where('query_id = ?', $query->getId());
108
  $adapter->query($adapter->deleteFromSelect($select, $this->getTable('catalogsearch/result')));
109
+ // @codingStandardsIgnoreEnd
110
  }
111
 
112
  try {
 
113
  // Fetch all results
114
  $results = $helper->getAllResults();
115
 
125
  foreach ($productCollection as $product) {
126
  $productIds[] = $product->getId();
127
  }
128
+
129
  $results = array_intersect($results, $productIds);
130
 
131
+ foreach ($results as $productId) {
132
  $data[] = array(
133
  'query_id' => $query->getId(),
134
+ 'product_id' => $productId,
135
  'relevance' => $relevance--,
136
  );
137
  }
143
  }
144
 
145
  $query->setIsProcessed(1);
 
146
  } catch (Exception $e) {
147
  Mage::logException($e);
148
  return parent::prepareResult($object, $queryText, $query);
161
  {
162
  $data = array();
163
  $relevance = count($results);
164
+
165
  foreach ($results as $productId) {
166
  $data[$productId] = $relevance--;
167
  }
app/code/community/Doofinder/Feed/Model/Config.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  /**
13
  * Config model for Doofinder Feed
14
  *
15
- * @version 1.8.10
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
@@ -21,17 +21,19 @@ class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
21
  const BASE_CONFIG_PATH = 'doofinder';
22
 
23
  protected $_directives = null;
24
- protected $_product_attribute_codes = null;
25
- protected $_product_directives = null;
26
 
27
  const OUT_OF_STOCK = 'out of stock';
28
  const IN_STOCK = 'in stock';
29
 
30
- public function getOutOfStockStatus() {
 
31
  return self::OUT_OF_STOCK;
32
  }
33
 
34
- public function getInStockStatus() {
 
35
  return self::IN_STOCK;
36
  }
37
 
@@ -39,8 +41,7 @@ class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
39
  // Get Config
40
  //
41
 
42
- public function getConfigVar($key, $storeId = null,
43
- $section = self::DEFAULT_SECTION)
44
  {
45
  if ($key == 'field_map')
46
  return $this->getConfigVarFieldMap($key, $storeId, $section);
@@ -50,8 +51,7 @@ class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
50
  return Mage::getStoreConfig($path, $storeId);
51
  }
52
 
53
- public function getConfigVarFieldMap($key, $storeId = null,
54
- $section = self::DEFAULT_SECTION)
55
  {
56
  $path = self::BASE_CONFIG_PATH . '/' . $section . '/' . $key;
57
  $data = Mage::getStoreConfig($path, $storeId);
@@ -62,14 +62,12 @@ class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
62
  return $data;
63
  }
64
 
65
- public function getMultipleSelectVar($key, $storeId = null,
66
- $section = self::DEFAULT_SECTION)
67
  {
68
  $str = $this->getConfigVar($key, $storeId, $section);
69
  $values = array();
70
 
71
- if (!empty($str))
72
- {
73
  $values = explode(',', $str);
74
  }
75
 
@@ -86,8 +84,7 @@ class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
86
  $result = array();
87
  $defaultMapping = $this->getConfigVar('default_field_map', $storeId);
88
 
89
- foreach ($defaultMapping as $field => $config)
90
- {
91
  $result[] = array(
92
  'label' => $config['label'],
93
  'attribute' => $config['attribute'],
@@ -105,7 +102,7 @@ class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
105
 
106
  public function isDirective($code, $storeId = null)
107
  {
108
- if (is_null($this->_directives))
109
  $this->_directives = $this->getConfigVar('directives', $storeId);
110
 
111
  return isset($this->_directives[$code]);
@@ -117,84 +114,40 @@ class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
117
  */
118
  public function compareMagentoVersion($infoArray)
119
  {
120
- $v = Mage::getVersionInfo();
121
 
122
- foreach (array('major', 'minor', 'revision', 'patch') as $key)
123
- {
124
- if ($v[$key] != $infoArray[$key])
125
- return $v[$key] > $infoArray[$key] ? 1 : -1;
126
  }
127
 
128
  return 0;
129
  }
130
 
131
-
132
- //
133
- // Tools for Dropdowns
134
- //
135
-
136
- // protected function _loadProductAttributeCodes($storeId = null)
137
- // {
138
- // if (!is_null($this->_product_attribute_codes))
139
- // return;
140
-
141
- // $config = Mage::getModel('eav/config');
142
-
143
- // $this->_product_attribute_codes = array();
144
-
145
- // $excludedAttrs = $this->getMultipleSelectVar('excluded_attributes');
146
- // $attributesCodes = $config->getEntityAttributeCodes(
147
- // 'catalog_product',
148
- // new Varien_Object(array('store_id' => $storeId))
149
- // );
150
-
151
- // foreach ($attributesCodes as $attrCode)
152
- // {
153
- // if (array_search($attrCode, $excludedAttrs) !== false)
154
- // continue;
155
-
156
- // $attr = $config->getAttribute('catalog_product', $attrCode);
157
-
158
- // if ($attr !== false && $attr->getAttributeId() > 0)
159
- // {
160
- // $code = $attr->getAttributeCode();
161
- // $this->_product_attribute_codes[$code] = addslashes(
162
- // $attr->getFrontend()->getLabel().' ('.$code.')'
163
- // );
164
- // }
165
- // }
166
-
167
- // asort($this->_product_attribute_codes);
168
- // }
169
-
170
  protected function _loadProductDirectives($storeId = null)
171
  {
172
- if (!is_null($this->_product_directives))
173
  return;
174
 
175
- $this->_product_directives = array();
176
 
177
- foreach ($this->getConfigVar('directives', $storeId) as $code => $cfg)
178
- {
179
- $this->_product_directives[$code] = $cfg['label'];
180
  }
181
 
182
- asort($this->_product_directives);
183
  }
184
 
185
- public function getProductAttributesCodes($storeId = null,
186
- $includeDirectives = true)
187
  {
188
  $this->_loadProductAttributeCodes($storeId);
189
 
190
- if ($includeDirectives === true)
191
- {
192
  $this->_loadProductDirectives($storeId);
193
 
194
- return array_merge($this->_product_directives,
195
- $this->_product_attribute_codes);
196
  }
197
 
198
- return $this->_product_attribute_codes;
199
  }
200
  }
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
  /**
13
  * Config model for Doofinder Feed
14
  *
15
+ * @version 1.8.11
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
21
  const BASE_CONFIG_PATH = 'doofinder';
22
 
23
  protected $_directives = null;
24
+ protected $_productAttributes = null;
25
+ protected $_productDirectives = null;
26
 
27
  const OUT_OF_STOCK = 'out of stock';
28
  const IN_STOCK = 'in stock';
29
 
30
+ public function getOutOfStockStatus()
31
+ {
32
  return self::OUT_OF_STOCK;
33
  }
34
 
35
+ public function getInStockStatus()
36
+ {
37
  return self::IN_STOCK;
38
  }
39
 
41
  // Get Config
42
  //
43
 
44
+ public function getConfigVar($key, $storeId = null, $section = self::DEFAULT_SECTION)
 
45
  {
46
  if ($key == 'field_map')
47
  return $this->getConfigVarFieldMap($key, $storeId, $section);
51
  return Mage::getStoreConfig($path, $storeId);
52
  }
53
 
54
+ public function getConfigVarFieldMap($key, $storeId = null, $section = self::DEFAULT_SECTION)
 
55
  {
56
  $path = self::BASE_CONFIG_PATH . '/' . $section . '/' . $key;
57
  $data = Mage::getStoreConfig($path, $storeId);
62
  return $data;
63
  }
64
 
65
+ public function getMultipleSelectVar($key, $storeId = null, $section = self::DEFAULT_SECTION)
 
66
  {
67
  $str = $this->getConfigVar($key, $storeId, $section);
68
  $values = array();
69
 
70
+ if (!empty($str)) {
 
71
  $values = explode(',', $str);
72
  }
73
 
84
  $result = array();
85
  $defaultMapping = $this->getConfigVar('default_field_map', $storeId);
86
 
87
+ foreach ($defaultMapping as $field => $config) {
 
88
  $result[] = array(
89
  'label' => $config['label'],
90
  'attribute' => $config['attribute'],
102
 
103
  public function isDirective($code, $storeId = null)
104
  {
105
+ if ($this->_directives === null)
106
  $this->_directives = $this->getConfigVar('directives', $storeId);
107
 
108
  return isset($this->_directives[$code]);
114
  */
115
  public function compareMagentoVersion($infoArray)
116
  {
117
+ $version = Mage::getVersionInfo();
118
 
119
+ foreach (array('major', 'minor', 'revision', 'patch') as $key) {
120
+ if ($version[$key] != $infoArray[$key])
121
+ return $version[$key] > $infoArray[$key] ? 1 : -1;
 
122
  }
123
 
124
  return 0;
125
  }
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  protected function _loadProductDirectives($storeId = null)
128
  {
129
+ if ($this->_productDirectives !== null)
130
  return;
131
 
132
+ $this->_productDirectives = array();
133
 
134
+ foreach ($this->getConfigVar('directives', $storeId) as $code => $cfg) {
135
+ $this->_productDirectives[$code] = $cfg['label'];
 
136
  }
137
 
138
+ asort($this->_productDirectives);
139
  }
140
 
141
+ public function getProductAttributesCodes($storeId = null, $includeDirectives = true)
 
142
  {
143
  $this->_loadProductAttributeCodes($storeId);
144
 
145
+ if ($includeDirectives === true) {
 
146
  $this->_loadProductDirectives($storeId);
147
 
148
+ return array_merge($this->_productDirectives, $this->_productAttributes);
 
149
  }
150
 
151
+ return $this->_productAttributes;
152
  }
153
  }
app/code/community/Doofinder/Feed/Model/Cron.php CHANGED
@@ -6,18 +6,20 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
- class Doofinder_Feed_Model_Cron extends Mage_Core_Model_Abstract {
 
13
 
14
 
15
- protected function _construct() {
 
16
  $this->_init('doofinder_feed/cron');
17
-
18
  }
19
 
20
- public function modeDisabled() {
 
21
  $helper = Mage::helper('doofinder_feed');
22
  $this->setStatus($helper::STATUS_DISABLED)
23
  ->setOffset(0)
@@ -28,7 +30,8 @@ class Doofinder_Feed_Model_Cron extends Mage_Core_Model_Abstract {
28
  ->save();
29
  }
30
 
31
- public function modeWaiting() {
 
32
  $helper = Mage::helper('doofinder_feed');
33
  $this->setStatus($helper::STATUS_WAITING)
34
  ->setMessage($helper::MSG_WAITING)
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.8.11
10
  */
11
 
12
+ class Doofinder_Feed_Model_Cron extends Mage_Core_Model_Abstract
13
+ {
14
 
15
 
16
+ protected function _construct()
17
+ {
18
  $this->_init('doofinder_feed/cron');
 
19
  }
20
 
21
+ public function modeDisabled()
22
+ {
23
  $helper = Mage::helper('doofinder_feed');
24
  $this->setStatus($helper::STATUS_DISABLED)
25
  ->setOffset(0)
30
  ->save();
31
  }
32
 
33
+ public function modeWaiting()
34
+ {
35
  $helper = Mage::helper('doofinder_feed');
36
  $this->setStatus($helper::STATUS_WAITING)
37
  ->setMessage($helper::MSG_WAITING)
app/code/community/Doofinder/Feed/Model/Generator.php CHANGED
@@ -6,18 +6,21 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.8.10
10
  */
11
 
12
  /**
13
  * Generator model for Doofinder Feed
14
  *
15
- * @version 1.8.10
16
  * @package Doofinder_Feed
17
  */
18
  if (!defined('DS'))
19
  define('DS', DIRECTORY_SEPARATOR);
20
 
 
 
 
21
  class Doofinder_Feed_Model_Generator extends Varien_Object
22
  {
23
  const DEFAULT_BATCH_SIZE = 100;
@@ -48,7 +51,7 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
48
 
49
  protected $_errors = array();
50
 
51
- protected $_lastProcessedProductId;
52
 
53
  /**
54
  * @var Doofinder_Feed_Helper_Log
@@ -88,10 +91,6 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
88
  }
89
  }
90
 
91
- //
92
- // public::Export
93
- //
94
-
95
  public function run()
96
  {
97
  $this->_log->debug("Running generator");
@@ -147,7 +146,9 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
147
  public function getMaxProductId()
148
  {
149
  $collection = $this->_getProductCollection();
 
150
  $collection->getSelect()->limit(1);
 
151
  $collection->getSelect()->order('e.entity_id DESC');
152
  $item = $collection->fetchItem();
153
 
@@ -162,7 +163,7 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
162
  */
163
  public function isFeedDone()
164
  {
165
- return $this->_lastProcessedProductId >= $this->_maxProductId;
166
  }
167
 
168
  /**
@@ -172,7 +173,7 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
172
  */
173
  public function getLastProcessedProductId()
174
  {
175
- return $this->_lastProcessedProductId;
176
  }
177
 
178
  /**
@@ -188,7 +189,7 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
188
  $all = $collection->getSize();
189
 
190
  $collection = $this->_getProductCollection();
191
- $collection->addAttributeToFilter('entity_id', array('lteq' => $this->_lastProcessedProductId));
192
  $now = $collection->getSize();
193
 
194
  return $now / $all;
@@ -199,15 +200,13 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
199
  try
200
  {
201
  $row = $args['row'];
202
- $this->_log->_debugEnabled && $this->_log->debug(sprintf('Adding product %d to feed', $row['entity_id']));
203
-
204
- $this->_lastProcessedProductId = $row['entity_id'];
205
 
206
- $parentEntityId = null;
207
 
208
  $map = $this->_getProductMapModel($row['type_id'], array());
209
 
210
- if (is_null($map)) {
211
  Mage::throwException("There is no map definition for product with type {$row['type_id']}");
212
  }
213
 
@@ -231,24 +230,22 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
231
 
232
  $map->unsetData();
233
 
234
- $this->_log->_debugEnabled && $this->_log->debug(sprintf('Product %d added to feed', $row['entity_id']));
235
  }
236
  catch (Exception $e)
237
  {
238
- $this->logError('Error processing product (ID: ' . $row['entity_id'] . '): ' . $e->getMessage(), Zend_Log::ERR);
 
 
 
239
  }
240
  }
241
 
242
-
243
- //
244
- // protected::Export
245
- //
246
-
247
  protected function _batchProcessProducts($offset, $limit)
248
  {
249
  // Make sure we have this initialized
250
  // in case of an empty collection
251
- $this->_lastProcessedProductId = $offset;
252
 
253
  $collection = $this->_getProductCollection($offset, $limit);
254
 
@@ -260,19 +257,29 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
260
 
261
  }
262
 
 
 
 
 
 
 
263
  protected function _addProductToXml(
264
- Doofinder_Feed_Model_Map_Product_Abstract $productMap)
265
- {
266
- $this->_log->_debugEnabled && $this->_log->debug(sprintf('Adding product %d to xml', $productMap->getProduct()->getId()));
 
 
 
267
 
268
  $iDumped = 0;
269
  $displayPrice = $this->getDisplayPrice();
270
 
271
  try
272
  {
273
- if ($productMap->isSkip())
274
- {
275
- $this->_log->_debugEnabled && $this->_log->debug(sprintf('Product %d skipped', $productMap->getProduct()->getId()));
 
276
  $this->_iSkipped++;
277
  return $this;
278
  }
@@ -281,34 +288,28 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
281
 
282
  if ($productMap->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
283
  && $productMap->hasAssocMaps()
284
- && $productMap->getIsVariants())
285
- {
286
  foreach ($productMap->getAssocMaps() as $assocMap)
287
  if ($assocMap->isSkip())
288
  $this->_iSkipped++;
289
  }
290
 
291
- if (($iProducts = count($productData)) > 1)
292
- {
293
  $productData[0] = array_filter($productData[0]);
294
- // $productData[0]['assoc_id'] = $productData[0]['id'];
295
 
296
- for ($i = 1; $i < $iProducts; $i++)
297
- {
298
  $productData[$i] = array_merge(
299
  $productData[0],
300
  array_filter($productData[$i])
301
  );
302
- // $productData[$i]['assoc_id'] = $productData[0]['id'];
303
  }
304
  }
305
 
306
- foreach ($productData as $data)
307
- {
308
  $this->_oXmlWriter->startElement(self::PRODUCT_ELEMENT);
309
 
310
- if (!isset($data['description']))
311
- {
312
  if (isset($data['long_description'])) {
313
  $data['description'] = $data['long_description'];
314
  unset($data['long_description']);
@@ -319,45 +320,44 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
319
 
320
  krsort($data);
321
 
322
- foreach ($data as $field => $value)
323
- {
324
-
325
- if (!is_array($value))
326
- {
327
  $value = trim($value);
328
  }
329
 
330
- if ($field != 'description' && empty($value))
331
- {
332
  continue;
333
  }
334
 
335
- if (!$displayPrice && ($field === 'price' || $field === 'sale_price'))
336
- {
337
  continue;
338
  }
339
 
340
  $this->_oXmlWriter->startElement($field);
341
 
342
  // Make sure $value is a flat array
343
- if (!is_array($value))
344
- {
345
  $value = array($value);
346
- }
347
- else if (!$this->_isArrayFlat($value))
348
- {
349
- $this->logErrorOnce("Value of $field field is a multidimensional array, encoded value: " . json_encode($value));
 
350
  $value = $this->_flattenArray($value);
351
  }
352
 
353
  $value = implode(self::VALUE_SEPARATOR, array_filter($value));
354
 
 
355
  $written = @$this->_oXmlWriter->writeCData($value);
356
- if ( ! $written )
357
- {
358
  $this->_oXmlWriter->writeComment("Cannot write the value for the $field field.");
359
 
360
- $this->logErrorOnce("Cannot write the value for the $field field, encoded value: " . json_encode($value));
 
 
 
361
  }
362
 
363
  $this->_oXmlWriter->endElement();
@@ -369,7 +369,9 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
369
  $iDumped++;
370
  }
37