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
- app/code/community/Doofinder/Feed/Block/Adminhtml/Log/View.php +44 -27
- app/code/community/Doofinder/Feed/Block/Adminhtml/Map/Additional.php +37 -24
- app/code/community/Doofinder/Feed/Block/Integration.php +8 -4
- app/code/community/Doofinder/Feed/Block/Settings/Buttons/Generate.php +6 -2
- app/code/community/Doofinder/Feed/Block/Settings/Buttons/ViewLog.php +3 -2
- app/code/community/Doofinder/Feed/Block/Settings/Locks.php +10 -7
- app/code/community/Doofinder/Feed/Block/Settings/Panel/AtomicUpdates.php +15 -4
- app/code/community/Doofinder/Feed/Block/Settings/Panel/Crondescription.php +6 -2
- app/code/community/Doofinder/Feed/Block/Settings/Panel/Datetime.php +10 -5
- app/code/community/Doofinder/Feed/Block/Settings/Panel/Description.php +7 -8
- app/code/community/Doofinder/Feed/Block/Settings/Panel/DynamicFeedUrl.php +7 -3
- app/code/community/Doofinder/Feed/Block/Settings/Panel/File.php +35 -14
- app/code/community/Doofinder/Feed/Block/Settings/Panel/Hashdescription.php +4 -2
- app/code/community/Doofinder/Feed/Block/Settings/Panel/Layerdescription.php +5 -3
- app/code/community/Doofinder/Feed/Block/Settings/Panel/Message.php +7 -5
- app/code/community/Doofinder/Feed/Helper/Data.php +53 -59
- app/code/community/Doofinder/Feed/Helper/Log.php +10 -10
- app/code/community/Doofinder/Feed/Helper/Search.php +11 -6
- app/code/community/Doofinder/Feed/Helper/Tax.php +2 -1
- app/code/community/Doofinder/Feed/Model/Adminhtml/System/Config/Backend/Cron.php +9 -10
- app/code/community/Doofinder/Feed/Model/Adminhtml/System/Config/Validation/Hashid.php +10 -4
- app/code/community/Doofinder/Feed/Model/CatalogSearch/Resource/Fulltext.php +30 -20
- app/code/community/Doofinder/Feed/Model/Config.php +27 -74
- app/code/community/Doofinder/Feed/Model/Cron.php +9 -6
- app/code/community/Doofinder/Feed/Model/Generator.php +149 -150
- app/code/community/Doofinder/Feed/Model/Log.php +5 -4
- app/code/community/Doofinder/Feed/Model/Map/Product/Abstract.php +66 -134
- app/code/community/Doofinder/Feed/Model/Map/Product/Associated.php +17 -25
- app/code/community/Doofinder/Feed/Model/Map/Product/Bundle.php +15 -13
- app/code/community/Doofinder/Feed/Model/Map/Product/Configurable.php +32 -36
- app/code/community/Doofinder/Feed/Model/Map/Product/Downloadable.php +6 -3
- app/code/community/Doofinder/Feed/Model/Map/Product/Grouped.php +7 -9
- app/code/community/Doofinder/Feed/Model/Map/Product/Simple.php +6 -3
- app/code/community/Doofinder/Feed/Model/Map/Product/Virtual.php +6 -3
- app/code/community/Doofinder/Feed/Model/Mysql4/Cron.php +7 -5
- app/code/community/Doofinder/Feed/Model/Mysql4/Cron/Collection.php +5 -3
- app/code/community/Doofinder/Feed/Model/Mysql4/Log.php +7 -5
- app/code/community/Doofinder/Feed/Model/Mysql4/Log/Collection.php +3 -2
- app/code/community/Doofinder/Feed/Model/Observers/Feed.php +150 -71
- app/code/community/Doofinder/Feed/Model/Observers/Logs.php +9 -3
- app/code/community/Doofinder/Feed/Model/Observers/Schedule.php +63 -35
- app/code/community/Doofinder/Feed/Model/Resource/Mysql4/Setup.php +5 -4
- app/code/community/Doofinder/Feed/Model/System/Config/Backend/Map/Additional.php +3 -2
- app/code/community/Doofinder/Feed/Model/System/Config/Backend/Password.php +7 -4
- app/code/community/Doofinder/Feed/Model/System/Config/Backend/Total/Limit.php +3 -3
- app/code/community/Doofinder/Feed/Model/System/Config/Reset.php +1 -1
- app/code/community/Doofinder/Feed/Model/System/Config/Source/Feed/Pricetaxmode.php +6 -6
- app/code/community/Doofinder/Feed/Model/System/Config/Source/Product/Attributes.php +1 -1
- app/code/community/Doofinder/Feed/Model/Tools.php +219 -119
- app/code/community/Doofinder/Feed/Test/Controller/Index.php +0 -4
- app/code/community/Doofinder/Feed/Test/Controller/Index/fixtures/testFeed.yaml +0 -3
- app/code/community/Doofinder/Feed/Test/Controller/Index/providers/testFeed.yaml +0 -1
- app/code/community/Doofinder/Feed/Test/Model/Product.php +8 -18
- app/code/community/Doofinder/Feed/controllers/DoofinderFeedFeedController.php +12 -3
- app/code/community/Doofinder/Feed/controllers/DoofinderFeedLogController.php +9 -1
- app/code/community/Doofinder/Feed/controllers/FeedController.php +33 -102
- app/code/community/Doofinder/Feed/controllers/IndexController.php +9 -3
- app/code/community/Doofinder/Feed/etc/config.xml +1 -1
- app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-install-1.5.4.php +104 -41
- app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-install-1.5.7.php +172 -101
- app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-upgrade-1.5.4-1.5.5.php +6 -9
- app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-upgrade-1.5.5-1.5.6.php +72 -48
- app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-upgrade-1.5.6-1.5.7.php +2 -0
- package.xml +5 -5
- 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 |
*/
|
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(
|
42 |
-
'
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
|
47 |
if (!$this->_processId) {
|
48 |
-
$this->addColumn(
|
49 |
-
'
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
-
$this->addColumn(
|
56 |
-
'
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
60 |
|
61 |
-
$this->addColumn(
|
62 |
-
'
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
67 |
|
68 |
-
$this->addColumn(
|
69 |
-
'
|
70 |
-
|
71 |
-
|
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 |
*/
|
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
|
|
|
36 |
$html .= '</tr></thead>';
|
37 |
$html .= '<tbody id="doofinder_feed_additional_mapping_container">';
|
38 |
|
39 |
$count = 0;
|
40 |
if ($this->_getValue('additional_mapping')) {
|
41 |
-
|
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 .=
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
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 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
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 |
*/
|
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 .=
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
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 |
*/
|
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(
|
|
|
|
|
|
|
|
|
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 |
*/
|
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 |
-
$
|
|
|
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 |
*/
|
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 |
-
$
|
29 |
|
30 |
$stores = array();
|
31 |
|
32 |
-
if ($
|
33 |
-
$stores[$
|
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 (
|
46 |
$msg = $this->getLayout()->createBlock('adminhtml/widget_button')
|
47 |
->setType('button')
|
48 |
->setClass('remove-lock')
|
49 |
->setLabel($helper->__('Remove lock'))
|
50 |
-
->setOnClick(
|
|
|
|
|
|
|
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 |
*/
|
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(
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
if (!$engineEnabled || !$atomicUpdatesEnabled) {
|
29 |
$message = $helper->__('Atomic updates are <strong>disabled</strong>.');
|
30 |
} else {
|
31 |
-
$message = $helper->__(
|
|
|
|
|
|
|
|
|
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 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Block_Settings_Panel_CronDescription extends Doofinder_Feed_Block_Settings_Panel_Description
|
13 |
{
|
14 |
-
protected $
|
|
|
|
|
|
|
|
|
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 |
*/
|
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 |
-
|
29 |
-
$
|
30 |
-
|
|
|
|
|
|
|
|
|
31 |
|
32 |
$class = 'feed-datetime';
|
33 |
$html = "<p class='{$class}'>{$msg}</p>";
|
34 |
}
|
35 |
}
|
|
|
36 |
return $html;
|
37 |
}
|
38 |
|
39 |
-
|
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 |
*/
|
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 $
|
18 |
-
protected $
|
|
|
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->
|
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 |
*/
|
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->__(
|
|
|
|
|
|
|
|
|
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 |
*/
|
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 |
-
->
|
|
|
|
|
|
|
|
|
28 |
|
29 |
$message = '';
|
30 |
-
if ($lastSchedule &&
|
31 |
$scheduleTime = strtotime($lastSchedule->getFinishedAt());
|
32 |
-
$currentTime =
|
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 |
-
|
|
|
|
|
|
|
|
|
41 |
Mage::helper('doofinder_feed')->__($message);
|
42 |
}
|
43 |
} else {
|
44 |
-
$message = Mage::helper('doofinder_feed')->__(
|
|
|
|
|
|
|
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 |
-
$
|
58 |
|
59 |
$stores = array();
|
60 |
|
61 |
-
if ($
|
62 |
-
$stores[$
|
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 &&
|
86 |
$message = '<p><a href=' . $fileUrl . ' target="_blank">';
|
87 |
-
$message .=
|
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->__(
|
|
|
|
|
|
|
|
|
|
|
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 $
|
5 |
-
protected $
|
|
|
|
|
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 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Block_Settings_Panel_LayerDescription extends Doofinder_Feed_Block_Settings_Panel_Description
|
13 |
{
|
14 |
-
protected $
|
15 |
-
protected $
|
|
|
|
|
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 |
*/
|
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')->__(
|
|
|
|
|
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 |
-
|
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 |
*/
|
11 |
|
12 |
/**
|
13 |
* Data helper for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
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 |
-
|
|
|
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
|
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 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
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 |
-
|
193 |
$helper = Mage::helper('doofinder_feed');
|
|
|
194 |
|
195 |
$config = $helper->getStoreConfig($process->getStoreCode());
|
196 |
|
197 |
// Set new schedule time
|
198 |
-
$delayInMin =
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
|
214 |
-
public function getScheduledAt($time = null, $frequency = null, $timezoneOffset = true)
|
215 |
-
|
|
|
|
|
|
|
|
|
216 |
$offset = $this->getTimezoneOffset();
|
217 |
|
218 |
-
$now =
|
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 |
-
|
|
|
|
|
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 |
-
|
|
|
|
|
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 |
*/
|
11 |
|
12 |
/**
|
13 |
* Log helper for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
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 $
|
28 |
|
29 |
/**
|
30 |
* Constructor
|
31 |
*/
|
32 |
-
function __construct()
|
33 |
{
|
34 |
-
$this->
|
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 |
-
|
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->
|
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 |
-
$
|
|
|
|
|
|
|
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 |
-
$
|
141 |
|
142 |
-
foreach ($
|
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 |
*/
|
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 |
*/
|
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 |
-
|
27 |
-
|
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 |
-
|
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 |
-
|
3 |
-
|
|
|
|
|
|
|
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(
|
14 |
-
|
|
|
|
|
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 $
|
9 |
* @param int $attr
|
10 |
* @return Varien_Db_Select
|
11 |
*/
|
12 |
-
protected function
|
13 |
{
|
14 |
$adapter = $this->_getReadAdapter();
|
15 |
|
|
|
16 |
$select = $adapter->select()
|
17 |
->from($this->getTable('catalogsearch/result'), $attr)
|
18 |
-
->where('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 $
|
28 |
* @param int $limit
|
29 |
* @return array
|
30 |
*/
|
31 |
-
protected function
|
32 |
{
|
33 |
$adapter = $this->_getReadAdapter();
|
34 |
-
$select = $this->
|
|
|
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 $
|
49 |
* @return array
|
50 |
*/
|
51 |
-
protected function
|
52 |
{
|
53 |
$adapter = $this->_getReadAdapter();
|
54 |
-
$select = $this->
|
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->
|
83 |
-
$maxResults = Mage::getStoreConfig(
|
|
|
|
|
|
|
84 |
|
85 |
// Compare results count and checksum
|
86 |
-
if (min($helper->getResultsCount(), $maxResults) == $this->
|
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 $
|
121 |
$data[] = array(
|
122 |
'query_id' => $query->getId(),
|
123 |
-
'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 |
*/
|
11 |
|
12 |
/**
|
13 |
* Config model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
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 $
|
25 |
-
protected $
|
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 (
|
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 |
-
$
|
121 |
|
122 |
-
foreach (array('major', 'minor', 'revision', 'patch') as $key)
|
123 |
-
|
124 |
-
|
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 (
|
173 |
return;
|
174 |
|
175 |
-
$this->
|
176 |
|
177 |
-
foreach ($this->getConfigVar('directives', $storeId) as $code => $cfg)
|
178 |
-
|
179 |
-
$this->_product_directives[$code] = $cfg['label'];
|
180 |
}
|
181 |
|
182 |
-
asort($this->
|
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->
|
195 |
-
$this->_product_attribute_codes);
|
196 |
}
|
197 |
|
198 |
-
return $this->
|
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 |
*/
|
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 |
*/
|
11 |
|
12 |
/**
|
13 |
* Generator model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
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 $
|
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->
|
166 |
}
|
167 |
|
168 |
/**
|
@@ -172,7 +173,7 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
172 |
*/
|
173 |
public function getLastProcessedProductId()
|
174 |
{
|
175 |
-
return $this->
|
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->
|
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->
|
203 |
-
|
204 |
-
$this->_lastProcessedProductId = $row['entity_id'];
|
205 |
|
206 |
-
$
|
207 |
|
208 |
$map = $this->_getProductMapModel($row['type_id'], array());
|
209 |
|
210 |
-
if (
|
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->
|
235 |
}
|
236 |
catch (Exception $e)
|
237 |
{
|
238 |
-
$this->logError(
|
|
|
|
|
|
|
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->
|
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 |
-
|
|
|
|
|
|
|
267 |
|
268 |
$iDumped = 0;
|
269 |
$displayPrice = $this->getDisplayPrice();
|
270 |
|
271 |
try
|
272 |
{
|
273 |
-
if ($productMap->isSkip())
|
274 |
-
|
275 |
-
|
|
|
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 =
|
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 |
-
|
348 |
-
|
349 |
-
|
|
|
350 |
$value = $this->_flattenArray($value);
|
351 |
}
|
352 |
|
353 |
$value = implode(self::VALUE_SEPARATOR, array_filter($value));
|
354 |
|
|
|
355 |
$written = @$this->_oXmlWriter->writeCData($value);
|
356 |
-
|
357 |
-
{
|
358 |
$this->_oXmlWriter->writeComment("Cannot write the value for the $field field.");
|
359 |
|
360 |
-
$this->logErrorOnce(
|
|
|
|
|
|
|
361 |
}
|
362 |
|
363 |
$this->_oXmlWriter->endElement();
|
@@ -369,7 +369,9 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
369 |
$iDumped++;
|
370 |
}
|
371 |
|
372 |
-
$this->_log->
|
|
|
|
|
373 |
}
|
374 |
catch (Exception $e)
|
375 |
{
|
@@ -379,11 +381,6 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
379 |
return $iDumped > 0;
|
380 |
}
|
381 |
|
382 |
-
|
383 |
-
//
|
384 |
-
// public::Configuration
|
385 |
-
//
|
386 |
-
|
387 |
public function getContentType()
|
388 |
{
|
389 |
return self::CONTENT_TYPE;
|
@@ -394,20 +391,14 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
394 |
return Mage::getSingleton('doofinder_feed/config');
|
395 |
}
|
396 |
|
397 |
-
public function getConfigVar($key, $storeId = null,
|
398 |
-
$section = Doofinder_Feed_Model_Config::DEFAULT_SECTION)
|
399 |
{
|
400 |
return $this->getConfig()->getConfigVar($key, $storeId, $section);
|
401 |
}
|
402 |
|
403 |
-
|
404 |
-
//
|
405 |
-
// public::Tools
|
406 |
-
//
|
407 |
-
|
408 |
public function getStore()
|
409 |
{
|
410 |
-
if (
|
411 |
$this->_loadStore();
|
412 |
|
413 |
return $this->_store;
|
@@ -435,8 +426,7 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
435 |
|
436 |
public function getRootCategory()
|
437 |
{
|
438 |
-
if (
|
439 |
-
{
|
440 |
$this->_oRootCategory = Mage::getModel('catalog/category')->load(
|
441 |
$this->getStore()->getRootCategoryId()
|
442 |
);
|
@@ -454,12 +444,12 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
454 |
->addFieldToFilter('path', array('like' => $this->_oRootCategory->getPath() . '/%'))
|
455 |
->addFieldToFilter('is_active', array('eq'=>'1'));
|
456 |
|
457 |
-
$
|
458 |
'doofinder_cron/feed_settings/categories_in_navigation',
|
459 |
$this->getStoreId()
|
460 |
);
|
461 |
|
462 |
-
if($
|
463 |
$prodCategories->addFieldToFilter('include_in_menu', array('eq'=> '1'));
|
464 |
}
|
465 |
|
@@ -467,14 +457,13 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
467 |
|
468 |
$prodCategories = array_keys($prodCategories);
|
469 |
|
470 |
-
foreach ($prodCategories as $id)
|
471 |
-
{
|
472 |
if (isset($this->_categories[$id]))
|
473 |
$tree = $this->_categories[$id];
|
474 |
else
|
475 |
$tree = $this->_getCategoryTree($id);
|
476 |
|
477 |
-
if (
|
478 |
$categories[] = $tree;
|
479 |
}
|
480 |
|
@@ -483,8 +472,7 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
483 |
$nbcategories = count($categories);
|
484 |
$result = array();
|
485 |
|
486 |
-
for ($i = 1; $i < $nbcategories; $i++)
|
487 |
-
{
|
488 |
if (strpos($categories[$i], $categories[$i - 1]) === 0)
|
489 |
continue;
|
490 |
$result[] = $this->_cleanFieldValue($categories[$i - 1]);
|
@@ -518,12 +506,9 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
518 |
->addAttributeToSort('path', 'asc')
|
519 |
->addAttributeToSelect('*');
|
520 |
|
521 |
-
foreach ($categories as $category)
|
522 |
-
|
523 |
-
|
524 |
-
{
|
525 |
-
if (strlen($category->getName()))
|
526 |
-
{
|
527 |
$tree[] = strip_tags($category->getName());
|
528 |
}
|
529 |
}
|
@@ -549,17 +534,11 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
549 |
return Mage::getSingleton('doofinder_feed/tools');
|
550 |
}
|
551 |
|
552 |
-
|
553 |
-
//
|
554 |
-
// protected::Output
|
555 |
-
//
|
556 |
-
|
557 |
protected function _initFeed()
|
558 |
{
|
559 |
$this->_oXmlWriter = new XMLWriter();
|
560 |
$this->_oXmlWriter->openMemory();
|
561 |
-
if (!$this->getData('_offset_'))
|
562 |
-
{
|
563 |
$this->_log->debug('Opening feed');
|
564 |
|
565 |
$this->_oXmlWriter->startDocument('1.0', 'UTF-8');
|
@@ -573,8 +552,13 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
573 |
$this->_oXmlWriter->startElement('link');
|
574 |
$this->_oXmlWriter->writeCData(Mage::getBaseUrl().'doofinder/feed');
|
575 |
$this->_oXmlWriter->endElement();
|
|
|
576 |
$this->_oXmlWriter->writeElement('pubDate', strftime('%a, %d %b %Y %H:%M:%S %Z'));
|
577 |
-
|
|
|
|
|
|
|
|
|
578 |
$this->_oXmlWriter->writeElement('description', 'Magento Product feed for Doofinder');
|
579 |
|
580 |
$this->_flushFeed();
|
@@ -585,25 +569,21 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
585 |
{
|
586 |
$this->_response .= $this->_oXmlWriter->flush(true);
|
587 |
|
588 |
-
if ($break)
|
589 |
-
{
|
590 |
$this->_response .= PHP_EOL;
|
591 |
}
|
592 |
}
|
593 |
|
594 |
protected function _closeFeed()
|
595 |
{
|
596 |
-
if ($this->isFeedDone())
|
597 |
-
|
598 |
-
if (!$this->getData('_offset_'))
|
599 |
-
{
|
600 |
$this->_oXmlWriter->endElement(); // Channel
|
601 |
$this->_oXmlWriter->endElement(); // RSS
|
602 |
$this->_oXmlWriter->endDocument();
|
603 |
|
604 |
$this->_flushFeed();
|
605 |
-
} else
|
606 |
-
{
|
607 |
$this->_response .= '</channel></rss>';
|
608 |
}
|
609 |
}
|
@@ -614,9 +594,11 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
614 |
$sanitized = array();
|
615 |
|
616 |
foreach ($data as $key => $value)
|
617 |
-
$sanitized[$key] = str_replace(
|
618 |
-
|
619 |
-
|
|
|
|
|
620 |
|
621 |
return $sanitized;
|
622 |
}
|
@@ -636,18 +618,12 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
636 |
);
|
637 |
|
638 |
// Check if we should disable specific types
|
639 |
-
if (
|
640 |
-
$collection->addAttributeToFilter('type_id',
|
641 |
-
array('nin' => $disabled));
|
642 |
|
643 |
return $collection;
|
644 |
}
|
645 |
|
646 |
-
|
647 |
-
//
|
648 |
-
// protected::Tools
|
649 |
-
//
|
650 |
-
|
651 |
protected function _loadStore()
|
652 |
{
|
653 |
if (!$this->hasData('store_code'))
|
@@ -671,8 +647,7 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
671 |
->getMultipleSelectVar('additional_attributes', $storeId);
|
672 |
$model = Mage::getModel('catalog/product')->setStoreId($storeId);
|
673 |
|
674 |
-
foreach ($attributeCodes as $attrCode)
|
675 |
-
{
|
676 |
$attribute = $model->getResource()->getAttribute($attrCode);
|
677 |
$this->_attributes[$attribute->getAttributeCode()] = $attribute;
|
678 |
}
|
@@ -681,12 +656,16 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
681 |
protected function _getProductCollection($offset = 0, $limit = 0)
|
682 |
{
|
683 |
$collection = $this->getProductCollection($offset, $limit);
|
|
|
684 |
|
685 |
-
if (
|
686 |
-
$collection->addAttributeToFilter('entity_id', array('in' => $
|
687 |
|
688 |
-
if ($limit && $limit > 0)
|
|
|
689 |
$collection->getSelect()->limit($limit, 0);
|
|
|
|
|
690 |
|
691 |
if ($offset)
|
692 |
$collection->addAttributeToFilter('entity_id', array('gt' => $offset));
|
@@ -704,15 +683,21 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
704 |
$this->_addProductTypeToFilter($collection);
|
705 |
|
706 |
$collection->addAttributeToFilter('status', 1);
|
707 |
-
$collection->addAttributeToFilter(
|
708 |
-
|
709 |
-
|
710 |
-
|
|
|
|
|
|
|
711 |
$collection->addAttributeToSelect('*');
|
712 |
|
713 |
return $collection;
|
714 |
}
|
715 |
|
|
|
|
|
|
|
716 |
protected function _getProductMapModel($typeId, $args = array())
|
717 |
{
|
718 |
$isAssoc = isset($args['is_assoc']) && $args['is_assoc'] ? true : false;
|
@@ -739,16 +724,22 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
739 |
return null;
|
740 |
}
|
741 |
|
742 |
-
return Mage::getModel(
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
|
|
|
|
|
|
747 |
}
|
748 |
|
|
|
|
|
|
|
749 |
protected function _getFieldsMap()
|
750 |
{
|
751 |
-
if (
|
752 |
return $this->_fieldMap;
|
753 |
|
754 |
$product = Mage::getModel('catalog/product')
|
@@ -762,15 +753,15 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
762 |
$map = Mage::getStoreConfig('doofinder_cron/attributes_mapping', $this->getStore());
|
763 |
$additional = array();
|
764 |
if (isset($map['additional'])) {
|
|
|
765 |
$additional = unserialize($map['additional']);
|
|
|
766 |
}
|
767 |
|
768 |
unset($map['additional']);
|
769 |
|
770 |
-
if (!empty($additional['additional_mapping']))
|
771 |
-
|
772 |
-
foreach ($additional['additional_mapping'] as $data)
|
773 |
-
{
|
774 |
if (isset($map[$data['field']])) continue;
|
775 |
|
776 |
$fields[$data['field']] = array('label' => $data['label']);
|
@@ -778,17 +769,13 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
778 |
}
|
779 |
}
|
780 |
|
781 |
-
foreach ($map as $key => $attName)
|
782 |
-
{
|
783 |
if (!isset($fields[$key])) continue;
|
784 |
|
785 |
-
if (!$this->getConfig()->isDirective($attName,
|
786 |
-
$this->getStoreId()))
|
787 |
-
{
|
788 |
$att = $product->getResource()->getAttribute($attName);
|
789 |
|
790 |
-
if ($att === false)
|
791 |
-
{
|
792 |
continue;
|
793 |
}
|
794 |
|
@@ -802,13 +789,17 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
802 |
'field' => $key,
|
803 |
);
|
804 |
}
|
|
|
805 |
return $this->_fieldMap;
|
806 |
}
|
807 |
|
808 |
protected function _cleanFieldValue($field)
|
809 |
{
|
810 |
// http://stackoverflow.com/questions/4224141/php-removing-invalid-utf-8-characters-in-xml-using-filter
|
811 |
-
$
|
|
|
|
|
|
|
812 |
|
813 |
$field = preg_replace('#<br(\s?/)?>#i', ' ', $field);
|
814 |
$field = strip_tags($field);
|
@@ -817,11 +808,14 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
817 |
$exField = explode(self::CATEGORY_TREE_SEPARATOR, $field);
|
818 |
$newField = array();
|
819 |
foreach ($exField as $el) {
|
|
|
820 |
$newField[] = html_entity_decode($el, null, 'UTF-8');
|
|
|
821 |
}
|
822 |
-
$field = implode(self::CATEGORY_TREE_SEPARATOR, $newField );
|
823 |
|
824 |
-
|
|
|
|
|
825 |
}
|
826 |
|
827 |
/**
|
@@ -834,10 +828,8 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
834 |
{
|
835 |
$isFlat = true;
|
836 |
|
837 |
-
foreach ($arr as $item)
|
838 |
-
|
839 |
-
if (is_array($item))
|
840 |
-
{
|
841 |
$isFlat = false;
|
842 |
break;
|
843 |
}
|
@@ -854,9 +846,16 @@ class Doofinder_Feed_Model_Generator extends Varien_Object
|
|
854 |
* @param array @arr
|
855 |
* @return array
|
856 |
*/
|
857 |
-
protected function _flattenArray(array $arr)
|
|
|
858 |
$flattenedArray = array();
|
859 |
-
array_walk_recursive(
|
|
|
|
|
|
|
|
|
|
|
|
|
860 |
return $flattenedArray;
|
861 |
}
|
862 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Generator model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
if (!defined('DS'))
|
19 |
define('DS', DIRECTORY_SEPARATOR);
|
20 |
|
21 |
+
/**
|
22 |
+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
|
23 |
+
*/
|
24 |
class Doofinder_Feed_Model_Generator extends Varien_Object
|
25 |
{
|
26 |
const DEFAULT_BATCH_SIZE = 100;
|
51 |
|
52 |
protected $_errors = array();
|
53 |
|
54 |
+
protected $_lastProductId;
|
55 |
|
56 |
/**
|
57 |
* @var Doofinder_Feed_Helper_Log
|
91 |
}
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
94 |
public function run()
|
95 |
{
|
96 |
$this->_log->debug("Running generator");
|
146 |
public function getMaxProductId()
|
147 |
{
|
148 |
$collection = $this->_getProductCollection();
|
149 |
+
// @codingStandardsIgnoreStart
|
150 |
$collection->getSelect()->limit(1);
|
151 |
+
// @codingStandardsIgnoreEnd
|
152 |
$collection->getSelect()->order('e.entity_id DESC');
|
153 |
$item = $collection->fetchItem();
|
154 |
|
163 |
*/
|
164 |
public function isFeedDone()
|
165 |
{
|
166 |
+
return $this->_lastProductId >= $this->_maxProductId;
|
167 |
}
|
168 |
|
169 |
/**
|
173 |
*/
|
174 |
public function getLastProcessedProductId()
|
175 |
{
|
176 |
+
return $this->_lastProductId;
|
177 |
}
|
178 |
|
179 |
/**
|
189 |
$all = $collection->getSize();
|
190 |
|
191 |
$collection = $this->_getProductCollection();
|
192 |
+
$collection->addAttributeToFilter('entity_id', array('lteq' => $this->_lastProductId));
|
193 |
$now = $collection->getSize();
|
194 |
|
195 |
return $now / $all;
|
200 |
try
|
201 |
{
|
202 |
$row = $args['row'];
|
203 |
+
$this->_log->debugEnabled && $this->_log->debug(sprintf('Adding product %d to feed', $row['entity_id']));
|
|
|
|
|
204 |
|
205 |
+
$this->_lastProductId = $row['entity_id'];
|
206 |
|
207 |
$map = $this->_getProductMapModel($row['type_id'], array());
|
208 |
|
209 |
+
if ($map === null) {
|
210 |
Mage::throwException("There is no map definition for product with type {$row['type_id']}");
|
211 |
}
|
212 |
|
230 |
|
231 |
$map->unsetData();
|
232 |
|
233 |
+
$this->_log->debugEnabled && $this->_log->debug(sprintf('Product %d added to feed', $row['entity_id']));
|
234 |
}
|
235 |
catch (Exception $e)
|
236 |
{
|
237 |
+
$this->logError(
|
238 |
+
'Error processing product (ID: ' . $row['entity_id'] . '): ' . $e->getMessage(),
|
239 |
+
Zend_Log::ERR
|
240 |
+
);
|
241 |
}
|
242 |
}
|
243 |
|
|
|
|
|
|
|
|
|
|
|
244 |
protected function _batchProcessProducts($offset, $limit)
|
245 |
{
|
246 |
// Make sure we have this initialized
|
247 |
// in case of an empty collection
|
248 |
+
$this->_lastProductId = $offset;
|
249 |
|
250 |
$collection = $this->_getProductCollection($offset, $limit);
|
251 |
|
257 |
|
258 |
}
|
259 |
|
260 |
+
/**
|
261 |
+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
262 |
+
* @SuppressWarnings(PHPMD.NPathComplexity)
|
263 |
+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
264 |
+
*/
|
265 |
+
// @codingStandardsIgnoreStart
|
266 |
protected function _addProductToXml(
|
267 |
+
Doofinder_Feed_Model_Map_Product_Abstract $productMap
|
268 |
+
) {
|
269 |
+
// @codingStandardsIgnoreEnd
|
270 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
271 |
+
sprintf('Adding product %d to xml', $productMap->getProduct()->getId())
|
272 |
+
);
|
273 |
|
274 |
$iDumped = 0;
|
275 |
$displayPrice = $this->getDisplayPrice();
|
276 |
|
277 |
try
|
278 |
{
|
279 |
+
if ($productMap->isSkip()) {
|
280 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
281 |
+
sprintf('Product %d skipped', $productMap->getProduct()->getId())
|
282 |
+
);
|
283 |
$this->_iSkipped++;
|
284 |
return $this;
|
285 |
}
|
288 |
|
289 |
if ($productMap->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
|
290 |
&& $productMap->hasAssocMaps()
|
291 |
+
&& $productMap->getIsVariants()
|
292 |
+
) {
|
293 |
foreach ($productMap->getAssocMaps() as $assocMap)
|
294 |
if ($assocMap->isSkip())
|
295 |
$this->_iSkipped++;
|
296 |
}
|
297 |
|
298 |
+
if (($iProducts = !empty($productData))) {
|
|
|
299 |
$productData[0] = array_filter($productData[0]);
|
|
|
300 |
|
301 |
+
for ($i = 1; $i < $iProducts; $i++) {
|
|
|
302 |
$productData[$i] = array_merge(
|
303 |
$productData[0],
|
304 |
array_filter($productData[$i])
|
305 |
);
|
|
|
306 |
}
|
307 |
}
|
308 |
|
309 |
+
foreach ($productData as $data) {
|
|
|
310 |
$this->_oXmlWriter->startElement(self::PRODUCT_ELEMENT);
|
311 |
|
312 |
+
if (!isset($data['description'])) {
|
|
|
313 |
if (isset($data['long_description'])) {
|
314 |
$data['description'] = $data['long_description'];
|
315 |
unset($data['long_description']);
|
320 |
|
321 |
krsort($data);
|
322 |
|
323 |
+
foreach ($data as $field => $value) {
|
324 |
+
if (!is_array($value)) {
|
|
|
|
|
|
|
325 |
$value = trim($value);
|
326 |
}
|
327 |
|
328 |
+
if ($field != 'description' && empty($value)) {
|
|
|
329 |
continue;
|
330 |
}
|
331 |
|
332 |
+
if (!$displayPrice && ($field === 'price' || $field === 'sale_price')) {
|
|
|
333 |
continue;
|
334 |
}
|
335 |
|
336 |
$this->_oXmlWriter->startElement($field);
|
337 |
|
338 |
// Make sure $value is a flat array
|
339 |
+
if (!is_array($value)) {
|
|
|
340 |
$value = array($value);
|
341 |
+
} else if (!$this->_isArrayFlat($value)) {
|
342 |
+
$this->logErrorOnce(
|
343 |
+
"Value of $field field is a multidimensional array, encoded value: " .
|
344 |
+
json_encode($value)
|
345 |
+
);
|
346 |
$value = $this->_flattenArray($value);
|
347 |
}
|
348 |
|
349 |
$value = implode(self::VALUE_SEPARATOR, array_filter($value));
|
350 |
|
351 |
+
// @codingStandardsIgnoreStart
|
352 |
$written = @$this->_oXmlWriter->writeCData($value);
|
353 |
+
// @codingStandardsIgnoreEnd
|
354 |
+
if (!$written) {
|
355 |
$this->_oXmlWriter->writeComment("Cannot write the value for the $field field.");
|
356 |
|
357 |
+
$this->logErrorOnce(
|
358 |
+
"Cannot write the value for the $field field, encoded value: " .
|
359 |
+
json_encode($value)
|
360 |
+
);
|
361 |
}
|
362 |
|
363 |
$this->_oXmlWriter->endElement();
|
369 |
$iDumped++;
|
370 |
}
|
371 |
|
372 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
373 |
+
sprintf('Product %d added to xml', $productMap->getProduct()->getId())
|
374 |
+
);
|
375 |
}
|
376 |
catch (Exception $e)
|
377 |
{
|
381 |
return $iDumped > 0;
|
382 |
}
|
383 |
|
|
|
|
|
|
|
|
|
|
|
384 |
public function getContentType()
|
385 |
{
|
386 |
return self::CONTENT_TYPE;
|
391 |
return Mage::getSingleton('doofinder_feed/config');
|
392 |
}
|
393 |
|
394 |
+
public function getConfigVar($key, $storeId = null, $section = Doofinder_Feed_Model_Config::DEFAULT_SECTION)
|
|
|
395 |
{
|
396 |
return $this->getConfig()->getConfigVar($key, $storeId, $section);
|
397 |
}
|
398 |
|
|
|
|
|
|
|
|
|
|
|
399 |
public function getStore()
|
400 |
{
|
401 |
+
if ($this->_store === null)
|
402 |
$this->_loadStore();
|
403 |
|
404 |
return $this->_store;
|
426 |
|
427 |
public function getRootCategory()
|
428 |
{
|
429 |
+
if ($this->_oRootCategory === null) {
|
|
|
430 |
$this->_oRootCategory = Mage::getModel('catalog/category')->load(
|
431 |
$this->getStore()->getRootCategoryId()
|
432 |
);
|
444 |
->addFieldToFilter('path', array('like' => $this->_oRootCategory->getPath() . '/%'))
|
445 |
->addFieldToFilter('is_active', array('eq'=>'1'));
|
446 |
|
447 |
+
$includeInMenu = Mage::getStoreConfig(
|
448 |
'doofinder_cron/feed_settings/categories_in_navigation',
|
449 |
$this->getStoreId()
|
450 |
);
|
451 |
|
452 |
+
if ($includeInMenu == 1) {
|
453 |
$prodCategories->addFieldToFilter('include_in_menu', array('eq'=> '1'));
|
454 |
}
|
455 |
|
457 |
|
458 |
$prodCategories = array_keys($prodCategories);
|
459 |
|
460 |
+
foreach ($prodCategories as $id) {
|
|
|
461 |
if (isset($this->_categories[$id]))
|
462 |
$tree = $this->_categories[$id];
|
463 |
else
|
464 |
$tree = $this->_getCategoryTree($id);
|
465 |
|
466 |
+
if ($tree)
|
467 |
$categories[] = $tree;
|
468 |
}
|
469 |
|
472 |
$nbcategories = count($categories);
|
473 |
$result = array();
|
474 |
|
475 |
+
for ($i = 1; $i < $nbcategories; $i++) {
|
|
|
476 |
if (strpos($categories[$i], $categories[$i - 1]) === 0)
|
477 |
continue;
|
478 |
$result[] = $this->_cleanFieldValue($categories[$i - 1]);
|
506 |
->addAttributeToSort('path', 'asc')
|
507 |
->addAttributeToSelect('*');
|
508 |
|
509 |
+
foreach ($categories as $category) {
|
510 |
+
if ($category->getId() != $this->_oRootCategory->getId()) {
|
511 |
+
if ($category->getName()) {
|
|
|
|
|
|
|
512 |
$tree[] = strip_tags($category->getName());
|
513 |
}
|
514 |
}
|
534 |
return Mage::getSingleton('doofinder_feed/tools');
|
535 |
}
|
536 |
|
|
|
|
|
|
|
|
|
|
|
537 |
protected function _initFeed()
|
538 |
{
|
539 |
$this->_oXmlWriter = new XMLWriter();
|
540 |
$this->_oXmlWriter->openMemory();
|
541 |
+
if (!$this->getData('_offset_')) {
|
|
|
542 |
$this->_log->debug('Opening feed');
|
543 |
|
544 |
$this->_oXmlWriter->startDocument('1.0', 'UTF-8');
|
552 |
$this->_oXmlWriter->startElement('link');
|
553 |
$this->_oXmlWriter->writeCData(Mage::getBaseUrl().'doofinder/feed');
|
554 |
$this->_oXmlWriter->endElement();
|
555 |
+
// @codingStandardsIgnoreStart
|
556 |
$this->_oXmlWriter->writeElement('pubDate', strftime('%a, %d %b %Y %H:%M:%S %Z'));
|
557 |
+
// @codingStandardsIgnoreEnd
|
558 |
+
$this->_oXmlWriter->writeElement(
|
559 |
+
'generator',
|
560 |
+
'Doofinder/' . Mage::getConfig()->getModuleConfig("Doofinder_Feed")->version
|
561 |
+
);
|
562 |
$this->_oXmlWriter->writeElement('description', 'Magento Product feed for Doofinder');
|
563 |
|
564 |
$this->_flushFeed();
|
569 |
{
|
570 |
$this->_response .= $this->_oXmlWriter->flush(true);
|
571 |
|
572 |
+
if ($break) {
|
|
|
573 |
$this->_response .= PHP_EOL;
|
574 |
}
|
575 |
}
|
576 |
|
577 |
protected function _closeFeed()
|
578 |
{
|
579 |
+
if ($this->isFeedDone()) {
|
580 |
+
if (!$this->getData('_offset_')) {
|
|
|
|
|
581 |
$this->_oXmlWriter->endElement(); // Channel
|
582 |
$this->_oXmlWriter->endElement(); // RSS
|
583 |
$this->_oXmlWriter->endDocument();
|
584 |
|
585 |
$this->_flushFeed();
|
586 |
+
} else {
|
|
|
587 |
$this->_response .= '</channel></rss>';
|
588 |
}
|
589 |
}
|
594 |
$sanitized = array();
|
595 |
|
596 |
foreach ($data as $key => $value)
|
597 |
+
$sanitized[$key] = str_replace(
|
598 |
+
$this->_badChars,
|
599 |
+
$this->_repChars,
|
600 |
+
$value
|
601 |
+
);
|
602 |
|
603 |
return $sanitized;
|
604 |
}
|
618 |
);
|
619 |
|
620 |
// Check if we should disable specific types
|
621 |
+
if (!empty($disabled))
|
622 |
+
$collection->addAttributeToFilter('type_id', array('nin' => $disabled));
|
|
|
623 |
|
624 |
return $collection;
|
625 |
}
|
626 |
|
|
|
|
|
|
|
|
|
|
|
627 |
protected function _loadStore()
|
628 |
{
|
629 |
if (!$this->hasData('store_code'))
|
647 |
->getMultipleSelectVar('additional_attributes', $storeId);
|
648 |
$model = Mage::getModel('catalog/product')->setStoreId($storeId);
|
649 |
|
650 |
+
foreach ($attributeCodes as $attrCode) {
|
|
|
651 |
$attribute = $model->getResource()->getAttribute($attrCode);
|
652 |
$this->_attributes[$attribute->getAttributeCode()] = $attribute;
|
653 |
}
|
656 |
protected function _getProductCollection($offset = 0, $limit = 0)
|
657 |
{
|
658 |
$collection = $this->getProductCollection($offset, $limit);
|
659 |
+
$products = $this->getProducts();
|
660 |
|
661 |
+
if (!empty($products))
|
662 |
+
$collection->addAttributeToFilter('entity_id', array('in' => $products));
|
663 |
|
664 |
+
if ($limit && $limit > 0) {
|
665 |
+
// @codingStandardsIgnoreStart
|
666 |
$collection->getSelect()->limit($limit, 0);
|
667 |
+
// @codingStandardsIgnoreEnd
|
668 |
+
}
|
669 |
|
670 |
if ($offset)
|
671 |
$collection->addAttributeToFilter('entity_id', array('gt' => $offset));
|
683 |
$this->_addProductTypeToFilter($collection);
|
684 |
|
685 |
$collection->addAttributeToFilter('status', 1);
|
686 |
+
$collection->addAttributeToFilter(
|
687 |
+
'visibility',
|
688 |
+
array(
|
689 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
|
690 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH
|
691 |
+
)
|
692 |
+
);
|
693 |
$collection->addAttributeToSelect('*');
|
694 |
|
695 |
return $collection;
|
696 |
}
|
697 |
|
698 |
+
/**
|
699 |
+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
700 |
+
*/
|
701 |
protected function _getProductMapModel($typeId, $args = array())
|
702 |
{
|
703 |
$isAssoc = isset($args['is_assoc']) && $args['is_assoc'] ? true : false;
|
724 |
return null;
|
725 |
}
|
726 |
|
727 |
+
return Mage::getModel(
|
728 |
+
$model,
|
729 |
+
array(
|
730 |
+
'store_code' => $this->getStoreCode(),
|
731 |
+
'store_id' => $this->getStoreId(),
|
732 |
+
'website_id' => $this->getWebsiteId(),
|
733 |
+
)
|
734 |
+
);
|
735 |
}
|
736 |
|
737 |
+
/**
|
738 |
+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
739 |
+
*/
|
740 |
protected function _getFieldsMap()
|
741 |
{
|
742 |
+
if ($this->_fieldMap !== null)
|
743 |
return $this->_fieldMap;
|
744 |
|
745 |
$product = Mage::getModel('catalog/product')
|
753 |
$map = Mage::getStoreConfig('doofinder_cron/attributes_mapping', $this->getStore());
|
754 |
$additional = array();
|
755 |
if (isset($map['additional'])) {
|
756 |
+
// @codingStandardsIgnoreStart
|
757 |
$additional = unserialize($map['additional']);
|
758 |
+
// @codingStandardsIgnoreEnd
|
759 |
}
|
760 |
|
761 |
unset($map['additional']);
|
762 |
|
763 |
+
if (!empty($additional['additional_mapping'])) {
|
764 |
+
foreach ($additional['additional_mapping'] as $data) {
|
|
|
|
|
765 |
if (isset($map[$data['field']])) continue;
|
766 |
|
767 |
$fields[$data['field']] = array('label' => $data['label']);
|
769 |
}
|
770 |
}
|
771 |
|
772 |
+
foreach ($map as $key => $attName) {
|
|
|
773 |
if (!isset($fields[$key])) continue;
|
774 |
|
775 |
+
if (!$this->getConfig()->isDirective($attName, $this->getStoreId())) {
|
|
|
|
|
776 |
$att = $product->getResource()->getAttribute($attName);
|
777 |
|
778 |
+
if ($att === false) {
|
|
|
779 |
continue;
|
780 |
}
|
781 |
|
789 |
'field' => $key,
|
790 |
);
|
791 |
}
|
792 |
+
|
793 |
return $this->_fieldMap;
|
794 |
}
|
795 |
|
796 |
protected function _cleanFieldValue($field)
|
797 |
{
|
798 |
// http://stackoverflow.com/questions/4224141/php-removing-invalid-utf-8-characters-in-xml-using-filter
|
799 |
+
$validUtf = '/([\x09\x0A\x0D\x20-\x7E]|[\xC2-\xDF][\x80-\xBF]|' .
|
800 |
+
'\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|' .
|
801 |
+
'\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|' .
|
802 |
+
'[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})|./x';
|
803 |
|
804 |
$field = preg_replace('#<br(\s?/)?>#i', ' ', $field);
|
805 |
$field = strip_tags($field);
|
808 |
$exField = explode(self::CATEGORY_TREE_SEPARATOR, $field);
|
809 |
$newField = array();
|
810 |
foreach ($exField as $el) {
|
811 |
+
// @codingStandardsIgnoreStart
|
812 |
$newField[] = html_entity_decode($el, null, 'UTF-8');
|
813 |
+
// @codingStandardsIgnoreEnd
|
814 |
}
|
|
|
815 |
|
816 |
+
$field = implode(self::CATEGORY_TREE_SEPARATOR, $newField);
|
817 |
+
|
818 |
+
return preg_replace($validUtf, '$1', $field);
|
819 |
}
|
820 |
|
821 |
/**
|
828 |
{
|
829 |
$isFlat = true;
|
830 |
|
831 |
+
foreach ($arr as $item) {
|
832 |
+
if (is_array($item)) {
|
|
|
|
|
833 |
$isFlat = false;
|
834 |
break;
|
835 |
}
|
846 |
* @param array @arr
|
847 |
* @return array
|
848 |
*/
|
849 |
+
protected function _flattenArray(array $arr)
|
850 |
+
{
|
851 |
$flattenedArray = array();
|
852 |
+
array_walk_recursive(
|
853 |
+
$arr,
|
854 |
+
function ($item) use (&$flattenedArray) {
|
855 |
+
$flattenedArray[] = $item;
|
856 |
+
}
|
857 |
+
);
|
858 |
+
|
859 |
return $flattenedArray;
|
860 |
}
|
861 |
}
|
app/code/community/Doofinder/Feed/Model/Log.php
CHANGED
@@ -6,12 +6,13 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
-
class Doofinder_Feed_Model_Log extends Mage_Core_Model_Abstract
|
13 |
-
|
14 |
-
protected function _construct()
|
|
|
15 |
$this->_init('doofinder_feed/log');
|
16 |
}
|
17 |
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
+
class Doofinder_Feed_Model_Log extends Mage_Core_Model_Abstract
|
13 |
+
{
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
$this->_init('doofinder_feed/log');
|
17 |
}
|
18 |
|
app/code/community/Doofinder/Feed/Model/Map/Product/Abstract.php
CHANGED
@@ -6,19 +6,19 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Abstract Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
19 |
{
|
20 |
-
protected $
|
21 |
-
protected $
|
22 |
protected $_attributeSetModel;
|
23 |
|
24 |
/**
|
@@ -37,23 +37,25 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
37 |
|
38 |
public function initialize()
|
39 |
{
|
40 |
-
$this->_log->
|
|
|
|
|
41 |
|
42 |
-
$
|
43 |
->getStore($this->getData('store_code'))
|
44 |
->getCurrentCurrencyCode();
|
45 |
|
46 |
-
$
|
47 |
->getStore($this->getData('store_id'))
|
48 |
->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA, false);
|
49 |
-
$
|
50 |
|
51 |
-
$
|
52 |
->getBaseMediaPath();
|
53 |
|
54 |
-
$this->setData('store_currency_code', $
|
55 |
-
$this->setData('images_url_prefix', $
|
56 |
-
$this->setData('images_path_prefix', $
|
57 |
|
58 |
$this->_attributeSetModel = Mage::getModel('eav/entity_attribute_set');
|
59 |
|
@@ -62,13 +64,15 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
62 |
|
63 |
public function map()
|
64 |
{
|
65 |
-
$this->_log->
|
66 |
|
67 |
$this->_beforeMap();
|
68 |
$rows = $this->_map();
|
69 |
$this->_afterMap($rows);
|
70 |
|
71 |
-
$this->_log->
|
|
|
|
|
72 |
|
73 |
return $rows;
|
74 |
}
|
@@ -78,16 +82,14 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
78 |
return $this;
|
79 |
}
|
80 |
|
|
|
|
|
|
|
81 |
public function _afterMap($rows)
|
82 |
{
|
83 |
return $this;
|
84 |
}
|
85 |
|
86 |
-
|
87 |
-
//
|
88 |
-
// protected::Mapping
|
89 |
-
//
|
90 |
-
|
91 |
/**
|
92 |
* @return array('column' => 'value')
|
93 |
*/
|
@@ -95,17 +97,14 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
95 |
{
|
96 |
$fields = array();
|
97 |
|
98 |
-
foreach ($this->
|
99 |
$fields[$column] = $this->mapField($column);
|
100 |
-
|
101 |
-
// $fields['magento_store'] = $this->getData('store_code');
|
102 |
|
103 |
$this->_attributeSetModel->load(
|
104 |
-
$this->getProduct()->getAttributeSetId()
|
105 |
-
|
106 |
-
// ->getAttributeSetName();
|
107 |
|
108 |
-
$i = 0;
|
109 |
$categories = $this->getGenerator()->getCategories($this->getProduct());
|
110 |
$fields['categories'] = implode(
|
111 |
Doofinder_Feed_Model_Generator::CATEGORY_SEPARATOR,
|
@@ -119,10 +118,10 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
119 |
{
|
120 |
$value = "";
|
121 |
|
122 |
-
if (!isset($this->
|
123 |
return $value;
|
124 |
|
125 |
-
$args = array('map' => $this->
|
126 |
$method = 'mapField' . $this->_camelize($column);
|
127 |
|
128 |
if (method_exists($this, $method))
|
@@ -148,29 +147,10 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
148 |
return $this->cleanField($fieldData);
|
149 |
}
|
150 |
|
151 |
-
protected function mapDoofinderAttribute($attribute, $product = null)
|
152 |
-
{
|
153 |
-
if (is_null($product))
|
154 |
-
$product = $this->getProduct();
|
155 |
-
|
156 |
-
if ($attribute === false)
|
157 |
-
$this->_attributeDoesNotExist($map['attribute']);
|
158 |
-
|
159 |
-
$fieldData = $this->getAttributeValue($product, $attribute);
|
160 |
-
|
161 |
-
return $this->cleanField($fieldData);
|
162 |
-
}
|
163 |
-
|
164 |
-
|
165 |
-
//
|
166 |
-
// protected::Mapping::Attributes
|
167 |
-
//
|
168 |
-
|
169 |
protected function mapAttributeDescription($params = array())
|
170 |
{
|
171 |
$map = $params['map'];
|
172 |
$product = $this->getProduct();
|
173 |
-
$fieldData = "";
|
174 |
|
175 |
$attribute = $this->getGenerator()
|
176 |
->getAttribute($map['attribute']);
|
@@ -183,17 +163,9 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
183 |
return $this->cleanField($description);
|
184 |
}
|
185 |
|
186 |
-
|
187 |
-
//
|
188 |
-
// protected::Mapping::Directives
|
189 |
-
//
|
190 |
-
|
191 |
protected function mapDirectiveId()
|
192 |
{
|
193 |
-
// $storeCode = $this->getStoreCode();
|
194 |
$fieldData = $this->getProduct()->getId();
|
195 |
-
// $fieldData .= '_'.preg_replace('/[^a-zA-Z0-9]/', '', $storeCode);
|
196 |
-
|
197 |
return $this->cleanField($fieldData);
|
198 |
}
|
199 |
|
@@ -203,8 +175,13 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
203 |
return $product->getUrlModel()->getUrl($product, array('_nosid' => true));
|
204 |
}
|
205 |
|
|
|
|
|
|
|
|
|
206 |
protected function mapDirectiveImageLink($args, $attributeName = 'image')
|
207 |
{
|
|
|
208 |
$product = $this->getProduct();
|
209 |
$image = $product->getData($attributeName);
|
210 |
|
@@ -297,15 +274,14 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
297 |
|
298 |
$defaultVal = isset($map['default_value']) ? $map['default_value'] : "";
|
299 |
|
300 |
-
if ($defaultVal != "")
|
301 |
-
|
302 |
-
$
|
303 |
-
$stock_status = trim(strtolower($stock_status));
|
304 |
|
305 |
-
if (false === array_search($
|
306 |
-
$
|
307 |
|
308 |
-
$fieldData = $
|
309 |
$fieldData = $this->cleanField($fieldData);
|
310 |
|
311 |
return $fieldData;
|
@@ -327,7 +303,6 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
327 |
protected function mapDirectiveCondition($params = array())
|
328 |
{
|
329 |
$map = $params['map'];
|
330 |
-
$product = $this->getProduct();
|
331 |
|
332 |
$defaultVal = isset($map['default_value']) ? $map['default_value'] : "";
|
333 |
$defaultVal = trim(strtolower($defaultVal));
|
@@ -351,19 +326,16 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
351 |
$args = array('map' => $params['map']);
|
352 |
$value = "";
|
353 |
|
354 |
-
$
|
355 |
'product_type_by_category',
|
356 |
$this->getStoreId()
|
357 |
);
|
358 |
|
359 |
-
$
|
360 |
|
361 |
-
if (!empty($
|
362 |
-
|
363 |
-
|
364 |
-
{
|
365 |
-
if (array_search($arr['category'], $category_ids) !== false)
|
366 |
-
{
|
367 |
$value = $arr['value'];
|
368 |
break;
|
369 |
}
|
@@ -378,26 +350,18 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
378 |
return htmlspecialchars_decode($value);
|
379 |
}
|
380 |
|
381 |
-
|
382 |
-
//
|
383 |
-
// public::Tools
|
384 |
-
//
|
385 |
-
|
386 |
public function getFieldValue($args = array())
|
387 |
{
|
388 |
$value = "";
|
389 |
$attName = $args['map']['attribute'];
|
390 |
|
391 |
-
if ($this->getConfig()->isDirective($attName, $this->getStoreId()))
|
392 |
-
{
|
393 |
$attName = str_replace('df_directive_', '', $attName);
|
394 |
$method = 'mapDirective' . $this->_camelize($attName);
|
395 |
|
396 |
if (method_exists($this, $method))
|
397 |
$value = $this->$method($args);
|
398 |
-
}
|
399 |
-
else
|
400 |
-
{
|
401 |
$method = 'mapAttribute' . $this->_camelize($attName);
|
402 |
|
403 |
if (method_exists($this, $method))
|
@@ -414,13 +378,11 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
414 |
$attrCode = $attribute->getAttributeCode();
|
415 |
|
416 |
if ($attribute->getFrontendInput() == 'select'
|
417 |
-
|| $attribute->getFrontendInput() == 'multiselect'
|
418 |
-
{
|
419 |
-
if (
|
420 |
$value = $product->getAttributeText($attrCode);
|
421 |
-
}
|
422 |
-
else
|
423 |
-
{
|
424 |
$value = $product->getData($attrCode);
|
425 |
}
|
426 |
|
@@ -434,13 +396,12 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
434 |
if ($product->getTypeId() != Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)
|
435 |
return false;
|
436 |
|
437 |
-
$
|
438 |
-
if ($
|
439 |
return $assocIds;
|
440 |
|
441 |
-
$
|
442 |
-
foreach ($
|
443 |
-
{
|
444 |
$attr = $this->getGenerator()->getAttribute('status');
|
445 |
$status = $this->getTools()->getProductAttributeValueBySql(
|
446 |
$attr,
|
@@ -459,42 +420,14 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
459 |
return $assocIds;
|
460 |
}
|
461 |
|
462 |
-
//
|
463 |
-
// protected::Tools
|
464 |
-
//
|
465 |
-
|
466 |
-
// protected function hasImage($product)
|
467 |
-
// {
|
468 |
-
// $image = $product->getData('image');
|
469 |
-
// $validator = new Zend_Validate_File_Exists;
|
470 |
-
|
471 |
-
// if ($image != 'no_selection' && $image != "")
|
472 |
-
// {
|
473 |
-
// // if ($validator->isValid($this->getData('images_path_prefix') . $image) != 'fileExistsDoesNotExist')
|
474 |
-
// // return false;
|
475 |
-
// if (!is_file($this->getData('images_path_prefix') . $image))
|
476 |
-
// return false;
|
477 |
-
// }
|
478 |
-
// else
|
479 |
-
// {
|
480 |
-
// return false;
|
481 |
-
// }
|
482 |
-
|
483 |
-
// return true;
|
484 |
-
// }
|
485 |
-
|
486 |
protected function cleanField($field)
|
487 |
{
|
488 |
-
if (is_array($field))
|
489 |
-
|
490 |
-
foreach ($field as &$value)
|
491 |
-
{
|
492 |
$value = $this->cleanFieldValue($value);
|
493 |
unset($value);
|
494 |
}
|
495 |
-
}
|
496 |
-
else
|
497 |
-
{
|
498 |
$field = $this->cleanFieldValue($field);
|
499 |
}
|
500 |
|
@@ -523,15 +456,20 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
523 |
protected function _cleanFieldValue($field)
|
524 |
{
|
525 |
// http://stackoverflow.com/questions/4224141/php-removing-invalid-utf-8-characters-in-xml-using-filter
|
526 |
-
$
|
|
|
|
|
|
|
527 |
|
528 |
$field = preg_replace('#<br(\s?/)?>#i', ' ', $field);
|
529 |
$field = strip_tags($field);
|
530 |
$field = preg_replace('/[ ]{2,}/', ' ', $field);
|
531 |
$field = trim($field);
|
|
|
532 |
$field = html_entity_decode($field, null, 'UTF-8');
|
|
|
533 |
|
534 |
-
return preg_replace($
|
535 |
}
|
536 |
|
537 |
protected function _attributeDoesNotExist($attName)
|
@@ -539,18 +477,12 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
539 |
Mage::throwException($attName . ' attribute does not exist!');
|
540 |
}
|
541 |
|
542 |
-
|
543 |
-
//
|
544 |
-
// public::Config
|
545 |
-
//
|
546 |
-
|
547 |
public function getConfig()
|
548 |
{
|
549 |
return $this->getGenerator()->getConfig();
|
550 |
}
|
551 |
|
552 |
-
public function getConfigVar($key,
|
553 |
-
$section = Doofinder_Feed_Model_Config::DEFAULT_SECTION)
|
554 |
{
|
555 |
return $this->getGenerator()->getConfigVar($key, null, $section);
|
556 |
}
|
@@ -562,7 +494,7 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
562 |
|
563 |
public function isSkip()
|
564 |
{
|
565 |
-
return $this->
|
566 |
}
|
567 |
|
568 |
public function checkSkipSubmission()
|
@@ -572,7 +504,7 @@ class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
|
572 |
|
573 |
public function setFieldsMap($arr)
|
574 |
{
|
575 |
-
$this->
|
576 |
|
577 |
return $this;
|
578 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Abstract Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
|
19 |
{
|
20 |
+
protected $_fieldMap = null;
|
21 |
+
protected $_skip = false;
|
22 |
protected $_attributeSetModel;
|
23 |
|
24 |
/**
|
37 |
|
38 |
public function initialize()
|
39 |
{
|
40 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
41 |
+
sprintf('Initializing %s for product %d', get_called_class(), $this->getProduct()->getId())
|
42 |
+
);
|
43 |
|
44 |
+
$currencyCode = Mage::app()
|
45 |
->getStore($this->getData('store_code'))
|
46 |
->getCurrentCurrencyCode();
|
47 |
|
48 |
+
$imagesUrlPrefix = Mage::app()
|
49 |
->getStore($this->getData('store_id'))
|
50 |
->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA, false);
|
51 |
+
$imagesUrlPrefix .= 'catalog/product';
|
52 |
|
53 |
+
$imagesPathPrefix = Mage::getSingleton('catalog/product_media_config')
|
54 |
->getBaseMediaPath();
|
55 |
|
56 |
+
$this->setData('store_currency_code', $currencyCode);
|
57 |
+
$this->setData('images_url_prefix', $imagesUrlPrefix);
|
58 |
+
$this->setData('images_path_prefix', $imagesPathPrefix);
|
59 |
|
60 |
$this->_attributeSetModel = Mage::getModel('eav/entity_attribute_set');
|
61 |
|
64 |
|
65 |
public function map()
|
66 |
{
|
67 |
+
$this->_log->debugEnabled && $this->_log->debug(sprintf('Mapping product %d', $this->getProduct()->getId()));
|
68 |
|
69 |
$this->_beforeMap();
|
70 |
$rows = $this->_map();
|
71 |
$this->_afterMap($rows);
|
72 |
|
73 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
74 |
+
sprintf('Map for product %d: %s', $this->getProduct()->getId(), json_encode($rows))
|
75 |
+
);
|
76 |
|
77 |
return $rows;
|
78 |
}
|
82 |
return $this;
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
87 |
+
*/
|
88 |
public function _afterMap($rows)
|
89 |
{
|
90 |
return $this;
|
91 |
}
|
92 |
|
|
|
|
|
|
|
|
|
|
|
93 |
/**
|
94 |
* @return array('column' => 'value')
|
95 |
*/
|
97 |
{
|
98 |
$fields = array();
|
99 |
|
100 |
+
foreach (array_keys($this->_fieldMap) as $column) {
|
101 |
$fields[$column] = $this->mapField($column);
|
102 |
+
}
|
|
|
103 |
|
104 |
$this->_attributeSetModel->load(
|
105 |
+
$this->getProduct()->getAttributeSetId()
|
106 |
+
);
|
|
|
107 |
|
|
|
108 |
$categories = $this->getGenerator()->getCategories($this->getProduct());
|
109 |
$fields['categories'] = implode(
|
110 |
Doofinder_Feed_Model_Generator::CATEGORY_SEPARATOR,
|
118 |
{
|
119 |
$value = "";
|
120 |
|
121 |
+
if (!isset($this->_fieldMap[$column]))
|
122 |
return $value;
|
123 |
|
124 |
+
$args = array('map' => $this->_fieldMap[$column]);
|
125 |
$method = 'mapField' . $this->_camelize($column);
|
126 |
|
127 |
if (method_exists($this, $method))
|
147 |
return $this->cleanField($fieldData);
|
148 |
}
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
protected function mapAttributeDescription($params = array())
|
151 |
{
|
152 |
$map = $params['map'];
|
153 |
$product = $this->getProduct();
|
|
|
154 |
|
155 |
$attribute = $this->getGenerator()
|
156 |
->getAttribute($map['attribute']);
|
163 |
return $this->cleanField($description);
|
164 |
}
|
165 |
|
|
|
|
|
|
|
|
|
|
|
166 |
protected function mapDirectiveId()
|
167 |
{
|
|
|
168 |
$fieldData = $this->getProduct()->getId();
|
|
|
|
|
169 |
return $this->cleanField($fieldData);
|
170 |
}
|
171 |
|
175 |
return $product->getUrlModel()->getUrl($product, array('_nosid' => true));
|
176 |
}
|
177 |
|
178 |
+
/**
|
179 |
+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
180 |
+
*/
|
181 |
+
// @codingStandardsIgnoreStart
|
182 |
protected function mapDirectiveImageLink($args, $attributeName = 'image')
|
183 |
{
|
184 |
+
// @codingStandardsIgnoreEnd
|
185 |
$product = $this->getProduct();
|
186 |
$image = $product->getData($attributeName);
|
187 |
|
274 |
|
275 |
$defaultVal = isset($map['default_value']) ? $map['default_value'] : "";
|
276 |
|
277 |
+
if ($defaultVal != "") {
|
278 |
+
$stockStatus = $defaultVal;
|
279 |
+
$stockStatus = trim(strtolower($stockStatus));
|
|
|
280 |
|
281 |
+
if (false === array_search($stockStatus, (array) $this->getConfig()->getAllowedStockStatuses()))
|
282 |
+
$stockStatus = $this->getConfig()->getOutOfStockStatus();
|
283 |
|
284 |
+
$fieldData = $stockStatus;
|
285 |
$fieldData = $this->cleanField($fieldData);
|
286 |
|
287 |
return $fieldData;
|
303 |
protected function mapDirectiveCondition($params = array())
|
304 |
{
|
305 |
$map = $params['map'];
|
|
|
306 |
|
307 |
$defaultVal = isset($map['default_value']) ? $map['default_value'] : "";
|
308 |
$defaultVal = trim(strtolower($defaultVal));
|
326 |
$args = array('map' => $params['map']);
|
327 |
$value = "";
|
328 |
|
329 |
+
$mapByCategory = $this->getConfig()->getMapCategorySorted(
|
330 |
'product_type_by_category',
|
331 |
$this->getStoreId()
|
332 |
);
|
333 |
|
334 |
+
$categoryIds = $this->getProduct()->getCategoryIds();
|
335 |
|
336 |
+
if (!empty($categoryIds) && !empty($mapByCategory)) {
|
337 |
+
foreach ($mapByCategory as $arr) {
|
338 |
+
if (array_search($arr['category'], $categoryIds) !== false) {
|
|
|
|
|
|
|
339 |
$value = $arr['value'];
|
340 |
break;
|
341 |
}
|
350 |
return htmlspecialchars_decode($value);
|
351 |
}
|
352 |
|
|
|
|
|
|
|
|
|
|
|
353 |
public function getFieldValue($args = array())
|
354 |
{
|
355 |
$value = "";
|
356 |
$attName = $args['map']['attribute'];
|
357 |
|
358 |
+
if ($this->getConfig()->isDirective($attName, $this->getStoreId())) {
|
|
|
359 |
$attName = str_replace('df_directive_', '', $attName);
|
360 |
$method = 'mapDirective' . $this->_camelize($attName);
|
361 |
|
362 |
if (method_exists($this, $method))
|
363 |
$value = $this->$method($args);
|
364 |
+
} else {
|
|
|
|
|
365 |
$method = 'mapAttribute' . $this->_camelize($attName);
|
366 |
|
367 |
if (method_exists($this, $method))
|
378 |
$attrCode = $attribute->getAttributeCode();
|
379 |
|
380 |
if ($attribute->getFrontendInput() == 'select'
|
381 |
+
|| $attribute->getFrontendInput() == 'multiselect'
|
382 |
+
) {
|
383 |
+
if ($product->getResource()->getAttribute($attrCode) !== null)
|
384 |
$value = $product->getAttributeText($attrCode);
|
385 |
+
} else {
|
|
|
|
|
386 |
$value = $product->getData($attrCode);
|
387 |
}
|
388 |
|
396 |
if ($product->getTypeId() != Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)
|
397 |
return false;
|
398 |
|
399 |
+
$children = $this->getTools()->getChildsIds($product->getId());
|
400 |
+
if ($children === false)
|
401 |
return $assocIds;
|
402 |
|
403 |
+
$children = $this->getTools()->getProductInStoresIds($children);
|
404 |
+
foreach ($children as $assocId => $s) {
|
|
|
405 |
$attr = $this->getGenerator()->getAttribute('status');
|
406 |
$status = $this->getTools()->getProductAttributeValueBySql(
|
407 |
$attr,
|
420 |
return $assocIds;
|
421 |
}
|
422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
protected function cleanField($field)
|
424 |
{
|
425 |
+
if (is_array($field)) {
|
426 |
+
foreach ($field as &$value) {
|
|
|
|
|
427 |
$value = $this->cleanFieldValue($value);
|
428 |
unset($value);
|
429 |
}
|
430 |
+
} else {
|
|
|
|
|
431 |
$field = $this->cleanFieldValue($field);
|
432 |
}
|
433 |
|
456 |
protected function _cleanFieldValue($field)
|
457 |
{
|
458 |
// http://stackoverflow.com/questions/4224141/php-removing-invalid-utf-8-characters-in-xml-using-filter
|
459 |
+
$validUtf = '/([\x09\x0A\x0D\x20-\x7E]|[\xC2-\xDF][\x80-\xBF]|' .
|
460 |
+
'\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|' .
|
461 |
+
'\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|' .
|
462 |
+
'[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})|./x';
|
463 |
|
464 |
$field = preg_replace('#<br(\s?/)?>#i', ' ', $field);
|
465 |
$field = strip_tags($field);
|
466 |
$field = preg_replace('/[ ]{2,}/', ' ', $field);
|
467 |
$field = trim($field);
|
468 |
+
// @codingStandardsIgnoreStart
|
469 |
$field = html_entity_decode($field, null, 'UTF-8');
|
470 |
+
// @codingStandardsIgnoreEnd
|
471 |
|
472 |
+
return preg_replace($validUtf, '$1', $field);
|
473 |
}
|
474 |
|
475 |
protected function _attributeDoesNotExist($attName)
|
477 |
Mage::throwException($attName . ' attribute does not exist!');
|
478 |
}
|
479 |
|
|
|
|
|
|
|
|
|
|
|
480 |
public function getConfig()
|
481 |
{
|
482 |
return $this->getGenerator()->getConfig();
|
483 |
}
|
484 |
|
485 |
+
public function getConfigVar($key, $section = Doofinder_Feed_Model_Config::DEFAULT_SECTION)
|
|
|
486 |
{
|
487 |
return $this->getGenerator()->getConfigVar($key, null, $section);
|
488 |
}
|
494 |
|
495 |
public function isSkip()
|
496 |
{
|
497 |
+
return $this->_skip;
|
498 |
}
|
499 |
|
500 |
public function checkSkipSubmission()
|
504 |
|
505 |
public function setFieldsMap($arr)
|
506 |
{
|
507 |
+
$this->_fieldMap = $arr;
|
508 |
|
509 |
return $this;
|
510 |
}
|
app/code/community/Doofinder/Feed/Model/Map/Product/Associated.php
CHANGED
@@ -6,13 +6,13 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Associated Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Associated
|
@@ -42,12 +42,9 @@ class Doofinder_Feed_Model_Map_Product_Associated
|
|
42 |
{
|
43 |
$product = $this->getProduct();
|
44 |
|
45 |
-
if ($product->isVisibleInSiteVisibility())
|
46 |
-
{
|
47 |
$value = $this->getCellValue(array('map' => $params['map']));
|
48 |
-
}
|
49 |
-
else
|
50 |
-
{
|
51 |
$value = $this->getParentMap()->mapField('link');
|
52 |
|
53 |
if ($this->getConfigVar('associated_products_link_add_unique', 'columns'))
|
@@ -65,12 +62,10 @@ class Doofinder_Feed_Model_Map_Product_Associated
|
|
65 |
{
|
66 |
$params = array();
|
67 |
|
68 |
-
foreach ($codes as $attrCode)
|
69 |
-
{
|
70 |
$data = $product->getData($attrCode);
|
71 |
|
72 |
-
if (empty($data))
|
73 |
-
{
|
74 |
$this->skip = true;
|
75 |
return $value;
|
76 |
}
|
@@ -79,12 +74,9 @@ class Doofinder_Feed_Model_Map_Product_Associated
|
|
79 |
}
|
80 |
|
81 |
$uri = Zend_Uri::factory($value);
|
82 |
-
$scheme = $uri->getScheme();
|
83 |
$query = $uri->getQueryAsArray();
|
84 |
-
$port = $uri->getPort();
|
85 |
|
86 |
-
if ($uri->valid())
|
87 |
-
{
|
88 |
$params = array_merge($query, $params);
|
89 |
$uri->setQuery($params);
|
90 |
|
@@ -145,16 +137,16 @@ class Doofinder_Feed_Model_Map_Product_Associated
|
|
145 |
if ($value != "")
|
146 |
return htmlspecialchars_decode($value);
|
147 |
|
148 |
-
$
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
{
|
158 |
$value = $arr['value'];
|
159 |
break;
|
160 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Associated Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Associated
|
42 |
{
|
43 |
$product = $this->getProduct();
|
44 |
|
45 |
+
if ($product->isVisibleInSiteVisibility()) {
|
|
|
46 |
$value = $this->getCellValue(array('map' => $params['map']));
|
47 |
+
} else {
|
|
|
|
|
48 |
$value = $this->getParentMap()->mapField('link');
|
49 |
|
50 |
if ($this->getConfigVar('associated_products_link_add_unique', 'columns'))
|
62 |
{
|
63 |
$params = array();
|
64 |
|
65 |
+
foreach ($codes as $attrCode) {
|
|
|
66 |
$data = $product->getData($attrCode);
|
67 |
|
68 |
+
if (empty($data)) {
|
|
|
69 |
$this->skip = true;
|
70 |
return $value;
|
71 |
}
|
74 |
}
|
75 |
|
76 |
$uri = Zend_Uri::factory($value);
|
|
|
77 |
$query = $uri->getQueryAsArray();
|
|
|
78 |
|
79 |
+
if ($uri->valid()) {
|
|
|
80 |
$params = array_merge($query, $params);
|
81 |
$uri->setQuery($params);
|
82 |
|
137 |
if ($value != "")
|
138 |
return htmlspecialchars_decode($value);
|
139 |
|
140 |
+
$mapByCategory = $this->getConfig()->getMapCategorySorted(
|
141 |
+
'product_type_by_category',
|
142 |
+
$this->getStoreId()
|
143 |
+
);
|
144 |
+
$categoryIds = $this->getProduct()->getCategoryIds();
|
145 |
+
if (empty($categoryIds))
|
146 |
+
$categoryIds = $this->getParentMap()->getProduct()->getCategoryIds();
|
147 |
+
if (!empty($categoryIds) && !empty($mapByCategory)) {
|
148 |
+
foreach ($mapByCategory as $arr) {
|
149 |
+
if (array_search($arr['category'], $categoryIds) !== false) {
|
150 |
$value = $arr['value'];
|
151 |
break;
|
152 |
}
|
app/code/community/Doofinder/Feed/Model/Map/Product/Bundle.php
CHANGED
@@ -6,13 +6,13 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Bundle Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Bundle
|
@@ -22,12 +22,9 @@ class Doofinder_Feed_Model_Map_Product_Bundle
|
|
22 |
{
|
23 |
$price = 0.0;
|
24 |
|
25 |
-
if (!$this->hasSpecialPrice())
|
26 |
-
{
|
27 |
$price = $this->calcMinimalPrice($this->getProduct());
|
28 |
-
}
|
29 |
-
else
|
30 |
-
{
|
31 |
$price = $this->calcMinimalPrice($this->getProduct());
|
32 |
}
|
33 |
|
@@ -37,11 +34,13 @@ class Doofinder_Feed_Model_Map_Product_Bundle
|
|
37 |
return $price;
|
38 |
}
|
39 |
|
40 |
-
public function calcMinimalPrice($product)
|
|
|
41 |
$price = 0.0;
|
42 |
|
43 |
if ($this->getConfig()->compareMagentoVersion(
|
44 |
-
|
|
|
45 |
$_prices = $product->getPriceModel()->getPrices($product);
|
46 |
else
|
47 |
$_prices = $product->getPriceModel()->getTotalPrices($product);
|
@@ -58,16 +57,19 @@ class Doofinder_Feed_Model_Map_Product_Bundle
|
|
58 |
{
|
59 |
$price = $this->calcMinimalPrice($this->getProduct());
|
60 |
|
61 |
-
$
|
62 |
|
63 |
-
if ($
|
64 |
return 0;
|
65 |
|
66 |
-
$
|
67 |
|
68 |
-
return $
|
69 |
}
|
70 |
|
|
|
|
|
|
|
71 |
protected function mapDirectiveSalePrice($params = array())
|
72 |
{
|
73 |
return null;
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Bundle Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Bundle
|
22 |
{
|
23 |
$price = 0.0;
|
24 |
|
25 |
+
if (!$this->hasSpecialPrice()) {
|
|
|
26 |
$price = $this->calcMinimalPrice($this->getProduct());
|
27 |
+
} else {
|
|
|
|
|
28 |
$price = $this->calcMinimalPrice($this->getProduct());
|
29 |
}
|
30 |
|
34 |
return $price;
|
35 |
}
|
36 |
|
37 |
+
public function calcMinimalPrice($product)
|
38 |
+
{
|
39 |
$price = 0.0;
|
40 |
|
41 |
if ($this->getConfig()->compareMagentoVersion(
|
42 |
+
array('major' => 1, 'minor' => 6, 'revision' => 0, 'patch' => 0)
|
43 |
+
))
|
44 |
$_prices = $product->getPriceModel()->getPrices($product);
|
45 |
else
|
46 |
$_prices = $product->getPriceModel()->getTotalPrices($product);
|
57 |
{
|
58 |
$price = $this->calcMinimalPrice($this->getProduct());
|
59 |
|
60 |
+
$specialPrice = $this->getProduct()->getSpecialPrice();
|
61 |
|
62 |
+
if ($specialPrice <= 0 || $specialPrice > 100)
|
63 |
return 0;
|
64 |
|
65 |
+
$specialPrice = (($specialPrice = (100 - $specialPrice) * $price / 100) > 0 ? $specialPrice : 0);
|
66 |
|
67 |
+
return $specialPrice;
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
72 |
+
*/
|
73 |
protected function mapDirectiveSalePrice($params = array())
|
74 |
{
|
75 |
return null;
|
app/code/community/Doofinder/Feed/Model/Map/Product/Configurable.php
CHANGED
@@ -6,13 +6,13 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Configurable Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Configurable
|
@@ -20,14 +20,14 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
20 |
{
|
21 |
protected static $_grouped = false;
|
22 |
|
23 |
-
public static function setGrouped($
|
24 |
{
|
25 |
-
self::$_grouped = (bool)$
|
26 |
}
|
27 |
|
28 |
-
protected $
|
29 |
protected $_assocs;
|
30 |
-
protected $
|
31 |
|
32 |
public function _beforeMap()
|
33 |
{
|
@@ -43,14 +43,12 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
43 |
->addAttributeToSelect('*')
|
44 |
->load();
|
45 |
|
46 |
-
foreach ($associatedProducts as $associated)
|
47 |
-
{
|
48 |
$this->_assocs[$associated->getId()] = $associated;
|
49 |
}
|
50 |
|
51 |
$assocMapArr = array();
|
52 |
-
foreach ($this->_assocs as $assoc)
|
53 |
-
{
|
54 |
$assocMap = $this->getAssocMapModel($assoc);
|
55 |
|
56 |
if ($assocMap->checkSkipSubmission()->isSkip())
|
@@ -64,10 +62,15 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
64 |
return parent::_beforeMap();
|
65 |
}
|
66 |
|
|
|
|
|
|
|
|
|
|
|
67 |
public function _map()
|
68 |
{
|
|
|
69 |
$rows = array();
|
70 |
-
// $grouped = ($this->getConfigVar('group_configurable_products') == 1);
|
71 |
$grouped = self::$_grouped;
|
72 |
|
73 |
$skipFields = array(
|
@@ -80,8 +83,7 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
80 |
);
|
81 |
|
82 |
// Check if this product should be in the feed
|
83 |
-
if (!$this->isSkip())
|
84 |
-
{
|
85 |
$masterData = parent::_map();
|
86 |
reset($masterData);
|
87 |
$masterData = current($masterData);
|
@@ -96,29 +98,22 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
96 |
}
|
97 |
|
98 |
// Map all child products
|
99 |
-
foreach ($this->getAssocMaps() as $
|
100 |
-
|
101 |
-
if (!$assocMap->isSkip())
|
102 |
-
{
|
103 |
$row = $assocMap->map();
|
104 |
reset($row);
|
105 |
$row = current($row);
|
106 |
|
107 |
// We can group multiple configurable products into the master product
|
108 |
-
if (!$grouped)
|
109 |
-
|
110 |
-
|
111 |
-
{
|
112 |
-
if (in_array($name, $skipFields))
|
113 |
-
{
|
114 |
continue;
|
115 |
}
|
116 |
|
117 |
$masterData = $this->_mapGrouped($name, $value, $masterData);
|
118 |
}
|
119 |
-
}
|
120 |
-
else
|
121 |
-
{
|
122 |
$rows[] = $row; // Add each product as separate product
|
123 |
}
|
124 |
}
|
@@ -129,6 +124,7 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
129 |
if (isset($masterData['boost']) && is_array($masterData['boost'])) {
|
130 |
$masterData['boost'] = max($masterData['boost']);
|
131 |
}
|
|
|
132 |
// Make sure availability has single value
|
133 |
if (isset($masterData['availability']) && is_array($masterData['availability'])) {
|
134 |
if (in_array($this->getConfig()->getInStockStatus(), $masterData['availability'])) {
|
@@ -151,6 +147,7 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
151 |
if (!is_array($value)) {
|
152 |
$value = array($value);
|
153 |
}
|
|
|
154 |
if (!is_array($childValue)) {
|
155 |
$childValue = array($childValue);
|
156 |
}
|
@@ -171,15 +168,15 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
171 |
|
172 |
public function getAssocIds()
|
173 |
{
|
174 |
-
if (
|
175 |
-
$this->
|
176 |
$this->getProduct(),
|
177 |
$this->getStoreId()
|
178 |
);
|
179 |
|
180 |
-
asort($this->
|
181 |
|
182 |
-
return $this->
|
183 |
}
|
184 |
|
185 |
protected function getAssocMapModel($oProduct)
|
@@ -190,12 +187,11 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
190 |
'website_id' => $this->getData('website_id'),
|
191 |
);
|
192 |
|
193 |
-
$productMap = Mage::getModel('doofinder_feed/map_product_associated',
|
194 |
-
$params);
|
195 |
|
196 |
$productMap->setGenerator($this->getGenerator())
|
197 |
->setProduct($oProduct)
|
198 |
-
->setFieldsMap($this->
|
199 |
->setParentMap($this)
|
200 |
->initialize();
|
201 |
|
@@ -204,10 +200,10 @@ class Doofinder_Feed_Model_Map_Product_Configurable
|
|
204 |
|
205 |
public function getConfigurableAttributeCodes()
|
206 |
{
|
207 |
-
if (
|
208 |
-
$this->
|
209 |
->getConfigurableAttributeCodes($this->getProduct()->getId());
|
210 |
|
211 |
-
return $this->
|
212 |
}
|
213 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Configurable Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Configurable
|
20 |
{
|
21 |
protected static $_grouped = false;
|
22 |
|
23 |
+
public static function setGrouped($arg)
|
24 |
{
|
25 |
+
self::$_grouped = (bool) $arg;
|
26 |
}
|
27 |
|
28 |
+
protected $_assocIds;
|
29 |
protected $_assocs;
|
30 |
+
protected $_attributeCache;
|
31 |
|
32 |
public function _beforeMap()
|
33 |
{
|
43 |
->addAttributeToSelect('*')
|
44 |
->load();
|
45 |
|
46 |
+
foreach ($associatedProducts as $associated) {
|
|
|
47 |
$this->_assocs[$associated->getId()] = $associated;
|
48 |
}
|
49 |
|
50 |
$assocMapArr = array();
|
51 |
+
foreach ($this->_assocs as $assoc) {
|
|
|
52 |
$assocMap = $this->getAssocMapModel($assoc);
|
53 |
|
54 |
if ($assocMap->checkSkipSubmission()->isSkip())
|
62 |
return parent::_beforeMap();
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
67 |
+
* @SuppressWarnings(PHPMD.NPathComplexity)
|
68 |
+
*/
|
69 |
+
// @codingStandardsIgnoreStart
|
70 |
public function _map()
|
71 |
{
|
72 |
+
// @codingStandardsIgnoreEnd
|
73 |
$rows = array();
|
|
|
74 |
$grouped = self::$_grouped;
|
75 |
|
76 |
$skipFields = array(
|
83 |
);
|
84 |
|
85 |
// Check if this product should be in the feed
|
86 |
+
if (!$this->isSkip()) {
|
|
|
87 |
$masterData = parent::_map();
|
88 |
reset($masterData);
|
89 |
$masterData = current($masterData);
|
98 |
}
|
99 |
|
100 |
// Map all child products
|
101 |
+
foreach ($this->getAssocMaps() as $assocMap) {
|
102 |
+
if (!$assocMap->isSkip()) {
|
|
|
|
|
103 |
$row = $assocMap->map();
|
104 |
reset($row);
|
105 |
$row = current($row);
|
106 |
|
107 |
// We can group multiple configurable products into the master product
|
108 |
+
if (!$grouped) {
|
109 |
+
foreach ($row as $name => $value) {
|
110 |
+
if (in_array($name, $skipFields)) {
|
|
|
|
|
|
|
111 |
continue;
|
112 |
}
|
113 |
|
114 |
$masterData = $this->_mapGrouped($name, $value, $masterData);
|
115 |
}
|
116 |
+
} else {
|
|
|
|
|
117 |
$rows[] = $row; // Add each product as separate product
|
118 |
}
|
119 |
}
|
124 |
if (isset($masterData['boost']) && is_array($masterData['boost'])) {
|
125 |
$masterData['boost'] = max($masterData['boost']);
|
126 |
}
|
127 |
+
|
128 |
// Make sure availability has single value
|
129 |
if (isset($masterData['availability']) && is_array($masterData['availability'])) {
|
130 |
if (in_array($this->getConfig()->getInStockStatus(), $masterData['availability'])) {
|
147 |
if (!is_array($value)) {
|
148 |
$value = array($value);
|
149 |
}
|
150 |
+
|
151 |
if (!is_array($childValue)) {
|
152 |
$childValue = array($childValue);
|
153 |
}
|
168 |
|
169 |
public function getAssocIds()
|
170 |
{
|
171 |
+
if ($this->_assocIds === null)
|
172 |
+
$this->_assocIds = $this->loadAssocIds(
|
173 |
$this->getProduct(),
|
174 |
$this->getStoreId()
|
175 |
);
|
176 |
|
177 |
+
asort($this->_assocIds);
|
178 |
|
179 |
+
return $this->_assocIds;
|
180 |
}
|
181 |
|
182 |
protected function getAssocMapModel($oProduct)
|
187 |
'website_id' => $this->getData('website_id'),
|
188 |
);
|
189 |
|
190 |
+
$productMap = Mage::getModel('doofinder_feed/map_product_associated', $params);
|
|
|
191 |
|
192 |
$productMap->setGenerator($this->getGenerator())
|
193 |
->setProduct($oProduct)
|
194 |
+
->setFieldsMap($this->_fieldMap)
|
195 |
->setParentMap($this)
|
196 |
->initialize();
|
197 |
|
200 |
|
201 |
public function getConfigurableAttributeCodes()
|
202 |
{
|
203 |
+
if ($this->_attributeCache === null)
|
204 |
+
$this->_attributeCache = $this->getTools()
|
205 |
->getConfigurableAttributeCodes($this->getProduct()->getId());
|
206 |
|
207 |
+
return $this->_attributeCache;
|
208 |
}
|
209 |
}
|
app/code/community/Doofinder/Feed/Model/Map/Product/Downloadable.php
CHANGED
@@ -6,15 +6,18 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Downloadable Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
|
|
18 |
class Doofinder_Feed_Model_Map_Product_Downloadable
|
19 |
extends Doofinder_Feed_Model_Map_Product_Abstract
|
20 |
-
{
|
|
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Downloadable Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
+
// @codingStandardsIgnoreStart
|
19 |
class Doofinder_Feed_Model_Map_Product_Downloadable
|
20 |
extends Doofinder_Feed_Model_Map_Product_Abstract
|
21 |
+
{
|
22 |
+
// @codingStandardsIgnoreEnd
|
23 |
+
}
|
app/code/community/Doofinder/Feed/Model/Map/Product/Grouped.php
CHANGED
@@ -6,13 +6,13 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Grouped Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Grouped
|
@@ -25,7 +25,6 @@ class Doofinder_Feed_Model_Map_Product_Grouped
|
|
25 |
*/
|
26 |
public function getPrice()
|
27 |
{
|
28 |
-
// $price = $this->calcGroupPrice($this->getProduct());
|
29 |
$price = $this->getMinPrice($this->getProduct());
|
30 |
|
31 |
if ($price <= 0)
|
@@ -37,9 +36,9 @@ class Doofinder_Feed_Model_Map_Product_Grouped
|
|
37 |
public function calcGroupPrice($product)
|
38 |
{
|
39 |
$price = 0.0;
|
40 |
-
$
|
41 |
|
42 |
-
foreach ($
|
43 |
$price += $associatedProduct->getPrice();
|
44 |
|
45 |
return $price; // Total price
|
@@ -49,14 +48,13 @@ class Doofinder_Feed_Model_Map_Product_Grouped
|
|
49 |
{
|
50 |
$price = null;
|
51 |
|
52 |
-
foreach ($product->getTypeInstance()->getAssociatedProducts() as $ap)
|
53 |
-
|
54 |
-
if (is_null($price))
|
55 |
$price = $ap->getPrice();
|
56 |
else
|
57 |
$price = min($price, $ap->getPrice());
|
58 |
}
|
59 |
|
60 |
-
return
|
61 |
}
|
62 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Grouped Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Map_Product_Grouped
|
25 |
*/
|
26 |
public function getPrice()
|
27 |
{
|
|
|
28 |
$price = $this->getMinPrice($this->getProduct());
|
29 |
|
30 |
if ($price <= 0)
|
36 |
public function calcGroupPrice($product)
|
37 |
{
|
38 |
$price = 0.0;
|
39 |
+
$associates = $product->getTypeInstance()->getAssociatedProducts();
|
40 |
|
41 |
+
foreach ($associates as $associatedProduct)
|
42 |
$price += $associatedProduct->getPrice();
|
43 |
|
44 |
return $price; // Total price
|
48 |
{
|
49 |
$price = null;
|
50 |
|
51 |
+
foreach ($product->getTypeInstance()->getAssociatedProducts() as $ap) {
|
52 |
+
if ($price === null)
|
|
|
53 |
$price = $ap->getPrice();
|
54 |
else
|
55 |
$price = min($price, $ap->getPrice());
|
56 |
}
|
57 |
|
58 |
+
return $price === null ? 0.0 : $price;
|
59 |
}
|
60 |
}
|
app/code/community/Doofinder/Feed/Model/Map/Product/Simple.php
CHANGED
@@ -6,15 +6,18 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Simple Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
|
|
18 |
class Doofinder_Feed_Model_Map_Product_Simple
|
19 |
extends Doofinder_Feed_Model_Map_Product_Abstract
|
20 |
-
{
|
|
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Simple Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
+
// @codingStandardsIgnoreStart
|
19 |
class Doofinder_Feed_Model_Map_Product_Simple
|
20 |
extends Doofinder_Feed_Model_Map_Product_Abstract
|
21 |
+
{
|
22 |
+
// @codingStandardsIgnoreEnd
|
23 |
+
}
|
app/code/community/Doofinder/Feed/Model/Map/Product/Virtual.php
CHANGED
@@ -6,15 +6,18 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Virtual Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
|
|
18 |
class Doofinder_Feed_Model_Map_Product_Virtual
|
19 |
extends Doofinder_Feed_Model_Map_Product_Abstract
|
20 |
-
{
|
|
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Virtual Product Map Model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
+
// @codingStandardsIgnoreStart
|
19 |
class Doofinder_Feed_Model_Map_Product_Virtual
|
20 |
extends Doofinder_Feed_Model_Map_Product_Abstract
|
21 |
+
{
|
22 |
+
// @codingStandardsIgnoreEnd
|
23 |
+
}
|
app/code/community/Doofinder/Feed/Model/Mysql4/Cron.php
CHANGED
@@ -6,12 +6,14 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
-
|
12 |
-
class Doofinder_Feed_Model_Mysql4_Cron extends Mage_Core_Model_Mysql4_Abstract
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
$this->_init('doofinder_feed/cron', 'id');
|
16 |
}
|
17 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
+
// @codingStandardsIgnoreStart
|
12 |
+
class Doofinder_Feed_Model_Mysql4_Cron extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
{
|
14 |
+
// @codingStandardsIgnoreEnd
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
$this->_init('doofinder_feed/cron', 'id');
|
18 |
}
|
19 |
}
|
app/code/community/Doofinder/Feed/Model/Mysql4/Cron/Collection.php
CHANGED
@@ -6,10 +6,12 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
-
|
12 |
-
class Doofinder_Feed_Model_Mysql4_Cron_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
|
|
|
|
13 |
protected function _construct()
|
14 |
{
|
15 |
$this->_init('doofinder_feed/cron');
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
+
// @codingStandardsIgnoreStart
|
12 |
+
class Doofinder_Feed_Model_Mysql4_Cron_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
+
{
|
14 |
+
// @codingStandardsIgnoreEnd
|
15 |
protected function _construct()
|
16 |
{
|
17 |
$this->_init('doofinder_feed/cron');
|
app/code/community/Doofinder/Feed/Model/Mysql4/Log.php
CHANGED
@@ -6,12 +6,14 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
-
|
12 |
-
class Doofinder_Feed_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
$this->_init('doofinder_feed/log', 'id');
|
16 |
}
|
17 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
+
// @codingStandardsIgnoreStart
|
12 |
+
class Doofinder_Feed_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
{
|
14 |
+
// @codingStandardsIgnoreEnd
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
$this->_init('doofinder_feed/log', 'id');
|
18 |
}
|
19 |
}
|
app/code/community/Doofinder/Feed/Model/Mysql4/Log/Collection.php
CHANGED
@@ -6,11 +6,12 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
-
|
12 |
class Doofinder_Feed_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
{
|
|
|
14 |
protected function _construct()
|
15 |
{
|
16 |
$this->_init('doofinder_feed/log');
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
+
// @codingStandardsIgnoreStart
|
12 |
class Doofinder_Feed_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
{
|
14 |
+
// @codingStandardsIgnoreEnd
|
15 |
protected function _construct()
|
16 |
{
|
17 |
$this->_init('doofinder_feed/log');
|
app/code/community/Doofinder/Feed/Model/Observers/Feed.php
CHANGED
@@ -6,17 +6,17 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_Observers_Feed
|
13 |
{
|
14 |
|
15 |
-
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
20 |
|
21 |
/**
|
22 |
* @var Doofinder_Feed_Helper_Log
|
@@ -34,6 +34,7 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
34 |
/**
|
35 |
* Update product index in given store context
|
36 |
*
|
|
|
37 |
* @param Mage_Catalog_Model_Product $product
|
38 |
* @param string $storeCode
|
39 |
*/
|
@@ -42,49 +43,58 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
42 |
$helper = Mage::helper('doofinder_feed');
|
43 |
|
44 |
// Set store code
|
45 |
-
$this->
|
46 |
|
47 |
// Get store config
|
48 |
-
$this->
|
49 |
|
50 |
// Set options
|
51 |
$options = array(
|
52 |
'close_empty' => true, // close xml even if there are no items
|
53 |
'products' => array($product->getId()), // list of products in feed
|
54 |
-
'store_code' => $this->
|
55 |
-
'grouped' => $this->_getBoolean($this->
|
56 |
-
'display_price' => $this->_getBoolean($this->
|
57 |
'minimal_price' => $this->_getBoolean('minimal_price', false),
|
58 |
-
'image_size' => $this->
|
59 |
'customer_group_id' => 0,
|
60 |
);
|
61 |
|
62 |
$generator = Mage::getModel('doofinder_feed/generator', $options);
|
63 |
|
64 |
-
$this->_log->
|
|
|
|
|
65 |
|
66 |
$xmlData = $generator->run();
|
67 |
|
68 |
if ($xmlData) {
|
69 |
$rss = simplexml_load_string($xmlData);
|
70 |
|
71 |
-
$hashId = Mage::getStoreConfig('doofinder_search/internal_settings/hash_id', $this->
|
72 |
if ($hashId === '') {
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
78 |
$this->_log->debug($warning);
|
79 |
Mage::getSingleton('adminhtml/session')->addWarning($warning);
|
80 |
return;
|
81 |
}
|
82 |
|
83 |
-
$searchEngine = Mage::helper('doofinder_feed/search')->getDoofinderSearchEngine($this->
|
84 |
|
85 |
// Check if search engine exists and skip foreach iteration if not.
|
86 |
if (!$searchEngine) {
|
87 |
-
$warning = sprintf(
|
|
|
|
|
|
|
|
|
88 |
$this->_log->debug($warning);
|
89 |
Mage::getSingleton('adminhtml/session')->addWarning($warning);
|
90 |
return;
|
@@ -97,20 +107,31 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
97 |
foreach ($item as $key => $value) {
|
98 |
$_product[$key] = (string)$value;
|
99 |
}
|
|
|
100 |
$products[] = $_product;
|
101 |
}
|
102 |
-
|
|
|
103 |
$searchEngine->updateItems('product', $products);
|
104 |
-
$this->_log->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
return;
|
106 |
}
|
107 |
|
108 |
-
$this->_log->
|
|
|
|
|
109 |
}
|
110 |
}
|
111 |
|
112 |
-
public function updateSearchEngineIndexes($observer)
|
113 |
-
|
114 |
$helper = Mage::helper('doofinder_feed');
|
115 |
|
116 |
$product = $observer->getProduct();
|
@@ -122,7 +143,7 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
122 |
if ($store->getCode() !== 'admin') {
|
123 |
$storeCodes[] = $store->getCode();
|
124 |
} else {
|
125 |
-
foreach(Mage::app()->getStores() as $store) {
|
126 |
$storeCodes[] = $store->getCode();
|
127 |
}
|
128 |
}
|
@@ -131,8 +152,14 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
131 |
foreach (array_keys($storeCodes) as $key) {
|
132 |
$storeCode = $storeCodes[$key];
|
133 |
|
134 |
-
$engineEnabled = Mage::getStoreConfig(
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
if (!$engineEnabled || !$atomicUpdatesEnabled) {
|
138 |
unset($storeCodes[$key]);
|
@@ -147,7 +174,11 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
147 |
try {
|
148 |
$this->updateProductIndex($product, $storeCode);
|
149 |
} catch (Exception $e) {
|
150 |
-
$warning = $helper->__(
|
|
|
|
|
|
|
|
|
151 |
$this->_log->debug($warning);
|
152 |
Mage::getSingleton('adminhtml/session')->addWarning($warning);
|
153 |
}
|
@@ -170,17 +201,23 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
170 |
|
171 |
// Create lock file
|
172 |
if (!$remove) {
|
173 |
-
$this->_log->
|
|
|
|
|
174 |
|
175 |
-
if (
|
176 |
Mage::throwException($helper->__('Process for store %s is already locked', $process->getStoreCode()));
|
177 |
}
|
178 |
|
|
|
179 |
touch($lockFilepath);
|
|
|
180 |
} else {
|
181 |
-
$this->_log->
|
|
|
|
|
182 |
|
183 |
-
|
184 |
}
|
185 |
}
|
186 |
|
@@ -194,20 +231,41 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
194 |
return $this->lockProcess($process, true);
|
195 |
}
|
196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
public function generateFeed($observer)
|
198 |
{
|
199 |
-
|
200 |
$helper = Mage::helper('doofinder_feed');
|
|
|
201 |
|
202 |
// Get doofinder process model
|
203 |
$collection = Mage::getModel('doofinder_feed/cron')->getCollection();
|
204 |
$collection
|
205 |
->addFieldToFilter('status', array('in' => array($helper::STATUS_PENDING, $helper::STATUS_RUNNING)))
|
206 |
-
->addFieldToFilter(
|
207 |
-
'
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
->setOrder('next_iteration', 'asc');
|
|
|
210 |
$collection->getSelect()->limit(1);
|
|
|
211 |
|
212 |
$process = $collection->fetchItem();
|
213 |
|
@@ -216,49 +274,52 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
216 |
return;
|
217 |
}
|
218 |
|
219 |
-
$this->_log->
|
|
|
|
|
220 |
|
221 |
try {
|
222 |
// Lock process
|
223 |
$this->lockProcess($process);
|
224 |
|
225 |
// Get store code
|
226 |
-
$this->
|
227 |
|
228 |
// Set store context
|
229 |
-
Mage::app()->setCurrentStore($this->
|
230 |
|
231 |
// Get store config
|
232 |
-
$this->
|
233 |
|
234 |
// Clear out the message
|
235 |
$process->setMessage($helper::MSG_EMPTY);
|
236 |
|
237 |
// Get current offset
|
238 |
-
$offset =
|
239 |
|
240 |
// Get step size
|
241 |
-
$stepSize =
|
242 |
|
243 |
// Set paths
|
244 |
-
$path = $helper->getFeedPath($this->
|
245 |
-
$tmpPath = $helper->getFeedTemporaryPath($this->
|
246 |
-
|
247 |
-
$this->_log->_debugEnabled && $this->_log->debug(sprintf('Feed path for store %s: ', $process->getStoreCode(), $path));
|
248 |
-
$this->_log->_debugEnabled && $this->_log->debug(sprintf('Temporary feed path for store %s: ', $process->getStoreCode(), $path));
|
249 |
|
250 |
-
|
251 |
-
|
|
|
|
|
|
|
|
|
252 |
|
253 |
// Set options for cron generator
|
254 |
$options = array(
|
255 |
'_limit_' => $stepSize,
|
256 |
'_offset_' => $offset,
|
257 |
-
'store_code' => $this->
|
258 |
-
'grouped' => $this->_getBoolean($this->
|
259 |
-
'display_price' => $this->_getBoolean($this->
|
260 |
'minimal_price' => $this->_getBoolean('minimal_price', false),
|
261 |
-
'image_size' => $this->
|
262 |
'customer_group_id' => 0,
|
263 |
);
|
264 |
|
@@ -268,7 +329,13 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
268 |
try {
|
269 |
$xmlData = $generator->run();
|
270 |
} catch (Exception $e) {
|
271 |
-
$this->_log->
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
throw $e;
|
273 |
}
|
274 |
|
@@ -281,24 +348,29 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
281 |
}
|
282 |
}
|
283 |
|
284 |
-
$message = $helper->__(
|
|
|
|
|
|
|
|
|
285 |
$this->_log->log($process, Doofinder_Feed_Helper_Log::STATUS, $message);
|
286 |
|
287 |
// If there is new data append to xml.tmp else convert into xml
|
288 |
if ($xmlData) {
|
289 |
$dir = Mage::getBaseDir('media').DS.'doofinder';
|
|
|
290 |
|
291 |
// If directory doesn't exist create one
|
292 |
-
if (
|
293 |
$helper->createFeedDirectory($dir);
|
294 |
}
|
295 |
|
296 |
// If file can not be save throw an error
|
297 |
-
if (!$
|
298 |
Mage::throwException($helper->__("File can not be saved: {$tmpPath}"));
|
299 |
}
|
300 |
|
301 |
-
$this->
|
302 |
} else {
|
303 |
$this->_log->log($process, Doofinder_Feed_Helper_Log::WARNING, $helper->__('No data added to feed'));
|
304 |
}
|
@@ -312,14 +384,13 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
312 |
} else {
|
313 |
$this->_log->log($process, Doofinder_Feed_Helper_Log::STATUS, $helper->__('Feed generation completed'));
|
314 |
|
315 |
-
if (!
|
316 |
Mage::throwException($helper->__("Cannot rename {$tmpPath} to {$path}"));
|
317 |
}
|
318 |
|
319 |
$process->setMessage($helper->__('Last process successfully completed. Now waiting for new schedule.'));
|
320 |
$this->_endProcess($process);
|
321 |
}
|
322 |
-
|
323 |
} catch (Exception $e) {
|
324 |
$this->_log->log($process, Doofinder_Feed_Helper_Log::ERROR, $e->getMessage());
|
325 |
$process->setErrorStack($process->getErrorStack() + 1);
|
@@ -333,6 +404,8 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
333 |
|
334 |
/**
|
335 |
* Cast any value to bool
|
|
|
|
|
336 |
* @param mixed $value
|
337 |
* @param bool $defaultValue
|
338 |
* @return bool
|
@@ -346,13 +419,13 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
346 |
return false;
|
347 |
}
|
348 |
|
349 |
-
$
|
350 |
-
$
|
351 |
|
352 |
-
if (
|
353 |
return true;
|
354 |
|
355 |
-
if (
|
356 |
return false;
|
357 |
|
358 |
return $defaultValue;
|
@@ -364,11 +437,12 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
364 |
* @param string $time
|
365 |
* @return array
|
366 |
*/
|
367 |
-
protected function timeToArray($time = null)
|
|
|
368 |
// Declare new time
|
369 |
$newTime;
|
370 |
// Validate $time variable
|
371 |
-
if(!$time || !is_string($time) || substr_count($time, ',') < 2) {
|
372 |
Mage::throwException('Incorrect time string.');
|
373 |
return false;
|
374 |
}
|
@@ -387,14 +461,15 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
387 |
* Concludes process.
|
388 |
* @param Doofinder_Feed_Model_Cron $process
|
389 |
*/
|
390 |
-
|
|
|
391 |
$helper = Mage::helper('doofinder_feed');
|
392 |
// Prepare data
|
393 |
$data = array(
|
394 |
'status' => $helper::STATUS_WAITING,
|
395 |
'next_run' => '-',
|
396 |
'next_iteration' => '-',
|
397 |
-
'last_feed_name' => $this->
|
398 |
'schedule_id' => null,
|
399 |
);
|
400 |
|
@@ -402,15 +477,19 @@ class Doofinder_Feed_Model_Observers_Feed
|
|
402 |
}
|
403 |
|
404 |
|
405 |
-
public function addButtons($observer)
|
|
|
406 |
$block = $observer->getBlock();
|
407 |
|
408 |
-
if ($block instanceof Mage_Adminhtml_Block_System_Config_Edit
|
|
|
|
|
409 |
$html = $block->getChild('save_button')->toHtml();
|
410 |
|
411 |
$html .= $block->getLayout()->createBlock('doofinder_feed/adminhtml_widget_button_reschedule')->toHtml();
|
412 |
|
413 |
-
$block->setChild(
|
|
|
414 |
$block->getLayout()->createBlock('core/text')->setText($html)
|
415 |
);
|
416 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_Observers_Feed
|
13 |
{
|
14 |
|
15 |
+
protected $_config;
|
16 |
|
17 |
+
protected $_storeCode;
|
18 |
|
19 |
+
protected $_productCount;
|
20 |
|
21 |
/**
|
22 |
* @var Doofinder_Feed_Helper_Log
|
34 |
/**
|
35 |
* Update product index in given store context
|
36 |
*
|
37 |
+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
38 |
* @param Mage_Catalog_Model_Product $product
|
39 |
* @param string $storeCode
|
40 |
*/
|
43 |
$helper = Mage::helper('doofinder_feed');
|
44 |
|
45 |
// Set store code
|
46 |
+
$this->_storeCode = $storeCode;
|
47 |
|
48 |
// Get store config
|
49 |
+
$this->_config = $helper->getStoreConfig($this->_storeCode);
|
50 |
|
51 |
// Set options
|
52 |
$options = array(
|
53 |
'close_empty' => true, // close xml even if there are no items
|
54 |
'products' => array($product->getId()), // list of products in feed
|
55 |
+
'store_code' => $this->_config['storeCode'],
|
56 |
+
'grouped' => $this->_getBoolean($this->_config['grouped']),
|
57 |
+
'display_price' => $this->_getBoolean($this->_config['display_price']),
|
58 |
'minimal_price' => $this->_getBoolean('minimal_price', false),
|
59 |
+
'image_size' => $this->_config['image_size'],
|
60 |
'customer_group_id' => 0,
|
61 |
);
|
62 |
|
63 |
$generator = Mage::getModel('doofinder_feed/generator', $options);
|
64 |
|
65 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
66 |
+
sprintf('Starting atomic update for product %d in store %s', $product->getId(), $storeCode)
|
67 |
+
);
|
68 |
|
69 |
$xmlData = $generator->run();
|
70 |
|
71 |
if ($xmlData) {
|
72 |
$rss = simplexml_load_string($xmlData);
|
73 |
|
74 |
+
$hashId = Mage::getStoreConfig('doofinder_search/internal_settings/hash_id', $this->_storeCode);
|
75 |
if ($hashId === '') {
|
76 |
+
$warning = sprintf(
|
77 |
+
'HashID is not set for the \'%s\' store view, ' .
|
78 |
+
'therefore, search indexes haven\'t been updated for ' .
|
79 |
+
'this store view. To fix this problem set HashID for ' .
|
80 |
+
'a given stor view or disable Internal Search in ' .
|
81 |
+
'Doofinder Search Configuration.',
|
82 |
+
$this->_storeCode
|
83 |
+
);
|
84 |
$this->_log->debug($warning);
|
85 |
Mage::getSingleton('adminhtml/session')->addWarning($warning);
|
86 |
return;
|
87 |
}
|
88 |
|
89 |
+
$searchEngine = Mage::helper('doofinder_feed/search')->getDoofinderSearchEngine($this->_storeCode);
|
90 |
|
91 |
// Check if search engine exists and skip foreach iteration if not.
|
92 |
if (!$searchEngine) {
|
93 |
+
$warning = sprintf(
|
94 |
+
'Search engine with HashID %s doesn\'t exists. ' .
|
95 |
+
'Please, check your configuration.',
|
96 |
+
$hashId
|
97 |
+
);
|
98 |
$this->_log->debug($warning);
|
99 |
Mage::getSingleton('adminhtml/session')->addWarning($warning);
|
100 |
return;
|
107 |
foreach ($item as $key => $value) {
|
108 |
$_product[$key] = (string)$value;
|
109 |
}
|
110 |
+
|
111 |
$products[] = $_product;
|
112 |
}
|
113 |
+
|
114 |
+
if (!empty($products)) {
|
115 |
$searchEngine->updateItems('product', $products);
|
116 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
117 |
+
sprintf(
|
118 |
+
'Atomic update for product %d in store %s done with: %s',
|
119 |
+
$product->getId(),
|
120 |
+
$storeCode,
|
121 |
+
json_encode($products)
|
122 |
+
)
|
123 |
+
);
|
124 |
return;
|
125 |
}
|
126 |
|
127 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
128 |
+
sprintf('Atomic update for product %d in store %s failed with no data', $product->getId(), $storeCode)
|
129 |
+
);
|
130 |
}
|
131 |
}
|
132 |
|
133 |
+
public function updateSearchEngineIndexes($observer)
|
134 |
+
{
|
135 |
$helper = Mage::helper('doofinder_feed');
|
136 |
|
137 |
$product = $observer->getProduct();
|
143 |
if ($store->getCode() !== 'admin') {
|
144 |
$storeCodes[] = $store->getCode();
|
145 |
} else {
|
146 |
+
foreach (Mage::app()->getStores() as $store) {
|
147 |
$storeCodes[] = $store->getCode();
|
148 |
}
|
149 |
}
|
152 |
foreach (array_keys($storeCodes) as $key) {
|
153 |
$storeCode = $storeCodes[$key];
|
154 |
|
155 |
+
$engineEnabled = Mage::getStoreConfig(
|
156 |
+
'doofinder_search/internal_settings/enable',
|
157 |
+
$storeCode
|
158 |
+
);
|
159 |
+
$atomicUpdatesEnabled = Mage::getStoreConfig(
|
160 |
+
'doofinder_cron/feed_settings/atomic_updates_enabled',
|
161 |
+
$storeCode
|
162 |
+
);
|
163 |
|
164 |
if (!$engineEnabled || !$atomicUpdatesEnabled) {
|
165 |
unset($storeCodes[$key]);
|
174 |
try {
|
175 |
$this->updateProductIndex($product, $storeCode);
|
176 |
} catch (Exception $e) {
|
177 |
+
$warning = $helper->__(
|
178 |
+
'There was an error during product %d indexing: %s',
|
179 |
+
$product->getId(),
|
180 |
+
$e->getMessage()
|
181 |
+
);
|
182 |
$this->_log->debug($warning);
|
183 |
Mage::getSingleton('adminhtml/session')->addWarning($warning);
|
184 |
}
|
201 |
|
202 |
// Create lock file
|
203 |
if (!$remove) {
|
204 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
205 |
+
sprintf('Locking cron process for store %s', $process->getStoreCode())
|
206 |
+
);
|
207 |
|
208 |
+
if ((new Varien_Io_File())->fileExists($lockFilepath)) {
|
209 |
Mage::throwException($helper->__('Process for store %s is already locked', $process->getStoreCode()));
|
210 |
}
|
211 |
|
212 |
+
// @codingStandardsIgnoreStart
|
213 |
touch($lockFilepath);
|
214 |
+
// @codingStandardsIgnoreEnd
|
215 |
} else {
|
216 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
217 |
+
sprintf('Unlocking cron process for store %s locked', $process->getStoreCode())
|
218 |
+
);
|
219 |
|
220 |
+
(new Varien_Io_File())->rm($lockFilepath);
|
221 |
}
|
222 |
}
|
223 |
|
231 |
return $this->lockProcess($process, true);
|
232 |
}
|
233 |
|
234 |
+
/**
|
235 |
+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
236 |
+
* @SuppressWarnings(PHPMD.NPathComplexity)
|
237 |
+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
238 |
+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
239 |
+
*/
|
240 |
+
// @codingStandardsIgnoreStart
|
241 |
public function generateFeed($observer)
|
242 |
{
|
243 |
+
// @codingStandardsIgnoreEnd
|
244 |
$helper = Mage::helper('doofinder_feed');
|
245 |
+
$date = Mage::getSingleton('core/date');
|
246 |
|
247 |
// Get doofinder process model
|
248 |
$collection = Mage::getModel('doofinder_feed/cron')->getCollection();
|
249 |
$collection
|
250 |
->addFieldToFilter('status', array('in' => array($helper::STATUS_PENDING, $helper::STATUS_RUNNING)))
|
251 |
+
->addFieldToFilter(
|
252 |
+
'next_iteration',
|
253 |
+
array(
|
254 |
+
'lteq' => $helper->getScheduledAt(
|
255 |
+
array(
|
256 |
+
// @codingStandardsIgnoreStart
|
257 |
+
$date->date('H') + $helper->getTimezoneOffset(),
|
258 |
+
$date->date('i'),
|
259 |
+
$date->date('s')
|
260 |
+
// @codingStandardsIgnoreEnd
|
261 |
+
)
|
262 |
+
)
|
263 |
+
)
|
264 |
+
)
|
265 |
->setOrder('next_iteration', 'asc');
|
266 |
+
// @codingStandardsIgnoreStart
|
267 |
$collection->getSelect()->limit(1);
|
268 |
+
// @codingStandardsIgnoreEnd
|
269 |
|
270 |
$process = $collection->fetchItem();
|
271 |
|
274 |
return;
|
275 |
}
|
276 |
|
277 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
278 |
+
sprintf('Starting cron process for store %s', $process->getStoreCode())
|
279 |
+
);
|
280 |
|
281 |
try {
|
282 |
// Lock process
|
283 |
$this->lockProcess($process);
|
284 |
|
285 |
// Get store code
|
286 |
+
$this->_storeCode = $process->getStoreCode();
|
287 |
|
288 |
// Set store context
|
289 |
+
Mage::app()->setCurrentStore($this->_storeCode);
|
290 |
|
291 |
// Get store config
|
292 |
+
$this->_config = $helper->getStoreConfig($this->_storeCode);
|
293 |
|
294 |
// Clear out the message
|
295 |
$process->setMessage($helper::MSG_EMPTY);
|
296 |
|
297 |
// Get current offset
|
298 |
+
$offset = (int) $process->getOffset();
|
299 |
|
300 |
// Get step size
|
301 |
+
$stepSize = (int) $this->_config['stepSize'];
|
302 |
|
303 |
// Set paths
|
304 |
+
$path = $helper->getFeedPath($this->_storeCode);
|
305 |
+
$tmpPath = $helper->getFeedTemporaryPath($this->_storeCode);
|
|
|
|
|
|
|
306 |
|
307 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
308 |
+
sprintf('Feed path for store %s: ', $process->getStoreCode(), $path)
|
309 |
+
);
|
310 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
311 |
+
sprintf('Temporary feed path for store %s: ', $process->getStoreCode(), $path)
|
312 |
+
);
|
313 |
|
314 |
// Set options for cron generator
|
315 |
$options = array(
|
316 |
'_limit_' => $stepSize,
|
317 |
'_offset_' => $offset,
|
318 |
+
'store_code' => $this->_config['storeCode'],
|
319 |
+
'grouped' => $this->_getBoolean($this->_config['grouped']),
|
320 |
+
'display_price' => $this->_getBoolean($this->_config['display_price']),
|
321 |
'minimal_price' => $this->_getBoolean('minimal_price', false),
|
322 |
+
'image_size' => $this->_config['image_size'],
|
323 |
'customer_group_id' => 0,
|
324 |
);
|
325 |
|
329 |
try {
|
330 |
$xmlData = $generator->run();
|
331 |
} catch (Exception $e) {
|
332 |
+
$this->_log->debugEnabled && $this->_log->debug(
|
333 |
+
sprintf(
|
334 |
+
'Generator run failed with exception "%s" and following errors: %s',
|
335 |
+
$e->getMessage(),
|
336 |
+
json_encode($generator->getErrors())
|
337 |
+
)
|
338 |
+
);
|
339 |
throw $e;
|
340 |
}
|
341 |
|
348 |
}
|
349 |
}
|
350 |
|
351 |
+
$message = $helper->__(
|
352 |
+
'Processed products with ids in range %d - %d',
|
353 |
+
$offset + 1,
|
354 |
+
$generator->getLastProcessedProductId()
|
355 |
+
);
|
356 |
$this->_log->log($process, Doofinder_Feed_Helper_Log::STATUS, $message);
|
357 |
|
358 |
// If there is new data append to xml.tmp else convert into xml
|
359 |
if ($xmlData) {
|
360 |
$dir = Mage::getBaseDir('media').DS.'doofinder';
|
361 |
+
$fileIo = new Varien_Io_File();
|
362 |
|
363 |
// If directory doesn't exist create one
|
364 |
+
if (!$fileIo->fileExists($dir)) {
|
365 |
$helper->createFeedDirectory($dir);
|
366 |
}
|
367 |
|
368 |
// If file can not be save throw an error
|
369 |
+
if (!$fileIo->filePutContent($tmpPath, $xmlData)) {
|
370 |
Mage::throwException($helper->__("File can not be saved: {$tmpPath}"));
|
371 |
}
|
372 |
|
373 |
+
$this->_productCount = $generator->getProductCount();
|
374 |
} else {
|
375 |
$this->_log->log($process, Doofinder_Feed_Helper_Log::WARNING, $helper->__('No data added to feed'));
|
376 |
}
|
384 |
} else {
|
385 |
$this->_log->log($process, Doofinder_Feed_Helper_Log::STATUS, $helper->__('Feed generation completed'));
|
386 |
|
387 |
+
if (!(new Varien_Io_File())->mv($tmpPath, $path)) {
|
388 |
Mage::throwException($helper->__("Cannot rename {$tmpPath} to {$path}"));
|
389 |
}
|
390 |
|
391 |
$process->setMessage($helper->__('Last process successfully completed. Now waiting for new schedule.'));
|
392 |
$this->_endProcess($process);
|
393 |
}
|
|
|
394 |
} catch (Exception $e) {
|
395 |
$this->_log->log($process, Doofinder_Feed_Helper_Log::ERROR, $e->getMessage());
|
396 |
$process->setErrorStack($process->getErrorStack() + 1);
|
404 |
|
405 |
/**
|
406 |
* Cast any value to bool
|
407 |
+
*
|
408 |
+
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
|
409 |
* @param mixed $value
|
410 |
* @param bool $defaultValue
|
411 |
* @return bool
|
419 |
return false;
|
420 |
}
|
421 |
|
422 |
+
$true = array('true', 'on', 'yes');
|
423 |
+
$false = array('false', 'off', 'no');
|
424 |
|
425 |
+
if (in_array($value, $true))
|
426 |
return true;
|
427 |
|
428 |
+
if (in_array($value, $false))
|
429 |
return false;
|
430 |
|
431 |
return $defaultValue;
|
437 |
* @param string $time
|
438 |
* @return array
|
439 |
*/
|
440 |
+
protected function timeToArray($time = null)
|
441 |
+
{
|
442 |
// Declare new time
|
443 |
$newTime;
|
444 |
// Validate $time variable
|
445 |
+
if (!$time || !is_string($time) || substr_count($time, ',') < 2) {
|
446 |
Mage::throwException('Incorrect time string.');
|
447 |
return false;
|
448 |
}
|
461 |
* Concludes process.
|
462 |
* @param Doofinder_Feed_Model_Cron $process
|
463 |
*/
|
464 |
+
protected function _endProcess(Doofinder_Feed_Model_Cron $process)
|
465 |
+
{
|
466 |
$helper = Mage::helper('doofinder_feed');
|
467 |
// Prepare data
|
468 |
$data = array(
|
469 |
'status' => $helper::STATUS_WAITING,
|
470 |
'next_run' => '-',
|
471 |
'next_iteration' => '-',
|
472 |
+
'last_feed_name' => $this->_config['xmlName'],
|
473 |
'schedule_id' => null,
|
474 |
);
|
475 |
|
477 |
}
|
478 |
|
479 |
|
480 |
+
public function addButtons($observer)
|
481 |
+
{
|
482 |
$block = $observer->getBlock();
|
483 |
|
484 |
+
if ($block instanceof Mage_Adminhtml_Block_System_Config_Edit
|
485 |
+
&& $block->getRequest()->getParam('section') == 'doofinder_cron'
|
486 |
+
) {
|
487 |
$html = $block->getChild('save_button')->toHtml();
|
488 |
|
489 |
$html .= $block->getLayout()->createBlock('doofinder_feed/adminhtml_widget_button_reschedule')->toHtml();
|
490 |
|
491 |
+
$block->setChild(
|
492 |
+
'save_button',
|
493 |
$block->getLayout()->createBlock('core/text')->setText($html)
|
494 |
);
|
495 |
}
|
app/code/community/Doofinder/Feed/Model/Observers/Logs.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_Observers_Logs
|
@@ -17,10 +17,13 @@ class Doofinder_Feed_Model_Observers_Logs
|
|
17 |
/**
|
18 |
* Clear logs that are beyond the limit
|
19 |
*
|
|
|
20 |
* @param Varien_Event_Observer $observer
|
21 |
*/
|
|
|
22 |
public function clearLogs($observer)
|
23 |
{
|
|
|
24 |
$collection = Mage::getModel('doofinder_feed/log')->getCollection();
|
25 |
|
26 |
$size = $collection->getSize();
|
@@ -30,12 +33,15 @@ class Doofinder_Feed_Model_Observers_Logs
|
|
30 |
|
31 |
$offset = max(static::MAX_SIZE, $size - static::BATCH_LIMIT);
|
32 |
|
33 |
-
|
34 |
-
|
|
|
35 |
|
36 |
$ids = array();
|
37 |
foreach ($collection->getItems() as $item) {
|
|
|
38 |
$item->delete();
|
|
|
39 |
$ids[] = $item->id;
|
40 |
}
|
41 |
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_Observers_Logs
|
17 |
/**
|
18 |
* Clear logs that are beyond the limit
|
19 |
*
|
20 |
+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
21 |
* @param Varien_Event_Observer $observer
|
22 |
*/
|
23 |
+
// @codingStandardsIgnoreStart
|
24 |
public function clearLogs($observer)
|
25 |
{
|
26 |
+
// @codingStandardsIgnoreEnd
|
27 |
$collection = Mage::getModel('doofinder_feed/log')->getCollection();
|
28 |
|
29 |
$size = $collection->getSize();
|
33 |
|
34 |
$offset = max(static::MAX_SIZE, $size - static::BATCH_LIMIT);
|
35 |
|
36 |
+
// @codingStandardsIgnoreStart
|
37 |
+
$collection->getSelect()->limit(static::BATCH_LIMIT, $offset);
|
38 |
+
// @codingStandardsIgnoreEnd
|
39 |
|
40 |
$ids = array();
|
41 |
foreach ($collection->getItems() as $item) {
|
42 |
+
// @codingStandardsIgnoreStart
|
43 |
$item->delete();
|
44 |
+
// @codingStandardsIgnoreEnd
|
45 |
$ids[] = $item->id;
|
46 |
}
|
47 |
|
app/code/community/Doofinder/Feed/Model/Observers/Schedule.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_Observers_Schedule
|
@@ -68,29 +68,18 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
68 |
* @param string $storeCode
|
69 |
* @return Doofinder_Feed_Model_Cron
|
70 |
*/
|
71 |
-
|
72 |
{
|
73 |
$process = Mage::getModel('doofinder_feed/cron')->load($storeCode, 'store_code');
|
74 |
return $process->getId() ? $process : null;
|
75 |
}
|
76 |
|
77 |
-
/**
|
78 |
-
* Checks if process is registered in doofinder cron table
|
79 |
-
*
|
80 |
-
* @param string $storeCode
|
81 |
-
* @return bool
|
82 |
-
*/
|
83 |
-
private function _isProcessRegistered($storeCode = 'default')
|
84 |
-
{
|
85 |
-
$process = $this->_getProcessByStoreCode($storeCode);
|
86 |
-
return $process ? true : false;
|
87 |
-
}
|
88 |
-
|
89 |
/**
|
90 |
* Update process for given store code.
|
91 |
* If process does not exits - create it.
|
92 |
* Reschedule the process if it needs it.
|
93 |
*
|
|
|
94 |
* @param Doofinder_Feed_Model_Cron $process
|
95 |
* @param boolean $reset
|
96 |
* @param boolean $now
|
@@ -102,10 +91,17 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
102 |
$helper = Mage::helper('doofinder_feed');
|
103 |
$config = $helper->getStoreConfig($storeCode);
|
104 |
$store = Mage::getModel('core/store')->load($storeCode);
|
|
|
105 |
|
106 |
// Override time if $now is enabled
|
107 |
if ($now) {
|
108 |
-
$config['time'] = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
|
111 |
$isEnabled = (bool) $config['enabled'];
|
@@ -125,23 +121,33 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
125 |
}
|
126 |
} else {
|
127 |
if ($process->getStatus() != $helper::STATUS_DISABLED) {
|
128 |
-
|
129 |
-
|
|
|
130 |
$this->_removeTmpXml($storeCode);
|
131 |
$this->_disableProcess($process);
|
132 |
}
|
|
|
133 |
return $this;
|
134 |
}
|
135 |
|
136 |
// Do not process the schedule if it has insufficient file permissions
|
137 |
if (!$this->_checkFeedFilePermission($storeCode)) {
|
138 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
return $this;
|
140 |
}
|
141 |
|
142 |
// Reschedule the process if it needs to
|
143 |
if ($reset || $process->getStatus() == $helper::STATUS_WAITING) {
|
144 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(
|
|
|
|
|
145 |
$this->_removeTmpXml($storeCode);
|
146 |
$this->_rescheduleProcess($config, $process);
|
147 |
}
|
@@ -152,7 +158,7 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
152 |
*
|
153 |
* @return Doofinder_Feed_Model_Cron
|
154 |
*/
|
155 |
-
|
156 |
{
|
157 |
$helper = Mage::helper('doofinder_feed');
|
158 |
$config = $helper->getStoreConfig($storeCode);
|
@@ -171,7 +177,11 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
171 |
);
|
172 |
$process = Mage::getModel('doofinder_feed/cron')->setData($data)->save();
|
173 |
|
174 |
-
Mage::helper('doofinder_feed/log')->log(
|
|
|
|
|
|
|
|
|
175 |
|
176 |
return $process;
|
177 |
}
|
@@ -181,11 +191,15 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
181 |
*
|
182 |
* @param Doofinder_Feed_Model_Cron $process
|
183 |
*/
|
184 |
-
|
185 |
{
|
186 |
$helper = Mage::helper('doofinder_feed');
|
187 |
$process->setStatus($helper::STATUS_WAITING)->save();
|
188 |
-
Mage::helper('doofinder_feed/log')->log(
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
|
191 |
/**
|
@@ -193,11 +207,15 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
193 |
*
|
194 |
* @param Doofinder_Feed_Model_Cron $process
|
195 |
*/
|
196 |
-
|
197 |
{
|
198 |
$helper = Mage::helper('doofinder_feed');
|
199 |
$process->setStatus($helper::STATUS_DISABLED)->save();
|
200 |
-
Mage::helper('doofinder_feed/log')->log(
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
|
203 |
/**
|
@@ -206,21 +224,26 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
206 |
* @param string $store_code
|
207 |
* @return bool
|
208 |
*/
|
209 |
-
|
210 |
{
|
211 |
-
if (empty($
|
212 |
return false;
|
213 |
}
|
|
|
214 |
$helper = Mage::helper('doofinder_feed');
|
215 |
-
$config = $helper->getStoreConfig($
|
216 |
$filePath = Mage::getBaseDir('media').DS.'doofinder'.DS.$config['xmlName'].'.tmp';
|
217 |
-
|
218 |
-
|
|
|
219 |
if ($success) {
|
220 |
Mage::getSingleton('core/session')->addSuccess("Temporary xml file: {$filePath} has beed removed.");
|
221 |
return true;
|
222 |
} else {
|
223 |
-
Mage::getSingleton('core/session')->addError(
|
|
|
|
|
|
|
224 |
return false;
|
225 |
}
|
226 |
}
|
@@ -247,7 +270,10 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
247 |
$path = $helper->getFeedPath($storeCode);
|
248 |
$tmpPath = $helper->getFeedTemporaryPath($storeCode);
|
249 |
|
250 |
-
|
|
|
|
|
|
|
251 |
}
|
252 |
|
253 |
/**
|
@@ -260,9 +286,7 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
260 |
{
|
261 |
$helper = Mage::helper('doofinder_feed');
|
262 |
|
263 |
-
$timecreated = strftime("%Y-%m-%d %H:%M:%S", mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")));
|
264 |
$timescheduled = $helper->getScheduledAt($config['time'], $config['frequency']);
|
265 |
-
$jobCode = $helper::JOB_CODE;
|
266 |
|
267 |
$process->setStatus($helper::STATUS_PENDING)
|
268 |
->setComplete('0%')
|
@@ -273,6 +297,10 @@ class Doofinder_Feed_Model_Observers_Schedule
|
|
273 |
->setErrorStack(0)
|
274 |
->save();
|
275 |
|
276 |
-
Mage::helper('doofinder_feed/log')->log(
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_Observers_Schedule
|
68 |
* @param string $storeCode
|
69 |
* @return Doofinder_Feed_Model_Cron
|
70 |
*/
|
71 |
+
protected function _getProcessByStoreCode($storeCode = 'default')
|
72 |
{
|
73 |
$process = Mage::getModel('doofinder_feed/cron')->load($storeCode, 'store_code');
|
74 |
return $process->getId() ? $process : null;
|
75 |
}
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
/**
|
78 |
* Update process for given store code.
|
79 |
* If process does not exits - create it.
|
80 |
* Reschedule the process if it needs it.
|
81 |
*
|
82 |
+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
83 |
* @param Doofinder_Feed_Model_Cron $process
|
84 |
* @param boolean $reset
|
85 |
* @param boolean $now
|
91 |
$helper = Mage::helper('doofinder_feed');
|
92 |
$config = $helper->getStoreConfig($storeCode);
|
93 |
$store = Mage::getModel('core/store')->load($storeCode);
|
94 |
+
$date = Mage::getSingleton('core/date');
|
95 |
|
96 |
// Override time if $now is enabled
|
97 |
if ($now) {
|
98 |
+
$config['time'] = array(
|
99 |
+
// @codingStandardsIgnoreStart
|
100 |
+
$date->date('H') + $helper->getTimezoneOffset(),
|
101 |
+
$date->date('i'),
|
102 |
+
$date->date('s')
|
103 |
+
// @codingStandardsIgnoreEnd
|
104 |
+
);
|
105 |
}
|
106 |
|
107 |
$isEnabled = (bool) $config['enabled'];
|
121 |
}
|
122 |
} else {
|
123 |
if ($process->getStatus() != $helper::STATUS_DISABLED) {
|
124 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
125 |
+
$helper->__('Process for store "%s" has been disabled', $store->getName())
|
126 |
+
);
|
127 |
$this->_removeTmpXml($storeCode);
|
128 |
$this->_disableProcess($process);
|
129 |
}
|
130 |
+
|
131 |
return $this;
|
132 |
}
|
133 |
|
134 |
// Do not process the schedule if it has insufficient file permissions
|
135 |
if (!$this->_checkFeedFilePermission($storeCode)) {
|
136 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
137 |
+
$helper->__(
|
138 |
+
'Insufficient file permissions for store: %s. ' .
|
139 |
+
'Check if the feed file is writeable',
|
140 |
+
$store->getName()
|
141 |
+
)
|
142 |
+
);
|
143 |
return $this;
|
144 |
}
|
145 |
|
146 |
// Reschedule the process if it needs to
|
147 |
if ($reset || $process->getStatus() == $helper::STATUS_WAITING) {
|
148 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
149 |
+
$helper->__('Process for store "%s" has been rescheduled', $store->getName())
|
150 |
+
);
|
151 |
$this->_removeTmpXml($storeCode);
|
152 |
$this->_rescheduleProcess($config, $process);
|
153 |
}
|
158 |
*
|
159 |
* @return Doofinder_Feed_Model_Cron
|
160 |
*/
|
161 |
+
protected function _registerProcess($storeCode = 'default')
|
162 |
{
|
163 |
$helper = Mage::helper('doofinder_feed');
|
164 |
$config = $helper->getStoreConfig($storeCode);
|
177 |
);
|
178 |
$process = Mage::getModel('doofinder_feed/cron')->setData($data)->save();
|
179 |
|
180 |
+
Mage::helper('doofinder_feed/log')->log(
|
181 |
+
$process,
|
182 |
+
Doofinder_Feed_Helper_Log::STATUS,
|
183 |
+
$helper->__('Process has been registered')
|
184 |
+
);
|
185 |
|
186 |
return $process;
|
187 |
}
|
191 |
*
|
192 |
* @param Doofinder_Feed_Model_Cron $process
|
193 |
*/
|
194 |
+
protected function _enableProcess(Doofinder_Feed_Model_Cron $process)
|
195 |
{
|
196 |
$helper = Mage::helper('doofinder_feed');
|
197 |
$process->setStatus($helper::STATUS_WAITING)->save();
|
198 |
+
Mage::helper('doofinder_feed/log')->log(
|
199 |
+
$process,
|
200 |
+
Doofinder_Feed_Helper_Log::STATUS,
|
201 |
+
$helper->__('Process has been enabled')
|
202 |
+
);
|
203 |
}
|
204 |
|
205 |
/**
|
207 |
*
|
208 |
* @param Doofinder_Feed_Model_Cron $process
|
209 |
*/
|
210 |
+
protected function _disableProcess(Doofinder_Feed_Model_Cron $process)
|
211 |
{
|
212 |
$helper = Mage::helper('doofinder_feed');
|
213 |
$process->setStatus($helper::STATUS_DISABLED)->save();
|
214 |
+
Mage::helper('doofinder_feed/log')->log(
|
215 |
+
$process,
|
216 |
+
Doofinder_Feed_Helper_Log::STATUS,
|
217 |
+
$helper->__('Process has been disabled')
|
218 |
+
);
|
219 |
}
|
220 |
|
221 |
/**
|
224 |
* @param string $store_code
|
225 |
* @return bool
|
226 |
*/
|
227 |
+
protected function _removeTmpXml($storeCode = null)
|
228 |
{
|
229 |
+
if (empty($storeCode)) {
|
230 |
return false;
|
231 |
}
|
232 |
+
|
233 |
$helper = Mage::helper('doofinder_feed');
|
234 |
+
$config = $helper->getStoreConfig($storeCode);
|
235 |
$filePath = Mage::getBaseDir('media').DS.'doofinder'.DS.$config['xmlName'].'.tmp';
|
236 |
+
$fileIo = new Varien_Io_File();
|
237 |
+
if ($fileIo->fileExists($filePath)) {
|
238 |
+
$success = $fileIo->rm($filePath);
|
239 |
if ($success) {
|
240 |
Mage::getSingleton('core/session')->addSuccess("Temporary xml file: {$filePath} has beed removed.");
|
241 |
return true;
|
242 |
} else {
|
243 |
+
Mage::getSingleton('core/session')->addError(
|
244 |
+
"Could not remove {$filePath}; This can lead to some errors. " .
|
245 |
+
"Remove this file manually."
|
246 |
+
);
|
247 |
return false;
|
248 |
}
|
249 |
}
|
270 |
$path = $helper->getFeedPath($storeCode);
|
271 |
$tmpPath = $helper->getFeedTemporaryPath($storeCode);
|
272 |
|
273 |
+
$fileIo = new Varien_Io_File();
|
274 |
+
return $fileIo->isWriteable($dir)
|
275 |
+
&& (!$fileIo->fileExists($path) || $fileIo->isWriteable($path))
|
276 |
+
&& (!$fileIo->fileExists($tmpPath) || $fileIo->isWriteable($tmpPath));
|
277 |
}
|
278 |
|
279 |
/**
|
286 |
{
|
287 |
$helper = Mage::helper('doofinder_feed');
|
288 |
|
|
|
289 |
$timescheduled = $helper->getScheduledAt($config['time'], $config['frequency']);
|
|
|
290 |
|
291 |
$process->setStatus($helper::STATUS_PENDING)
|
292 |
->setComplete('0%')
|
297 |
->setErrorStack(0)
|
298 |
->save();
|
299 |
|
300 |
+
Mage::helper('doofinder_feed/log')->log(
|
301 |
+
$process,
|
302 |
+
Doofinder_Feed_Helper_Log::STATUS,
|
303 |
+
$helper->__('Process has been scheduled')
|
304 |
+
);
|
305 |
}
|
306 |
}
|
app/code/community/Doofinder/Feed/Model/Resource/Mysql4/Setup.php
CHANGED
@@ -6,9 +6,10 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
-
|
12 |
-
class Doofinder_Feed_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup
|
13 |
-
|
|
|
14 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
+
// @codingStandardsIgnoreStart
|
12 |
+
class Doofinder_Feed_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup
|
13 |
+
{
|
14 |
+
// @codingStandardsIgnoreEnd
|
15 |
}
|
app/code/community/Doofinder/Feed/Model/System/Config/Backend/Map/Additional.php
CHANGED
@@ -6,10 +6,11 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
-
class Doofinder_Feed_Model_System_Config_Backend_Map_Additional
|
|
|
13 |
{
|
14 |
protected function _beforeSave()
|
15 |
{
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
+
class Doofinder_Feed_Model_System_Config_Backend_Map_Additional
|
13 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Serialized
|
14 |
{
|
15 |
protected function _beforeSave()
|
16 |
{
|
app/code/community/Doofinder/Feed/Model/System/Config/Backend/Password.php
CHANGED
@@ -7,10 +7,13 @@ class Doofinder_Feed_Model_System_Config_Backend_Password extends Mage_Core_Mode
|
|
7 |
if (!preg_match('/^[a-zA-Z0-9_-]*$/', $this->getValue())) {
|
8 |
$config = $this->getFieldConfig();
|
9 |
|
10 |
-
|
11 |
-
'
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
}
|
15 |
|
16 |
return parent::_beforeSave();
|
7 |
if (!preg_match('/^[a-zA-Z0-9_-]*$/', $this->getValue())) {
|
8 |
$config = $this->getFieldConfig();
|
9 |
|
10 |
+
Mage::throwException(
|
11 |
+
Mage::helper('doofinder_feed')->__(
|
12 |
+
'%s value is invalid. Only alphanumeric characters with underscores (_) ' .
|
13 |
+
'and hyphens (-) are allowed.',
|
14 |
+
$config->label
|
15 |
+
)
|
16 |
+
);
|
17 |
}
|
18 |
|
19 |
return parent::_beforeSave();
|
app/code/community/Doofinder/Feed/Model/System/Config/Backend/Total/Limit.php
CHANGED
@@ -5,12 +5,12 @@ class Doofinder_Feed_Model_System_Config_Backend_Total_Limit extends Mage_Core_M
|
|
5 |
protected function _beforeSave()
|
6 |
{
|
7 |
if (!$this->getValue()) {
|
8 |
-
|
9 |
} else if (!is_numeric($this->getValue())) {
|
10 |
-
|
11 |
}
|
12 |
|
13 |
-
$this->setValue(
|
14 |
|
15 |
return parent::_beforeSave();
|
16 |
}
|
5 |
protected function _beforeSave()
|
6 |
{
|
7 |
if (!$this->getValue()) {
|
8 |
+
Mage::throwException(Mage::helper('doofinder_feed')->__('Total limit is required.'));
|
9 |
} else if (!is_numeric($this->getValue())) {
|
10 |
+
Mage::throwException(Mage::helper('doofinder_feed')->__('Total limit is not a number.'));
|
11 |
}
|
12 |
|
13 |
+
$this->setValue((int) $this->getValue());
|
14 |
|
15 |
return parent::_beforeSave();
|
16 |
}
|
app/code/community/Doofinder/Feed/Model/System/Config/Reset.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_System_Config_Reset extends Mage_Core_Model_Config_Data
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_System_Config_Reset extends Mage_Core_Model_Config_Data
|
app/code/community/Doofinder/Feed/Model/System/Config/Source/Feed/Pricetaxmode.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_System_Config_Source_Feed_Pricetaxmode
|
@@ -22,10 +22,10 @@ class Doofinder_Feed_Model_System_Config_Source_Feed_Pricetaxmode
|
|
22 |
*/
|
23 |
public function toOptionArray()
|
24 |
{
|
25 |
-
return
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
}
|
31 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_System_Config_Source_Feed_Pricetaxmode
|
22 |
*/
|
23 |
public function toOptionArray()
|
24 |
{
|
25 |
+
return array(
|
26 |
+
array('value' => 0, 'label' => __('Auto')),
|
27 |
+
array('value' => 1, 'label' => __('With Tax')),
|
28 |
+
array('value' => -1, 'label' => __('Without Tax')),
|
29 |
+
);
|
30 |
}
|
31 |
}
|
app/code/community/Doofinder/Feed/Model/System/Config/Source/Product/Attributes.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_System_Config_Source_Product_Attributes
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_Model_System_Config_Source_Product_Attributes
|
app/code/community/Doofinder/Feed/Model/Tools.php
CHANGED
@@ -6,13 +6,13 @@
|
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Tools model for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Tools extends Varien_Object
|
@@ -25,19 +25,17 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
25 |
|
26 |
public function loadEntityType($type)
|
27 |
{
|
28 |
-
if (is_array($type))
|
29 |
-
{
|
30 |
foreach ($type as $t)
|
31 |
if (is_string($t))
|
32 |
$this->loadEntityType($t);
|
33 |
-
}
|
34 |
-
else
|
35 |
-
{
|
36 |
$entityType = Mage::getModel('eav/config')->getEntityType('catalog_product');
|
37 |
|
38 |
Mage::unregister('doofinder_feed/entity_type/'.$type);
|
39 |
Mage::register('doofinder_feed/entity_type/'.$type, $entityType);
|
40 |
}
|
|
|
41 |
return $this;
|
42 |
}
|
43 |
|
@@ -46,43 +44,71 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
46 |
return Mage::registry('doofinder_feed/entity_type/'.$type);
|
47 |
}
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
-
if (
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
$attributeId = $attribute->getAttributeId();
|
62 |
|
63 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
|
|
64 |
$query = $conn->select()
|
65 |
-
->from(
|
66 |
-
array('
|
67 |
-
|
|
|
|
|
|
|
68 |
'val.attribute_id=eav.attribute_id',
|
69 |
-
array()
|
|
|
70 |
->where('val.entity_id = ?', $productId)
|
71 |
->where('val.entity_type_id = ?', $this->getEntityType('catalog_product')->getEntityTypeId())
|
72 |
->where('val.store_id = ?', $storeId)
|
73 |
->where('val.attribute_id = ?', $attributeId);
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
86 |
}
|
87 |
|
88 |
return $value;
|
@@ -91,72 +117,99 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
91 |
/**
|
92 |
* Check if there is a parent of type (configurable, ..)
|
93 |
*
|
94 |
-
* @param string $
|
95 |
* @param string $sku
|
96 |
-
* @param string $
|
97 |
* @return array|false
|
98 |
*/
|
99 |
-
public function isChildOfProductType($
|
100 |
{
|
101 |
$data = false;
|
102 |
|
103 |
-
if ($
|
104 |
return $data;
|
105 |
|
106 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
|
|
107 |
$query = $conn->select()
|
108 |
-
->from(
|
109 |
-
array('
|
|
|
|
|
110 |
'sku' => 'cpe.sku',
|
111 |
'parent_entity_id' => 'cpe_parent.entity_id',
|
112 |
-
'parent_sku' => 'cpe_parent.sku'
|
113 |
-
|
|
|
|
|
|
|
114 |
'cpe.entity_id = cpsl.product_id',
|
115 |
-
array()
|
116 |
-
|
|
|
|
|
117 |
'cpsl.parent_id = cpe_parent.entity_id',
|
118 |
-
array()
|
|
|
119 |
->where('cpe.sku', $sku)
|
120 |
-
->where('cpe_parent.type_id', $
|
|
|
121 |
|
122 |
$result = $this->getConnRead()->fetchRow($query);
|
123 |
|
124 |
-
if ($result !== false)
|
125 |
-
{
|
126 |
$data = $result;
|
127 |
}
|
128 |
|
129 |
return $data;
|
130 |
}
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
}
|
138 |
|
139 |
$attributeId = $attribute->getAttributeId();
|
140 |
|
141 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
|
|
142 |
$query = $conn->select()
|
143 |
-
->from(
|
144 |
-
|
|
|
|
|
145 |
->where('opt.option_id = ?', $valueId)
|
146 |
->where('opt.attribute_id = ?', $attributeId)
|
147 |
->where('opt.store_id = ?', $storeId);
|
|
|
148 |
|
149 |
-
$value = $this->
|
150 |
-
if (is_array($value) && @$value[0] === null)
|
151 |
-
$value = null;
|
152 |
-
elseif (is_array($value) && isset($value[0]))
|
153 |
-
$value = $value[0];
|
154 |
-
else if (is_array($value) && count($value) == 0)
|
155 |
-
$value = null;
|
156 |
|
157 |
-
if (
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
|
162 |
return $value;
|
@@ -175,19 +228,25 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
175 |
$data = false;
|
176 |
|
177 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
|
|
178 |
$query = $conn->select()
|
179 |
-
->from(
|
180 |
-
|
|
|
|
|
181 |
->where('product_id = ?', $productId);
|
|
|
182 |
|
|
|
183 |
$result = $this->getConnRead()->fetchAll($query);
|
|
|
184 |
|
185 |
-
if ($result !== false)
|
186 |
-
{
|
187 |
$data = array();
|
188 |
-
foreach ($result as $
|
189 |
$data[] = $row['category_id'];
|
190 |
}
|
|
|
191 |
return $data;
|
192 |
}
|
193 |
|
@@ -201,38 +260,50 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
201 |
|
202 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
203 |
|
204 |
-
if (is_array($productId))
|
205 |
-
{
|
206 |
$value = array();
|
207 |
foreach ($productId as $pid)
|
208 |
$value[$pid] = array();
|
209 |
|
|
|
210 |
$query = $conn->select()
|
211 |
-
->from(
|
212 |
-
array('
|
213 |
-
|
214 |
-
|
|
|
|
|
215 |
's.website_id = pw.website_id',
|
216 |
-
array()
|
|
|
217 |
->where('pw.product_id IN (?)', $productId);
|
|
|
218 |
|
|
|
219 |
$rows = $this->getConnRead()->fetchAll($query);
|
220 |
-
|
221 |
-
{
|
222 |
if (!isset($value[$row['product_id']]))
|
223 |
$value[$row['product_id']] = array();
|
224 |
$value[$row['product_id']][] = $row['store_id'];
|
225 |
}
|
|
|
226 |
return $value;
|
227 |
}
|
228 |
|
|
|
229 |
$query = $conn->select()
|
230 |
-
->from(
|
231 |
-
'
|
232 |
-
|
|
|
|
|
|
|
233 |
's.website_id = pw.website_id',
|
234 |
-
array()
|
|
|
235 |
->where('pw.product_id = ?', $productId);
|
|
|
236 |
|
237 |
$value = $this->getConnRead()->fetchCol($query);
|
238 |
|
@@ -248,24 +319,31 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
248 |
$data = false;
|
249 |
|
250 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
|
|
251 |
$query = $conn->select()
|
252 |
-
->from(
|
|
|
253 |
array('cpe.entity_id')
|
254 |
-
|
255 |
-
->joinInner(
|
|
|
256 |
'cpe.entity_id = cpsl.product_id',
|
257 |
-
array()
|
258 |
-
|
|
|
|
|
259 |
'cpsl.parent_id = cpe_parent.entity_id',
|
260 |
-
array()
|
|
|
261 |
->where('cpe_parent.entity_id = ?', $productId);
|
|
|
262 |
|
|
|
263 |
$result = $this->getConnRead()->fetchAll($query);
|
|
|
264 |
|
265 |
-
if ($result !== false)
|
266 |
-
|
267 |
-
foreach ($result as $row)
|
268 |
-
{
|
269 |
$data[] = $row['entity_id'];
|
270 |
}
|
271 |
}
|
@@ -282,20 +360,26 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
282 |
$data = false;
|
283 |
|
284 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
|
|
285 |
$query = $conn->select()
|
286 |
-
->from(
|
287 |
-
array('
|
288 |
-
|
|
|
|
|
|
|
289 |
'eav.attribute_id = csa.attribute_code',
|
290 |
-
array()
|
|
|
291 |
->where('csa.product_id = ?', $productId);
|
|
|
292 |
|
|
|
293 |
$result = $this->getConnRead()->fetchAll($query);
|
|
|
294 |
|
295 |
-
if ($result !== false)
|
296 |
-
|
297 |
-
foreach ($result as $row)
|
298 |
-
{
|
299 |
$data[] = $row['attribute_code'];
|
300 |
}
|
301 |
}
|
@@ -306,11 +390,11 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
306 |
public function explodeMultiselectValue($value)
|
307 |
{
|
308 |
$arr = array();
|
309 |
-
if (!empty($value))
|
310 |
-
{
|
311 |
$arr = explode(',', $value);
|
312 |
foreach ($arr as $k => $v) $arr[$k] = trim($v);
|
313 |
}
|
|
|
314 |
return $arr;
|
315 |
}
|
316 |
|
@@ -319,10 +403,10 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
319 |
*/
|
320 |
public function getRes()
|
321 |
{
|
322 |
-
if (
|
323 |
-
{
|
324 |
$this->_res = Mage::getSingleton('core/resource');
|
325 |
}
|
|
|
326 |
return $this->_res;
|
327 |
}
|
328 |
|
@@ -331,11 +415,11 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
331 |
*/
|
332 |
public function getConnRead()
|
333 |
{
|
334 |
-
if (
|
335 |
-
|
336 |
-
$this->_conn_read = $this->getRes()->getConnection('core_read');
|
337 |
}
|
338 |
-
|
|
|
339 |
}
|
340 |
|
341 |
/**
|
@@ -343,31 +427,31 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
343 |
*/
|
344 |
public function getConnWrite()
|
345 |
{
|
346 |
-
if (
|
347 |
-
|
348 |
-
$this->_conn_write = $this->getRes()->getConnection('core_write');
|
349 |
}
|
350 |
-
|
|
|
351 |
}
|
352 |
|
353 |
public function getMagentoEdition()
|
354 |
{
|
355 |
-
if (is_callable('Mage::getEdition'))
|
356 |
-
{
|
357 |
return Mage::getEdition();
|
358 |
-
}
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
|
|
|
|
363 |
$editions = array(
|
364 |
'Enterprise' => array(true, true, true, true), // ALL features
|
365 |
'Professional' => array(true, false), // ONLY the first
|
366 |
'Community' => array(false), // NO features
|
367 |
);
|
368 |
|
369 |
-
foreach ($editions as $editionName => $featuresMap)
|
370 |
-
{
|
371 |
$match = true;
|
372 |
|
373 |
foreach($featuresMap as $i => $featureValue)
|
@@ -380,4 +464,20 @@ class Doofinder_Feed_Model_Tools extends Varien_Object
|
|
380 |
return "Unknown";
|
381 |
}
|
382 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
}
|
6 |
/**
|
7 |
* @category Models
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Tools model for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_Model_Tools extends Varien_Object
|
25 |
|
26 |
public function loadEntityType($type)
|
27 |
{
|
28 |
+
if (is_array($type)) {
|
|
|
29 |
foreach ($type as $t)
|
30 |
if (is_string($t))
|
31 |
$this->loadEntityType($t);
|
32 |
+
} else {
|
|
|
|
|
33 |
$entityType = Mage::getModel('eav/config')->getEntityType('catalog_product');
|
34 |
|
35 |
Mage::unregister('doofinder_feed/entity_type/'.$type);
|
36 |
Mage::register('doofinder_feed/entity_type/'.$type, $entityType);
|
37 |
}
|
38 |
+
|
39 |
return $this;
|
40 |
}
|
41 |
|
44 |
return Mage::registry('doofinder_feed/entity_type/'.$type);
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
49 |
+
*/
|
50 |
+
// @codingStandardsIgnoreStart
|
51 |
+
public function getProductAttributeValueBySql(
|
52 |
+
$attribute,
|
53 |
+
$type = "text",
|
54 |
+
$productId = null,
|
55 |
+
$storeId = null,
|
56 |
+
$strict = false,
|
57 |
+
$debug = false
|
58 |
+
) {
|
59 |
+
// @codingStandardsIgnoreEnd
|
60 |
+
if (array_search($type, array('text', 'int', 'decimal', 'varchar', 'datetime')) === false) {
|
61 |
+
Mage::throwException(
|
62 |
+
sprintf(
|
63 |
+
"Unknown attribute backend type %s for attribute code %s.",
|
64 |
+
$type,
|
65 |
+
$attribute->getAttributeCode()
|
66 |
+
)
|
67 |
+
);
|
68 |
}
|
69 |
|
70 |
+
if ($storeId === null) {
|
71 |
+
return $this->getProductAttributeValueBySql(
|
72 |
+
$attribute,
|
73 |
+
$type,
|
74 |
+
$productId,
|
75 |
+
Mage_Core_Model_App::ADMIN_STORE_ID,
|
76 |
+
true,
|
77 |
+
$debug
|
78 |
+
);
|
79 |
}
|
80 |
|
81 |
$attributeId = $attribute->getAttributeId();
|
82 |
|
83 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
84 |
+
// @codingStandardsIgnoreStart
|
85 |
$query = $conn->select()
|
86 |
+
->from(
|
87 |
+
array('val' => $this->getRes()->getTableName('catalog/product') . "_" . $type),
|
88 |
+
array('value')
|
89 |
+
)
|
90 |
+
->joinInner(
|
91 |
+
array('eav' => $this->getRes()->getTableName('eav/attribute')),
|
92 |
'val.attribute_id=eav.attribute_id',
|
93 |
+
array()
|
94 |
+
)
|
95 |
->where('val.entity_id = ?', $productId)
|
96 |
->where('val.entity_type_id = ?', $this->getEntityType('catalog_product')->getEntityTypeId())
|
97 |
->where('val.store_id = ?', $storeId)
|
98 |
->where('val.attribute_id = ?', $attributeId);
|
99 |
+
// @codingStandardsIgnoreEnd
|
100 |
+
|
101 |
+
$value = $this->getValueFromQuery($query);
|
102 |
+
|
103 |
+
if ($value === null && $storeId != Mage_Core_Model_App::ADMIN_STORE_ID && $strict === false) {
|
104 |
+
return $this->getProductAttributeValueBySql(
|
105 |
+
$attribute,
|
106 |
+
$type,
|
107 |
+
$productId,
|
108 |
+
Mage_Core_Model_App::ADMIN_STORE_ID,
|
109 |
+
true,
|
110 |
+
$debug
|
111 |
+
);
|
112 |
}
|
113 |
|
114 |
return $value;
|
117 |
/**
|
118 |
* Check if there is a parent of type (configurable, ..)
|
119 |
*
|
120 |
+
* @param string $typeId
|
121 |
* @param string $sku
|
122 |
+
* @param string $parentTypeId
|
123 |
* @return array|false
|
124 |
*/
|
125 |
+
public function isChildOfProductType($typeId, $sku, $parentTypeId)
|
126 |
{
|
127 |
$data = false;
|
128 |
|
129 |
+
if ($typeId != Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
|
130 |
return $data;
|
131 |
|
132 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
133 |
+
// @codingStandardsIgnoreStart
|
134 |
$query = $conn->select()
|
135 |
+
->from(
|
136 |
+
array('cpe' => $this->getRes()->getTableName('catalog/product')),
|
137 |
+
array(
|
138 |
+
'entity_id' => 'cpe.entity_id',
|
139 |
'sku' => 'cpe.sku',
|
140 |
'parent_entity_id' => 'cpe_parent.entity_id',
|
141 |
+
'parent_sku' => 'cpe_parent.sku'
|
142 |
+
)
|
143 |
+
)
|
144 |
+
->joinInner(
|
145 |
+
array('cpsl' => $this->getRes()->getTableName('catalog/product_super_link')),
|
146 |
'cpe.entity_id = cpsl.product_id',
|
147 |
+
array()
|
148 |
+
)
|
149 |
+
->joinInner(
|
150 |
+
array('cpe_parent' => $this->getRes()->getTableName('catalog/product')),
|
151 |
'cpsl.parent_id = cpe_parent.entity_id',
|
152 |
+
array()
|
153 |
+
)
|
154 |
->where('cpe.sku', $sku)
|
155 |
+
->where('cpe_parent.type_id', $parentTypeId);
|
156 |
+
// @codingStandardsIgnoreEnd
|
157 |
|
158 |
$result = $this->getConnRead()->fetchRow($query);
|
159 |
|
160 |
+
if ($result !== false) {
|
|
|
161 |
$data = $result;
|
162 |
}
|
163 |
|
164 |
return $data;
|
165 |
}
|
166 |
|
167 |
+
/**
|
168 |
+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
169 |
+
*/
|
170 |
+
// @codingStandardsIgnoreStart
|
171 |
+
public function getProductAttributeSelectValue(
|
172 |
+
$attribute,
|
173 |
+
$valueId,
|
174 |
+
$storeId = null,
|
175 |
+
$strict = false,
|
176 |
+
$debug = false
|
177 |
+
) {
|
178 |
+
// @codingStandardsIgnoreEnd
|
179 |
+
if ($storeId === null) {
|
180 |
+
return $this->getProductAttributeSelectValue(
|
181 |
+
$attribute,
|
182 |
+
$valueId,
|
183 |
+
Mage_Core_Model_App::ADMIN_STORE_ID,
|
184 |
+
true,
|
185 |
+
$debug
|
186 |
+
);
|
187 |
}
|
188 |
|
189 |
$attributeId = $attribute->getAttributeId();
|
190 |
|
191 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
192 |
+
// @codingStandardsIgnoreStart
|
193 |
$query = $conn->select()
|
194 |
+
->from(
|
195 |
+
$this->getRes()->getTableName('eav/attribute_option'),
|
196 |
+
array('opt')
|
197 |
+
)
|
198 |
->where('opt.option_id = ?', $valueId)
|
199 |
->where('opt.attribute_id = ?', $attributeId)
|
200 |
->where('opt.store_id = ?', $storeId);
|
201 |
+
// @codingStandardsIgnoreEnd
|
202 |
|
203 |
+
$value = $this->getValueFromQuery($query);
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
|
205 |
+
if ($value === null && $storeId != Mage_Core_Model_App::ADMIN_STORE_ID && $strict === false) {
|
206 |
+
return $this->getProductAttributeSelectValue(
|
207 |
+
$attribute,
|
208 |
+
$valueId,
|
209 |
+
Mage_Core_Model_App::ADMIN_STORE_ID,
|
210 |
+
true,
|
211 |
+
$debug
|
212 |
+
);
|
213 |
}
|
214 |
|
215 |
return $value;
|
228 |
$data = false;
|
229 |
|
230 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
231 |
+
// @codingStandardsIgnoreStart
|
232 |
$query = $conn->select()
|
233 |
+
->from(
|
234 |
+
$this->getRes()->getTableName('catalog/category_product'),
|
235 |
+
array('category_id')
|
236 |
+
)
|
237 |
->where('product_id = ?', $productId);
|
238 |
+
// @codingStandardsIgnoreEnd
|
239 |
|
240 |
+
// @codingStandardsIgnoreStart
|
241 |
$result = $this->getConnRead()->fetchAll($query);
|
242 |
+
// @codingStandardsIgnoreEnd
|
243 |
|
244 |
+
if ($result !== false) {
|
|
|
245 |
$data = array();
|
246 |
+
foreach ($result as $row)
|
247 |
$data[] = $row['category_id'];
|
248 |
}
|
249 |
+
|
250 |
return $data;
|
251 |
}
|
252 |
|
260 |
|
261 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
262 |
|
263 |
+
if (is_array($productId)) {
|
|
|
264 |
$value = array();
|
265 |
foreach ($productId as $pid)
|
266 |
$value[$pid] = array();
|
267 |
|
268 |
+
// @codingStandardsIgnoreStart
|
269 |
$query = $conn->select()
|
270 |
+
->from(
|
271 |
+
array('pw' => $this->getRes()->getTableName('catalog/product_website')),
|
272 |
+
array('product_id' => 'pw.product_id', 'store_id' => 's.store_id')
|
273 |
+
)
|
274 |
+
->joinInner(
|
275 |
+
array('s' => $this->getRes()->getTableName('core/store')),
|
276 |
's.website_id = pw.website_id',
|
277 |
+
array()
|
278 |
+
)
|
279 |
->where('pw.product_id IN (?)', $productId);
|
280 |
+
// @codingStandardsIgnoreEnd
|
281 |
|
282 |
+
// @codingStandardsIgnoreStart
|
283 |
$rows = $this->getConnRead()->fetchAll($query);
|
284 |
+
// @codingStandardsIgnoreEnd
|
285 |
+
foreach ($rows as $row) {
|
286 |
if (!isset($value[$row['product_id']]))
|
287 |
$value[$row['product_id']] = array();
|
288 |
$value[$row['product_id']][] = $row['store_id'];
|
289 |
}
|
290 |
+
|
291 |
return $value;
|
292 |
}
|
293 |
|
294 |
+
// @codingStandardsIgnoreStart
|
295 |
$query = $conn->select()
|
296 |
+
->from(
|
297 |
+
array('pw' => $this->getRes()->getTableName('catalog/product_website')),
|
298 |
+
's.store_id'
|
299 |
+
)
|
300 |
+
->joinInner(
|
301 |
+
array('s' => $this->getRes()->getTableName('core/store')),
|
302 |
's.website_id = pw.website_id',
|
303 |
+
array()
|
304 |
+
)
|
305 |
->where('pw.product_id = ?', $productId);
|
306 |
+
// @codingStandardsIgnoreEnd
|
307 |
|
308 |
$value = $this->getConnRead()->fetchCol($query);
|
309 |
|
319 |
$data = false;
|
320 |
|
321 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
322 |
+
// @codingStandardsIgnoreStart
|
323 |
$query = $conn->select()
|
324 |
+
->from(
|
325 |
+
array('cpe' => $this->getRes()->getTableName('catalog/product')),
|
326 |
array('cpe.entity_id')
|
327 |
+
)
|
328 |
+
->joinInner(
|
329 |
+
array('cpsl' => $this->getRes()->getTableName('catalog/product_super_link')),
|
330 |
'cpe.entity_id = cpsl.product_id',
|
331 |
+
array()
|
332 |
+
)
|
333 |
+
->joinInner(
|
334 |
+
array('cpe_parent' => $this->getRes()->getTableName('catalog/product')),
|
335 |
'cpsl.parent_id = cpe_parent.entity_id',
|
336 |
+
array()
|
337 |
+
)
|
338 |
->where('cpe_parent.entity_id = ?', $productId);
|
339 |
+
// @codingStandardsIgnoreEnd
|
340 |
|
341 |
+
// @codingStandardsIgnoreStart
|
342 |
$result = $this->getConnRead()->fetchAll($query);
|
343 |
+
// @codingStandardsIgnoreEnd
|
344 |
|
345 |
+
if ($result !== false) {
|
346 |
+
foreach ($result as $row) {
|
|
|
|
|
347 |
$data[] = $row['entity_id'];
|
348 |
}
|
349 |
}
|
360 |
$data = false;
|
361 |
|
362 |
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
363 |
+
// @codingStandardsIgnoreStart
|
364 |
$query = $conn->select()
|
365 |
+
->from(
|
366 |
+
array('csa' => $this->getRes()->getTableName('catalog/product_super_attribute')),
|
367 |
+
array('eav.attribute_code')
|
368 |
+
)
|
369 |
+
->joinInner(
|
370 |
+
array('eav' => $this->getRes()->getTableName('eav/attribute')),
|
371 |
'eav.attribute_id = csa.attribute_code',
|
372 |
+
array()
|
373 |
+
)
|
374 |
->where('csa.product_id = ?', $productId);
|
375 |
+
// @codingStandardsIgnoreEnd
|
376 |
|
377 |
+
// @codingStandardsIgnoreStart
|
378 |
$result = $this->getConnRead()->fetchAll($query);
|
379 |
+
// @codingStandardsIgnoreEnd
|
380 |
|
381 |
+
if ($result !== false) {
|
382 |
+
foreach ($result as $row) {
|
|
|
|
|
383 |
$data[] = $row['attribute_code'];
|
384 |
}
|
385 |
}
|
390 |
public function explodeMultiselectValue($value)
|
391 |
{
|
392 |
$arr = array();
|
393 |
+
if (!empty($value)) {
|
|
|
394 |
$arr = explode(',', $value);
|
395 |
foreach ($arr as $k => $v) $arr[$k] = trim($v);
|
396 |
}
|
397 |
+
|
398 |
return $arr;
|
399 |
}
|
400 |
|
403 |
*/
|
404 |
public function getRes()
|
405 |
{
|
406 |
+
if ($this->_res === null) {
|
|
|
407 |
$this->_res = Mage::getSingleton('core/resource');
|
408 |
}
|
409 |
+
|
410 |
return $this->_res;
|
411 |
}
|
412 |
|
415 |
*/
|
416 |
public function getConnRead()
|
417 |
{
|
418 |
+
if ($this->_connRead === null) {
|
419 |
+
$this->_connRead = $this->getRes()->getConnection('core_read');
|
|
|
420 |
}
|
421 |
+
|
422 |
+
return $this->_connRead;
|
423 |
}
|
424 |
|
425 |
/**
|
427 |
*/
|
428 |
public function getConnWrite()
|
429 |
{
|
430 |
+
if ($this->_connWrite === null) {
|
431 |
+
$this->_connWrite = $this->getRes()->getConnection('core_write');
|
|
|
432 |
}
|
433 |
+
|
434 |
+
return $this->_connWrite;
|
435 |
}
|
436 |
|
437 |
public function getMagentoEdition()
|
438 |
{
|
439 |
+
if (is_callable('Mage::getEdition')) {
|
|
|
440 |
return Mage::getEdition();
|
441 |
+
} else {
|
442 |
+
$features = array(
|
443 |
+
'Enterprise_Enterprise',
|
444 |
+
'Enterprise_AdminGws',
|
445 |
+
'Enterprise_Checkout',
|
446 |
+
'Enterprise_Customer'
|
447 |
+
);
|
448 |
$editions = array(
|
449 |
'Enterprise' => array(true, true, true, true), // ALL features
|
450 |
'Professional' => array(true, false), // ONLY the first
|
451 |
'Community' => array(false), // NO features
|
452 |
);
|
453 |
|
454 |
+
foreach ($editions as $editionName => $featuresMap) {
|
|
|
455 |
$match = true;
|
456 |
|
457 |
foreach($featuresMap as $i => $featureValue)
|
464 |
return "Unknown";
|
465 |
}
|
466 |
}
|
467 |
+
|
468 |
+
/**
|
469 |
+
* Get value from query
|
470 |
+
*/
|
471 |
+
protected function getValueFromQuery($query)
|
472 |
+
{
|
473 |
+
$value = $this->getConnRead()->fetchCol($query);
|
474 |
+
if (is_array($value) && (!isset($value[0]) || $value[0] === null))
|
475 |
+
$value = null;
|
476 |
+
elseif (is_array($value) && isset($value[0]))
|
477 |
+
$value = $value[0];
|
478 |
+
else if (is_array($value) && count($value) == 0)
|
479 |
+
$value = null;
|
480 |
+
|
481 |
+
return $value;
|
482 |
+
}
|
483 |
}
|
app/code/community/Doofinder/Feed/Test/Controller/Index.php
CHANGED
@@ -25,9 +25,6 @@ class Doofinder_Feed_Test_Controller_Index extends EcomDev_PHPUnit_Test_Case_Con
|
|
25 |
{
|
26 |
$this->dispatch('doofinder/feed');
|
27 |
$this->assertRequestRoute('doofinder_feed/feed/index');
|
28 |
-
// var_dump($this->getResponse());
|
29 |
-
// $this->reset;
|
30 |
-
// $this->assertRequestRoute('cms');
|
31 |
}
|
32 |
|
33 |
/**
|
@@ -42,6 +39,5 @@ class Doofinder_Feed_Test_Controller_Index extends EcomDev_PHPUnit_Test_Case_Con
|
|
42 |
{
|
43 |
$this->dispatch('doofinder/feed/config');
|
44 |
$this->assertRequestRoute('doofinder_feed/feed/config');
|
45 |
-
// $this->assertRequestRoute('cms');
|
46 |
}
|
47 |
}
|
25 |
{
|
26 |
$this->dispatch('doofinder/feed');
|
27 |
$this->assertRequestRoute('doofinder_feed/feed/index');
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
/**
|
39 |
{
|
40 |
$this->dispatch('doofinder/feed/config');
|
41 |
$this->assertRequestRoute('doofinder_feed/feed/config');
|
|
|
42 |
}
|
43 |
}
|
app/code/community/Doofinder/Feed/Test/Controller/Index/fixtures/testFeed.yaml
CHANGED
@@ -1,6 +1,3 @@
|
|
1 |
-
<<<<<<< HEAD
|
2 |
-
|
3 |
-
=======
|
4 |
config:
|
5 |
default/catalog/price/scope: 1 # Set price scope to website
|
6 |
-
>>>>>>> bug/price-calculation
|
|
|
1 |
-
|
|
|
2 |
config:
|
3 |
default/catalog/price/scope: 1 # Set price scope to website
|
|
app/code/community/Doofinder/Feed/Test/Controller/Index/providers/testFeed.yaml
CHANGED
@@ -1,2 +1 @@
|
|
1 |
-
|
2 |
-
-
|
1 |
-
|
|
app/code/community/Doofinder/Feed/Test/Model/Product.php
CHANGED
@@ -13,37 +13,27 @@ class Doofinder_Feed_Test_Model_Product extends EcomDev_PHPUnit_Test_Case
|
|
13 |
{
|
14 |
$storeId = Mage::app()->getStore($storeId)->getId();
|
15 |
|
16 |
-
// var_dump(Mage::getConfig()->getNode('default/tax/calculation'));
|
17 |
-
|
18 |
$generator = Mage::helper('doofinder_feed');
|
19 |
|
20 |
-
/* @var $product Mage_Catalog_Model_Product */
|
21 |
$product = Mage::getModel('catalog/product')
|
22 |
->setStoreId($storeId)
|
23 |
->load($productId);
|
24 |
|
25 |
$prices = $generator->collectProductPrices(
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
|
33 |
$finalPriceInclTax = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true);
|
34 |
$finalPriceExclTax = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), false);
|
35 |
|
36 |
-
|
37 |
-
// $this->assertNotEquals(
|
38 |
-
// $finalPriceInclTax,
|
39 |
-
// $finalPriceExclTax
|
40 |
-
// );
|
41 |
-
|
42 |
-
$expected = $this->expected('%s-%s', $productId, $storeId);
|
43 |
|
44 |
// Check that final price matches expected
|
45 |
-
if (isset($prices['sale_price']))
|
46 |
-
{
|
47 |
// With tax
|
48 |
$this->assertEquals(
|
49 |
Mage::helper('core')->currency($finalPriceInclTax, true, false),
|
13 |
{
|
14 |
$storeId = Mage::app()->getStore($storeId)->getId();
|
15 |
|
|
|
|
|
16 |
$generator = Mage::helper('doofinder_feed');
|
17 |
|
|
|
18 |
$product = Mage::getModel('catalog/product')
|
19 |
->setStoreId($storeId)
|
20 |
->load($productId);
|
21 |
|
22 |
$prices = $generator->collectProductPrices(
|
23 |
+
$product,
|
24 |
+
$storeId,
|
25 |
+
false,
|
26 |
+
false,
|
27 |
+
true
|
28 |
+
);
|
29 |
|
30 |
$finalPriceInclTax = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true);
|
31 |
$finalPriceExclTax = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), false);
|
32 |
|
33 |
+
$this->expected('%s-%s', $productId, $storeId);
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
// Check that final price matches expected
|
36 |
+
if (isset($prices['sale_price'])) {
|
|
|
37 |
// With tax
|
38 |
$this->assertEquals(
|
39 |
Mage::helper('core')->currency($finalPriceInclTax, true, false),
|
app/code/community/Doofinder/Feed/controllers/DoofinderFeedFeedController.php
CHANGED
@@ -6,11 +6,19 @@
|
|
6 |
/**
|
7 |
* @category controllers
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_DoofinderFeedFeedController extends Mage_Adminhtml_Controller_Action
|
13 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
/**
|
15 |
* Generate feed action
|
16 |
*/
|
@@ -56,8 +64,9 @@ class Doofinder_Feed_DoofinderFeedFeedController extends Mage_Adminhtml_Controll
|
|
56 |
|
57 |
$lockPath = Mage::helper('doofinder_feed')->getFeedLockPath($storeCode);
|
58 |
|
59 |
-
|
60 |
-
|
|
|
61 |
} else {
|
62 |
$response->setBody('Lock file not exists.');
|
63 |
return;
|
6 |
/**
|
7 |
* @category controllers
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_DoofinderFeedFeedController extends Mage_Adminhtml_Controller_Action
|
13 |
{
|
14 |
+
/**
|
15 |
+
* Override _isAllowed method
|
16 |
+
*/
|
17 |
+
protected function _isAllowed()
|
18 |
+
{
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
|
22 |
/**
|
23 |
* Generate feed action
|
24 |
*/
|
64 |
|
65 |
$lockPath = Mage::helper('doofinder_feed')->getFeedLockPath($storeCode);
|
66 |
|
67 |
+
$fileIo = new Varien_Io_File();
|
68 |
+
if ($fileIo->fileExists($lockPath)) {
|
69 |
+
$fileIo->rm($lockPath);
|
70 |
} else {
|
71 |
$response->setBody('Lock file not exists.');
|
72 |
return;
|
app/code/community/Doofinder/Feed/controllers/DoofinderFeedLogController.php
CHANGED
@@ -6,11 +6,19 @@
|
|
6 |
/**
|
7 |
* @category controllers
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_DoofinderFeedLogController extends Mage_Adminhtml_Controller_Action
|
13 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
/**
|
15 |
* View log for specified process.
|
16 |
*/
|
6 |
/**
|
7 |
* @category controllers
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
class Doofinder_Feed_DoofinderFeedLogController extends Mage_Adminhtml_Controller_Action
|
13 |
{
|
14 |
+
/**
|
15 |
+
* Override _isAllowed method
|
16 |
+
*/
|
17 |
+
protected function _isAllowed()
|
18 |
+
{
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
|
22 |
/**
|
23 |
* View log for specified process.
|
24 |
*/
|
app/code/community/Doofinder/Feed/controllers/FeedController.php
CHANGED
@@ -6,13 +6,13 @@
|
|
6 |
/**
|
7 |
* @category controllers
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Feed controller for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
@@ -80,7 +80,9 @@ class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
|
80 |
|
81 |
if ($offset > 0) {
|
82 |
$collection = $generator->getProductCollection();
|
|
|
83 |
$collection->getSelect()->limit(1, $offset);
|
|
|
84 |
|
85 |
$item = $collection->fetchItem();
|
86 |
|
@@ -115,28 +117,23 @@ class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
|
115 |
$filesUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'doofinder'.DS;
|
116 |
$filesPath = Mage::getBaseDir('media').DS.'doofinder'.DS;
|
117 |
|
118 |
-
foreach ($storeCodes as $code)
|
119 |
-
{
|
120 |
$settings = $helper->getStoreConfig($code, false);
|
121 |
|
122 |
-
if ($settings['enabled'])
|
123 |
-
{
|
124 |
$filepath = $filesPath.$settings['xmlName'];
|
125 |
-
$fileurl = $filesUrl.$settings['xmlName'];
|
126 |
$feedUrl = $filesUrl.$settings['xmlName'];
|
127 |
$feedExists = (bool) $this->_feedExists($filepath);
|
128 |
-
}
|
129 |
-
else
|
130 |
-
{
|
131 |
$feedUrl = Mage::getUrl('doofinder/feed', array('_store' => $code));
|
132 |
$feedExists = true;
|
133 |
}
|
134 |
|
135 |
$oStore = Mage::app()->getStore($code);
|
136 |
-
$
|
137 |
$password = Mage::getStoreConfig('doofinder_cron/feed_settings/password', $code);
|
138 |
$storesConfiguration[$code] = array(
|
139 |
-
'language' => strtoupper(substr($
|
140 |
'currency' => $oStore->getCurrentCurrencyCode(),
|
141 |
'feed' => $feedUrl,
|
142 |
'feed_exists' => $feedExists,
|
@@ -168,19 +165,21 @@ class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
|
168 |
* @param string $filepath
|
169 |
* @return bool
|
170 |
*/
|
171 |
-
protected function _feedExists($filepath = null)
|
172 |
-
|
|
|
173 |
return true;
|
174 |
}
|
|
|
175 |
return false;
|
176 |
}
|
177 |
|
178 |
-
protected function _dumpMessage($
|
179 |
{
|
180 |
-
$error = array('status' => $
|
181 |
|
182 |
-
if (is_array($
|
183 |
-
$error = array_merge($error, $
|
184 |
|
185 |
$this->_setJSONHeaders();
|
186 |
|
@@ -202,10 +201,10 @@ class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
|
202 |
{
|
203 |
$storeCode = $this->getRequest()->getParam('language');
|
204 |
|
205 |
-
if (
|
206 |
$storeCode = $this->getRequest()->getParam('store'); // Backwards...
|
207 |
|
208 |
-
if (
|
209 |
$storeCode = Mage::app()->getStore()->getCode();
|
210 |
|
211 |
try
|
@@ -214,8 +213,11 @@ class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
|
214 |
}
|
215 |
catch(Mage_Core_Model_Store_Exception $e)
|
216 |
{
|
217 |
-
$this->_dumpMessage(
|
218 |
-
|
|
|
|
|
|
|
219 |
}
|
220 |
}
|
221 |
|
@@ -223,16 +225,16 @@ class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
|
223 |
{
|
224 |
$value = strtolower($this->getRequest()->getParam($param));
|
225 |
|
226 |
-
if (
|
227 |
return ((int)($value *= 1) > 0);
|
228 |
|
229 |
-
$
|
230 |
-
$
|
231 |
|
232 |
-
if (
|
233 |
return true;
|
234 |
|
235 |
-
if (
|
236 |
return false;
|
237 |
|
238 |
return $defaultValue;
|
@@ -241,7 +243,7 @@ class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
|
241 |
protected function _getInteger($param, $defaultValue)
|
242 |
{
|
243 |
$value = $this->getRequest()->getParam($param);
|
244 |
-
if (
|
245 |
return (int)($value *= 1);
|
246 |
return $defaultValue;
|
247 |
}
|
@@ -251,81 +253,10 @@ class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
|
251 |
* @param string $dir
|
252 |
* @return bool
|
253 |
*/
|
254 |
-
protected function _createDirectory($dir = null)
|
255 |
-
|
256 |
-
|
257 |
-
if(!mkdir($dir, 0777, true)) {
|
258 |
-
Mage::throwException('Could not create directory: '.$dir);
|
259 |
-
}
|
260 |
|
261 |
return true;
|
262 |
}
|
263 |
-
|
264 |
-
/*
|
265 |
-
TEST TOOLS
|
266 |
-
*/
|
267 |
-
|
268 |
-
// public function testsAction()
|
269 |
-
// {
|
270 |
-
// if ( !in_array(Mage::helper('core/http')->getRemoteAddr(), array('127.0.0.1', '::1')) )
|
271 |
-
// {
|
272 |
-
// $this->norouteAction();
|
273 |
-
// return false;
|
274 |
-
// }
|
275 |
-
|
276 |
-
// $oStore = Mage::app()->getStore($this->_getStoreCode());
|
277 |
-
// $bGrouped = $this->_getBoolean('grouped', true);
|
278 |
-
// $bMinimalPrice = $this->_getBoolean('minimal_price', false);
|
279 |
-
// $bCurrencyConvert = $this->_getBoolean('convert_currency', true);
|
280 |
-
// $iCustomerGroupId = $this->_getInteger('customer_group', 0);
|
281 |
-
|
282 |
-
// $ids = array(
|
283 |
-
// 'simple' => array(166, 27),
|
284 |
-
// 'grouped' => 54,
|
285 |
-
// 'configurable' => 83,
|
286 |
-
// 'virtual' => 142,
|
287 |
-
// 'bundle' => 158,
|
288 |
-
// 'downloadable' => 167
|
289 |
-
// );
|
290 |
-
|
291 |
-
// $data = array(
|
292 |
-
// 'store' => array(
|
293 |
-
// 'store_id' => $oStore->getStoreId(),
|
294 |
-
// 'website_id' => $oStore->getWebsiteId(),
|
295 |
-
// 'base_currency' => $oStore->getBaseCurrencyCode(),
|
296 |
-
// 'current_currency' => $oStore->getCurrentCurrencyCode(),
|
297 |
-
// 'default_currency' => $oStore->getDefaultCurrencyCode(),
|
298 |
-
// ),
|
299 |
-
// 'products' => array(),
|
300 |
-
// );
|
301 |
-
|
302 |
-
// $rule = Mage::getModel('catalogrule/rule');
|
303 |
-
// $dataHelper = Mage::helper('doofinder_feed');
|
304 |
-
|
305 |
-
// foreach ($ids as $product_type => $ids)
|
306 |
-
// {
|
307 |
-
// foreach ((array) $ids as $id)
|
308 |
-
// {
|
309 |
-
// $product = Mage::getModel('catalog/product')
|
310 |
-
// ->setStoreId($oStore->getStoreId())
|
311 |
-
// ->setCustomerGroupId($iCustomerGroupId)
|
312 |
-
// ->load($id);
|
313 |
-
|
314 |
-
// $data['products'][$id] = array(
|
315 |
-
// 'product_type' => $product_type,
|
316 |
-
// 'name' => $product->getName(),
|
317 |
-
// );
|
318 |
-
|
319 |
-
// $data['products'][$id] = array_merge(
|
320 |
-
// $data['products'][$id],
|
321 |
-
// $dataHelper->collectProductPrices($product, $oStore, $bCurrencyConvert, $bMinimalPrice, $bGrouped)
|
322 |
-
// );
|
323 |
-
// }
|
324 |
-
// }
|
325 |
-
|
326 |
-
// $this->_setJSONHeaders();
|
327 |
-
|
328 |
-
// $response = Mage::helper('core')->jsonEncode($data);
|
329 |
-
// $this->getResponse()->setBody($response);
|
330 |
-
// }
|
331 |
}
|
6 |
/**
|
7 |
* @category controllers
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Feed controller for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
|
80 |
|
81 |
if ($offset > 0) {
|
82 |
$collection = $generator->getProductCollection();
|
83 |
+
// @codingStandardsIgnoreStart
|
84 |
$collection->getSelect()->limit(1, $offset);
|
85 |
+
// @codingStandardsIgnoreEnd
|
86 |
|
87 |
$item = $collection->fetchItem();
|
88 |
|
117 |
$filesUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'doofinder'.DS;
|
118 |
$filesPath = Mage::getBaseDir('media').DS.'doofinder'.DS;
|
119 |
|
120 |
+
foreach ($storeCodes as $code) {
|
|
|
121 |
$settings = $helper->getStoreConfig($code, false);
|
122 |
|
123 |
+
if ($settings['enabled']) {
|
|
|
124 |
$filepath = $filesPath.$settings['xmlName'];
|
|
|
125 |
$feedUrl = $filesUrl.$settings['xmlName'];
|
126 |
$feedExists = (bool) $this->_feedExists($filepath);
|
127 |
+
} else {
|
|
|
|
|
128 |
$feedUrl = Mage::getUrl('doofinder/feed', array('_store' => $code));
|
129 |
$feedExists = true;
|
130 |
}
|
131 |
|
132 |
$oStore = Mage::app()->getStore($code);
|
133 |
+
$locale = Mage::getStoreConfig('general/locale/code', $oStore->getId());
|
134 |
$password = Mage::getStoreConfig('doofinder_cron/feed_settings/password', $code);
|
135 |
$storesConfiguration[$code] = array(
|
136 |
+
'language' => strtoupper(substr($locale, 0, 2)),
|
137 |
'currency' => $oStore->getCurrentCurrencyCode(),
|
138 |
'feed' => $feedUrl,
|
139 |
'feed_exists' => $feedExists,
|
165 |
* @param string $filepath
|
166 |
* @return bool
|
167 |
*/
|
168 |
+
protected function _feedExists($filepath = null)
|
169 |
+
{
|
170 |
+
if ((new Varien_Io_File)->fileExists($filepath)) {
|
171 |
return true;
|
172 |
}
|
173 |
+
|
174 |
return false;
|
175 |
}
|
176 |
|
177 |
+
protected function _dumpMessage($level, $message, $extra = array())
|
178 |
{
|
179 |
+
$error = array('status' => $level, 'message' => $message);
|
180 |
|
181 |
+
if (is_array($extra) && !empty($extra))
|
182 |
+
$error = array_merge($error, $extra);
|
183 |
|
184 |
$this->_setJSONHeaders();
|
185 |
|
201 |
{
|
202 |
$storeCode = $this->getRequest()->getParam('language');
|
203 |
|
204 |
+
if ($storeCode === null)
|
205 |
$storeCode = $this->getRequest()->getParam('store'); // Backwards...
|
206 |
|
207 |
+
if ($storeCode === null)
|
208 |
$storeCode = Mage::app()->getStore()->getCode();
|
209 |
|
210 |
try
|
213 |
}
|
214 |
catch(Mage_Core_Model_Store_Exception $e)
|
215 |
{
|
216 |
+
$this->_dumpMessage(
|
217 |
+
'error',
|
218 |
+
'Invalid <language> parameter.',
|
219 |
+
array('code' => 'INVALID_OPTIONS')
|
220 |
+
);
|
221 |
}
|
222 |
}
|
223 |
|
225 |
{
|
226 |
$value = strtolower($this->getRequest()->getParam($param));
|
227 |
|
228 |
+
if (is_numeric($value))
|
229 |
return ((int)($value *= 1) > 0);
|
230 |
|
231 |
+
$true = array('true', 'on', 'yes');
|
232 |
+
$false = array('false', 'off', 'no');
|
233 |
|
234 |
+
if (in_array($value, $true))
|
235 |
return true;
|
236 |
|
237 |
+
if (in_array($value, $false))
|
238 |
return false;
|
239 |
|
240 |
return $defaultValue;
|
243 |
protected function _getInteger($param, $defaultValue)
|
244 |
{
|
245 |
$value = $this->getRequest()->getParam($param);
|
246 |
+
if (is_numeric($value))
|
247 |
return (int)($value *= 1);
|
248 |
return $defaultValue;
|
249 |
}
|
253 |
* @param string $dir
|
254 |
* @return bool
|
255 |
*/
|
256 |
+
protected function _createDirectory($dir = null)
|
257 |
+
{
|
258 |
+
(new Varien_Io_File())->checkAndCreateFolder($dir, 0777);
|
|
|
|
|
|
|
259 |
|
260 |
return true;
|
261 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
}
|
app/code/community/Doofinder/Feed/controllers/IndexController.php
CHANGED
@@ -6,13 +6,13 @@
|
|
6 |
/**
|
7 |
* @category controllers
|
8 |
* @package Doofinder_Feed
|
9 |
-
* @version 1.8.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Index controller for Doofinder Feed
|
14 |
*
|
15 |
-
* @version 1.8.
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_IndexController extends Mage_Core_Controller_Front_Action
|
@@ -22,10 +22,16 @@ class Doofinder_Feed_IndexController extends Mage_Core_Controller_Front_Action
|
|
22 |
$this->_redirect('/');
|
23 |
}
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
$allStores = Mage::app()->getStores();
|
27 |
foreach ($allStores as $store) {
|
|
|
28 |
var_dump($store->getCode());
|
|
|
29 |
}
|
30 |
|
31 |
}
|
6 |
/**
|
7 |
* @category controllers
|
8 |
* @package Doofinder_Feed
|
9 |
+
* @version 1.8.11
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Index controller for Doofinder Feed
|
14 |
*
|
15 |
+
* @version 1.8.11
|
16 |
* @package Doofinder_Feed
|
17 |
*/
|
18 |
class Doofinder_Feed_IndexController extends Mage_Core_Controller_Front_Action
|
22 |
$this->_redirect('/');
|
23 |
}
|
24 |
|
25 |
+
/**
|
26 |
+
* @SuppressWarnings(PHPMD)
|
27 |
+
*/
|
28 |
+
public function testAction()
|
29 |
+
{
|
30 |
$allStores = Mage::app()->getStores();
|
31 |
foreach ($allStores as $store) {
|
32 |
+
// @codingStandardsIgnoreStart
|
33 |
var_dump($store->getCode());
|
34 |
+
// @codingStandardsIgnoreEnd
|
35 |
}
|
36 |
|
37 |
}
|
app/code/community/Doofinder/Feed/etc/config.xml
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
|
4 |
<modules>
|
5 |
<Doofinder_Feed>
|
6 |
-
<version>1.8.
|
7 |
</Doofinder_Feed>
|
8 |
</modules>
|
9 |
<global>
|
3 |
|
4 |
<modules>
|
5 |
<Doofinder_Feed>
|
6 |
+
<version>1.8.11</version>
|
7 |
</Doofinder_Feed>
|
8 |
</modules>
|
9 |
<global>
|
app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-install-1.5.4.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
<?php
|
|
|
2 |
|
3 |
$installer = $this;
|
4 |
|
@@ -8,51 +9,113 @@ $installer->startSetup();
|
|
8 |
* Cron table
|
9 |
*/
|
10 |
|
11 |
-
if (version_compare(Mage::getVersion(), '1.6', '<'))
|
12 |
-
{
|
13 |
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('doofinder_feed/cron')};");
|
14 |
-
}
|
15 |
-
|
16 |
-
{
|
17 |
-
$installer->getConnection()->dropTable( $installer->getTable('doofinder_feed/cron') );
|
18 |
}
|
19 |
|
20 |
$table = $installer->getConnection()
|
21 |
->newTable($installer->getTable('doofinder_feed/cron'))
|
22 |
-
->addColumn(
|
23 |
-
'
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
'
|
32 |
-
|
33 |
-
->addColumn(
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
$installer->getConnection()->createTable($table);
|
58 |
|
1 |
+
<?php // @codingStandardsIgnoreStart
|
2 |
+
// @codingStandardsIgnoreEnd
|
3 |
|
4 |
$installer = $this;
|
5 |
|
9 |
* Cron table
|
10 |
*/
|
11 |
|
12 |
+
if (version_compare(Mage::getVersion(), '1.6', '<')) {
|
|
|
13 |
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('doofinder_feed/cron')};");
|
14 |
+
} else {
|
15 |
+
$installer->getConnection()->dropTable($installer->getTable('doofinder_feed/cron'));
|
|
|
|
|
16 |
}
|
17 |
|
18 |
$table = $installer->getConnection()
|
19 |
->newTable($installer->getTable('doofinder_feed/cron'))
|
20 |
+
->addColumn(
|
21 |
+
'id',
|
22 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
23 |
+
null,
|
24 |
+
array(
|
25 |
+
'nullable' => false,
|
26 |
+
'identity' => true,
|
27 |
+
'primary' => true,
|
28 |
+
),
|
29 |
+
'ID'
|
30 |
+
)
|
31 |
+
->addColumn(
|
32 |
+
'store_code',
|
33 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
34 |
+
255,
|
35 |
+
array(
|
36 |
+
'nullable' => false,
|
37 |
+
),
|
38 |
+
'Store Code'
|
39 |
+
)
|
40 |
+
->addColumn(
|
41 |
+
'status',
|
42 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
43 |
+
255,
|
44 |
+
array(
|
45 |
+
'length' => 255,
|
46 |
+
),
|
47 |
+
'Status'
|
48 |
+
)
|
49 |
+
->addColumn(
|
50 |
+
'message',
|
51 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
52 |
+
255,
|
53 |
+
array(),
|
54 |
+
'Message'
|
55 |
+
)
|
56 |
+
->addColumn(
|
57 |
+
'error_stack',
|
58 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
59 |
+
null,
|
60 |
+
array(
|
61 |
+
'default' => 0,
|
62 |
+
),
|
63 |
+
'Error Stack'
|
64 |
+
)
|
65 |
+
->addColumn(
|
66 |
+
'complete',
|
67 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
68 |
+
255,
|
69 |
+
array(
|
70 |
+
'length' => 12,
|
71 |
+
),
|
72 |
+
'Complete'
|
73 |
+
)
|
74 |
+
->addColumn(
|
75 |
+
'next_run',
|
76 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
77 |
+
255,
|
78 |
+
array(
|
79 |
+
'length' => 255,
|
80 |
+
),
|
81 |
+
'Next Run'
|
82 |
+
)
|
83 |
+
->addColumn(
|
84 |
+
'next_iteration',
|
85 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
86 |
+
255,
|
87 |
+
array(
|
88 |
+
'length' => 255,
|
89 |
+
),
|
90 |
+
'Next Iteration'
|
91 |
+
)
|
92 |
+
->addColumn(
|
93 |
+
'last_feed_name',
|
94 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
95 |
+
255,
|
96 |
+
array(
|
97 |
+
'length' => 255,
|
98 |
+
),
|
99 |
+
'Last Feed Name'
|
100 |
+
)
|
101 |
+
->addColumn(
|
102 |
+
'offset',
|
103 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
104 |
+
null,
|
105 |
+
array(
|
106 |
+
'default' => 0,
|
107 |
+
),
|
108 |
+
'Offset'
|
109 |
+
)
|
110 |
+
->addColumn(
|
111 |
+
'schedule_id',
|
112 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
113 |
+
null,
|
114 |
+
array(
|
115 |
+
'default' => null,
|
116 |
+
),
|
117 |
+
'Schedule ID'
|
118 |
+
);
|
119 |
|
120 |
$installer->getConnection()->createTable($table);
|
121 |
|
app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-install-1.5.7.php
CHANGED
@@ -4,17 +4,14 @@ $installer = $this;
|
|
4 |
|
5 |
$installer->startSetup();
|
6 |
|
7 |
-
// 1.5
|
8 |
-
if (
|
9 |
-
{
|
10 |
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('doofinder_feed/cron')};");
|
11 |
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('doofinder_feed/log')};");
|
12 |
-
}
|
13 |
-
// 1.6+
|
14 |
-
|
15 |
-
|
16 |
-
$installer->getConnection()->dropTable( $installer->getTable('doofinder_feed/cron') );
|
17 |
-
$installer->getConnection()->dropTable( $installer->getTable('doofinder_feed/log') );
|
18 |
}
|
19 |
|
20 |
/**
|
@@ -23,87 +20,172 @@ else
|
|
23 |
|
24 |
$table = $installer->getConnection()
|
25 |
->newTable($installer->getTable('doofinder_feed/cron'))
|
26 |
-
->addColumn(
|
27 |
-
'
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
'
|
36 |
-
|
37 |
-
->addColumn(
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
$installer->getConnection()->createTable($table);
|
59 |
|
60 |
-
// 1.5
|
61 |
-
if (
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
67 |
-
|
68 |
-
");
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
* Log table
|
73 |
*/
|
74 |
|
75 |
-
// 1.6+
|
76 |
-
if (
|
77 |
-
{
|
78 |
// Add log table
|
79 |
$table = $installer->getConnection()
|
80 |
->newTable($installer->getTable('doofinder_feed/log'))
|
81 |
-
->addColumn(
|
82 |
-
'
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
'
|
91 |
-
|
92 |
-
->addColumn(
|
93 |
-
'
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
// Add indexes to log table
|
101 |
$table->addIndex(
|
102 |
$installer->getIdxName(
|
103 |
'doofinder_feed/log',
|
104 |
array(
|
105 |
-
|
106 |
-
|
107 |
),
|
108 |
Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
|
109 |
),
|
@@ -128,36 +210,25 @@ if ( ! version_compare(Mage::getVersion(), '1.6', '<') )
|
|
128 |
);
|
129 |
|
130 |
$installer->getConnection()->createTable($table);
|
131 |
-
}
|
132 |
-
// 1.5
|
133 |
-
|
134 |
-
{
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
);
|
144 |
-
|
145 |
-
ALTER TABLE {$installer->getTable('doofinder_feed/log')}
|
146 |
-
ADD PRIMARY KEY (`id`), ADD KEY `IDX_DOOFINDER_LOG_PROCESS_ID_TYPE` (`process_id`,`type`), ADD KEY `IDX_DOOFINDER_LOG_TIME` (`time`);
|
147 |
-
|
148 |
-
ALTER TABLE {$installer->getTable('doofinder_feed/log')}
|
149 |
-
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
150 |
-
|
151 |
-
");
|
152 |
}
|
153 |
|
154 |
-
// /**
|
155 |
-
// * Trigger feed generation
|
156 |
-
// */
|
157 |
-
// $scheduleObserver = Mage::getSingleton('doofinder_feed/observers_schedule');
|
158 |
-
|
159 |
-
// foreach (Mage::getModel('core/store')->getCollection() as $store) {
|
160 |
-
// $scheduleObserver->updateProcess($store->getCode(), true, true);
|
161 |
-
// }
|
162 |
-
|
163 |
$installer->endSetup();
|
4 |
|
5 |
$installer->startSetup();
|
6 |
|
7 |
+
// version 1.5
|
8 |
+
if (version_compare(Mage::getVersion(), '1.6', '<')) {
|
|
|
9 |
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('doofinder_feed/cron')};");
|
10 |
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('doofinder_feed/log')};");
|
11 |
+
} else {
|
12 |
+
// version 1.6+
|
13 |
+
$installer->getConnection()->dropTable($installer->getTable('doofinder_feed/cron'));
|
14 |
+
$installer->getConnection()->dropTable($installer->getTable('doofinder_feed/log'));
|
|
|
|
|
15 |
}
|
16 |
|
17 |
/**
|
20 |
|
21 |
$table = $installer->getConnection()
|
22 |
->newTable($installer->getTable('doofinder_feed/cron'))
|
23 |
+
->addColumn(
|
24 |
+
'id',
|
25 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
26 |
+
null,
|
27 |
+
array(
|
28 |
+
'nullable' => false,
|
29 |
+
'identity' => true,
|
30 |
+
'primary' => true,
|
31 |
+
),
|
32 |
+
'ID'
|
33 |
+
)
|
34 |
+
->addColumn(
|
35 |
+
'store_code',
|
36 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
37 |
+
255,
|
38 |
+
array(
|
39 |
+
'nullable' => false,
|
40 |
+
),
|
41 |
+
'Store Code'
|
42 |
+
)
|
43 |
+
->addColumn(
|
44 |
+
'status',
|
45 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
46 |
+
255,
|
47 |
+
array(
|
48 |
+
'length' => 255,
|
49 |
+
),
|
50 |
+
'Status'
|
51 |
+
)
|
52 |
+
->addColumn(
|
53 |
+
'message',
|
54 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
55 |
+
255,
|
56 |
+
array(),
|
57 |
+
'Message'
|
58 |
+
)
|
59 |
+
->addColumn(
|
60 |
+
'error_stack',
|
61 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
62 |
+
null,
|
63 |
+
array(
|
64 |
+
'default' => 0,
|
65 |
+
),
|
66 |
+
'Error Stack'
|
67 |
+
)
|
68 |
+
->addColumn(
|
69 |
+
'complete',
|
70 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
71 |
+
255,
|
72 |
+
array(
|
73 |
+
'length' => 12,
|
74 |
+
),
|
75 |
+
'Complete'
|
76 |
+
)
|
77 |
+
->addColumn(
|
78 |
+
'next_run',
|
79 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
80 |
+
255,
|
81 |
+
array(
|
82 |
+
'length' => 255,
|
83 |
+
),
|
84 |
+
'Next Run'
|
85 |
+
)
|
86 |
+
->addColumn(
|
87 |
+
'next_iteration',
|
88 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
89 |
+
255,
|
90 |
+
array(
|
91 |
+
'length' => 255,
|
92 |
+
),
|
93 |
+
'Next Iteration'
|
94 |
+
)
|
95 |
+
->addColumn(
|
96 |
+
'last_feed_name',
|
97 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
98 |
+
255,
|
99 |
+
array(
|
100 |
+
'length' => 255,
|
101 |
+
),
|
102 |
+
'Last Feed Name'
|
103 |
+
)
|
104 |
+
->addColumn(
|
105 |
+
'offset',
|
106 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
107 |
+
null,
|
108 |
+
array(
|
109 |
+
'default' => 0,
|
110 |
+
),
|
111 |
+
'Offset'
|
112 |
+
);
|
113 |
|
114 |
$installer->getConnection()->createTable($table);
|
115 |
|
116 |
+
// version 1.5
|
117 |
+
if (version_compare(Mage::getVersion(), '1.6', '<')) {
|
118 |
+
$installer->run(
|
119 |
+
"ALTER TABLE {$installer->getTable('doofinder_feed/cron')}
|
120 |
+
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;"
|
121 |
+
);
|
|
|
|
|
|
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
* Log table
|
126 |
*/
|
127 |
|
128 |
+
// version 1.6+
|
129 |
+
if (!version_compare(Mage::getVersion(), '1.6', '<')) {
|
|
|
130 |
// Add log table
|
131 |
$table = $installer->getConnection()
|
132 |
->newTable($installer->getTable('doofinder_feed/log'))
|
133 |
+
->addColumn(
|
134 |
+
'id',
|
135 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
136 |
+
null,
|
137 |
+
array(
|
138 |
+
'nullable' => false,
|
139 |
+
'identity' => true,
|
140 |
+
'primary' => true,
|
141 |
+
),
|
142 |
+
'ID'
|
143 |
+
)
|
144 |
+
->addColumn(
|
145 |
+
'process_id',
|
146 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
147 |
+
255,
|
148 |
+
array(
|
149 |
+
'nullable' => false,
|
150 |
+
),
|
151 |
+
'Store Code'
|
152 |
+
)
|
153 |
+
->addColumn(
|
154 |
+
'type',
|
155 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
156 |
+
255,
|
157 |
+
array(
|
158 |
+
'nullable' => false,
|
159 |
+
),
|
160 |
+
'Type'
|
161 |
+
)
|
162 |
+
->addColumn(
|
163 |
+
'time',
|
164 |
+
Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
165 |
+
null,
|
166 |
+
array(
|
167 |
+
'nullable' => false,
|
168 |
+
'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT,
|
169 |
+
),
|
170 |
+
'Type'
|
171 |
+
)
|
172 |
+
->addColumn(
|
173 |
+
'message',
|
174 |
+
Varien_Db_Ddl_Table::TYPE_TEXT,
|
175 |
+
null,
|
176 |
+
array(
|
177 |
+
'nullable' => false,
|
178 |
+
),
|
179 |
+
'Message'
|
180 |
+
);
|
181 |
|
182 |
// Add indexes to log table
|
183 |
$table->addIndex(
|
184 |
$installer->getIdxName(
|
185 |
'doofinder_feed/log',
|
186 |
array(
|
187 |
+
'process_id',
|
188 |
+
'type',
|
189 |
),
|
190 |
Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
|
191 |
),
|
210 |
);
|
211 |
|
212 |
$installer->getConnection()->createTable($table);
|
213 |
+
} else {
|
214 |
+
// version 1.5
|
215 |
+
$installer->run(
|
216 |
+
"CREATE TABLE {$installer->getTable('doofinder_feed/log')} (
|
217 |
+
`id` int(11) NOT NULL COMMENT 'ID',
|
218 |
+
`process_id` varchar(255) NOT NULL COMMENT 'Store Code',
|
219 |
+
`type` varchar(255) NOT NULL COMMENT 'Type',
|
220 |
+
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Type',
|
221 |
+
`message` text NOT NULL COMMENT 'Message'
|
222 |
+
);
|
223 |
+
|
224 |
+
ALTER TABLE {$installer->getTable('doofinder_feed/log')}
|
225 |
+
ADD PRIMARY KEY (`id`),
|
226 |
+
ADD KEY `IDX_DOOFINDER_LOG_PROCESS_ID_TYPE` (`process_id`,`type`),
|
227 |
+
ADD KEY `IDX_DOOFINDER_LOG_TIME` (`time`);
|
228 |
+
|
229 |
+
ALTER TABLE {$installer->getTable('doofinder_feed/log')}
|
230 |
+
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;"
|
231 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
}
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
$installer->endSetup();
|
app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-upgrade-1.5.4-1.5.5.php
CHANGED
@@ -4,15 +4,12 @@ $installer = $this;
|
|
4 |
|
5 |
$installer->startSetup();
|
6 |
|
7 |
-
// 1.5
|
8 |
-
if (
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
14 |
-
|
15 |
-
");
|
16 |
}
|
17 |
|
18 |
$installer->endSetup();
|
4 |
|
5 |
$installer->startSetup();
|
6 |
|
7 |
+
// version 1.5
|
8 |
+
if (version_compare(Mage::getVersion(), '1.6', '<')) {
|
9 |
+
$installer->run(
|
10 |
+
"ALTER TABLE {$installer->getTable('doofinder_feed/cron')}
|
11 |
+
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;"
|
12 |
+
);
|
|
|
|
|
|
|
13 |
}
|
14 |
|
15 |
$installer->endSetup();
|
app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-upgrade-1.5.5-1.5.6.php
CHANGED
@@ -4,45 +4,71 @@ $installer = $this;
|
|
4 |
|
5 |
$installer->startSetup();
|
6 |
|
7 |
-
// 1.5
|
8 |
-
if (
|
9 |
-
{
|
10 |
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('doofinder_feed/log')};");
|
11 |
-
}
|
12 |
-
// 1.6+
|
13 |
-
|
14 |
-
{
|
15 |
-
$installer->getConnection()->dropTable( $installer->getTable('doofinder_feed/log') );
|
16 |
}
|
17 |
|
18 |
/**
|
19 |
* Log table
|
20 |
*/
|
21 |
|
22 |
-
// 1.6+
|
23 |
-
if (
|
24 |
-
{
|
25 |
// Add log table
|
26 |
$table = $installer->getConnection()
|
27 |
->newTable($installer->getTable('doofinder_feed/log'))
|
28 |
-
->addColumn(
|
29 |
-
'
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
'
|
38 |
-
|
39 |
-
->addColumn(
|
40 |
-
'
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
// Add indexes to log table
|
48 |
$table->addIndex(
|
@@ -75,27 +101,25 @@ if ( ! version_compare(Mage::getVersion(), '1.6', '<') )
|
|
75 |
);
|
76 |
|
77 |
$installer->getConnection()->createTable($table);
|
78 |
-
}
|
79 |
-
// 1.5
|
80 |
-
|
81 |
-
{
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Type',
|
89 |
-
`message` text NOT NULL COMMENT 'Message'
|
90 |
-
);
|
91 |
-
|
92 |
-
ALTER TABLE {$installer->getTable('doofinder_feed/log')}
|
93 |
-
ADD PRIMARY KEY (`id`), ADD KEY `IDX_DOOFINDER_LOG_PROCESS_ID_TYPE` (`process_id`,`type`), ADD KEY `IDX_DOOFINDER_LOG_TIME` (`time`);
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
");
|
99 |
}
|
100 |
|
101 |
$installer->endSetup();
|
4 |
|
5 |
$installer->startSetup();
|
6 |
|
7 |
+
// version 1.5
|
8 |
+
if (version_compare(Mage::getVersion(), '1.6', '<')) {
|
|
|
9 |
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('doofinder_feed/log')};");
|
10 |
+
} else {
|
11 |
+
// version 1.6+
|
12 |
+
$installer->getConnection()->dropTable($installer->getTable('doofinder_feed/log'));
|
|
|
|
|
13 |
}
|
14 |
|
15 |
/**
|
16 |
* Log table
|
17 |
*/
|
18 |
|
19 |
+
// version 1.6+
|
20 |
+
if (!version_compare(Mage::getVersion(), '1.6', '<')) {
|
|
|
21 |
// Add log table
|
22 |
$table = $installer->getConnection()
|
23 |
->newTable($installer->getTable('doofinder_feed/log'))
|
24 |
+
->addColumn(
|
25 |
+
'id',
|
26 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
27 |
+
null,
|
28 |
+
array(
|
29 |
+
'nullable' => false,
|
30 |
+
'identity' => true,
|
31 |
+
'primary' => true,
|
32 |
+
),
|
33 |
+
'ID'
|
34 |
+
)
|
35 |
+
->addColumn(
|
36 |
+
'process_id',
|
37 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
38 |
+
255,
|
39 |
+
array(
|
40 |
+
'nullable' => false,
|
41 |
+
),
|
42 |
+
'Store Code'
|
43 |
+
)
|
44 |
+
->addColumn(
|
45 |
+
'type',
|
46 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
47 |
+
255,
|
48 |
+
array(
|
49 |
+
'nullable' => false,
|
50 |
+
),
|
51 |
+
'Type'
|
52 |
+
)
|
53 |
+
->addColumn(
|
54 |
+
'time',
|
55 |
+
Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
56 |
+
null,
|
57 |
+
array(
|
58 |
+
'nullable' => false,
|
59 |
+
'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT,
|
60 |
+
),
|
61 |
+
'Type'
|
62 |
+
)
|
63 |
+
->addColumn(
|
64 |
+
'message',
|
65 |
+
Varien_Db_Ddl_Table::TYPE_TEXT,
|
66 |
+
null,
|
67 |
+
array(
|
68 |
+
'nullable' => false,
|
69 |
+
),
|
70 |
+
'Message'
|
71 |
+
);
|
72 |
|
73 |
// Add indexes to log table
|
74 |
$table->addIndex(
|
101 |
);
|
102 |
|
103 |
$installer->getConnection()->createTable($table);
|
104 |
+
} else {
|
105 |
+
// version 1.5
|
106 |
+
$installer->run(
|
107 |
+
"CREATE TABLE {$installer->getTable('doofinder_feed/log')} (
|
108 |
+
`id` int(11) NOT NULL COMMENT 'ID',
|
109 |
+
`process_id` varchar(255) NOT NULL COMMENT 'Store Code',
|
110 |
+
`type` varchar(255) NOT NULL COMMENT 'Type',
|
111 |
+
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Type',
|
112 |
+
`message` text NOT NULL COMMENT 'Message'
|
113 |
+
);
|
114 |
|
115 |
+
ALTER TABLE {$installer->getTable('doofinder_feed/log')}
|
116 |
+
ADD PRIMARY KEY (`id`),
|
117 |
+
ADD KEY `IDX_DOOFINDER_LOG_PROCESS_ID_TYPE` (`process_id`,`type`),
|
118 |
+
ADD KEY `IDX_DOOFINDER_LOG_TIME` (`time`);
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
+
ALTER TABLE {$installer->getTable('doofinder_feed/log')}
|
121 |
+
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;"
|
122 |
+
);
|
|
|
123 |
}
|
124 |
|
125 |
$installer->endSetup();
|
app/code/community/Doofinder/Feed/sql/doofinder_feed_setup/mysql4-upgrade-1.5.6-1.5.7.php
CHANGED
@@ -13,7 +13,9 @@ $collection = Mage::getModel('cron/schedule')->getCollection()
|
|
13 |
->addFieldToFilter('job_code', Doofinder_Feed_Helper_Data::JOB_CODE);
|
14 |
|
15 |
foreach ($collection->getItems() as $item) {
|
|
|
16 |
$item->delete();
|
|
|
17 |
}
|
18 |
|
19 |
$installer->endSetup();
|
13 |
->addFieldToFilter('job_code', Doofinder_Feed_Helper_Data::JOB_CODE);
|
14 |
|
15 |
foreach ($collection->getItems() as $item) {
|
16 |
+
// @codingStandardsIgnoreStart
|
17 |
$item->delete();
|
18 |
+
// @codingStandardsIgnoreEnd
|
19 |
}
|
20 |
|
21 |
$installer->endSetup();
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Doofinder_Feed</name>
|
4 |
-
<version>1.8.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
@@ -48,11 +48,11 @@ Doofinder is fast and innovative. With no doubt, it is the best search engine fo
|
|
48 |
You can get more info and create your account visiting the Doofinder site:
|
49 |

|
50 |
http://www.doofinder.com</description>
|
51 |
-
<notes>
|
52 |
<authors><author><name>Carlos Escribano Rey</name><user>doofinder</user><email>carlos@doofinder.com</email></author></authors>
|
53 |
-
<date>2017-
|
54 |
-
<time>
|
55 |
-
<contents><target name="magecommunity"><dir name="Doofinder"><dir name="Feed"><dir name="Block"><dir name="Adminhtml"><dir name="Log"><file name="View.php" hash="
|
56 |
<compatible/>
|
57 |
<dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
|
58 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Doofinder_Feed</name>
|
4 |
+
<version>1.8.11</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
48 |
You can get more info and create your account visiting the Doofinder site:
|
49 |

|
50 |
http://www.doofinder.com</description>
|
51 |
+
<notes>Code standards.</notes>
|
52 |
<authors><author><name>Carlos Escribano Rey</name><user>doofinder</user><email>carlos@doofinder.com</email></author></authors>
|
53 |
+
<date>2017-07-05</date>
|
54 |
+
<time>12:01:43</time>
|
55 |
+
<contents><target name="magecommunity"><dir name="Doofinder"><dir name="Feed"><dir name="Block"><dir name="Adminhtml"><dir name="Log"><file name="View.php" hash="2f2c55c993dd6e25b930ba65d7a8e03e"/></dir><dir name="Map"><file name="Additional.php" hash="61e583353d968e889976030cee88c0a0"/></dir></dir><file name="Integration.php" hash="f4cfce344b0f8f3a0631ae02d476c3d0"/><dir name="Settings"><dir name="Buttons"><file name="Generate.php" hash="50dd6904aa1af429d25dff620f45c773"/><file name="ViewLog.php" hash="e38683f909e4d66890a273833396d4a9"/></dir><file name="Locks.php" hash="12ac7032b2a2af99715096d7458b49b5"/><dir name="Panel"><file name="AtomicUpdates.php" hash="ad8b9ef18b2a9aa2dd4d0070cf983fe4"/><file name="Crondescription.php" hash="47d4bcfd8edc0229a069d2a6c9977861"/><file name="Datetime.php" hash="b29cbede1da16de0969ec0c0810c2658"/><file name="Description.php" hash="9bbf23cececdf0de70706994bc8d609e"/><file name="DynamicFeedUrl.php" hash="c8a9e4f0ebfcfb6739a7b77f327a5a76"/><file name="File.php" hash="3b7c5de170997849bef8086f48f3bc2d"/><file name="Hashdescription.php" hash="05c800c37b8f557316776f563bb80a8e"/><file name="Layerdescription.php" hash="daba876ef5b2bf8c4a139823088bd38d"/><file name="Message.php" hash="090cef6c20c95ca3ee2ebb17e45da5b9"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ffcb0859ceea3fba50033bde3eab8a2a"/><file name="Log.php" hash="5a12bf38222ac06acfef66e48cfdcea0"/><file name="Search.php" hash="e4c58c4d69e9d31bc7b367183f647775"/><file name="Tax.php" hash="551a1df3d1d35ccd18b0b9064a669e78"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Cron.php" hash="4e0bda7e8bd09cfa3c4c242c902f8138"/></dir><dir name="Validation"><file name="Hashid.php" hash="e76803d8ac26fcd21f80fbd613b4c9fa"/></dir></dir></dir></dir><dir name="CatalogSearch"><dir name="Resource"><file name="Fulltext.php" hash="c5a29ec1970cded42514b65f7ebb60f3"/></dir></dir><file name="Config.php" hash="41deb5017b33cc90ccaffe2ccc7b1900"/><file name="Cron.php" hash="f4e349ff0fc6761b279e88a9aa07d192"/><file name="Generator.php" hash="0d1fcb601e83c7592c830f2f689c3265"/><file name="Log.php" hash="0ee15a3c73c3bbeabc1b10efe80f1f78"/><dir name="Map"><dir name="Product"><file name="Abstract.php" hash="98d124046b9c5c295203e86b8d4e50c3"/><file name="Associated.php" hash="ac602820542ac6c84a15ca8bfe8d6b1b"/><file name="Bundle.php" hash="3634d942b16cb918ea4841e8f474e906"/><file name="Configurable.php" hash="52634db66359b2a0ad2be85b6d8f899e"/><file name="Downloadable.php" hash="9057304e7c6886e22dc3a90a892b2a6c"/><file name="Grouped.php" hash="934b1f7fb805388625307cfd9a580cbc"/><file name="Simple.php" hash="67843480bfc8c73e07b1425091cb068d"/><file name="Virtual.php" hash="bdacc4b9234a7557ca481c12d87c22d7"/></dir></dir><dir name="Mysql4"><dir name="Cron"><file name="Collection.php" hash="9ee21fec580e61479c490e6684ae62d8"/></dir><file name="Cron.php" hash="3a852f633dcb3b59846f94df3e715e28"/><dir name="Log"><file name="Collection.php" hash="f7acb031bb205cc1dab826f7aa8561b7"/></dir><file name="Log.php" hash="c52bcd22ccbdc84dc70e46302cd04b58"/></dir><dir name="Observers"><file name="Feed.php" hash="bfeb45ddd07d3dc6c91bdee81daf4c79"/><file name="Logs.php" hash="aa1d036be1bc5da39067a8648c2e97a4"/><file name="Schedule.php" hash="b41b9295bf15ed2e233083065ba5773c"/></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="56c0fc6a310b877d351a4df22c2c3035"/></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Map"><file name="Additional.php" hash="500f45ac81a9732b57b258469672802d"/></dir><file name="Password.php" hash="bc3f1ece8a3bd6b51737eaf21691b67f"/><dir name="Total"><file name="Limit.php" hash="85dbe458d2b4513120211af51a747c3a"/></dir></dir><file name="Reset.php" hash="b0afb1b09d14b9a85c23ff5d8376be2b"/><dir name="Source"><dir name="Feed"><file name="Pricetaxmode.php" hash="f35d06947f16c961c48d5e9b5a6969fb"/></dir><dir name="Product"><file name="Attributes.php" hash="3df22f6abd0e09afe0f4db0ab777b506"/></dir></dir></dir></dir><file name="Tools.php" hash="e7506007327bb83576640ac81e072716"/></dir><dir name="Test"><dir name="Controller"><dir name="Index"><dir name="fixtures"><file name="testConfig.yaml" hash="0a1f21a3417389e0c0a13392c79a7a89"/><file name="testFeed.yaml" hash="32191e86e4036ebd681a8dff684be83a"/><file name="testIndex.yaml" hash="0a1f21a3417389e0c0a13392c79a7a89"/></dir><dir name="providers"><file name="testConfig.yaml" hash="0a1f21a3417389e0c0a13392c79a7a89"/><file name="testFeed.yaml" hash="0a1f21a3417389e0c0a13392c79a7a89"/><file name="testIndex.yaml" hash="0a1f21a3417389e0c0a13392c79a7a89"/></dir></dir><file name="Index.php" hash="e2e77aed8d7ed07e3f03ede97178a911"/></dir><dir name="Model"><dir name="Product"><dir name="expectations"><file name="testGenerator.yaml" hash="232dda1f4fd88b8ef081393f08044731"/></dir><dir name="fixtures"><file name="testGenerator.yaml" hash="df25e3ca67fd98ab1b933c4951c599ef"/></dir><dir name="providers"><file name="testGenerator.yaml" hash="84779d5dcd8d92abdecf0cd5ee65cfb0"/></dir></dir><file name="Product.php" hash="1bf5947dbbe2b99f20659c3da3cf4621"/></dir></dir><dir name="controllers"><file name="DoofinderFeedFeedController.php" hash="a88e482e4881f6b270f5340c14df1027"/><file name="DoofinderFeedLogController.php" hash="6a921ef1d5bcf3d33b7ce0218b7735da"/><file name="FeedController.php" hash="478377910630fd34a960d0e657285aae"/><file name="IndexController.php" hash="8349cb1b96650a3d57741741acd55265"/></dir><dir name="etc"><file name="config.xml" hash="ac29cee29f712a0491c9bd1b45d401c7"/><file name="system.xml" hash="4fba4adc1eaf2f1700757f981272d866"/></dir><dir name="sql"><dir name="doofinder_feed_setup"><file name="mysql4-install-1.5.4.php" hash="6ac53ca537803a63e73fc3e38b79bbe0"/><file name="mysql4-install-1.5.7.php" hash="a9ed5fb3d35162622c2049a303bc2b48"/><file name="mysql4-upgrade-1.5.4-1.5.5.php" hash="7ebdb63d2c55b11d1e41f16781fabb9c"/><file name="mysql4-upgrade-1.5.5-1.5.6.php" hash="81115e9985db00c187ae33d004d677f2"/><file name="mysql4-upgrade-1.5.6-1.5.7.php" hash="c7ffec01b48b3a162d4f6d5a7a7b4650"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Doofinder_Feed.xml" hash="9d3b6fbbbec12708461c33260715451c"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="doofinder.xml" hash="a7b9105a4e613086340b042845793d9f"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="doofinder.xml" hash="48a8636096950914917461260416c355"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="doofinder"><file name="admin.js" hash="ca050b0527ae101c75532fbca1c4a274"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="doofinder"><file name="styles.css" hash="fd53b0128822fda40bcda7828fcc9f51"/></dir></dir></dir></dir></target><target name="magelib"><dir name="php-doofinder"><file name="CHANGELOG.txt" hash="b4fc19b1cb37810d8faa6a1e784ab32b"/><file name="README.md" hash="f9eda30362e3356947f86a9248122c2f"/><file name="autoload.php" hash="1ab27f8a639e30c5a25a6100f1a3035d"/><file name="composer.json" hash="76f54c3a763a3ae683fa677106b41027"/><file name="phpunit.xml" hash="97d89bb72790578c7ca60aebe7e3b1dd"/><dir name="src"><dir name="Management"><file name="AggregatesIterator.php" hash="431618213beb8294f6cab35376c935c8"/><file name="Client.php" hash="3d4dc1dbabcb42c7b1e4835ff5056d21"/><dir name="Errors"><file name="BadRequest.php" hash="45113fccee9500f4ee2a20e845ef8ee2"/><file name="NotAllowed.php" hash="98169302570fcf34a49277c5afbbed20"/><file name="NotFound.php" hash="9b08d95a549cfaea5562ecfa74a28746"/><file name="NotProcessedResponse.php" hash="63984cfbe90b6912e8d53faa293e65d6"/><file name="QuotaExhausted.php" hash="75f95704e509d7b5a4c61ebdb76208f5"/><file name="ThrottledResponse.php" hash="d3cd9c6df62246b5c3e80de3e1ecfc9c"/><file name="Utils.php" hash="be1220fc529292e8cc723dc9f68ef81d"/><file name="WrongResponse.php" hash="3c0fd79d6c04ac2c8f93984912369333"/></dir><file name="ItemsResultSet.php" hash="67532bd88b478fb4e0ce9f05d2ffd94a"/><file name="ScrollIterator.php" hash="0d916403f85a791af8e4e2240ad9e1be"/><file name="SearchEngine.php" hash="417e44ce9f11be52d3a6679161014eb8"/><file name="TopTermsIterator.php" hash="9ef2a784ce1d2cae81e577ce8c13ed08"/></dir><dir name="Search"><file name="Client.php" hash="857ed6a6594776f3060d87c2c9b86aca"/><file name="Error.php" hash="38a4283a860ed443f43a8452cc931c99"/><file name="Results.php" hash="87417657ec8a4908d6fd35868b782d7e"/></dir><dir name="Test"><dir name="Management"><file name="AggregatesIteratorTest.php" hash="eb9abdc3de26ac6396efc007373906ca"/><file name="ClientTest.php" hash="9958013403856eab97a44a14b8c32569"/><file name="ScrollIteratorTest.php" hash="34ef0111f1bb3633e6950151efd5e3ec"/><file name="SearchEngineTest.php" hash="a354a2e690851ab8d2b9a41495fcd979"/><file name="TopTermsIteratorTest.php" hash="9804ca4b89dce16d1e89b6614c11c2c0"/></dir><dir name="Search"><file name="ClientTest.php" hash="6aeac0a72fc4a4798233dfde15014543"/><file name="ResultsTests.php" hash="64503776af865c5d23e261b71d36a6bc"/></dir></dir></dir></dir></target></contents>
|
56 |
<compatible/>
|
57 |
<dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
|
58 |
</package>
|
skin/adminhtml/default/default/doofinder/styles.css
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
}
|
21 |
|
22 |
#row_doofinder_cron_schedule_settings_time .df-separator:before {
|
23 |
-
content: " : "
|
24 |
}
|
25 |
|
26 |
#row_doofinder_search_layer_settings_script textarea {
|
@@ -34,7 +34,7 @@
|
|
34 |
.doofinder-warning {
|
35 |
padding: 10px;
|
36 |
border: 1px solid transparent;
|
37 |
-
font-size: .95em !important;
|
38 |
}
|
39 |
|
40 |
.doofinder-info {
|
@@ -44,7 +44,7 @@
|
|
44 |
}
|
45 |
|
46 |
.doofinder-warning {
|
47 |
-
border-color: #
|
48 |
-
background-color: #
|
49 |
-
color: #
|
50 |
}
|
20 |
}
|
21 |
|
22 |
#row_doofinder_cron_schedule_settings_time .df-separator:before {
|
23 |
+
content: " : ";
|
24 |
}
|
25 |
|
26 |
#row_doofinder_search_layer_settings_script textarea {
|
34 |
.doofinder-warning {
|
35 |
padding: 10px;
|
36 |
border: 1px solid transparent;
|
37 |
+
font-size: 0.95em !important;
|
38 |
}
|
39 |
|
40 |
.doofinder-info {
|
44 |
}
|
45 |
|
46 |
.doofinder-warning {
|
47 |
+
border-color: #eee2be;
|
48 |
+
background-color: #fff9e9;
|
49 |
+
color: #5a4421;
|
50 |
}
|