Steerfox_Plugins - Version 1.0.5

Version Notes

- Before release

Download this release

Release Info

Developer Steerfox
Extension Steerfox_Plugins
Version 1.0.5
Comparing to
See all releases


Version 1.0.5

Files changed (93) hide show
  1. app/code/community/Steerfox/Plugins/Block/Adminhtml/Steerfoxproduct.php +41 -0
  2. app/code/community/Steerfox/Plugins/Block/Adminhtml/Steerfoxproduct/Grid.php +237 -0
  3. app/code/community/Steerfox/Plugins/Block/Adminhtml/System/Config/Form/Fieldset/Steerfoxform.php +71 -0
  4. app/code/community/Steerfox/Plugins/Block/Tags.php +346 -0
  5. app/code/community/Steerfox/Plugins/Enum/Tags.php +26 -0
  6. app/code/community/Steerfox/Plugins/Helper/Core/Data.php +121 -0
  7. app/code/community/Steerfox/Plugins/Helper/Core/Exception.php +6 -0
  8. app/code/community/Steerfox/Plugins/Helper/Data.php +189 -0
  9. app/code/community/Steerfox/Plugins/Model/Adapter/Configuration.php +152 -0
  10. app/code/community/Steerfox/Plugins/Model/Adapter/Product.php +379 -0
  11. app/code/community/Steerfox/Plugins/Model/Adapter/Service/Log.php +74 -0
  12. app/code/community/Steerfox/Plugins/Model/Adapter/Service/Shop.php +109 -0
  13. app/code/community/Steerfox/Plugins/Model/Adapter/Shop.php +100 -0
  14. app/code/community/Steerfox/Plugins/Model/Adapter/Tools.php +129 -0
  15. app/code/community/Steerfox/Plugins/Model/Apikey.php +54 -0
  16. app/code/community/Steerfox/Plugins/Model/Currencies.php +49 -0
  17. app/code/community/Steerfox/Plugins/Model/Entity/Attribute/Backend/Profit.php +32 -0
  18. app/code/community/Steerfox/Plugins/Model/Entity/Attribute/Backend/Profit/Ratio.php +40 -0
  19. app/code/community/Steerfox/Plugins/Model/Languages.php +31 -0
  20. app/code/community/Steerfox/Plugins/Model/Log.php +96 -0
  21. app/code/community/Steerfox/Plugins/Model/Observer.php +232 -0
  22. app/code/community/Steerfox/Plugins/Model/Product.php +79 -0
  23. app/code/community/Steerfox/Plugins/Model/Resource/Log.php +31 -0
  24. app/code/community/Steerfox/Plugins/Model/Resource/Log/Collection.php +33 -0
  25. app/code/community/Steerfox/Plugins/Model/Resource/Product.php +31 -0
  26. app/code/community/Steerfox/Plugins/Model/Resource/Product/Collection.php +82 -0
  27. app/code/community/Steerfox/Plugins/Model/Resource/Setup.php +6 -0
  28. app/code/community/Steerfox/Plugins/Model/System/Config/Source/Group.php +38 -0
  29. app/code/community/Steerfox/Plugins/controllers/Adminhtml/SteerfoxindexController.php +71 -0
  30. app/code/community/Steerfox/Plugins/controllers/Adminhtml/SteerfoxproductController.php +248 -0
  31. app/code/community/Steerfox/Plugins/controllers/LogsController.php +50 -0
  32. app/code/community/Steerfox/Plugins/controllers/ProductController.php +90 -0
  33. app/code/community/Steerfox/Plugins/data/steerfox_plugins_setup/data-install-0.1.0.php +80 -0
  34. app/code/community/Steerfox/Plugins/data/steerfox_plugins_setup/data-upgrade-0.1.2-0.1.3.php +54 -0
  35. app/code/community/Steerfox/Plugins/data/steerfox_plugins_setup/data-upgrade-0.1.3-0.1.4.php +22 -0
  36. app/code/community/Steerfox/Plugins/data/steerfox_plugins_setup/data-upgrade-0.1.4-1.0.5.php +40 -0
  37. app/code/community/Steerfox/Plugins/etc/adminhtml.xml +44 -0
  38. app/code/community/Steerfox/Plugins/etc/config.xml +223 -0
  39. app/code/community/Steerfox/Plugins/etc/steerfox.xml +50 -0
  40. app/code/community/Steerfox/Plugins/etc/system.xml +220 -0
  41. app/code/community/Steerfox/Plugins/etc/widget.xml +2 -0
  42. app/code/community/Steerfox/Plugins/lib/Api/Connectors/SteerfoxAbstractConnector.php +190 -0
  43. app/code/community/Steerfox/Plugins/lib/Api/Connectors/SteerfoxCurlConnector.php +72 -0
  44. app/code/community/Steerfox/Plugins/lib/Api/Connectors/SteerfoxFopenConnector.php +86 -0
  45. app/code/community/Steerfox/Plugins/lib/Api/SteerfoxApiService.php +618 -0
  46. app/code/community/Steerfox/Plugins/lib/Configuration/SteerfoxConfigurationInterface.php +80 -0
  47. app/code/community/Steerfox/Plugins/lib/Configuration/SteerfoxConfigurationService.php +73 -0
  48. app/code/community/Steerfox/Plugins/lib/Exceptions/SteerfoxConnectorException.php +63 -0
  49. app/code/community/Steerfox/Plugins/lib/Exceptions/SteerfoxException.php +28 -0
  50. app/code/community/Steerfox/Plugins/lib/Export/Helper/SteerfoxExporterHelper.php +7 -0
  51. app/code/community/Steerfox/Plugins/lib/Export/Model/SteerfoxProductExporter.php +371 -0
  52. app/code/community/Steerfox/Plugins/lib/Export/SteerfoxExportService.php +90 -0
  53. app/code/community/Steerfox/Plugins/lib/Logger/SteerfoxAbstractLoggerService.php +78 -0
  54. app/code/community/Steerfox/Plugins/lib/Model/SteerfoxAbstractShopService.php +76 -0
  55. app/code/community/Steerfox/Plugins/lib/Model/SteerfoxProductAdapterInterface.php +201 -0
  56. app/code/community/Steerfox/Plugins/lib/Model/SteerfoxShopAdapterInterface.php +82 -0
  57. app/code/community/Steerfox/Plugins/lib/Model/SteerfoxToolsAdapterInterface.php +86 -0
  58. app/code/community/Steerfox/Plugins/lib/README.md +32 -0
  59. app/code/community/Steerfox/Plugins/lib/Samples/ContainerUse.php +35 -0
  60. app/code/community/Steerfox/Plugins/lib/Samples/ModelAdapters/Configuration.php +177 -0
  61. app/code/community/Steerfox/Plugins/lib/Samples/ModelAdapters/Product.php +380 -0
  62. app/code/community/Steerfox/Plugins/lib/Samples/ModelAdapters/Shop.php +108 -0
  63. app/code/community/Steerfox/Plugins/lib/Samples/ModelAdapters/Tools.php +129 -0
  64. app/code/community/Steerfox/Plugins/lib/Samples/ServiceAdapters/Log.php +88 -0
  65. app/code/community/Steerfox/Plugins/lib/Samples/ServiceAdapters/Shop.php +90 -0
  66. app/code/community/Steerfox/Plugins/lib/Samples/conf.xml +50 -0
  67. app/code/community/Steerfox/Plugins/lib/SteerfoxContainer.php +194 -0
  68. app/code/community/Steerfox/Plugins/sql/steerfox_plugins_setup/install-0.1.0.php +265 -0
  69. app/design/adminhtml/default/default/layout/steerfox_plugins.xml +22 -0
  70. app/design/adminhtml/default/default/template/steerfox/plugins/dashboard.phtml +91 -0
  71. app/design/adminhtml/default/default/template/steerfox/plugins/welcome.phtml +109 -0
  72. app/design/frontend/base/default/layout/steerfox_plugins.xml +22 -0
  73. app/design/frontend/base/default/template/steerfox_plugins/adwords_order_tag.phtml +26 -0
  74. app/design/frontend/base/default/template/steerfox_plugins/bing_header_tag.phtml +26 -0
  75. app/design/frontend/base/default/template/steerfox_plugins/bing_order_tag.phtml +21 -0
  76. app/design/frontend/base/default/template/steerfox_plugins/fb_header_tag.phtml +65 -0
  77. app/design/frontend/base/default/template/steerfox_plugins/fb_order_tag.phtml +14 -0
  78. app/design/frontend/base/default/template/steerfox_plugins/foxtag_header_tag.phtml +66 -0
  79. app/design/frontend/base/default/template/steerfox_plugins/foxtag_order_tag.phtml +60 -0
  80. app/design/frontend/base/default/template/steerfox_plugins/gsv_tag.phtml +6 -0
  81. app/design/frontend/base/default/template/steerfox_plugins/gtm_tag.phtml +27 -0
  82. app/etc/modules/Steerfox_Plugins.xml +12 -0
  83. app/locale/en_US/Steerfox_Plugins.csv +107 -0
  84. app/locale/fr_FR/Steerfox_Plugins.csv +107 -0
  85. package.xml +18 -0
  86. skin/adminhtml/default/default/images/steerfox/icon-file-text.png +0 -0
  87. skin/adminhtml/default/default/images/steerfox/icon-globe.png +0 -0
  88. skin/adminhtml/default/default/images/steerfox/icon-road.png +0 -0
  89. skin/adminhtml/default/default/images/steerfox/icon-warning.png +0 -0
  90. skin/adminhtml/default/default/images/steerfox/steerfox-logo.png +0 -0
  91. skin/adminhtml/default/default/images/steerfox/steerfox-reporting.png +0 -0
  92. skin/adminhtml/default/default/steerfox/steerfox.css +856 -0
  93. skin/adminhtml/default/default/steerfox/steerfox.js +53 -0
app/code/community/Steerfox/Plugins/Block/Adminhtml/Steerfoxproduct.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Block_Adminhtml_Product
24
+ */
25
+ class Steerfox_Plugins_Block_Adminhtml_Steerfoxproduct extends Mage_Adminhtml_Block_Widget_Grid_Container
26
+ {
27
+ public function __construct()
28
+ {
29
+ $this->_blockGroup = 'steerfox_plugins';
30
+ $this->_controller = 'adminhtml_steerfoxproduct';
31
+ $this->_headerText = Mage::helper('steerfox_plugins')->__('Manage Steerfox products export');
32
+
33
+ parent::__construct();
34
+ $this->_removeButton('add');
35
+ }
36
+
37
+ public function getCreateUrl()
38
+ {
39
+ return $this->getUrl('steerfox_plugins/adminhtml_steerfoxproduct/edit');
40
+ }
41
+ }
app/code/community/Steerfox/Plugins/Block/Adminhtml/Steerfoxproduct/Grid.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright 2015 Steerfox SAS.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License. You may obtain
8
+ * a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+ * License for the specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ * @author Steerfox <tech@steerfox.com>
19
+ * @copyright 2015 Steerfox SAS
20
+ * @license http://www.apache.org/licenses/LICENSE-2.0
21
+ */
22
+
23
+ /**
24
+ * Class Steerfox_Plugins_Block_Adminhtml_Product_Grid
25
+ */
26
+ class Steerfox_Plugins_Block_adminhtml_Steerfoxproduct_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
+ {
28
+ /**
29
+ * Init Grid default properties
30
+ */
31
+ public function __construct()
32
+ {
33
+ parent::__construct();
34
+ $this->setId('steerfoxproduct_list_grid');
35
+ $this->setDefaultSort('created_at');
36
+ $this->setDefaultDir('DESC');
37
+ $this->setSaveParametersInSession(true);
38
+ $this->setUseAjax(true);
39
+ }
40
+
41
+ /**
42
+ * Return row URL for js event handlers
43
+ *
44
+ * @return string
45
+ */
46
+ public function getRowUrl($row)
47
+ {
48
+ return $this->getUrl('adminhtml/catalog_product/edit', array(
49
+ 'id'=>$row->getData('id_product'))
50
+ );
51
+ }
52
+
53
+ /**
54
+ * Grid url getter
55
+ *
56
+ * @return string current grid url
57
+ */
58
+ public function getGridUrl()
59
+ {
60
+ return $this->getUrl('*/*/grid', array('_current' => true));
61
+ }
62
+
63
+ protected function _prepareCollection()
64
+ {
65
+ $collection = Mage::getResourceModel('steerfox_plugins/product_collection');
66
+ $collection->getSelect()
67
+ ->joinLeft(
68
+ array('prod' => 'catalog_product_entity'),
69
+ 'prod.entity_id = main_table.id_product',
70
+ array('sku')
71
+ )
72
+ ->group('prod.entity_id')
73
+ ->group('main_table.id_shop');
74
+ $collection->addProductData();
75
+
76
+ $this->setCollection($collection);
77
+
78
+ return parent::_prepareCollection();
79
+ }
80
+
81
+ protected function _prepareMassaction()
82
+ {
83
+ $this->setMassactionIdField('entity_id');
84
+ $this->getMassactionBlock()->setFormFieldName('entity_id');
85
+
86
+ $this->getMassactionBlock()->addItem(
87
+ 'publish',
88
+ array(
89
+ 'label' => $this->_getHelper()->__('Publish on Steerfox'),
90
+ 'url' => $this->getUrl('*/*/massPublish'),
91
+ )
92
+ );
93
+
94
+ $this->getMassactionBlock()->addItem(
95
+ 'unpublish',
96
+ array(
97
+ 'label' => $this->_getHelper()->__('Unpublish on Steerfox'),
98
+ 'url' => $this->getUrl('*/*/massUnpublish'),
99
+ )
100
+ );
101
+
102
+ return $this;
103
+ }
104
+
105
+
106
+ protected function _prepareColumns()
107
+ {
108
+ $this->addColumn(
109
+ 'id_lang',
110
+ array(
111
+ 'header' => $this->_getHelper()->__('ID language'),
112
+ 'type' => 'number',
113
+ 'index' => 'id_lang',
114
+ )
115
+ );
116
+
117
+ $this->addColumn('id_shop',
118
+ array(
119
+ 'header'=> Mage::helper('catalog')->__('Shop'),
120
+ 'width' => '100px',
121
+ 'sortable' => false,
122
+ 'index' => 'id_shop',
123
+ 'type' => 'options',
124
+ 'options' => Mage::helper('steerfox_plugins')->getWebsiteOption(),
125
+ ));
126
+
127
+ $this->addColumn(
128
+ 'id_product',
129
+ array(
130
+ 'header' => $this->_getHelper()->__('ID product'),
131
+ 'type' => 'number',
132
+ 'index' => 'id_product',
133
+ )
134
+ );
135
+
136
+ $this->addColumn(
137
+ 'sku',
138
+ array(
139
+ 'header' => $this->_getHelper()->__('SKU product'),
140
+ 'type' => 'text',
141
+ 'index' => 'sku',
142
+ )
143
+ );
144
+
145
+
146
+ $this->addColumn(
147
+ 'product_name',
148
+ array(
149
+ 'header' => $this->_getHelper()->__('Product name'),
150
+ 'type' => 'text',
151
+ 'index' => 'name_table.value',
152
+ )
153
+ );
154
+
155
+ $this->addColumn(
156
+ 'product_price',
157
+ array(
158
+ 'header' => $this->_getHelper()->__('Product price'),
159
+ 'type' => 'number',
160
+ 'index' => 'price_table.value',
161
+ )
162
+ );
163
+
164
+ $this->addColumn(
165
+ 'product_cost',
166
+ array(
167
+ 'header' => $this->_getHelper()->__('Product cost'),
168
+ 'type' => 'number',
169
+ 'index' => 'cost_table.value',
170
+ )
171
+ );
172
+
173
+ if (false != Mage::helper('steerfox_plugins')->getConfig('catalog/export_margin')) {
174
+ $this->addColumn(
175
+ 'product_profit',
176
+ array(
177
+ 'header' => $this->_getHelper()->__('Product profit'),
178
+ 'type' => 'number',
179
+ 'index' => 'product_profit_table.value',
180
+ )
181
+ );
182
+
183
+ $this->addColumn(
184
+ 'product_profit_ratio',
185
+ array(
186
+ 'header' => $this->_getHelper()->__('Product profit ratio'),
187
+ 'type' => 'number',
188
+ 'index' => 'product_profit_ratio_table.value',
189
+ )
190
+ );
191
+ }
192
+
193
+ $brandSingleton = Mage::getSingleton('steerfox_plugins/product');
194
+ $this->addColumn(
195
+ 'active',
196
+ array(
197
+ 'header' => $this->_getHelper()->__('Export status'),
198
+ 'type' => 'options',
199
+ 'index' => 'active',
200
+ 'options' => $brandSingleton->getAvailableStates(),
201
+ )
202
+ );
203
+
204
+ $this->addColumn(
205
+ 'created_at',
206
+ array(
207
+ 'header' => $this->_getHelper()->__('Created'),
208
+ 'type' => 'datetime',
209
+ 'index' => 'created_at',
210
+ )
211
+ );
212
+
213
+ $this->addColumn(
214
+ 'updated_at',
215
+ array(
216
+ 'header' => $this->_getHelper()->__('Updated'),
217
+ 'type' => 'datetime',
218
+ 'index' => 'updated_at',
219
+ )
220
+ );
221
+
222
+ return parent::_prepareColumns();
223
+ }
224
+
225
+ protected function _filterStoreCondition($collection, $column){
226
+ if (!$value = $column->getFilter()->getValue()) {
227
+ return;
228
+ }
229
+ $this->getCollection()->addStoreFilter($value);
230
+ }
231
+
232
+
233
+ protected function _getHelper()
234
+ {
235
+ return Mage::helper('steerfox_plugins');
236
+ }
237
+ }
app/code/community/Steerfox/Plugins/Block/Adminhtml/System/Config/Form/Fieldset/Steerfoxform.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Block_Adminhtml_System_Config_Form_Fieldset_Steerfoxform
24
+ */
25
+ class Steerfox_Plugins_Block_Adminhtml_System_Config_Form_Fieldset_Steerfoxform
26
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
27
+ {
28
+ public function render(Varien_Data_Form_Element_Abstract $element)
29
+ {
30
+ // If no store is selecteed
31
+ $selected_website = Mage::app()->getRequest()->getParam('website', null);
32
+ $selected_store = Mage::app()->getRequest()->getParam('store', null);
33
+
34
+ // Add the version notity if necessary
35
+ Mage::helper('steerfox_plugins')->notifyOldRelease();
36
+
37
+ // Valid user
38
+ if (Mage::helper('steerfox_plugins')->isValidUser($selected_website, $selected_store)) {
39
+ $tpl = $this->renderDashboardScreen();
40
+ // Render Welcome / Settings + form
41
+ return $tpl ;
42
+ } else {
43
+ return $this->renderWelcomeScreen();
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Render Welcome screen with register action : scr-001
49
+ * @return mixed
50
+ */
51
+ public function renderWelcomeScreen()
52
+ {
53
+ return Mage::app()->getLayout()->createBlock('adminhtml/template')->setTemplate(
54
+ 'steerfox/plugins/welcome.phtml'
55
+ )->toHtml();
56
+ }
57
+
58
+ /**
59
+ * Render Settings screen with dashboard : scr-002
60
+ * @return mixed
61
+ */
62
+ public function renderDashboardScreen()
63
+ {
64
+ $block = Mage::app()->getLayout()->createBlock('adminhtml/template');
65
+ $block->assign(array('checklist' => Mage::helper('steerfox_plugins')->getSettingsChecklist()));
66
+
67
+ return $block->setTemplate(
68
+ 'steerfox/plugins/dashboard.phtml'
69
+ )->toHtml();
70
+ }
71
+ }
app/code/community/Steerfox/Plugins/Block/Tags.php ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Steerfox_Plugins_Block_Tags extends Mage_Core_Block_Template
4
+ {
5
+
6
+ public function getGoogleAdwordsId()
7
+ {
8
+ return $this->getConfig('tags/adwords_id');
9
+ }
10
+
11
+ public function getGoogleAdwordsLabel()
12
+ {
13
+ return $this->getConfig('tags/adwords_label');
14
+ }
15
+
16
+ public function getBingId()
17
+ {
18
+ return $this->getConfig('tags/bing_id');
19
+ }
20
+
21
+ public function getFacebookId()
22
+ {
23
+ return $this->getConfig('tags/facebook_id');
24
+ }
25
+
26
+ public function getGtmId()
27
+ {
28
+ return $this->getConfig('tags/gtm_id');
29
+ }
30
+
31
+ /**
32
+ * Return the foxtag id store in conf.
33
+ *
34
+ * @return String
35
+ */
36
+ public function getFoxtagId()
37
+ {
38
+ return (String)$this->getConfig('tags/foxtag_id');
39
+ }
40
+
41
+ public function getGsv()
42
+ {
43
+ return $this->getConfig('google/google_site_verification');
44
+ }
45
+
46
+ /**
47
+ * Return the conversion amount of the transaction
48
+ *
49
+ * @param Mage_Sales_Model_Order $order
50
+ * @return float
51
+ */
52
+ public function getConvertionAmount($order)
53
+ {
54
+ $withShipping = (boolean)$this->getConfig('tags/shipping');
55
+
56
+ return number_format(round($order->getGrandTotal() - ($withShipping ? 0 : $order->getShippingAmount()) - $order->getTaxAmount(), 2), 2, '.', '');
57
+ }
58
+
59
+ /**
60
+ * Return the conversion subtotal of the transaction
61
+ *
62
+ * @param Mage_Sales_Model_Order $order
63
+ * @return float
64
+ */
65
+ public function getConvertionSubtotal($order)
66
+ {
67
+ return $order->getGrandTotal() - $order->getShippingAmount() - $order->getTaxAmount();
68
+ }
69
+
70
+ public function getConvertionMargin($order)
71
+ {
72
+ $margin = 0;
73
+
74
+ if ($order instanceof Mage_Sales_Model_Order) {
75
+ foreach ($order->getAllVisibleItems() as $item) {
76
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
77
+ $margin += ($product->getProductProfit() * $item->getQtyOrdered());
78
+ }
79
+ }
80
+
81
+ return $margin;
82
+ }
83
+
84
+ /**
85
+ * Return the conversion taxes of the transaction
86
+ *
87
+ * @param Mage_Sales_Model_Order $order
88
+ * @return float
89
+ */
90
+ public function getConvertionTax($order)
91
+ {
92
+ return $order->getTaxAmount();
93
+ }
94
+
95
+ /**
96
+ * Return the conversion amount of the transaction
97
+ *
98
+ * @param Mage_Sales_Model_Order $order
99
+ * @return float
100
+ */
101
+ public function getConvertionShipping($order)
102
+ {
103
+ return $order->getShippingAmount();
104
+ }
105
+
106
+ /**
107
+ * Return the conversion discount of the transaction
108
+ *
109
+ * @param Mage_Sales_Model_Order $order
110
+ * @return float
111
+ */
112
+ public function getConvertionDiscount($order)
113
+ {
114
+ return $order->getDiscountAmount();
115
+ }
116
+
117
+ /**
118
+ * Return the currency code of the current store
119
+ *
120
+ * @return String
121
+ */
122
+ public function getCurrencyCode()
123
+ {
124
+ return Mage::app()->getStore()->getCurrentCurrencyCode();;
125
+ }
126
+
127
+ /**
128
+ * Get the order object if we are on the checkout success page.
129
+ *
130
+ * @return null
131
+ */
132
+ public function getOrder()
133
+ {
134
+ // Do work only on checkout success page
135
+ if (('success' == Mage::app()->getRequest()->getActionName() && 'checkout' == Mage::app()->getRequest()->getRouteName())) {
136
+ $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());;
137
+ } else {
138
+ $order = null;
139
+ }
140
+
141
+ return $order;
142
+ }
143
+
144
+ /**
145
+ * Return the items formatted for tags
146
+ *
147
+ * @param Mage_Sales_Model_Order $order
148
+ * @return array
149
+ */
150
+ public function getItemList($order)
151
+ {
152
+ $itemList = array();
153
+
154
+ if ($order instanceof Mage_Sales_Model_Order) {
155
+ foreach ($order->getAllVisibleItems() as $item) {
156
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
157
+ $categories = $product->getCategoryIds();
158
+ $catId = null;
159
+ if (0 < count($categories)) {
160
+ $catId = $categories[0];
161
+ }
162
+ $itemList[] = array(
163
+ 'id' => $product->getId(),
164
+ 'sku' => $product->getSku(),
165
+ 'name' => $product->getName(),
166
+ 'cat' => $catId,
167
+ 'price' => $product->getPrice(),
168
+ 'margin' => $product->getProductProfit(),
169
+ 'qty' => $item->getQtyOrdered()
170
+ );
171
+ }
172
+ }
173
+ return $itemList;
174
+ }
175
+
176
+ /**
177
+ * Return the ids of the order's products as a string separate by a comma
178
+ *
179
+ * @param Mage_Sales_Model_Order $order
180
+ * @return array
181
+ */
182
+ public function getProductsIdsString($order)
183
+ {
184
+ $returnArray = array();
185
+
186
+ if ($order instanceof Mage_Sales_Model_Order) {
187
+ foreach ($order->getAllItems() as $item) {
188
+ $returnArray[] = $item->getProductId();
189
+ }
190
+ }
191
+ return implode(',', $returnArray);
192
+ }
193
+
194
+ public function getLocaleCode()
195
+ {
196
+ return Mage::app()->getLocale()->getLocaleCode();
197
+ }
198
+
199
+ /**
200
+ * Get the url of the js file for foxtag.
201
+ * TODO: delete this function and use the long therm URL when it's ready
202
+ * @return string
203
+ */
204
+ public function getFoxtagJsUrl()
205
+ {
206
+ return '/skin/frontend/default/default/steerfox/foxtagTMP.js';
207
+ }
208
+
209
+ /**
210
+ * Get the url of the server for foxtag.
211
+ * TODO: delete this function and use the long therm URL when it's ready
212
+ * @return string
213
+ */
214
+ public function getFoxtagUrl()
215
+ {
216
+ return 'http://logstash-test.docker:800/track';
217
+ }
218
+
219
+ /**
220
+ * Return the foxtag page corresponding to the current page.
221
+ *
222
+ * @return string
223
+ */
224
+ public function getFoxtagPage()
225
+ {
226
+ $page = 'other';
227
+ if ($this->isHomePage()) {
228
+ $page = 'home';
229
+ } elseif (Mage::registry('current_product') instanceof Mage_Catalog_Model_Product) {
230
+ $page = 'product';
231
+ } elseif (Mage::registry('current_category') instanceof Mage_Catalog_Model_Category) {
232
+ $page = 'category';
233
+ } elseif ($this->isSearchResultsPage()) {
234
+ $page = 'searchresults';
235
+ } elseif ($this->isCartPage()) {
236
+ $page = 'cart';
237
+ }
238
+ return $page;
239
+ }
240
+
241
+ /**
242
+ * Return the Id of the user if he is logged in.
243
+ *
244
+ * @return string
245
+ */
246
+ public function getUserId()
247
+ {
248
+ $userId = '';
249
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
250
+ $userId = Mage::getSingleton('customer/session')->getCustomer()->getId();
251
+ }
252
+ return $userId;
253
+ }
254
+
255
+ /**
256
+ * Return true if current page is home page.
257
+ *
258
+ * @return bool
259
+ */
260
+ public function isHomePage()
261
+ {
262
+ $request = Mage::app()->getFrontController()->getRequest();
263
+ return 'cms' == $request->getModuleName() && 'index' == $request->getControllerName() && 'index' == $request->getActionName();
264
+ }
265
+
266
+ /**
267
+ * Return true if current page is search results page.
268
+ *
269
+ * @return bool
270
+ */
271
+ public function isSearchResultsPage()
272
+ {
273
+ $request = Mage::app()->getFrontController()->getRequest();
274
+ return 'catalogsearch' == $request->getModuleName() && 'result' == $request->getControllerName() && 'index' == $request->getActionName();
275
+ }
276
+
277
+ /**
278
+ * Return true if current page is cart page.
279
+ *
280
+ * @return bool
281
+ */
282
+ public function isCartPage()
283
+ {
284
+ $request = Mage::app()->getFrontController()->getRequest();
285
+ return 'checkout' == $request->getModuleName() && 'cart' == $request->getControllerName() && 'index' == $request->getActionName();
286
+ }
287
+
288
+ /**
289
+ * Return the product of the page if we are on a product page.
290
+ *
291
+ * @return Mage_Catalog_Model_Product
292
+ */
293
+ public function getCurrentProduct()
294
+ {
295
+ $product = null;
296
+ $request = Mage::app()->getFrontController()->getRequest();
297
+ if ('catalog' == $request->getModuleName() && 'product' == $request->getControllerName() && 'view' == $request->getActionName()) {
298
+ $product = Mage::registry('current_product');
299
+ }
300
+ return $product;
301
+ }
302
+
303
+ /**
304
+ * Return the category of the page if we are on a category page.
305
+ *
306
+ * @return Mage_Catalog_Model_Category
307
+ */
308
+ public function getCurrentCategory()
309
+ {
310
+ $category = null;
311
+ $request = Mage::app()->getFrontController()->getRequest();
312
+ if ('catalog' == $request->getModuleName() && 'category' == $request->getControllerName() && 'view' == $request->getActionName()) {
313
+ $category = Mage::registry('current_category');
314
+ }
315
+ return $category;
316
+ }
317
+
318
+ /**
319
+ * Return product added to cart for foxtag if it exists.
320
+ *
321
+ * @return array
322
+ */
323
+ public function getFoxtagProductAddToCart()
324
+ {
325
+ $product = Mage::getSingleton('core/session')->getData(Steerfox_Plugins_Enum_Tags::FOXTAG_ADD_TO_CART);
326
+ Mage::getSingleton('core/session')->setData(Steerfox_Plugins_Enum_Tags::FOXTAG_ADD_TO_CART, null);
327
+ return $product;
328
+ }
329
+
330
+ /**
331
+ * Return product added to cart for facebook if it exists.
332
+ *
333
+ * @return array
334
+ */
335
+ public function getFacebookProductAddToCart()
336
+ {
337
+ $product = Mage::getSingleton('core/session')->getData(Steerfox_Plugins_Enum_Tags::FACEBOOK_ADD_TO_CART);
338
+ Mage::getSingleton('core/session')->setData(Steerfox_Plugins_Enum_Tags::FACEBOOK_ADD_TO_CART, null);
339
+ return $product;
340
+ }
341
+
342
+ protected function getConfig($path)
343
+ {
344
+ return Mage::helper('steerfox_plugins')->getConfig($path);
345
+ }
346
+ }
app/code/community/Steerfox/Plugins/Enum/Tags.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2016 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2016 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ class Steerfox_Plugins_Enum_Tags
23
+ {
24
+ const FOXTAG_ADD_TO_CART = 'foxtag_add_to_cart';
25
+ const FACEBOOK_ADD_TO_CART = 'facebook_add_to_cart';
26
+ }
app/code/community/Steerfox/Plugins/Helper/Core/Data.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright 2015 Steerfox SAS.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License. You may obtain
8
+ * a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+ * License for the specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ * @author Steerfox <tech@steerfox.com>
19
+ * @copyright 2015 Steerfox SAS
20
+ * @license http://www.apache.org/licenses/LICENSE-2.0
21
+ */
22
+
23
+ //Add Steerfox Librarie
24
+ require_once dirname(__FILE__) . '/../../lib/SteerfoxContainer.php';
25
+
26
+ /**
27
+ * Class Steerfox_Plugins_Helper_Core_Data
28
+ */
29
+ class Steerfox_Plugins_Helper_Core_Data extends Mage_Core_Helper_Abstract
30
+ {
31
+ public static $hParams = array();
32
+ private $types
33
+ = array(
34
+ 0 => 'none',
35
+ 1 => 'curl',
36
+ 2 => 'fopen',
37
+ );
38
+ private $services
39
+ = array(
40
+ 'createAccount' => array(
41
+ 'path' => 'account',
42
+ 'method' => 'POST',
43
+ 'args' => array(
44
+ 'source',
45
+ 'shop_name',
46
+ 'shop_url',
47
+ 'logo_url',
48
+ 'feed_url',
49
+ 'locale',
50
+ 'email',
51
+ ),
52
+ ),
53
+ 'updateAccount' => array(
54
+ 'path' => 'feeds/@id',
55
+ 'method' => 'PUT',
56
+ 'args' => array(
57
+ 'id',
58
+ 'url',
59
+ 'locale',
60
+ ),
61
+ 'get_args' => array(
62
+ 'api_key',
63
+ ),
64
+ ),
65
+ 'retrieveAccount' => array(
66
+ 'path' => 'feeds',
67
+ 'method' => 'POST',
68
+ 'args' => array(
69
+ 'url',
70
+ 'locale',
71
+ ),
72
+ 'get_args' => array(
73
+ 'api_key',
74
+ 'shop_url',
75
+ ),
76
+ ),
77
+ );
78
+
79
+ /**
80
+ * Steerfox_Plugins_Helper_Core_Data constructor.
81
+ */
82
+ public function __construct()
83
+ {
84
+ SteerfoxContainer::createInstance(Mage::getModuleDir('etc', 'Steerfox_Plugins') . '/steerfox.xml');
85
+ }
86
+
87
+ /**
88
+ * Return an instance of steerfox container.
89
+ *
90
+ * @return SteerfoxContainer
91
+ */
92
+ public function getSteerfoxContainer()
93
+ {
94
+ return SteerfoxContainer::getInstance();
95
+ }
96
+
97
+ /**
98
+ * Update Steerfox API account information's.
99
+ */
100
+ public function apiUpdate()
101
+ {
102
+ // Update only if account key existe and Account status is active
103
+ $apiKey = Mage::getStoreConfig('steerfox_plugins/account/api_key');
104
+ $accountStatus = Mage::getStoreConfig('steerfox_plugins/account/status');
105
+
106
+ if (!empty($apiKey) && 1 == $accountStatus) {
107
+ $coreHelper = Mage::helper('steerfox_plugins/core_data');
108
+ $steerfoxContainer = $coreHelper->getSteerfoxContainer();
109
+ $steerfoxApi = $steerfoxContainer->get('api');
110
+ $steerfoxApi instanceof SteerfoxApiService;
111
+ $result = $steerfoxApi->updateAccount();
112
+
113
+ if (!$result) {
114
+ Mage::getSingleton('core/session')->addError('Steerfox update account : Error occurred.');
115
+ }
116
+
117
+ Mage::app()->getStore()->resetConfig();
118
+ }
119
+ }
120
+
121
+ }
app/code/community/Steerfox/Plugins/Helper/Core/Exception.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Steerfox_Plugins_Helper_Core_Exception extends Mage_Exception
4
+ {
5
+
6
+ }
app/code/community/Steerfox/Plugins/Helper/Data.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright 2015 Steerfox SAS.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License. You may obtain
8
+ * a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+ * License for the specific language governing permissions and limitations
16
+ * under the License.
17
+ *
18
+ * @author Steerfox <tech@steerfox.com>
19
+ * @copyright 2015 Steerfox SAS
20
+ * @license http://www.apache.org/licenses/LICENSE-2.0
21
+ */
22
+
23
+ /**
24
+ * Class Steerfox_Plugins_Helper_Data
25
+ */
26
+ class Steerfox_Plugins_Helper_Data extends Mage_Core_Helper_Abstract
27
+ {
28
+ const STEERFOX_SOURCE_MAGE = 3;
29
+ public $dashboard_action = 'http://dashboard.steerfox.com/';
30
+
31
+ public function getDashboardAction()
32
+ {
33
+ return $this->dashboard_action;
34
+ }
35
+
36
+ public function getRegisterAction()
37
+ {
38
+ return Mage::helper("adminhtml")->getUrl("adminhtml/steerfoxindex/start/");
39
+ }
40
+
41
+ /**
42
+ * Get the source (magento)
43
+ * @return int
44
+ */
45
+ public function getSource()
46
+ {
47
+ return self::STEERFOX_SOURCE_MAGE;
48
+ }
49
+
50
+ /**
51
+ * Return the current magento store.
52
+ *
53
+ * @return bool|Mage_Core_Model_Store
54
+ */
55
+ public function currentStore()
56
+ {
57
+ if (true) {
58
+ return Mage::app()->getStore();
59
+ }
60
+
61
+ return false;
62
+ }
63
+
64
+ /**
65
+ * Check if user is valid or not
66
+ * @return bool
67
+ */
68
+ public function isValidUser($website = null, $store = null)
69
+ {
70
+
71
+ if ($store === null) {
72
+ if ($website === null) {
73
+ $api_key = Mage::getStoreConfig('steerfox_plugins/account/api_key');
74
+ } else {
75
+ $api_key = Mage::app()->getWebsite($website)->getConfig('steerfox_plugins/account/api_key');
76
+ }
77
+ } else {
78
+ $api_key = Mage::app()->getStore($store)->getConfig('steerfox_plugins/account/api_key');
79
+ }
80
+
81
+ return (($api_key && !empty($api_key)) ? true : false);
82
+ }
83
+
84
+ /**
85
+ * Get settings checklist to display
86
+ * @return bool
87
+ */
88
+ public function getSettingsChecklist()
89
+ {
90
+ return array(
91
+ array(
92
+ 'title' => $this->__('Connector status : Steerfox can be reached'),
93
+ 'state' => ((bool)function_exists('curl_version')) || ((bool)ini_get('allow_url_fopen')),
94
+ ),
95
+ array(
96
+ 'title' => $this->__('Steerfox authentication : API_KEY validity'),
97
+ 'state' => (Mage::getStoreConfig('steerfox_plugins/account/status') == 1 ? true : false),
98
+ ),
99
+ );
100
+ }
101
+
102
+ /**
103
+ * Default product per page.
104
+ *
105
+ * @return int
106
+ */
107
+ public function getProductsPerPage()
108
+ {
109
+ return 100;
110
+ }
111
+
112
+ /**
113
+ * Get the config by name.
114
+ *
115
+ * @param $name
116
+ *
117
+ * @return mixed
118
+ */
119
+ public function getConfig($name)
120
+ {
121
+ return Mage::getStoreConfig('steerfox_plugins/'.$name);
122
+ }
123
+
124
+ /**
125
+ * Update config.
126
+ *
127
+ * @param $name
128
+ * @param $value
129
+ * @param string $scope
130
+ * @param int $scopeId
131
+ *
132
+ * @return void
133
+ */
134
+ public function updateConfig($name, $value, $scope = 'default', $scopeId = 0)
135
+ {
136
+ $config = new Mage_Core_Model_Config();
137
+ $config->saveConfig($name, $value, $scope, $scopeId);
138
+ }
139
+
140
+ /**
141
+ * Return the current extension version
142
+ * .
143
+ * @return string
144
+ */
145
+ public function getExtensionVersion()
146
+ {
147
+ return (string)Mage::getConfig()->getNode()->modules->Steerfox_Plugins->version;
148
+ }
149
+
150
+ /**
151
+ * Returns array with all availaible website.
152
+ *
153
+ * @return array
154
+ */
155
+ public function getWebsiteOption()
156
+ {
157
+ $websites = Mage::app()->getWebsites();
158
+
159
+
160
+ $websiteOptions = array();
161
+ foreach ($websites as $website) {
162
+ $websiteOptions[$website->getId()] = $website->getName();
163
+ }
164
+
165
+ return $websiteOptions;
166
+ }
167
+
168
+ /**
169
+ * Notify the user if the current plugin is older than the last release.
170
+ */
171
+ public function notifyOldRelease()
172
+ {
173
+ $lastReleaseVersion = Mage::getSingleton('core/session')->getData('steerfox_plugins_latest_version');
174
+
175
+ if (null != $lastReleaseVersion) {
176
+ $currentVersion = $this->getExtensionVersion();
177
+
178
+ // Remove dots to reliable the test
179
+ $lastReleaseVersion = str_replace('.', '', $lastReleaseVersion);
180
+ $currentVersion = str_replace('.', '', $currentVersion);
181
+
182
+ if ($currentVersion < $lastReleaseVersion) {
183
+ Mage::getSingleton('adminhtml/session')->addWarning(
184
+ $this->__("A new version of Steerfox plugins is available. Please update to take advantage of new features.")
185
+ );
186
+ }
187
+ }
188
+ }
189
+ }
app/code/community/Steerfox/Plugins/Model/Adapter/Configuration.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins') . '/lib/SteerfoxContainer.php';
4
+
5
+ class Steerfox_Plugins_Model_Adapter_Configuration implements SteerfoxConfigurationInterface
6
+ {
7
+
8
+ protected static $nameMapping = array(
9
+ 'STEERFOX_ACCOUNT_API_KEY' => array(
10
+ 'key' => 'steerfox_plugins/account/api_key',
11
+ 'scope' => 'default',
12
+ ),
13
+ 'STEERFOX_ACCOUNT_STATUS' => array(
14
+ 'key' => 'steerfox_plugins/account/status',
15
+ 'scope' => 'default',
16
+ ),
17
+ 'STEERFOX_SHOP_ID' => array(
18
+ 'key' => 'steerfox_plugins/catalog/shop_id',
19
+ 'scope' => 'websites',
20
+ ),
21
+ 'STEERFOX_EXPORT_LANG' => array(
22
+ 'key' => 'steerfox_plugins/catalog/export_lang',
23
+ 'scope' => 'websites',
24
+ ),
25
+ 'STEERFOX_EXPORT_CURRENCY' => array(
26
+ 'key' => 'steerfox_plugins/catalog/export_currency',
27
+ 'scope' => 'websites',
28
+ ),
29
+ 'STEERFOX_FEED_ID' => array(
30
+ 'key' => 'steerfox_plugins/catalog/feed_id',
31
+ 'scope' => 'websites',
32
+ ),
33
+ );
34
+
35
+ const STEERFOX_SOURCE_MAGENTO = 3;
36
+
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ public function get($key, $shopId = null)
41
+ {
42
+ $key = $this->getMappedKey($key);
43
+ return Mage::getStoreConfig($key, $shopId);
44
+ }
45
+
46
+ /**
47
+ * @inheritDoc
48
+ */
49
+ public function getGlobal($key)
50
+ {
51
+ $key = $this->getMappedKey($key);
52
+ return Mage::getStoreConfig($key);
53
+ }
54
+
55
+ /**
56
+ * @inheritDoc
57
+ */
58
+ public function set($key, $value, $shopId = 0)
59
+ {
60
+ $key = $this->getMappedKey($key);
61
+ $scope = $this->getMappedScope($key);
62
+ return Mage::helper('steerfox_plugins')->updateConfig($key, $value, $scope, $shopId);
63
+ }
64
+
65
+ /**
66
+ * @inheritDoc
67
+ */
68
+ public function setGlobal($key, $value)
69
+ {
70
+ $key = $this->getMappedKey($key);
71
+ return Mage::helper('steerfox_plugins')->updateConfig($key, $value);
72
+ }
73
+
74
+ /**
75
+ * @inheritDoc
76
+ */
77
+ public function getCmsId()
78
+ {
79
+ return self::STEERFOX_SOURCE_MAGENTO;
80
+ }
81
+
82
+ /**
83
+ * @inheritDoc
84
+ */
85
+ public function getEmail()
86
+ {
87
+ $user = Mage::getSingleton('admin/session');
88
+ $userEmail = $user->getUser()->getEmail();
89
+ if (empty($userEmail)) {
90
+ $userEmail = Mage::getStoreConfig('trans_email/ident_general/email');
91
+ }
92
+
93
+ if (getenv('STEERFOX_API_DEV') &&
94
+ getenv('STEERFOX_API_USER') &&
95
+ getenv('STEERFOX_API_PWD')
96
+ ) {
97
+ $userEmail = uniqid() . '@test.com';
98
+ }
99
+
100
+ return $userEmail;
101
+ }
102
+
103
+ /**
104
+ * Resolve the good key config if parameters keys is in mapping config.
105
+ *
106
+ * @param string $key
107
+ *
108
+ * @return string
109
+ */
110
+ private function getMappedKey($key)
111
+ {
112
+
113
+ if (array_key_exists($key, self::$nameMapping)) {
114
+ $key = self::$nameMapping[$key]['key'];
115
+ }
116
+
117
+ return $key;
118
+ }
119
+
120
+ /**
121
+ * Resolve the good scope config if parameters keys is in mapping config.
122
+ *
123
+ * @param string $key
124
+ *
125
+ * @return string
126
+ */
127
+ private function getMappedScope($key)
128
+ {
129
+ $scope = 'default';
130
+
131
+ if (array_key_exists($key, self::$nameMapping)) {
132
+ $scope = self::$nameMapping[$key]['scope'];
133
+ }
134
+
135
+ return $scope;
136
+ }
137
+
138
+ /**
139
+ * Assert if scope is website, shopid cannot be empty.
140
+ *
141
+ * @param string $scope
142
+ * @param integer $shopId
143
+ * @throws Mage_Core_Exception
144
+ */
145
+ private function assertScope($scope, $shopId)
146
+ {
147
+ if ('websites' == $scope && (null == $shopId || 0 == $shopId)) {
148
+ Mage::throwException('shopId cannot be empty if scope is "websites".');
149
+ }
150
+ }
151
+
152
+ }
app/code/community/Steerfox/Plugins/Model/Adapter/Product.php ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins') . '/lib/SteerfoxContainer.php';
4
+
5
+ class Steerfox_Plugins_Model_Adapter_Product implements SteerfoxProductAdapterInterface
6
+ {
7
+ /**
8
+ * Store Magento.
9
+ *
10
+ * @var Steerfox_Plugins_Model_Product
11
+ */
12
+ private $steerfoxProduct;
13
+
14
+ /**
15
+ * Store Magento.
16
+ *
17
+ * @var Mage_Catalog_Model_Product
18
+ */
19
+ private $product;
20
+
21
+ public function __construct(Steerfox_Plugins_Model_Product $steerfoxProduct){
22
+ $this->steerfoxProduct = $steerfoxProduct;
23
+ $this->product = Mage::getModel('catalog/product')->load($steerfoxProduct->getIdProduct());
24
+ }
25
+
26
+ /**
27
+ * Return id.
28
+ *
29
+ * @return mixed
30
+ */
31
+ public function getId()
32
+ {
33
+ return $this->product->getId();
34
+ }
35
+
36
+ /**
37
+ * Return Title
38
+ *
39
+ * @return mixed
40
+ */
41
+ public function getTitle()
42
+ {
43
+ return $this->product->getName();
44
+ }
45
+
46
+ /**
47
+ * Return Description
48
+ *
49
+ * @return mixed
50
+ */
51
+ public function getDescription()
52
+ {
53
+ return $this->product->getDescription();
54
+ }
55
+
56
+ /**
57
+ * Return ProductType
58
+ *
59
+ * @return mixed
60
+ */
61
+ public function getProductType()
62
+ {
63
+ $type = null;
64
+ if(null != $this->product->getApparelType()){
65
+ //Cas pour le jeu produit des vêtements
66
+ $type = $this->product->getResource()
67
+ ->getAttribute('apparel_type')
68
+ ->getSource()
69
+ ->getOptionText($this->product->getApparelType());
70
+ }else if(null != $this->product->getAttributeSetId()){
71
+ // Cas par défaut
72
+ $attributeSetModel = Mage::getModel("eav/entity_attribute_set");
73
+ $attributeSetModel->load($this->product->getAttributeSetId());
74
+ $type = $attributeSetModel->getAttributeSetName();
75
+ }
76
+
77
+ return $type;
78
+ }
79
+
80
+ /**
81
+ * Return Link
82
+ *
83
+ * @return mixed
84
+ */
85
+ public function getLink()
86
+ {
87
+ return $this->product->getProductUrl();
88
+ }
89
+
90
+ /**
91
+ * Return Image Link
92
+ *
93
+ * @return mixed
94
+ */
95
+ public function getImageLink()
96
+ {
97
+ return $this->product->getImageUrl();
98
+ }
99
+
100
+ /**
101
+ * Return Condition
102
+ *
103
+ * @return mixed
104
+ */
105
+ public function getCondition()
106
+ {
107
+ $currentDate = Mage::getModel('core/date')->date('Y-m-d');
108
+ $fromDate = substr($this->product->getNewsFromDate(), 0, 10);
109
+ $toDate = substr($this->product->getNewsToDate(), 0, 10);
110
+
111
+ $isNew = ($currentDate >= $fromDate && $currentDate <= $toDate) || ($fromDate == '' && $currentDate <= $toDate && $toDate != '') || ($fromDate != '' && $currentDate >= $fromDate && $toDate == '') ;
112
+ return ( $isNew ) ? 'new' : null;
113
+ }
114
+
115
+ /**
116
+ * Return Availability
117
+ *
118
+ * @return mixed
119
+ */
120
+ public function getAvailability()
121
+ {
122
+ $availability = 'out of stock';
123
+ $productStock = $this->product->getStockItem();
124
+ if(null != $productStock){
125
+ if($productStock->getIsInStock()){
126
+ $availability = 'in stock';
127
+ }
128
+ }
129
+
130
+ return $availability;
131
+ }
132
+
133
+ /**
134
+ * Return Availability Date
135
+ *
136
+ * @return mixed
137
+ */
138
+ public function getAvailabilityDate()
139
+ {
140
+ return null;
141
+ }
142
+
143
+ /**
144
+ * Return Price
145
+ *
146
+ * @return mixed
147
+ */
148
+ public function getPrice()
149
+ {
150
+ return $this->product->getPrice();
151
+ }
152
+
153
+ /**
154
+ * Return Sale Price
155
+ *
156
+ * @return mixed
157
+ */
158
+ public function getSalePrice()
159
+ {
160
+ return $this->product->getFinalPrice();
161
+ }
162
+
163
+ /**
164
+ * Return Sale Price Effective Date
165
+ *
166
+ * @return mixed
167
+ */
168
+ public function getSalePriceEffectiveDate()
169
+ {
170
+ $salesPriceAvailabilityDates = null;
171
+
172
+ // si le produit à un prix et des dates de promotion
173
+ if(null != $this->product->getSpecialPrice() && null != $this->product->getSpecialFromDate() && null != $this->product->getSpecialToDate()){
174
+ $fromDate = new DateTime($this->product->getSpecialFromDate());
175
+ $toDate = new DateTime($this->product->getSpecialToDate());
176
+ $salesPriceAvailabilityDates = $fromDate->format(DateTime::ISO8601) . '/' . $toDate->format(DateTime::ISO8601);
177
+ }
178
+
179
+ return $salesPriceAvailabilityDates;
180
+ }
181
+
182
+ /**
183
+ * Return Gtin
184
+ *
185
+ * @return mixed
186
+ */
187
+ public function getGtin()
188
+ {
189
+ return $this->product->getSku();
190
+ }
191
+
192
+ /**
193
+ * Return Brand
194
+ *
195
+ * @return mixed
196
+ */
197
+ public function getBrand()
198
+ {
199
+ $manufacturer = null;
200
+ if(null != $this->product->getManufacturer()){
201
+ $manufacturer = $this->product->getResource()
202
+ ->getAttribute('manufacturer')
203
+ ->getSource()
204
+ ->getOptionText($this->product->getManufacturer());
205
+ }
206
+
207
+ return $manufacturer;
208
+ }
209
+
210
+ /**
211
+ * Return Mpn
212
+ *
213
+ * @return String
214
+ */
215
+ public function getMpn()
216
+ {
217
+ $mpn = '';
218
+ // If we have to use sku for mpn we use it.
219
+ if (Mage::helper('steerfox_plugins')->getConfig('catalog/use_sku_for_mpn')) {
220
+ $mpn = $this->product->getSku();
221
+ } else {
222
+ // Else we use the attribute in conf is any.
223
+ $mpnAttributeCode = Mage::helper('steerfox_plugins')->getConfig('catalog/mpn_attribute_code');
224
+ if (!empty($mpnAttributeCode)) {
225
+ foreach ($this->product->getAttributes() as $attribute) {
226
+ if ($mpnAttributeCode == $attribute->getAttributeCode()) {
227
+ $attributeText = $this->product->getAttributeText($mpnAttributeCode);
228
+ if (false !== $attributeText) {
229
+ $mpn = $attributeText;
230
+ break;
231
+ }
232
+ }
233
+ }
234
+ }
235
+ }
236
+ return $mpn;
237
+ }
238
+
239
+ /**
240
+ * Return Identifier Exists
241
+ *
242
+ * @return mixed
243
+ */
244
+ public function getIdentifierExists()
245
+ {
246
+ // Not available in Magento
247
+ return null;
248
+ }
249
+
250
+ /**
251
+ * Return Item Group Id
252
+ *
253
+ * @return mixed
254
+ */
255
+ public function getItemGroupId()
256
+ {
257
+ // Not available in Magento
258
+ return null;
259
+ }
260
+
261
+ /**
262
+ * Return Gender
263
+ *
264
+ * @return mixed
265
+ */
266
+ public function getGender()
267
+ {
268
+ $gender = null;
269
+ if(null != $this->product->getGender()){
270
+ $gender = $this->product->getResource()
271
+ ->getAttribute('gender')
272
+ ->getSource()
273
+ ->getOptionText($this->product->getGender());
274
+ }
275
+
276
+ return $gender;
277
+ }
278
+
279
+ /**
280
+ * Return Age Group
281
+ *
282
+ * @return mixed
283
+ */
284
+ public function getAgeGroup()
285
+ {
286
+ // Not available in Magento
287
+ return null;
288
+ }
289
+
290
+ /**
291
+ * Return Color
292
+ *
293
+ * @return mixed
294
+ */
295
+ public function getColor()
296
+ {
297
+ $color = null;
298
+ if(null != $this->product->getColor()){
299
+ $color = $this->product->getResource()
300
+ ->getAttribute('color')
301
+ ->getSource()
302
+ ->getOptionText($this->product->getColor());
303
+ }
304
+
305
+ return $color;
306
+ }
307
+
308
+ /**
309
+ * Return Size
310
+ *
311
+ * @return mixed
312
+ */
313
+ public function getSize()
314
+ {
315
+ $size = null;
316
+ if(null != $this->product->getSize()){
317
+ $size = $this->product->getResource()
318
+ ->getAttribute('size')
319
+ ->getSource()
320
+ ->getOptionText($this->product->getSize());
321
+ }
322
+
323
+ return $size;
324
+ }
325
+
326
+ /**
327
+ * Return Shipping
328
+ *
329
+ * @return mixed
330
+ */
331
+ public function getShipping()
332
+ {
333
+ // Not implement because it's heavy treatment on Magento for each product.
334
+ return null;
335
+ }
336
+
337
+ /**
338
+ * Return Shipping Weight
339
+ *
340
+ * @return mixed
341
+ */
342
+ public function getShippingWeight()
343
+ {
344
+ return $this->product->getWeight();
345
+ }
346
+
347
+ /**
348
+ * Return GrossProfit
349
+ *
350
+ * @return mixed
351
+ */
352
+ public function getGrossProfit()
353
+ {
354
+ $profit = null;
355
+ if (false != Mage::helper('steerfox_plugins')->getConfig('catalog/export_margin')) {
356
+ $profit = $this->product->getProductProfit();
357
+ }
358
+ return $profit;
359
+ }
360
+
361
+ /**
362
+ * Return Gross Margin
363
+ *
364
+ * @return mixed
365
+ */
366
+ public function getGrossMargin()
367
+ {
368
+ $margin = null;
369
+ if (false != Mage::helper('steerfox_plugins')->getConfig('catalog/export_margin')) {
370
+ if (null != $this->product->getCost()) {
371
+ $margin = $this->product->getFinalPrice() - $this->product->getCost();
372
+ }
373
+ }
374
+
375
+ return $margin;
376
+ }
377
+
378
+
379
+ }
app/code/community/Steerfox/Plugins/Model/Adapter/Service/Log.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: loic
5
+ * Date: 05/02/16
6
+ * Time: 17:44
7
+ */
8
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins') . '/lib/SteerfoxContainer.php';
9
+
10
+ class Steerfox_Plugins_Model_Adapter_Service_Log extends SteerfoxAbstractLoggerService
11
+ {
12
+ /**
13
+ * Return all logs.
14
+ *
15
+ * @return array
16
+ */
17
+ public function getAllLogs()
18
+ {
19
+ $logList = array();
20
+ $logCollection = Mage::getModel('steerfox_plugins/log')->getCollection();
21
+
22
+ foreach($logCollection as $log){
23
+ $logInfo = array(
24
+ 'action' => $log->getAction(),
25
+ 'type' => $log->getType(),
26
+ 'feed_id' => $log->getFeedId(),
27
+ 'shop' => $log->getShop(),
28
+ 'locale' => $log->getLocale(),
29
+ 'message' => json_decode($log->getMessage()),
30
+ 'created_at' => $log->getCreatedAt(),
31
+ 'created_at_zone' => date('O')
32
+ );
33
+ $logList[] = $logInfo;
34
+ }
35
+
36
+ return $logList;
37
+ }
38
+
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ protected function getPluginVersion()
43
+ {
44
+ return (string) Mage::helper('steerfox_plugins')->getExtensionVersion();
45
+ }
46
+
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ protected function getCmsVersion()
51
+ {
52
+ return Mage::getVersion();
53
+ }
54
+
55
+
56
+ /**
57
+ * Add a log in database.
58
+ *
59
+ * @param string $message The message.
60
+ * @param string $action The action.
61
+ * @param int $level The level.
62
+ */
63
+ public function addLog($message, $action, $level)
64
+ {
65
+ $log = Mage::getModel('steerfox_plugins/log');
66
+ $log->setData(
67
+ array(
68
+ 'action' => $action,
69
+ 'type' => $level,
70
+ 'message' => $message,
71
+ )
72
+ )->setOrigData()->save();
73
+ }
74
+ }
app/code/community/Steerfox/Plugins/Model/Adapter/Service/Shop.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins') . '/lib/SteerfoxContainer.php';
23
+
24
+ /**
25
+ * Tool adapter.
26
+ */
27
+ class Steerfox_Plugins_Model_Adapter_Service_Shop extends SteerfoxAbstractShopService
28
+ {
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ public function getShops()
33
+ {
34
+ $websiteList = Mage::app()->getWebsites();
35
+ $shopList = array();
36
+
37
+ foreach ($websiteList as $website) {
38
+ $shopList[] = new Steerfox_Plugins_Model_Adapter_Shop($website);
39
+ }
40
+
41
+ return $shopList;
42
+ }
43
+
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ public function getMainShop()
48
+ {
49
+ $websiteList = Mage::app()->getWebsites();
50
+ //On récupère le premier webstite
51
+ $websiteArray = array_values($websiteList);
52
+ $website = $websiteArray[0];
53
+
54
+ return new Steerfox_Plugins_Model_Adapter_Shop($website);
55
+ }
56
+
57
+ /**
58
+ * @inheritDoc
59
+ */
60
+ public function getCurrentShop()
61
+ {
62
+ return new Steerfox_Plugins_Model_Adapter_Shop(Mage::app()->getWebsite());
63
+ }
64
+
65
+ /**
66
+ * Return current shop.
67
+ *
68
+ * @return SteerfoxProductAdapterInterface[]
69
+ */
70
+ public function getProductsToExport(SteerfoxShopAdapterInterface $shop)
71
+ {
72
+ //On charge les produits à exporter.
73
+ $steerfoxProductCollection = Mage::getModel('steerfox_plugins/product')->getCollection();
74
+ $steerfoxProductCollection->addFilter('active', 1);
75
+ $steerfoxProductCollection->addFilter('id_shop', $shop->getId());
76
+
77
+ // TODO Keep this for future use of export by store group.
78
+ // // recreate this function
79
+ // $shopCategory = Mage::getModel('catalog/category')->load($shop->getDefaultCategoryId());
80
+ // $steerfoxProductCollection = Mage::getModel('steerfox_plugins/product')
81
+ // ->getCollection();
82
+ // $steerfoxProductCollection
83
+ // ->getSelect()
84
+ // ->joinLeft(
85
+ // array('categ' => Mage::getSingleton('core/resource')->getTableName('catalog/category_product')),
86
+ // 'categ.product_id=main_table.id_product',
87
+ // array()
88
+ // )
89
+ // ->group('main_table.id_product')
90
+ // ->group('main_table.id_shop')
91
+ // ->order('main_table.entity_id');
92
+ // ;
93
+ // $steerfoxProductCollection
94
+ // ->addFieldToFilter('active', 1)
95
+ // ->addFieldToFilter('id_shop', $shop->getId())
96
+ // ->addFieldToFilter('category_id', array('in' => explode(',', $shopCategory->getAllChildren())))
97
+ // ;
98
+ // FIN TODO
99
+ $productsToExport = array();
100
+
101
+ foreach ($steerfoxProductCollection as $steerfoxProduct) {
102
+ $productsToExport[] = new Steerfox_Plugins_Model_Adapter_Product($steerfoxProduct);
103
+ }
104
+
105
+ return $productsToExport;
106
+ }
107
+
108
+
109
+ }
app/code/community/Steerfox/Plugins/Model/Adapter/Shop.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins') . '/lib/SteerfoxContainer.php';
4
+
5
+ class Steerfox_Plugins_Model_Adapter_Shop implements SteerfoxShopAdapterInterface
6
+ {
7
+ /**
8
+ * Store Magento.
9
+ *
10
+ * @var Mage_Core_Model_Website
11
+ */
12
+ private $shop;
13
+
14
+ /**
15
+ * return feed Url.
16
+ *
17
+ * @return string
18
+ */
19
+ public function getShopFeedUrl()
20
+ {
21
+ $hash = Mage::getStoreConfig('steerfox_plugins/catalog/hash_ws');
22
+ return Mage::getUrl('steerfox/product/export') . '/secure/' . $hash . '?id_shop=' . $this->getId();
23
+ }
24
+
25
+ public function __construct(Mage_Core_Model_Website $store)
26
+ {
27
+ $this->shop = $store;
28
+ }
29
+
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ public function getId()
34
+ {
35
+ return $this->shop->getId();
36
+ }
37
+
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ public function getUrl()
42
+ {
43
+ $url = $this->shop->getDefaultStore()->getBaseUrl();
44
+
45
+ if (getenv('STEERFOX_API_DEV') &&
46
+ getenv('STEERFOX_API_USER') &&
47
+ getenv('STEERFOX_API_PWD')
48
+ ) {
49
+ $url = 'http://test.' . uniqid() . '.com/';
50
+ }
51
+
52
+ return $url;
53
+ }
54
+
55
+ /**
56
+ * @inheritDoc
57
+ */
58
+ public function getName()
59
+ {
60
+ return $this->shop->getName();
61
+ }
62
+
63
+ /**
64
+ * @inheritDoc
65
+ */
66
+ public function getLanguage()
67
+ {
68
+ return Mage::getStoreConfig('general/locale/code', $this->shop->getDefaultStore());
69
+ }
70
+
71
+ /**
72
+ * @inheritDoc
73
+ */
74
+ public function getLogo()
75
+ {
76
+ // Emulate front store env to get logo
77
+ $appEmulation = Mage::getSingleton('core/app_emulation');
78
+ $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($this->shop->getDefaultStore()->getId());
79
+ $logoUrl = Mage::getDesign()->getSkinUrl() . Mage::getStoreConfig('design/header/logo_src', $this->shop->getDefaultStore());
80
+ $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
81
+
82
+ return $logoUrl;
83
+ }
84
+
85
+ /**
86
+ * @inheritDoc
87
+ */
88
+ public function getCurrency()
89
+ {
90
+ return $this->shop->getDefaultStore()->getCurrentCurrencyCode();
91
+ }
92
+
93
+ /**
94
+ * @inheritDoc
95
+ */
96
+ public function getLocale()
97
+ {
98
+ return Mage::app()->getLocale()->getLocaleCode();
99
+ }
100
+ }
app/code/community/Steerfox/Plugins/Model/Adapter/Tools.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins') . '/lib/SteerfoxContainer.php';
23
+
24
+ /**
25
+ * Tool adapter.
26
+ */
27
+ class Steerfox_Plugins_Model_Adapter_Tools implements SteerfoxToolsAdapterInterface
28
+ {
29
+ /**
30
+ * Encode as json.
31
+ *
32
+ * @param mixed $value Value to encode.
33
+ *
34
+ * @return string
35
+ */
36
+ public function jsonEncode($value)
37
+ {
38
+ return json_encode($value);
39
+ }
40
+
41
+ /**
42
+ * Decode JSON string
43
+ *
44
+ * @param string $json Json value to decode
45
+ * @param bool $assoc Return an assoc array
46
+ *
47
+ * @return mixed
48
+ */
49
+ public function jsonDecode($json, $assoc = false)
50
+ {
51
+ return json_decode($json, $assoc);
52
+ }
53
+
54
+ /**
55
+ * Return sting length.
56
+ *
57
+ * @param string $string
58
+ *
59
+ * @return bool|int
60
+ */
61
+ public function strlen($string)
62
+ {
63
+ return strlen($string);
64
+ }
65
+
66
+ /**
67
+ * Return part of string.
68
+ *
69
+ * @param string $string Source string.
70
+ * @param int $start Start position.
71
+ * @param int|bool $length Length.
72
+ *
73
+ * @return mixed
74
+ */
75
+ public function substr($string, $start, $length = false)
76
+ {
77
+ return substr($string, $start, $length);
78
+ }
79
+
80
+ /**
81
+ * Return content file
82
+ *
83
+ * @param string $url URL.
84
+ * @param bool $useIncludePath Use php include path.
85
+ * @param null $streamContext Stream context
86
+ *
87
+ * @return mixed
88
+ */
89
+ public function fileGetContents($url, $useIncludePath = false, $streamContext = null)
90
+ {
91
+ return file_get_contents($url, $useIncludePath, $streamContext);
92
+ }
93
+
94
+ /**
95
+ * Save export file on disk
96
+ *
97
+ * @param $filename File Name
98
+ * @param $fileContent File Content
99
+ *
100
+ * @return void
101
+ */
102
+ public function saveExportFile($filename, $fileContent)
103
+ {
104
+ $folderPath = Mage::getBaseDir('var') . DS . Mage::getStoreConfig('steerfox_plugins/export/folder_name');
105
+ $file = new Varien_Io_File();
106
+
107
+ //Si le dossier n'existe pas on le crée
108
+ if(!is_dir($folderPath)) {
109
+ $folderCreate = $file->mkdir($folderPath);
110
+ if (!$folderCreate) {
111
+ Mage::throwException('Can\'t create folder');
112
+ }
113
+ }
114
+
115
+ $filePath = $folderPath . DS . $filename;
116
+
117
+ //Si un ancien fichier existe on le supprime.
118
+ if(file_exists($filePath)){
119
+ unlink($filePath);
120
+ }
121
+
122
+ //On écrit le fichier sur disque.
123
+ if(!$file->write($filePath,$fileContent)){
124
+ Mage::throwException('Can\'t create file');
125
+ }
126
+ }
127
+
128
+
129
+ }
app/code/community/Steerfox/Plugins/Model/Apikey.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2016 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2016 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+
23
+ /**
24
+ * Class Steerfox_Plugins_Model_Apikey
25
+ */
26
+ class Steerfox_Plugins_Model_Apikey extends Mage_Core_Model_Config_Data
27
+ {
28
+ /**
29
+ * Méthode permettant de valider le champ de config steerfox_plugins/account/api_key
30
+ *
31
+ * @return Mage_Core_Model_Abstract
32
+ * @throws Exception
33
+ * @throws Mage_Core_Exception
34
+ */
35
+ public function save()
36
+ {
37
+ parent::save();
38
+
39
+ // Refresh the config.
40
+ Mage::app()->getStore()->resetConfig();
41
+
42
+ $coreHelper = Mage::helper('steerfox_plugins/core_data');
43
+ $steerfoxContainer = $coreHelper->getSteerfoxContainer();
44
+ $steerfoxApi = $steerfoxContainer->get('api');
45
+ $steerfoxApi instanceof SteerfoxApiService;
46
+ $result = $steerfoxApi->retrieveAccount();
47
+
48
+ if (!$result) {
49
+ Mage::getSingleton('core/session')->addError('Invalid APi Key, module account disabled.');
50
+ }
51
+
52
+ return $this; //call original save method so whatever happened
53
+ }
54
+ }
app/code/community/Steerfox/Plugins/Model/Currencies.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Model_Currencies
24
+ */
25
+ class Steerfox_Plugins_Model_Currencies
26
+ {
27
+ public function toOptionArray()
28
+ {
29
+ $currencies = array();
30
+ $codes = Mage::app()->getStore()->getAvailableCurrencyCodes(true);
31
+ if (is_array($codes) && count($codes) >= 1) {
32
+ $rates = Mage::getModel('directory/currency')->getCurrencyRates(
33
+ Mage::app()->getStore()->getBaseCurrency(),
34
+ $codes
35
+ );
36
+
37
+ $i = 0;
38
+ foreach ($codes as $code) {
39
+ if (isset($rates[$code])) {
40
+ $currencies[$i]['value'] = $code;
41
+ $currencies[$i]['label'] = Mage::app()->getLocale()->getTranslation($code, 'nametocurrency');
42
+ }
43
+ $i++;
44
+ }
45
+ }
46
+
47
+ return $currencies;
48
+ }
49
+ }
app/code/community/Steerfox/Plugins/Model/Entity/Attribute/Backend/Profit.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Steerfox_Plugins_Model_Entity_Attribute_Backend_Profit extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
4
+ {
5
+ public function afterLoad($object)
6
+ {
7
+ $cost = $object->getCost() === null ? 0 : $object->getCost();
8
+
9
+ $finalPrice = $object->getFinalPrice();
10
+ $taxHelper = Mage::helper('tax');
11
+ $price = $taxHelper->getPrice($object, $finalPrice, false);
12
+
13
+ $profit = $price - $cost;
14
+ $object->setProductProfit($profit);
15
+
16
+ return $this;
17
+ }
18
+
19
+ public function beforeSave($object)
20
+ {
21
+ $cost = $object->getCost() === null ? 0 : $object->getCost();
22
+
23
+ $finalPrice = $object->getFinalPrice();
24
+ $taxHelper = Mage::helper('tax');
25
+ $price = $taxHelper->getPrice($object, $finalPrice, false);
26
+
27
+ $profit = $price - $cost;
28
+ $object->setProductProfit($profit);
29
+
30
+ return $this;
31
+ }
32
+ }
app/code/community/Steerfox/Plugins/Model/Entity/Attribute/Backend/Profit/Ratio.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Steerfox_Plugins_Model_Entity_Attribute_Backend_Profit_Ratio
4
+ extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
5
+ {
6
+ public function afterLoad($object)
7
+ {
8
+ $cost = $object->getCost() === null ? 0 : $object->getCost();
9
+
10
+ $finalPrice = $object->getFinalPrice();
11
+ $taxHelper = Mage::helper('tax');
12
+ $price = $taxHelper->getPrice($object, $finalPrice, false);
13
+
14
+ if (0 < $price) {
15
+ $profit = $price - $cost;
16
+ $ratio = ($profit / $price) * 100;
17
+ $object->setProductProfitRatio($ratio);
18
+ }
19
+
20
+ return $this;
21
+ }
22
+
23
+ public function beforeSave($object)
24
+ {
25
+ $cost = $object->getCost() === null ? 0 : $object->getCost();
26
+
27
+ $finalPrice = $object->getFinalPrice();
28
+ $taxHelper = Mage::helper('tax');
29
+ $price = $taxHelper->getPrice($object, $finalPrice, false);
30
+
31
+ if (0 < $price) {
32
+ $profit = $price - $cost;
33
+ $ratio = ($profit / $price) * 100;
34
+ $object->setProductProfitRatio($ratio);
35
+ }
36
+
37
+ return $this;
38
+ }
39
+
40
+ }
app/code/community/Steerfox/Plugins/Model/Languages.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Model_Languages
24
+ */
25
+ class Steerfox_Plugins_Model_Languages
26
+ {
27
+ public function toOptionArray()
28
+ {
29
+ return Mage::app()->getLocale()->getOptionLocales();
30
+ }
31
+ }
app/code/community/Steerfox/Plugins/Model/Log.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Model_Log
24
+ */
25
+ class Steerfox_Plugins_Model_Log extends Mage_Core_Model_Abstract
26
+ {
27
+ const STEERFOX_LOG_TYPE_INFO = 'info';
28
+ const STEERFOX_LOG_TYPE_ERROR = 'error';
29
+ const STEERFOX_LOG_TYPE_WARNING = 'warning';
30
+
31
+ protected function _construct()
32
+ {
33
+ $this->_init('steerfox_plugins/log');
34
+ }
35
+
36
+
37
+ /**
38
+ * Before save hook : update timestamps
39
+ * @return $this
40
+ */
41
+ protected function _beforeSave()
42
+ {
43
+ parent::_beforeSave();
44
+
45
+ // Update Shop and locale
46
+ $this->_updateShop();
47
+
48
+ // Actions before save
49
+ $this->_updateTimestamps();
50
+
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * Implements timestamps => now + zone
56
+ * @return $this
57
+ */
58
+ protected function _updateTimestamps()
59
+ {
60
+ $timestamp = now();
61
+
62
+ // Set the last updated timestamp.
63
+ $this->setCreatedAt($timestamp);
64
+
65
+ // Set the timezone
66
+ $this->setCreatedAtZone(date('O'));
67
+
68
+ return $this;
69
+ }
70
+
71
+
72
+ /**
73
+ * Implements locale + shop
74
+ * @return $this
75
+ */
76
+ protected function _updateShop()
77
+ {
78
+ $store = Mage::app()->getStore();
79
+
80
+ // Locale
81
+ $this->setLocale(Mage::getStoreConfig('steerfox_plugins/catalog/export_lang') === null ? Mage::getStoreConfig('general/locale/code', $this->getData('id_shop')) : Mage::getStoreConfig('steerfox_plugins/catalog/export_lang'));
82
+
83
+ // Feed_id
84
+ $feed_id = Mage::getStoreConfig('steerfox_plugins/account/feed_id');
85
+ if ($feed_id > 0) {
86
+ $this->setFeedId($feed_id);
87
+ }
88
+
89
+ // Shop : {websiteid}-{group_name}
90
+ if (null === $this->getShop) {
91
+ $this->setShop($store->getWebsiteId() . '-' . $store->getGroup()->getName());
92
+ }
93
+
94
+ return $this;
95
+ }
96
+ }
app/code/community/Steerfox/Plugins/Model/Observer.php ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Steerfox_Plugins_Model_Observer
4
+ {
5
+
6
+ /**
7
+ * Update a single Steerfox product.
8
+ *
9
+ * @param Varien_Event_Observer $observer
10
+ */
11
+ public function afterCatalogProductSave(Varien_Event_Observer $observer)
12
+ {
13
+ $this->updateSteerfoxProduct($observer->getProduct(), $observer);
14
+ }
15
+
16
+ /**
17
+ * Delete a single Steerfox product.
18
+ *
19
+ * @param Varien_Event_Observer $observer
20
+ */
21
+ public function afterCatalogProductDelete(Varien_Event_Observer $observer)
22
+ {
23
+ $this->deleteSteerfoxProduct($observer->getEvent()->getProduct()->getId());
24
+ }
25
+
26
+ /**
27
+ * Update all the Steerfox products for a mass update.
28
+ *
29
+ * @param Varien_Event_Observer $observer
30
+ */
31
+ public function afterProductMassUpdate(Varien_Event_Observer $observer)
32
+ {
33
+ $productIds = $observer->getData('product_ids');
34
+ $products = Mage::getModel('catalog/product')->getCollection()
35
+ ->addFieldToFilter('entity_id', array('in' => $productIds));
36
+ foreach ($products as $product) {
37
+ $loadedProduct = Mage::getModel('catalog/product')->load($product->getId());
38
+ $this->updateSteerfoxProduct($loadedProduct, $observer);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Create Steerfox products after import.
44
+ *
45
+ * @param Varien_Event_Observer $observer
46
+ */
47
+ public function afterCatalogProductImport(Varien_Event_Observer $observer)
48
+ {
49
+ $products = $observer->getEvent()->getAdapter()->getNewSku();
50
+ foreach ($products as $productData) {
51
+ $product = Mage::getModel('catalog/product')->load($productData['entity_id']);
52
+ $this->updateSteerfoxProduct($product, $observer);
53
+ }
54
+ }
55
+
56
+ public function setTagsOnOrderSuccessPageView(Varien_Event_Observer $observer)
57
+ {
58
+ $orderIds = $observer->getEvent()->getOrderIds();
59
+ if (empty($orderIds) || !is_array($orderIds)) {
60
+ return;
61
+ }
62
+ $collection = Mage::getResourceModel('sales/order_collection')
63
+ ->addFieldToFilter('entity_id', array('in' => $orderIds));
64
+ $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('steerfox_fb_order_tags');
65
+ if ($block) {
66
+ $block->setOrders($collection);
67
+ }
68
+ $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('steerfox_bing_order_tags');
69
+ if ($block) {
70
+ $block->setOrders($collection);
71
+ }
72
+ $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock(
73
+ 'steerfox_adwords_order_tags'
74
+ );
75
+ if ($block) {
76
+ $block->setOrders($collection);
77
+ }
78
+ }
79
+
80
+ public function sectionUpdate(Varien_Event_Observer $observer)
81
+ {
82
+ Mage::helper('steerfox_plugins/core_data')->apiUpdate();
83
+ }
84
+
85
+ private function updateSteerfoxProduct($product, Varien_Event_Observer $observer)
86
+ {
87
+ // Remove product by default
88
+ $steerfoxProductCollection = Mage::getModel('steerfox_plugins/product')->getCollection();
89
+ $steerfoxProductCollection
90
+ ->addFilter('id_product', $product->getId());
91
+
92
+ $archivedStatus = array();
93
+
94
+ if ($steerfoxProductCollection->count() > 0) {
95
+ foreach ($steerfoxProductCollection as $steerfoxroduct) {
96
+ $archivedStatus[$steerfoxroduct->getData('id_product') .'_' . $steerfoxroduct->getData('id_shop')] = $steerfoxroduct->getData('active');
97
+ $steerfoxroduct->delete();
98
+ }
99
+ }
100
+
101
+ // Add the product for on a good websites
102
+ if (Mage_Catalog_Model_Product_Status::STATUS_ENABLED == $product->getData('status')) {
103
+ if (Mage_Catalog_Model_Product_Status::STATUS_ENABLED == $product->getData('status')) {
104
+ foreach ($product->getWebsiteIds() as $websiteId) {
105
+ $active = 1;
106
+ if(array_key_exists($product->getId() . '_' . $websiteId, $archivedStatus)){
107
+ $active = $archivedStatus[$product->getId() . '_' . $websiteId];
108
+ }
109
+
110
+ Mage::getModel('steerfox_plugins/product')
111
+ ->setData(
112
+ array(
113
+ 'id_product' => $product->getId(),
114
+ 'id_shop' => $websiteId,
115
+ 'active' => $active,
116
+ )
117
+ )
118
+ ->setOrigData()
119
+ ->save();
120
+ }
121
+ }
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Delete a Steerfox product for all shop or for just one shop if precised.
127
+ *
128
+ * @param $productId
129
+ * @param $shopId
130
+ */
131
+ private function deleteSteerfoxProduct($productId, $shopId = null)
132
+ {
133
+ // Remove product by default
134
+ $steerfoxProductCollection = Mage::getModel('steerfox_plugins/product')->getCollection();
135
+ $steerfoxProductCollection
136
+ ->addFilter('id_product', $productId);
137
+ if (null !== $shopId) {
138
+ $steerfoxProductCollection->addFilter('id_shop', $shopId);
139
+ }
140
+
141
+ if ($steerfoxProductCollection->count() > 0) {
142
+ foreach ($steerfoxProductCollection as $steerfoxProduct) {
143
+ $steerfoxProduct->delete();
144
+ }
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Check the current plugin version with latest release.
150
+ *
151
+ * @param Varien_Event_Observer $observer
152
+ */
153
+ public function checkPluginVersion(Varien_Event_Observer $observer){
154
+ $version = null;
155
+ $releaseInfoUrl = Mage::getConfig()->getNode('default/steerfox_plugins/latest_release_info');
156
+
157
+ // Reduce timeout to get release info
158
+ $ctx = stream_context_create(array('http'=>
159
+ array(
160
+ 'timeout' => 5,
161
+ )
162
+ ));
163
+ $releaseInfoJson = @file_get_contents($releaseInfoUrl, false, $ctx);
164
+
165
+ if(false != $releaseInfoJson){
166
+ // Version find
167
+ $releaseInfoData = json_decode(trim($releaseInfoJson));
168
+
169
+ if (false != $releaseInfoData){
170
+ $version = $releaseInfoData->version;
171
+ }
172
+ }
173
+
174
+ Mage::getSingleton('core/session')->setData('steerfox_plugins_latest_version', $version);
175
+
176
+ // Add the version notity if necessary
177
+ Mage::helper('steerfox_plugins')->notifyOldRelease();
178
+ }
179
+
180
+ /**
181
+ * Save the add to cart action in cookies for tags
182
+ *
183
+ * @param Varien_Event_Observer $observer
184
+ */
185
+ public function notifyAddToCart(Varien_Event_Observer $observer)
186
+ {
187
+ $product = $observer->getEvent()->getProduct();
188
+ $categories = $product->getCategoryIds();
189
+ $catId = null;
190
+ if (0 < count($categories)) {
191
+ $catId = $categories[0];
192
+ }
193
+ $steerfoxProduct = Mage::getModel('steerfox_plugins/product')->getCollection()
194
+ ->addFieldToFilter('id_product', $product->getId())
195
+ ->getFirstItem();
196
+ $productAdapter = new Steerfox_Plugins_Model_Adapter_Product($steerfoxProduct);
197
+ $sku = $productAdapter->getMpn();
198
+ if ('' === $sku) {
199
+ $sku = $product->getSku();
200
+ }
201
+ $productArray = array(
202
+ 'id' => $product->getId(),
203
+ 'sku' => $sku,
204
+ 'name' => $product->getName(),
205
+ 'cat' => $catId,
206
+ 'price' => $product->getPrice(),
207
+ 'margin' => $product->getProductProfit(),
208
+ 'qty' => $product->getQty(),
209
+ );
210
+ Mage::getSingleton('core/session')->setData(Steerfox_Plugins_Enum_Tags::FOXTAG_ADD_TO_CART, $productArray);
211
+ Mage::getSingleton('core/session')->setData(Steerfox_Plugins_Enum_Tags::FACEBOOK_ADD_TO_CART, $productArray);
212
+ }
213
+
214
+ /**
215
+ * Delete Steerfox products from a deleted website.
216
+ *
217
+ * @param Varien_Event_Observer $observer
218
+ */
219
+ public function websiteRemove(Varien_Event_Observer $observer)
220
+ {
221
+ /* @var $website Mage_Core_Model_Website */
222
+ $productCollection = Mage::getModel('steerfox_plugins/product')
223
+ ->getCollection()
224
+ ->addFieldToFilter(
225
+ 'id_shop',
226
+ array('eq' => $observer->getEvent()->getWebsite()->getId())
227
+ );
228
+ foreach($productCollection as $product){
229
+ $product->delete();
230
+ }
231
+ }
232
+ }
app/code/community/Steerfox/Plugins/Model/Product.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Model_Product
24
+ */
25
+ class Steerfox_Plugins_Model_Product extends Mage_Core_Model_Abstract
26
+ {
27
+ const ACTIVE = 1;
28
+ const INACTIVE = 0;
29
+
30
+ protected function _construct()
31
+ {
32
+ $this->_init('steerfox_plugins/product');
33
+ }
34
+
35
+
36
+ /**
37
+ * Return available states as an array
38
+ * @return array
39
+ */
40
+ public function getAvailableStates()
41
+ {
42
+ return array(
43
+ self::ACTIVE => Mage::helper('steerfox_plugins')->__('Active'),
44
+ self::INACTIVE => Mage::helper('steerfox_plugins')->__('Inactive'),
45
+ );
46
+ }
47
+
48
+ /**
49
+ * Before save hook : update timestamps
50
+ * @return $this
51
+ */
52
+ protected function _beforeSave()
53
+ {
54
+ parent::_beforeSave();
55
+
56
+ // Actions before save
57
+ $this->_updateTimestamps();
58
+
59
+ return $this;
60
+ }
61
+
62
+
63
+ /**
64
+ * Implements timestamps => now
65
+ * @return $this
66
+ */
67
+ protected function _updateTimestamps()
68
+ {
69
+ // Set the last updated timestamp.
70
+ $this->setData('updated_at', Varien_Date::now());
71
+
72
+ // If we have a brand new object, set the created timestamp.
73
+ if ($this->isObjectNew()) {
74
+ $this->setData('created_at', Varien_Date::now());
75
+ }
76
+
77
+ return $this;
78
+ }
79
+ }
app/code/community/Steerfox/Plugins/Model/Resource/Log.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Model_Resource_Log
24
+ */
25
+ class Steerfox_Plugins_Model_Resource_Log extends Mage_Core_Model_Resource_Db_Abstract
26
+ {
27
+ protected function _construct()
28
+ {
29
+ $this->_init('steerfox_plugins/log', 'id_log');
30
+ }
31
+ }
app/code/community/Steerfox/Plugins/Model/Resource/Log/Collection.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Model_Resource_Log_Collection
24
+ */
25
+ class Steerfox_Plugins_Model_Resource_Log_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
26
+ {
27
+ protected function _construct()
28
+ {
29
+ parent::_construct();
30
+
31
+ $this->_init('steerfox_plugins/log', 'steerfox_plugins/log');
32
+ }
33
+ }
app/code/community/Steerfox/Plugins/Model/Resource/Product.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Model_Resource_Product
24
+ */
25
+ class Steerfox_Plugins_Model_Resource_Product extends Mage_Core_Model_Resource_Db_Abstract
26
+ {
27
+ protected function _construct()
28
+ {
29
+ $this->_init('steerfox_plugins/product', 'entity_id');
30
+ }
31
+ }
app/code/community/Steerfox/Plugins/Model/Resource/Product/Collection.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Model_Resource_Product_Collection
24
+ */
25
+ class Steerfox_Plugins_Model_Resource_Product_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
26
+ {
27
+ protected function _construct()
28
+ {
29
+ parent::_construct();
30
+
31
+ $this->_init('steerfox_plugins/product');
32
+ }
33
+
34
+ public function prepareForList($page)
35
+ {
36
+ $this->setPageSize(Mage::helper('steerfox_plugins')->getProductsPerPage());
37
+ }
38
+
39
+ public function addProductData()
40
+ {
41
+ // alias then field name
42
+ $productAttributes = array('product_name' => 'name', 'product_cost' => 'cost', 'product_profit' => 'product_profit', 'product_profit_ratio' => 'product_profit_ratio', 'product_price' => 'price');
43
+ foreach ($productAttributes as $alias => $attributeCode) {
44
+ $tableAlias = $attributeCode . '_table';
45
+ $attribute = Mage::getSingleton('eav/config')
46
+ ->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode);
47
+
48
+ //Add eav attribute value
49
+ $this->getSelect()->joinLeft(
50
+ array($tableAlias => $attribute->getBackendTable()),
51
+ "main_table.id_product = $tableAlias.entity_id AND $tableAlias.attribute_id={$attribute->getId()}",
52
+ array($tableAlias.'.value' => 'value')
53
+ );
54
+ }
55
+
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * @inheritdoc
61
+ */
62
+ public function getSelectCountSql()
63
+ {
64
+ $this->_renderFilters();
65
+ $countSelect = clone $this->getSelect();
66
+ $countSelect->reset(Zend_Db_Select::ORDER);
67
+ $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
68
+ $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
69
+ $countSelect->reset(Zend_Db_Select::COLUMNS);
70
+
71
+ // Count doesn't work with group by columns keep the group by
72
+ if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
73
+ $countSelect->reset(Zend_Db_Select::GROUP);
74
+ $countSelect->distinct(true);
75
+ $group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
76
+ $countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
77
+ } else {
78
+ $countSelect->columns('COUNT(*)');
79
+ }
80
+ return $countSelect;
81
+ }
82
+ }
app/code/community/Steerfox/Plugins/Model/Resource/Setup.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Steerfox_Plugins_Model_Resource_Setup extends Mage_Sales_Model_Mysql4_Setup
4
+ {
5
+
6
+ }
app/code/community/Steerfox/Plugins/Model/System/Config/Source/Group.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2016 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2016 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ class Steerfox_Plugins_Model_System_Config_Source_Group
23
+ {
24
+ protected $_options;
25
+
26
+ public function toOptionArray()
27
+ {
28
+ if (!$this->_options) {
29
+ if (strlen($code = Mage::getSingleton('adminhtml/config_data')->getWebsite())) {
30
+ $websiteId = Mage::getModel('core/website')->load($code)->getId();
31
+ $this->_options = Mage::getResourceModel('core/store_group_collection')
32
+ ->addWebsiteFilter($websiteId)
33
+ ->load()->toOptionArray();
34
+ }
35
+ }
36
+ return $this->_options;
37
+ }
38
+ }
app/code/community/Steerfox/Plugins/controllers/Adminhtml/SteerfoxindexController.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2016 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2016 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Adminhtml_IndexController
24
+ */
25
+ class Steerfox_Plugins_Adminhtml_SteerfoxindexController extends Mage_Adminhtml_Controller_Action
26
+ {
27
+
28
+ const STEERFOX_SOURCE_MAGENTO = 2;
29
+
30
+
31
+ protected function startAction()
32
+ {
33
+ try{
34
+ $coreHelper = Mage::helper('steerfox_plugins/core_data');
35
+ $steerfoxContainer = $coreHelper->getSteerfoxContainer();
36
+ $steerfoxApi = $steerfoxContainer->get('api');
37
+ $steerfoxApi instanceof SteerfoxApiService;
38
+ $confirmUrl = $steerfoxApi->createAccount();
39
+ Mage::app()->getStore()->resetConfig();
40
+
41
+ $this->_redirectUrl($confirmUrl);
42
+ }catch(Exception $ex) {
43
+ // Refresh the config.
44
+ Mage::app()->getStore()->resetConfig();
45
+ Mage::logException($ex);
46
+ Mage::getSingleton('core/session')->addError($ex->getMessage());
47
+
48
+ $this->_redirect('adminhtml/system_config/edit', array('section' => 'steerfox_plugins'));
49
+ }
50
+ }
51
+
52
+ /**
53
+ * ACL
54
+ * @return mixed
55
+ */
56
+ protected function _isAllowed()
57
+ {
58
+ $actionName = $this->getRequest()->getActionName();
59
+ switch ($actionName) {
60
+ case 'index':
61
+ case 'edit':
62
+ case 'delete':
63
+ default:
64
+ $adminSession = Mage::getSingleton('admin/session');
65
+ $isAllowed = $adminSession->isAllowed('system/config/steerfox_plugins');
66
+ break;
67
+ }
68
+
69
+ return $isAllowed;
70
+ }
71
+ }
app/code/community/Steerfox/Plugins/controllers/Adminhtml/SteerfoxproductController.php ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_Adminhtml_SteerfoxproductController
24
+ */
25
+ class Steerfox_Plugins_Adminhtml_SteerfoxproductController extends Mage_Adminhtml_Controller_Action
26
+ {
27
+ /**
28
+ * Display grid
29
+ */
30
+ public function indexAction()
31
+ {
32
+ $this->_title($this->__('Steerfox'))
33
+ ->_title($this->__('Manage exported products'));
34
+
35
+ $this->_initAction();
36
+ $this->renderLayout();
37
+ }
38
+
39
+ /**
40
+ * Grid ajax action
41
+ */
42
+ public function gridAction()
43
+ {
44
+ $this->_initAction();
45
+
46
+ $this->loadLayout();
47
+ $this->renderLayout();
48
+ }
49
+
50
+ /**
51
+ * Publish in mass.
52
+ */
53
+ public function massPublishAction()
54
+ {
55
+ $entityIds = $this->getRequest()->getParam('entity_id');
56
+ $logs = array();
57
+
58
+
59
+ if (!is_array($entityIds)) {
60
+ Mage::getSingleton('adminhtml/session')->addError(
61
+ Mage::helper('steerfox_plugins')->__('Please select product(s)')
62
+ );
63
+ $logs[] = Mage::getModel('steerfox_plugins/log')->setData(
64
+ array(
65
+ 'action' => 'steerfoxproduct::publish',
66
+ 'type' => Steerfox_Plugins_Model_Log::STEERFOX_LOG_TYPE_WARNING,
67
+ 'message' => json_encode(
68
+ array(
69
+ 'entityIds' => json_encode($entityIds),
70
+ )
71
+ ),
72
+ )
73
+ );
74
+ } else {
75
+ try {
76
+ $productModel = Mage::getModel('steerfox_plugins/product');
77
+ $published = 0;
78
+ foreach ($entityIds as $entityId) {
79
+ $product = $productModel->load($entityId);
80
+
81
+ if (!$product->getData('active')) {
82
+ $published++;
83
+ $productModel->load($entityId)->setData('active', 1)->save();
84
+ $store = Mage::getModel('core/store')->load($product->getData('id_shop'));
85
+ $logs[] = Mage::getModel('steerfox_plugins/log')
86
+ ->setData(
87
+ array(
88
+ 'action' => 'steerfoxproduct::publish',
89
+ 'type' => Steerfox_Plugins_Model_Log::STEERFOX_LOG_TYPE_INFO,
90
+ 'shop' => $store->getWebsiteId() . '-' . $store->getGroup()->getName(),
91
+ 'message' => json_encode(
92
+ array(
93
+ 'entity_id' => $product->getData('entity_id'),
94
+ 'id_product' => $product->getData('id_product'),
95
+ 'id_lang' => $product->getData('id_lang'),
96
+ 'id_shop' => $product->getData('id_shop'),
97
+ )
98
+ ),
99
+ )
100
+ );
101
+ }
102
+ }
103
+ Mage::getSingleton('adminhtml/session')->addSuccess(
104
+ Mage::helper('steerfox_plugins')->__('%d product(s) published', $published)
105
+ );
106
+ } catch (Exception $e) {
107
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('steerfox_plugins')->__($e->getMessage()));
108
+ $logs[] = Mage::getModel('steerfox_plugins/log')->setData(
109
+ array(
110
+ 'action' => 'steerfoxproduct::publish',
111
+ 'type' => Steerfox_Plugins_Model_Log::STEERFOX_LOG_TYPE_ERROR,
112
+ 'message' => json_encode(
113
+ array(
114
+ 'exception' => $e->getMessage(),
115
+ )
116
+ ),
117
+ )
118
+ );
119
+ }
120
+ }
121
+
122
+ foreach ($logs as $log) {
123
+ $log->save();
124
+ }
125
+
126
+ $this->_redirect('*/*/index');
127
+ }
128
+
129
+ /**
130
+ * Publish in mass.
131
+ */
132
+ public function massUnpublishAction()
133
+ {
134
+ $entityIds = $this->getRequest()->getParam('entity_id');
135
+ $logs = array();
136
+ if (!is_array($entityIds)) {
137
+ Mage::getSingleton('adminhtml/session')->addError(
138
+ Mage::helper('steerfox_plugins')->__('Please select product(s)')
139
+ );
140
+ $logs[] = Mage::getModel('steerfox_plugins/log')->setData(
141
+ array(
142
+ 'action' => 'steerfoxproduct::unpublish',
143
+ 'type' => Steerfox_Plugins_Model_Log::STEERFOX_LOG_TYPE_WARNING,
144
+ 'message' => json_encode(
145
+ array(
146
+ 'entityIds' => json_encode($entityIds),
147
+ )
148
+ ),
149
+ )
150
+ );
151
+ } else {
152
+ try {
153
+ $productModel = Mage::getModel('steerfox_plugins/product');
154
+ $published = 0;
155
+ foreach ($entityIds as $entityId) {
156
+ $product = $productModel->load($entityId);
157
+ if ($product->getData('active')) {
158
+ $published++;
159
+ $productModel->load($entityId)->setData('active', 0)->save();
160
+ $store = Mage::getModel('core/store')->load($product->getData('id_shop'));
161
+ $logs[] = Mage::getModel('steerfox_plugins/log')
162
+ ->setData(
163
+ array(
164
+ 'action' => 'steerfoxproduct::publish',
165
+ 'type' => Steerfox_Plugins_Model_Log::STEERFOX_LOG_TYPE_INFO,
166
+ 'shop' => $store->getWebsiteId() . '-' . $store->getGroup()->getName(),
167
+ 'message' => json_encode(
168
+ array(
169
+ 'entity_id' => $product->getData('entity_id'),
170
+ 'id_product' => $product->getData('id_product'),
171
+ 'id_lang' => $product->getData('id_lang'),
172
+ 'id_shop' => $product->getData('id_shop'),
173
+ )
174
+ ),
175
+ )
176
+ )->setOrigData();
177
+ }
178
+
179
+ }
180
+ Mage::getSingleton('adminhtml/session')->addSuccess(
181
+ Mage::helper('steerfox_plugins')->__('%d product(s) unpublished', $published)
182
+ );
183
+ } catch (Exception $e) {
184
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
185
+ $logs[] = Mage::getModel('steerfox_plugins/log')->setData(
186
+ array(
187
+ 'action' => 'steerfoxproduct::publish',
188
+ 'type' => Steerfox_Plugins_Model_Log::STEERFOX_LOG_TYPE_ERROR,
189
+ 'message' => json_encode(
190
+ array(
191
+ 'exception' => $e->getMessage(),
192
+ )
193
+ ),
194
+ )
195
+ );
196
+ }
197
+ }
198
+
199
+ foreach ($logs as $log) {
200
+ $log->save();
201
+ }
202
+
203
+ $this->_redirect('*/*/index');
204
+ }
205
+
206
+ /**
207
+ * Init module.
208
+ *
209
+ * @return Steerfox_Plugins_Adminhtml_ProductController
210
+ */
211
+ protected function _initAction()
212
+ {
213
+ // Add the version notity if necessary
214
+ Mage::helper('steerfox_plugins')->notifyOldRelease();
215
+ $this->loadLayout()
216
+ ->_setActiveMenu('steerfox_product/manage')
217
+ ->_addBreadcrumb(
218
+ Mage::helper('steerfox_plugins')->__('Products'),
219
+ Mage::helper('steerfox_plugins')->__('Products')
220
+ )
221
+ ->_addBreadcrumb(
222
+ Mage::helper('steerfox_plugins')->__('Manage exported products'),
223
+ Mage::helper('steerfox_plugins')->__('Manage exported products')
224
+ );
225
+
226
+ return $this;
227
+ }
228
+
229
+ /**
230
+ * ACL
231
+ * @return mixed
232
+ */
233
+ protected function _isAllowed()
234
+ {
235
+ $actionName = $this->getRequest()->getActionName();
236
+ switch ($actionName) {
237
+ case 'index':
238
+ case 'edit':
239
+ case 'delete':
240
+ default:
241
+ $adminSession = Mage::getSingleton('admin/session');
242
+ $isAllowed = $adminSession->isAllowed('steerfox_product/manage');
243
+ break;
244
+ }
245
+
246
+ return $isAllowed;
247
+ }
248
+ }
app/code/community/Steerfox/Plugins/controllers/LogsController.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_LogsController
24
+ */
25
+ class Steerfox_Plugins_LogsController extends Mage_Core_Controller_Front_Action
26
+ {
27
+ /**
28
+ * Action affichant au froma JSON les logs.
29
+ */
30
+ public function getAction(){
31
+ $apiKey = $this->getRequest()->getParam('api_key', null);
32
+
33
+ if(null == $apiKey){
34
+ Mage::throwException('Missing parameter');
35
+ }
36
+
37
+ $configApiKey = Mage::getStoreConfig('steerfox_plugins/account/api_key');
38
+
39
+ if($configApiKey != $apiKey){
40
+ Mage::throwException('Invalid parameter');
41
+ }
42
+
43
+ $coreHelper = Mage::helper('steerfox_plugins/core_data');
44
+ $steerfoxContainer = $coreHelper->getSteerfoxContainer();
45
+ $logs = $steerfoxContainer->get('logger')->getAllLogs();
46
+
47
+ $this->getResponse()->clearHeaders()->setHeader('Content-type','application/json',true);
48
+ $this->getResponse()->setBody(json_encode($logs));
49
+ }
50
+ }
app/code/community/Steerfox/Plugins/controllers/ProductController.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Class Steerfox_Plugins_ProductController
24
+ */
25
+ class Steerfox_Plugins_ProductController extends Mage_Core_Controller_Front_Action
26
+ {
27
+
28
+ /**
29
+ * Action générant l'export steerfox les produits sélectionnés.
30
+ */
31
+ public function exportAction()
32
+ {
33
+ // we verify if the hash is correct
34
+ $params = $this->getRequest()->getParams();
35
+ $hash = Mage::getStoreConfig('steerfox_plugins/catalog/hash_ws');
36
+ if (
37
+ empty($hash)
38
+ || !array_key_exists('secure', $params)
39
+ || $hash !== $params['secure']
40
+ ) {
41
+ $this->returnError();
42
+ }
43
+
44
+ $shopId = $this->getRequest()->getParam('id_shop');
45
+ // TODO keep for future use of export by store
46
+ // if (0 !== $shopId && empty($shopId)) {
47
+ // $shopId = Mage::getStoreConfig('steerfox_plugins/catalog/main_store_view');
48
+ // }
49
+ // if (!in_array($shopId, Mage::app()->getWebsite()->getGroupIds())) {
50
+ // $this->returnError();
51
+ // }
52
+ // Fin TODO
53
+ $exportFormat = $this->getRequest()->getParam('format', 'gz');
54
+
55
+ $coreHelper = Mage::helper('steerfox_plugins/core_data');
56
+ $steerfoxContainer = $coreHelper->getSteerfoxContainer();
57
+ $steerfoxExport = $steerfoxContainer->get('export');
58
+
59
+ $shop = new Steerfox_Plugins_Model_Adapter_Shop(Mage::app()->getWebsite($shopId));
60
+
61
+ if ($this->getRequest()->getParam('file', false)) {
62
+ $steerfoxExport->saveProductExporter($shop, $exportFormat);
63
+ } else {
64
+ /** @var SteerfoxProductExporter $exporter */
65
+ $exporter = $steerfoxExport->getProductExporter($shop, $exportFormat);
66
+ $fileContent = $exporter->getContent();
67
+ $this->getResponse()
68
+ ->setHttpResponseCode(200)
69
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
70
+ ->setHeader('Pragma', 'public', true)
71
+ ->setHeader('Content-type', 'application/force-download')
72
+ ->setHeader('Content-Length', strlen($fileContent))
73
+ ->setHeader('Content-Disposition', 'attachment' . '; filename=' . $exporter->getFileName());
74
+ $this->getResponse()->clearBody();
75
+ $this->getResponse()->sendHeaders();
76
+ echo $fileContent;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Sends 404 header with no content.
82
+ */
83
+ private function returnError()
84
+ {
85
+ $this->getResponse()->setHttpResponseCode(404);
86
+ $this->getResponse()->clearBody();
87
+ $this->getResponse()->sendHeaders();
88
+ exit;
89
+ }
90
+ }
app/code/community/Steerfox/Plugins/data/steerfox_plugins_setup/data-install-0.1.0.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ $websiteList = Mage::app()->getWebsites();
23
+ $shopList = array();
24
+
25
+ foreach($websiteList as $website){
26
+
27
+ $productCollection = Mage::getModel("catalog/product")
28
+ ->getCollection()
29
+ ->addWebsiteFilter($website->getId())
30
+ ->addAttributeToFilter(
31
+ 'status',
32
+ array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
33
+ )
34
+ ->addAttributeToSelect("*");
35
+ foreach($productCollection as $product){
36
+ Mage::getModel('steerfox_plugins/product')
37
+ ->setData(
38
+ array(
39
+ 'id_product' => $product->getId(),
40
+ 'id_shop' => $website->getId(),
41
+ 'active' => 1,
42
+ )
43
+ )
44
+ ->setOrigData()
45
+ ->save();
46
+ }
47
+ }
48
+
49
+ // Set default values
50
+ Mage::getModel('core/config')->saveConfig('steerfox_plugins/account/status', 0);
51
+ Mage::getModel('core/config')->saveConfig('steerfox_plugins/account/feed_id', 0);
52
+ Mage::getModel('core/config')->saveConfig(
53
+ 'steerfox_plugins/catalog/export_lang', Mage::getStoreConfig('general/locale/code')
54
+ );
55
+ Mage::getModel('core/config')->saveConfig(
56
+ 'steerfox_plugins/catalog/export_currency', Mage::getStoreConfig('currency/options/default')
57
+ );
58
+
59
+ // Insert installation log
60
+ $store = Mage::app()->getStore();
61
+ $steerfox_helper = Mage::helper('steerfox_plugins');
62
+ $conf = array(
63
+ 'source' => $steerfox_helper->getSource(),
64
+ 'version' => Mage::getVersion(),
65
+ 'shop_url' => $store->getHomeUrl(),
66
+ 'php' => array(
67
+ 'version' => phpversion(),
68
+ 'memory_limit' => ini_get('memory_limit'),
69
+ 'max_execution_time' => ini_get('max_execution_time'),
70
+ ),
71
+ 'message' => 'Installation complete',
72
+ );
73
+ $log = Mage::getModel('steerfox_plugins/log');
74
+ $log->setData(
75
+ array(
76
+ 'action' => 'module::install',
77
+ 'type' => Steerfox_Plugins_Model_Log::STEERFOX_LOG_TYPE_INFO,
78
+ 'message' => json_encode($conf),
79
+ )
80
+ )->setOrigData()->save();
app/code/community/Steerfox/Plugins/data/steerfox_plugins_setup/data-upgrade-0.1.2-0.1.3.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2016 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2016 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ // Remove all inactive product from steerfox product collection
23
+
24
+ $websiteList = Mage::app()->getWebsites();
25
+ $shopList = array();
26
+
27
+ foreach ($websiteList as $website) {
28
+
29
+ $productCollection = Mage::getModel("catalog/product")
30
+ ->getCollection()
31
+ ->addWebsiteFilter($website->getId())
32
+ ->addAttributeToFilter(
33
+ 'status',
34
+ array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED)
35
+ )
36
+ ->addAttributeToSelect("*");
37
+
38
+ $productIdsToDelete = array();
39
+
40
+ foreach ($productCollection as $product) {
41
+ $productIdsToDelete[] = $product->getId();
42
+ }
43
+
44
+ if (!empty($productIdsToDelete)) {
45
+ $steerfoxProducts = Mage::getModel('steerfox_plugins/product')->getCollection()
46
+ ->addFieldToFilter('id_product', array('in' => $productIdsToDelete))
47
+ ->addFieldToFilter('id_shop', array('eq' => $website->getId()));
48
+ if (0 < $steerfoxProducts->count()) {
49
+ foreach ($steerfoxProducts as $steerfoxProduct) {
50
+ $steerfoxProduct->delete();
51
+ }
52
+ }
53
+ }
54
+ }
app/code/community/Steerfox/Plugins/data/steerfox_plugins_setup/data-upgrade-0.1.3-0.1.4.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2016 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2016 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+ // Update steerfox data for renew feed url infos
22
+ Mage::helper('steerfox_plugins/core_data')->apiUpdate();
app/code/community/Steerfox/Plugins/data/steerfox_plugins_setup/data-upgrade-0.1.4-1.0.5.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2016 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2016 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ // Generate hash for secure url
23
+ $uniqid = uniqid();
24
+ $hash = hash('adler32', $uniqid);
25
+
26
+ Mage::getModel('core/config')->saveConfig('steerfox_plugins/catalog/hash_ws', $hash);
27
+
28
+ $websiteList = Mage::app()->getWebsites();
29
+ foreach($websiteList as $website){
30
+ /* @var $website Mage_Core_Model_Website */
31
+ Mage::getModel('core/config')->saveConfig(
32
+ 'steerfox_plugins/catalog/main_store_view',
33
+ $website->getDefaultStore()->getId(),
34
+ 'website',
35
+ $website->getId()
36
+ );
37
+ }
38
+
39
+ // Update steerfox data for renew feed url infos
40
+ Mage::helper('steerfox_plugins/core_data')->apiUpdate();
app/code/community/Steerfox/Plugins/etc/adminhtml.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <steerfox_product translate="title" module="steerfox_plugins">
5
+ <title>Steerfox</title>
6
+ <sort_order>100</sort_order>
7
+ <children>
8
+ <manage translate="title" module="steerfox_plugins">
9
+ <title>Manage export Products</title>
10
+ <action>adminhtml/steerfoxproduct</action>
11
+ <sort_order>10</sort_order>
12
+ </manage>
13
+ </children>
14
+ </steerfox_product>
15
+ </menu>
16
+ <acl>
17
+ <resources>
18
+ <admin>
19
+ <children>
20
+ <steerfox_product translate="title" module="steerfox_plugins">
21
+ <title>Steerfox Plugins</title>
22
+ <sort_order>75</sort_order>
23
+ <children>
24
+ <manage translate="title" module="steerfox_plugins">
25
+ <title>Manage Products</title>
26
+ </manage>
27
+ </children>
28
+ </steerfox_product>
29
+ <system>
30
+ <children>
31
+ <config>
32
+ <children>
33
+ <steerfox_plugins>
34
+ <title>Steerfox Plugins</title>
35
+ </steerfox_plugins>
36
+ </children>
37
+ </config>
38
+ </children>
39
+ </system>
40
+ </children>
41
+ </admin>
42
+ </resources>
43
+ </acl>
44
+ </config>
app/code/community/Steerfox/Plugins/etc/config.xml ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Steerfox_Plugins>
5
+ <version>1.0.5</version>
6
+ </Steerfox_Plugins>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <steerfox_plugins>
11
+ <class>Steerfox_Plugins_Block</class>
12
+ </steerfox_plugins>
13
+ </blocks>
14
+ <helpers>
15
+ <steerfox_plugins>
16
+ <class>Steerfox_Plugins_Helper</class>
17
+ </steerfox_plugins>
18
+ <steerfox_core>
19
+ <class>Steerfox_Plugins_Helper</class>
20
+ </steerfox_core>
21
+ <steerfox_helper>
22
+ <class>Steerfox_Plugins_Helper</class>
23
+ </steerfox_helper>
24
+ </helpers>
25
+ <models>
26
+ <steerfox_plugins>
27
+ <class>Steerfox_Plugins_Model</class>
28
+ <resourceModel>steerfox_plugins_resource</resourceModel>
29
+ </steerfox_plugins>
30
+ <steerfox_plugins_resource>
31
+ <class>Steerfox_Plugins_Model_Resource</class>
32
+ <entities>
33
+ <product>
34
+ <table>steerfox_plugins_products</table>
35
+ </product>
36
+ <log>
37
+ <table>steerfox_plugins_logs</table>
38
+ </log>
39
+ </entities>
40
+ </steerfox_plugins_resource>
41
+ </models>
42
+ <resources>
43
+ <steerfox_plugins_setup>
44
+ <setup>
45
+ <module>Steerfox_Plugins</module>
46
+ <class>Mage_Core_Model_Resource_Setup</class>
47
+ </setup>
48
+ <connection>
49
+ <use>core_setup</use>
50
+ </connection>
51
+ </steerfox_plugins_setup>
52
+ </resources>
53
+ <events>
54
+ <catalog_product_save_after>
55
+ <observers>
56
+ <steerfox_plugins>
57
+ <type>singleton</type>
58
+ <class>steerfox_plugins/observer</class>
59
+ <method>afterCatalogProductSave</method>
60
+ </steerfox_plugins>
61
+ </observers>
62
+ </catalog_product_save_after>
63
+ <catalog_product_delete_after>
64
+ <observers>
65
+ <steerfox_plugins>
66
+ <type>singleton</type>
67
+ <class>steerfox_plugins/observer</class>
68
+ <method>afterCatalogProductDelete</method>
69
+ </steerfox_plugins>
70
+ </observers>
71
+ </catalog_product_delete_after>
72
+ <catalog_product_attribute_update_after>
73
+ <observers>
74
+ <steerfox_plugins>
75
+ <type>singleton</type>
76
+ <class>steerfox_plugins/observer</class>
77
+ <method>afterProductMassUpdate</method>
78
+ </steerfox_plugins>
79
+ </observers>
80
+ </catalog_product_attribute_update_after>
81
+ <catalog_product_website_update>
82
+ <observers>
83
+ <steerfox_plugins>
84
+ <type>singleton</type>
85
+ <class>steerfox_plugins/observer</class>
86
+ <method>afterProductMassUpdate</method>
87
+ </steerfox_plugins>
88
+ </observers>
89
+ </catalog_product_website_update>
90
+ <catalog_product_import_finish_before>
91
+ <observers>
92
+ <steerfox_plugins>
93
+ <type>singleton</type>
94
+ <class>steerfox_plugins/observer</class>
95
+ <method>afterCatalogProductImport</method>
96
+ </steerfox_plugins>
97
+ </observers>
98
+ </catalog_product_import_finish_before>
99
+ <checkout_cart_add_product_complete>
100
+ <observers>
101
+ <steerfox_add_to_cart>
102
+ <class>steerfox_plugins/observer</class>
103
+ <method>notifyAddToCart</method>
104
+ </steerfox_add_to_cart>
105
+ </observers>
106
+ </checkout_cart_add_product_complete>
107
+ <checkout_onepage_controller_success_action>
108
+ <observers>
109
+ <steerfox_order_success>
110
+ <class>steerfox_plugins/observer</class>
111
+ <method>setTagsOnOrderSuccessPageView</method>
112
+ </steerfox_order_success>
113
+ </observers>
114
+ </checkout_onepage_controller_success_action>
115
+ <checkout_multishipping_controller_success_action>
116
+ <observers>
117
+ <steerfox_order_success>
118
+ <class>steerfox_plugins/observer</class>
119
+ <method>setTagsOnOrderSuccessPageView</method>
120
+ </steerfox_order_success>
121
+ </observers>
122
+ </checkout_multishipping_controller_success_action>
123
+ <admin_system_config_changed_section_steerfox_plugins>
124
+ <observers>
125
+ <modulename>
126
+ <type>singleton</type>
127
+ <class>steerfox_plugins/observer</class>
128
+ <method>sectionUpdate</method>
129
+ </modulename>
130
+ </observers>
131
+ </admin_system_config_changed_section_steerfox_plugins>
132
+ <admin_session_user_login_success>
133
+ <observers>
134
+ <modulename>
135
+ <type>singleton</type>
136
+ <class>steerfox_plugins/observer</class>
137
+ <method>checkPluginVersion</method>
138
+ </modulename>
139
+ </observers>
140
+ </admin_session_user_login_success>
141
+ <website_delete_after>
142
+ <observers>
143
+ <modulename>
144
+ <type>singleton</type>
145
+ <class>steerfox_plugins/observer</class>
146
+ <method>websiteRemove</method>
147
+ </modulename>
148
+ </observers>
149
+ </website_delete_after>
150
+ </events>
151
+ </global>
152
+ <admin>
153
+ <routers>
154
+ <adminhtml>
155
+ <args>
156
+ <modules>
157
+ <Steerfox_Plugins before="Mage_Adminhtml">Steerfox_Plugins_Adminhtml</Steerfox_Plugins>
158
+ </modules>
159
+ </args>
160
+ </adminhtml>
161
+ </routers>
162
+ </admin>
163
+ <frontend>
164
+ <layout>
165
+ <updates>
166
+ <steerfox_plugins>
167
+ <file>steerfox_plugins.xml</file>
168
+ </steerfox_plugins>
169
+ </updates>
170
+ </layout>
171
+ <routers>
172
+ <steerfox>
173
+ <use>standard</use>
174
+ <args>
175
+ <module>Steerfox_Plugins</module>
176
+ <frontName>steerfox</frontName>
177
+ </args>
178
+ </steerfox>
179
+ </routers>
180
+ <translate>
181
+ <modules>
182
+ <steerfox_plugins>
183
+ <files>
184
+ <default>Steerfox_Plugins.csv</default>
185
+ </files>
186
+ </steerfox_plugins>
187
+ </modules>
188
+ </translate>
189
+ </frontend>
190
+ <adminhtml>
191
+ <layout>
192
+ <updates>
193
+ <steerfox_plugins>
194
+ <file>steerfox_plugins.xml</file>
195
+ </steerfox_plugins>
196
+ </updates>
197
+ </layout>
198
+ <translate>
199
+ <modules>
200
+ <steerfox_plugins>
201
+ <files>
202
+ <default>Steerfox_Plugins.csv</default>
203
+ </files>
204
+ </steerfox_plugins>
205
+ </modules>
206
+ </translate>
207
+ </adminhtml>
208
+ <default>
209
+ <steerfox_plugins>
210
+ <export>
211
+ <folder_name>steerfox_export</folder_name>
212
+ </export>
213
+ <catalog>
214
+ <export_margin>1</export_margin>
215
+ <use_sku_for_mpn>1</use_sku_for_mpn>
216
+ </catalog>
217
+ <tags>
218
+ <shipping>1</shipping>
219
+ </tags>
220
+ <latest_release_info>http://plugins.steerfox.com/magento_info.json</latest_release_info>
221
+ </steerfox_plugins>
222
+ </default>
223
+ </config>
app/code/community/Steerfox/Plugins/etc/steerfox.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!--
3
+ ~ Copyright 2015 SteerFox SAS.
4
+ ~
5
+ ~ Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ ~ not use this file except in compliance with the License. You may obtain
7
+ ~ a copy of the License at
8
+ ~
9
+ ~ http://www.apache.org/licenses/LICENSE-2.0
10
+ ~
11
+ ~ Unless required by applicable law or agreed to in writing, software
12
+ ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ ~ License for the specific language governing permissions and limitations
15
+ ~ under the License.
16
+ ~
17
+ ~ @author SteerFox <tech@steerfox.com>
18
+ ~ @copyright 2015 SteerFox SAS
19
+ ~ @license http://www.apache.org/licenses/LICENSE-2.0
20
+ -->
21
+
22
+ <container>
23
+ <parameters>
24
+ <!--Adapters-->
25
+ <parameter id="configuration_class">Steerfox_Plugins_Model_Adapter_Configuration</parameter>
26
+ <parameter id="shop_service_class">Steerfox_Plugins_Model_Adapter_Service_Shop</parameter>
27
+ <parameter id="log_service_class">Steerfox_Plugins_Model_Adapter_Service_Log</parameter>
28
+ <parameter id="shop_class">Steerfox_Plugins_Model_Adapter_Shop</parameter>
29
+ <parameter id="tools_service_class">Steerfox_Plugins_Model_Adapter_Tools</parameter>
30
+
31
+ <!--Core Steerfox-->
32
+ <parameter id="api_service_class">SteerfoxApiService</parameter>
33
+ <parameter id="export_service_class">SteerfoxExportService</parameter>
34
+ </parameters>
35
+ <services>
36
+ <service id="config" class="SteerfoxConfigurationService">
37
+ <argument>%configuration_class%</argument>
38
+ </service>
39
+ <service id="logger" class="%log_service_class%">
40
+ </service>
41
+ <service id="api" class="%api_service_class%">
42
+ </service>
43
+ <service id="export" class="%export_service_class%">
44
+ </service>
45
+ <service id="shop" class="%shop_service_class%">
46
+ <argument>%shop_class%</argument>
47
+ </service>
48
+ <service id="tools" class="%tools_service_class%" />
49
+ </services>
50
+ </container>
app/code/community/Steerfox/Plugins/etc/system.xml ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <steerfox_plugins translate="label" module="steerfox_plugins">
5
+ <label>Steerfox</label>
6
+ <sort_order>1</sort_order>
7
+ </steerfox_plugins>
8
+ </tabs>
9
+ <sections>
10
+ <steerfox_plugins translate="label" module="steerfox_plugins">
11
+ <label>Settings</label>
12
+ <tab>steerfox_plugins</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>0</show_in_store>
18
+ <groups>
19
+ <welcolme translate="label" module="steerfox_plugins">
20
+ <label>Account settings</label>
21
+ <frontend_model>steerfox_plugins/adminhtml_system_config_form_fieldset_steerfoxform</frontend_model>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>0</show_in_website>
25
+ <show_in_store>0</show_in_store>
26
+ </welcolme>
27
+ <account translate="label" module="steerfox_plugins">
28
+ <label>Account settings</label>
29
+ <sort_order>1</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>0</show_in_store>
33
+ <fields>
34
+ <api_key>
35
+ <backend_model>steerfox_plugins/apikey</backend_model>
36
+ <label>API key</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>1</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>0</show_in_website>
41
+ <show_in_store>0</show_in_store>
42
+ <comment>Enter your API key if you already have a SteerFox account</comment>
43
+ </api_key>
44
+ </fields>
45
+ </account>
46
+ <catalog translate="label" module="steerfox_plugins">
47
+ <label>Catalog settings</label>
48
+ <sort_order>2</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>0</show_in_store>
52
+ <fields>
53
+ <export_lang>
54
+ <label>Language</label>
55
+ <frontend_type>select</frontend_type>
56
+ <source_model>steerfox_plugins/languages</source_model>
57
+ <sort_order>1</sort_order>
58
+ <show_in_default>0</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>0</show_in_store>
61
+ <comment>Choose language of your catalog</comment>
62
+ </export_lang>
63
+ <export_currency>
64
+ <label>Currency</label>
65
+ <frontend_type>select</frontend_type>
66
+ <source_model>steerfox_plugins/currencies</source_model>
67
+ <sort_order>2</sort_order>
68
+ <show_in_default>0</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>0</show_in_store>
71
+ <comment>Choose currency of products in your catalog</comment>
72
+ </export_currency>
73
+ <export_margin>
74
+ <label>Display margin in export</label>
75
+ <frontend_type>select</frontend_type>
76
+ <source_model>adminhtml/system_config_source_yesno</source_model>
77
+ <sort_order>3</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>0</show_in_website>
80
+ <show_in_store>0</show_in_store>
81
+ <comment>Choose to export the margin on your products in Steerfox products' flow</comment>
82
+ </export_margin>
83
+ <use_sku_for_mpn>
84
+ <label>Use SKU for MPN</label>
85
+ <frontend_type>select</frontend_type>
86
+ <source_model>adminhtml/system_config_source_yesno</source_model>
87
+ <sort_order>4</sort_order>
88
+ <show_in_default>0</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ <comment>Choose to use the SKU value to fill MPN</comment>
92
+ </use_sku_for_mpn>
93
+ <mpn_attribute_code>
94
+ <label>MPN attribute code</label>
95
+ <frontend_type>text</frontend_type>
96
+ <sort_order>5</sort_order>
97
+ <show_in_default>0</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>0</show_in_store>
100
+ <comment>The attribute code to use to fill MPN. (used only if SKU for MPN is false)</comment>
101
+ </mpn_attribute_code>
102
+ <!-- TODO : For future use of export by store -->
103
+ <!--<main_store_view>-->
104
+ <!--<label>Store used</label>-->
105
+ <!--<frontend_type>select</frontend_type>-->
106
+ <!--<source_model>steerfox_plugins/system_config_source_group</source_model>-->
107
+ <!--<sort_order>10</sort_order>-->
108
+ <!--<show_in_default>0</show_in_default>-->
109
+ <!--<show_in_website>1</show_in_website>-->
110
+ <!--<show_in_store>0</show_in_store>-->
111
+ <!--<comment>Store used to represent the website for export</comment>-->
112
+ <!--</main_store_view>-->
113
+ <!-- FIN TODO -->
114
+ <shop_id>
115
+ <label>Shop ID</label>
116
+ <frontend_type>text</frontend_type>
117
+ <sort_order>50</sort_order>
118
+ <show_in_default>0</show_in_default>
119
+ <show_in_website>0</show_in_website>
120
+ <show_in_store>0</show_in_store>
121
+ <comment>Shop APi ID</comment>
122
+ </shop_id>
123
+ </fields>
124
+ </catalog>
125
+ <tags translate="label" module="steerfox_plugins">
126
+ <label>Conversion tracking settings</label>
127
+ <sort_order>3</sort_order>
128
+ <show_in_default>0</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>0</show_in_store>
131
+ <fields>
132
+ <gtm_id>
133
+ <label>Google Tag Manager ID</label>
134
+ <frontend_type>text</frontend_type>
135
+ <sort_order>1</sort_order>
136
+ <show_in_default>0</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>0</show_in_store>
139
+ <comment>Enter the ID of your Google Tag Manager container ID if you wish to install it automatically</comment>
140
+ </gtm_id>
141
+ <adwords_id>
142
+ <label>Google Adwords ID</label>
143
+ <frontend_type>text</frontend_type>
144
+ <sort_order>2</sort_order>
145
+ <show_in_default>0</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>0</show_in_store>
148
+ </adwords_id>
149
+ <adwords_label>
150
+ <label>Google Adwords Label</label>
151
+ <frontend_type>text</frontend_type>
152
+ <sort_order>3</sort_order>
153
+ <show_in_default>0</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ <comment>Enter the google_conversion_id and google_conversion_label of your Google Adwords conversion tracking tag if you wish to install it automatically</comment>
157
+ </adwords_label>
158
+ <bing_id>
159
+ <label>Bing ID</label>
160
+ <frontend_type>text</frontend_type>
161
+ <sort_order>4</sort_order>
162
+ <show_in_default>0</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>0</show_in_store>
165
+ <comment>Enter the ID of your Bing UET tracking tag if you wish to install it automatically</comment>
166
+ </bing_id>
167
+ <facebook_id>
168
+ <label>Facebook ID</label>
169
+ <frontend_type>text</frontend_type>
170
+ <sort_order>5</sort_order>
171
+ <show_in_default>0</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>0</show_in_store>
174
+ <comment>Enter the ID of your Facebook tracking pixel if you wish to install it automatically</comment>
175
+ </facebook_id>
176
+ <!-- TODO retrait du foxtag de la version -->
177
+ <!--<foxtag_id>-->
178
+ <!--<label>Foxtag ID</label>-->
179
+ <!--<frontend_type>text</frontend_type>-->
180
+ <!--<sort_order>6</sort_order>-->
181
+ <!--<show_in_default>0</show_in_default>-->
182
+ <!--<show_in_website>1</show_in_website>-->
183
+ <!--<show_in_store>0</show_in_store>-->
184
+ <!--<comment>Enter the ID of your Foxtag account if you wish to install it automatically</comment>-->
185
+ <!--</foxtag_id>-->
186
+ <!-- END TODO -->
187
+ <shipping>
188
+ <label>Include shipping in conversion</label>
189
+ <comment>Include shipping price in conversion value.</comment>
190
+ <frontend_type>select</frontend_type>
191
+ <source_model>adminhtml/system_config_source_yesno</source_model>
192
+ <sort_order>7</sort_order>
193
+ <show_in_default>0</show_in_default>
194
+ <show_in_website>1</show_in_website>
195
+ <show_in_store>0</show_in_store>
196
+ </shipping>
197
+ </fields>
198
+ </tags>
199
+ <google translate="label" module="steerfox_plugins">
200
+ <label>Google site verification</label>
201
+ <sort_order>4</sort_order>
202
+ <show_in_default>0</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>0</show_in_store>
205
+ <fields>
206
+ <google_site_verification>
207
+ <label>Google site verification</label>
208
+ <frontend_type>text</frontend_type>
209
+ <sort_order>1</sort_order>
210
+ <show_in_default>0</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>0</show_in_store>
213
+ <comment>Enter the Google site verification if you want to link your account and website</comment>
214
+ </google_site_verification>
215
+ </fields>
216
+ </google>
217
+ </groups>
218
+ </steerfox_plugins>
219
+ </sections>
220
+ </config>
app/code/community/Steerfox/Plugins/etc/widget.xml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?xml version="1.0"?>
2
+ <widgets />
app/code/community/Steerfox/Plugins/lib/Api/Connectors/SteerfoxAbstractConnector.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Abstract api connection class
24
+ */
25
+ abstract class SteerfoxAbstractConnector
26
+ {
27
+ /**
28
+ * Execute GET request.
29
+ *
30
+ * @param string $url URL.
31
+ * @param string $action Action.
32
+ *
33
+ * @return mixed
34
+ */
35
+ public function get($url, $action = '')
36
+ {
37
+ return $this->query($url, 'GET', array(), $action);
38
+ }
39
+
40
+ /**
41
+ * Execute POST request.
42
+ *
43
+ * @param string $url URL.
44
+ * @param array $bodyParameters Request body parameters.
45
+ * @param string $action Action.
46
+ *
47
+ * @return mixed
48
+ */
49
+ public function post($url, $bodyParameters = array(), $action = '')
50
+ {
51
+ return $this->query($url, 'POST', $bodyParameters, $action);
52
+ }
53
+
54
+ /**
55
+ * Execute PUT request.
56
+ *
57
+ * @param string $url URL
58
+ * @param array $bodyParameters Request body parameters.
59
+ * @param string $action Action.
60
+ *
61
+ * @return mixed
62
+ */
63
+ public function put($url, $bodyParameters = array(), $action = '')
64
+ {
65
+ return $this->query($url, 'PUT', $bodyParameters, $action);
66
+ }
67
+
68
+ /**
69
+ * Execute HTTP request.
70
+ *
71
+ * @param string $url URL.
72
+ * @param string $method HTTP Method.
73
+ * @param array $bodyParameters Request body parameters.
74
+ * @param string $action Action.
75
+ *
76
+ * @return mixed
77
+ */
78
+ abstract protected function query($url, $method, $bodyParameters = array(), $action = '');
79
+
80
+ /**
81
+ * Handle return HTTP code.
82
+ *
83
+ * @param string $code HTTP Code
84
+ * @param string $action Action
85
+ * @param string $return Return infos.
86
+ *
87
+ * @throws SteerfoxConnectorException
88
+ * @throws SteerfoxException
89
+ */
90
+ protected function handleErrors($code, $action, $return, $bodyParameters = null)
91
+ {
92
+ $container = SteerfoxContainer::getInstance();
93
+ /** @var SteerfoxToolsAdapterInterface $tools */
94
+ $tools = $container->get('tools');
95
+ // If not 20x status -> error
96
+ if ($tools->substr($code, 0, 2) != 20) {
97
+ switch ($code) {
98
+ case 400:
99
+ $message = '';
100
+ // Case of email already use
101
+ if (array_key_exists('errors', $return)) {
102
+ $message = $tools->jsonEncode($return['errors']);
103
+ if (
104
+ array_key_exists('children', $return['errors'])
105
+ && array_key_exists('email', $return['errors']['children'])
106
+ && array_key_exists('errors', $return['errors']['children']['email'])
107
+ && array_key_exists(0,$return['errors']['children']['email']['errors'])
108
+ ) {
109
+ if ('Email already taken' == $return['errors']['children']['email']['errors'][0]) {
110
+ $locale = 'en';
111
+ if (null != $bodyParameters && array_key_exists('locale', $bodyParameters)) {
112
+ $locale = $bodyParameters['locale'];
113
+ }
114
+
115
+ if ('fr' == $tools->substr($locale, 0, 2)) {
116
+ $message = ' - Un ancien compte existe déjà pour votre boutique. Veuillez cliquer sur "Parametères avancés" et rentrez votre clé API. Si vous ne la connaissez pas, veuillez contacter votre conseiller SteerFox.';
117
+ } else {
118
+ $message = ' - An older account already exist for your shop. Please click "Advanced settings" and enter your api key. If you do not know it, please contact your Steerfox account manager.';
119
+ }
120
+ }
121
+
122
+ }
123
+ }
124
+
125
+ throw new SteerfoxConnectorException(
126
+ "HTTP 400 : Error in parameters".$message,
127
+ $action,
128
+ $return,
129
+ 2
130
+ );
131
+ case
132
+ 401:
133
+ throw new SteerfoxConnectorException(
134
+ "HTTP 401 : Authentication error".(isset($return['errors']) ? ' - '.$return['errors'] : ''),
135
+ $action,
136
+ $return,
137
+ 3
138
+ );
139
+ case 403:
140
+ throw new SteerfoxConnectorException("HTTP 403 : Access right error", $action, $return, 4);
141
+ case 404:
142
+ throw new SteerfoxConnectorException("HTTP 404 : Route not found", $action, $return, 5);
143
+ case 405:
144
+ throw new SteerfoxConnectorException(
145
+ "HTTP 405 : Method not allowed".(isset($return['errors']) ? ' - '.$return['errors'] : ''),
146
+ $action,
147
+ $return,
148
+ 6
149
+ );
150
+ case 429:
151
+ throw new SteerfoxConnectorException("HTTP 429 : Too many requests", $action, $return, 9);
152
+ default:
153
+ throw new SteerfoxConnectorException(
154
+ "HTTP $code : To implement return",
155
+ $action,
156
+ $return,
157
+ 7
158
+ );
159
+ }
160
+ }
161
+ if (isset($return['errors']) && !empty($return['errors'])) {
162
+ throw new SteerfoxConnectorException((string)$return['message'], $action, $return);
163
+ }
164
+ }
165
+
166
+ protected
167
+ function logCall(
168
+ $params,
169
+ $url,
170
+ $return
171
+ ) {
172
+ /** @var SteerfoxContainer $container */
173
+ $container = SteerfoxContainer::getInstance();
174
+ /** @var SteerfoxToolsAdapterInterface $tools */
175
+ $tools = $container->get('tools');
176
+ /** @var SteerfoxAbstractLoggerService $logger */
177
+ $logger = $container->get('logger');
178
+ $logger->addLog(
179
+ $tools->jsonEncode(
180
+ array(
181
+ 'call_parameters' => $params,
182
+ 'url' => $url,
183
+ 'api_return' => $return,
184
+ )
185
+ ),
186
+ 'api:call',
187
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_INFO
188
+ );
189
+ }
190
+ }
app/code/community/Steerfox/Plugins/lib/Api/Connectors/SteerfoxCurlConnector.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * CURL Api connector
24
+ */
25
+ class SteerfoxCurlConnector extends SteerfoxAbstractConnector
26
+ {
27
+ /**
28
+ * @inheritdoc
29
+ */
30
+ protected function query($url, $method, $bodyParameters = array(), $action = '')
31
+ {
32
+ $container = SteerfoxContainer::getInstance();
33
+ /** @var SteerfoxToolsAdapterInterface $tools */
34
+ $tools = $container->get('tools');
35
+
36
+ // Create curl resource
37
+ $ch = curl_init();
38
+ $datas = $tools->jsonEncode($bodyParameters);
39
+
40
+ // Setups
41
+ curl_setopt($ch, CURLOPT_URL, $url); // URL
42
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
43
+ curl_setopt(
44
+ $ch,
45
+ CURLOPT_HTTPHEADER,
46
+ array(
47
+ 'Content-Type: application/json',
48
+ 'Content-Length: '.$tools->strlen($datas),
49
+ )
50
+ );
51
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $datas); // Post datas
52
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Return
53
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
54
+ curl_setopt($ch, CURLOPT_TIMEOUT, 30);
55
+
56
+ // Execute
57
+ $return = curl_exec($ch);
58
+ $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
59
+
60
+ // Close curl resource
61
+ curl_close($ch);
62
+
63
+ // Format return
64
+ $return = $tools->jsonDecode($return, true);
65
+
66
+ $this->logCall($bodyParameters, $url, $return);
67
+
68
+ $this->handleErrors($http_code, $action, $return, $bodyParameters);
69
+
70
+ return $return;
71
+ }
72
+ }
app/code/community/Steerfox/Plugins/lib/Api/Connectors/SteerfoxFopenConnector.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * FOPEN Api connector
24
+ */
25
+ class SteerfoxFopenConnector extends SteerfoxAbstractConnector
26
+ {
27
+ /**
28
+ * @inheritdoc
29
+ */
30
+ protected function query($url, $method, $bodyParameters = array(), $action = '')
31
+ {
32
+ $container = SteerfoxContainer::getInstance();
33
+ /** @var SteerfoxToolsAdapterInterface $tools */
34
+ $tools = $container->get('tools');
35
+ $datas = $tools->jsonEncode($bodyParameters);
36
+ // Format header
37
+ $header = array(
38
+ 'http' =>
39
+ array(
40
+ 'method' => $method,
41
+ 'header' => "Content-Type: application/json\r\n".
42
+ "Content-Length: ".$tools->strlen($datas)."\r\n".
43
+ "Connection: close\r\n",
44
+ 'content' => $datas, // Datas
45
+ 'timeout' => 5,
46
+ 'ignore_errors' => true, // Ignore HTTP error codes
47
+ ),
48
+ );
49
+ $context = stream_context_create($header);
50
+
51
+ // Execute
52
+ $return = $tools->fileGetContents($url, false, $context);
53
+ $responseCode = $this->getHttpResponseCode($http_response_header);
54
+
55
+ // Format return
56
+ $return = $tools->jsonDecode($return, true);
57
+
58
+ // HTTP code Errors management
59
+ $this->handleErrors($responseCode, $action, $return, $bodyParameters);
60
+ }
61
+
62
+ /**
63
+ * Determine HTTP response code.
64
+ *
65
+ * @param array $httpResponseHeader HTTP response headers
66
+ *
67
+ * @return mixed
68
+ */
69
+ private function getHttpResponseCode($httpResponseHeader)
70
+ {
71
+ $head = array();
72
+ foreach ($httpResponseHeader as $header) {
73
+ $t = explode(':', $header, 2);
74
+ if (isset($t[1])) {
75
+ $head[trim($t[0])] = trim($t[1]);
76
+ } else {
77
+ $head[] = $header;
78
+ if (preg_match('#HTTP/[0-9\.]+\s+([0-9]+)#', $header, $out)) {
79
+ $head['reponse_code'] = (int)$out[1];
80
+ }
81
+ }
82
+ }
83
+
84
+ return $head['reponse_code'];
85
+ }
86
+ }
app/code/community/Steerfox/Plugins/lib/Api/SteerfoxApiService.php ADDED
@@ -0,0 +1,618 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+
23
+ /**
24
+ * Connect to steerfox API
25
+ */
26
+ class SteerfoxApiService
27
+ {
28
+ /**
29
+ * Le connecteur (CURL ou FOPEN)
30
+ *
31
+ * @var SteerfoxAbstractConnector
32
+ */
33
+ protected $connector;
34
+
35
+ /**
36
+ * Api version.
37
+ *
38
+ * @var string
39
+ */
40
+ protected $apiVersion = '1.0';
41
+
42
+ /**
43
+ * Base url.
44
+ *
45
+ * @var string
46
+ */
47
+ protected $baseUrl;
48
+
49
+ protected $requestParameters
50
+ = array(
51
+ 'account' => array(
52
+ 'cPOST' => array(
53
+ 'source' => array('required' => true),
54
+ 'name' => array('required' => true),
55
+ 'locale' => array('required' => false, 'default' => 'en_GB'),
56
+ 'email' => array('required' => true),
57
+ ),
58
+ ),
59
+ 'shop' => array(
60
+ 'cPOST' => array(
61
+ 'name' => array('required' => true),
62
+ 'url' => array('required' => true),
63
+ 'logo' => array('required' => true),
64
+ 'email' => array('required' => true),
65
+ 'locale' => array('required' => false, 'default' => 'en_GB'),
66
+ 'currency' => array('required' => false, 'default' => 'EUR'),
67
+ ),
68
+ 'iPUT' => array(
69
+ 'name' => array('required' => true),
70
+ 'url' => array('required' => true),
71
+ 'logo' => array('required' => true),
72
+ 'email' => array('required' => true),
73
+ 'locale' => array('required' => false, 'default' => 'en_GB'),
74
+ 'currency' => array('required' => false, 'default' => 'EUR'),
75
+ ),
76
+ ),
77
+ 'feed' => array(
78
+ 'cPOST' => array(
79
+ 'url' => array('required' => true),
80
+ 'locale' => array('required' => false, 'default' => 'en_GB'),
81
+ 'currency' => array('required' => false, 'default' => 'EUR'),
82
+ 'active' => array('required' => false, 'default' => 'true'),
83
+ 'shop_id' => array('required' => true),
84
+ ),
85
+ 'iPUT' => array(
86
+ 'url' => array('required' => true),
87
+ 'locale' => array('required' => false, 'default' => 'en_GB'),
88
+ 'currency' => array('required' => false, 'default' => 'EUR'),
89
+ 'active' => array('required' => false, 'default' => 'true'),
90
+ 'shop_id' => array('required' => true),
91
+ ),
92
+ 'cGet' => array(
93
+ 'shop_id' => array('required' => false),
94
+ ),
95
+ ),
96
+ );
97
+
98
+ /**
99
+ * SteerfoxApiConnector constructor.
100
+ */
101
+ public function __construct()
102
+ {
103
+ $this->setMethod();
104
+ $this->setBaseUrl();
105
+ }
106
+
107
+ /**
108
+ * Création d'un compte d'essai.
109
+ *
110
+ * @throws SteerfoxConnectorException
111
+ */
112
+ public function createAccount()
113
+ {
114
+ $container = SteerfoxContainer::getInstance();
115
+ /** @var SteerfoxConfigurationInterface $config */
116
+ $config = $container->get('config');
117
+ /** @var SteerfoxAbstractShopService $shopService */
118
+ $shopService = $container->get('shop');
119
+ /** @var SteerfoxAbstractLoggerService $logger */
120
+ $logger = $container->get('logger');
121
+ /** @var SteerfoxToolsAdapterInterface $tool */
122
+ $tool = $container->get('tools');
123
+ try {
124
+ /** @var SteerfoxShopAdapterInterface $mainShop */
125
+ $mainShop = $shopService->getMainShop();
126
+ $url = $this->getUrl('/account');
127
+ $params = array(
128
+ 'source' => $config->getCmsId(),
129
+ 'name' => $mainShop->getName(),
130
+ 'locale' => $mainShop->getLocale(),
131
+ 'email' => $config->getEmail(),
132
+
133
+ );
134
+ $requestBody = $this->setRequestBody($this->requestParameters['account']['cPOST'], $params);
135
+ $response = $this->connector->post($url, $requestBody, 'createAccount');
136
+ $config->setGlobal('STEERFOX_ACCOUNT_API_KEY', $response['api_key']);
137
+ $config->setGlobal('STEERFOX_ACCOUNT_STATUS', true);
138
+ $confirmUrl = $response['confirm_url'];
139
+ $shops = $shopService->getShops();
140
+
141
+ /** @var SteerfoxShopAdapterInterface $shop */
142
+ foreach ($shops as $shop) {
143
+ $shopResponse = $this->createShop($response['api_key'], $shop);
144
+ $this->createFeed($response['api_key'], $shopResponse['id'], $shop);
145
+ }
146
+
147
+ $logger->addLog(
148
+ $tool->jsonEncode('Success'),
149
+ 'createAccount',
150
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_INFO
151
+ );
152
+
153
+ return $confirmUrl;
154
+ } catch (SteerfoxException $ste) {
155
+ $logger->addLog(
156
+ addslashes($tool->jsonEncode($ste->getMessage())),
157
+ 'createAccount',
158
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_ERROR
159
+ );
160
+ throw new Exception($ste->getMessage());
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Check if the current API KEY is good and get the stores API info.
166
+ *
167
+ * @return bool TRUE if account is found
168
+ */
169
+ public function retrieveAccount()
170
+ {
171
+ $container = SteerfoxContainer::getInstance();
172
+ /** @var SteerfoxConfigurationInterface $config */
173
+ $config = $container->get('config');
174
+ /** @var SteerfoxAbstractShopService $shopService */
175
+ $shopService = $container->get('shop');
176
+ /** @var SteerfoxAbstractLoggerService $logger */
177
+ $logger = $container->get('logger');
178
+ /** @var SteerfoxToolsAdapterInterface $tool */
179
+ $tool = $container->get('tools');
180
+ try {
181
+ $apiKey = $config->get('STEERFOX_ACCOUNT_API_KEY');
182
+ $accountStatus = $config->get('STEERFOX_ACCOUNT_STATUS');
183
+
184
+ if (empty($apiKey) || 1 == $accountStatus) {
185
+ // if empty apiKey or already enable account, stop treatment
186
+ return false;
187
+ }
188
+
189
+ $retrieveUrl = $this->getUrl('/shops?api_key='.$apiKey);
190
+ $localShopList = $shopService->getShops();
191
+ $accountShopList = $this->connector->get($retrieveUrl, 'getShopList');
192
+ $config->set('STEERFOX_ACCOUNT_STATUS', 1);
193
+
194
+ foreach ($accountShopList as $shop) {
195
+
196
+ /** @var SteerfoxShopAdapterInterface $localShop */
197
+ foreach ($localShopList as $localShop) {
198
+ if ($localShop->getUrl() == $shop['url']) {
199
+ // Shop exist, define conf.
200
+ $config->set('STEERFOX_EXPORT_LANG', $localShop->getLanguage(), $localShop->getId());
201
+ $config->set('STEERFOX_EXPORT_CURRENCY', $shop['currency'], $localShop->getId());
202
+ $config->set('STEERFOX_SHOP_ID', $shop['id'], $localShop->getId());
203
+
204
+ //retrieve feed
205
+ $retrieveFeedUrl = $this->getUrl('/feeds?api_key='.$apiKey.'&shop_id='.$shop['id']);
206
+ $feedResponse = $this->connector->get($retrieveFeedUrl, 'getFeedList');
207
+
208
+ if (0 < count($feedResponse)) {
209
+ $config->set('STEERFOX_FEED_ID', $feedResponse[0]['id'], $localShop->getId());
210
+ }
211
+
212
+ }
213
+ }
214
+ }
215
+
216
+ $logger->addLog(
217
+ $tool->jsonEncode('Success'),
218
+ 'retrieveAccount',
219
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_INFO
220
+ );
221
+ $success = true;
222
+ } catch (Exception $ste) {
223
+ // Disable Account
224
+ $config->set('STEERFOX_ACCOUNT_STATUS', 0);
225
+ $logger->addLog(
226
+ $tool->jsonEncode($ste->getMessage()),
227
+ 'retrieveAccount',
228
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_ERROR
229
+ );
230
+ $success = false;
231
+ }
232
+
233
+ return $success;
234
+ }
235
+
236
+ /**
237
+ * Update API information's with CMS datas
238
+ *
239
+ * @return bool TRUE if account is updated
240
+ */
241
+ public function updateAccount()
242
+ {
243
+ $container = SteerfoxContainer::getInstance();
244
+ /** @var SteerfoxConfigurationService $config */
245
+ $config = $container->get('config');
246
+ /** @var SteerfoxAbstractShopService $shopService */
247
+ $shopService = $container->get('shop');
248
+ /** @var SteerfoxAbstractLoggerService $logger */
249
+ $logger = $container->get('logger');
250
+ /** @var SteerfoxToolsAdapterInterface $tool */
251
+ $tool = $container->get('tools');
252
+ try {
253
+ $apiKey = $config->getGlobal('STEERFOX_ACCOUNT_API_KEY');
254
+
255
+ if (empty($apiKey)) {
256
+ // if empty apiKey, stop treatment
257
+ return false;
258
+ }
259
+
260
+ $localShopList = $shopService->getShops();
261
+ $oneUpdate = false;
262
+
263
+ /** @var SteerfoxShopAdapterInterface $localShop */
264
+ foreach ($localShopList as $localShop) {
265
+
266
+ $shopIdApi = $config->get('STEERFOX_SHOP_ID', $localShop->getId());
267
+
268
+ if (empty($shopIdApi)) {
269
+ // Shop ID not find in configuration
270
+ $retrieveShop = false;
271
+ try {
272
+ //Create new shop
273
+ $responseShop = $this->createShop($apiKey, $localShop);
274
+ $shopIdApi = $responseShop['id'];
275
+ $oneUpdate = true;
276
+ } catch (Exception $ex) {
277
+ // Error during create, try to retrieve shop.
278
+ $retrieveShop = true;
279
+ }
280
+
281
+ if ($retrieveShop) {
282
+ // Shop NOT EXIST in conf and CANNOT BE CREATE, try to retrieve and update it.
283
+ $shop = $this->retrieveShop($apiKey, $localShop);
284
+ if (null != $shop) {
285
+ $shopIdApi = $shop['id'];
286
+ $this->updateShop($apiKey, $shopIdApi, $localShop, $config);
287
+ $oneUpdate = true;
288
+ }
289
+ }
290
+ } else {
291
+ $this->updateShop($apiKey, $shopIdApi, $localShop, $config);
292
+ $oneUpdate = true;
293
+ }
294
+
295
+ if (!empty($shopIdApi)) {
296
+ $feedIdApi = $config->get('STEERFOX_FEED_ID', $localShop->getId());
297
+
298
+ if (empty($feedIdApi)) {
299
+ $retrieveFeed = false;
300
+ try {
301
+ //Create new shop
302
+ $this->createFeed($apiKey, $shopIdApi, $localShop);
303
+ $oneUpdate = true;
304
+ } catch (Exception $ex) {
305
+ // Error during create, try to retrieve shop.
306
+ $retrieveFeed = true;
307
+ }
308
+
309
+ if ($retrieveFeed) {
310
+ // Feed NOT EXIST in conf and CANNOT BE CREATE, try to retrieve it.
311
+ $feed = $this->retrieveFeed($apiKey, $shopIdApi, $localShop);
312
+ if (null != $feed) {
313
+ $this->updateFeed($apiKey, $feed['id'], $shopIdApi, $localShop);
314
+ $oneUpdate = true;
315
+ }
316
+ }
317
+ } else {
318
+ //UPDATE
319
+ $this->updateFeed($apiKey, $feedIdApi, $shopIdApi, $localShop);
320
+ $oneUpdate = true;
321
+ }
322
+ }
323
+ }
324
+
325
+ $success = true;
326
+
327
+ if (!$oneUpdate) {
328
+ $config->setGlobal('STEERFOX_ACCOUNT_STATUS', 0);
329
+ $success = false;
330
+ $logger->addLog(
331
+ $tool->jsonEncode('Nothing to update'),
332
+ 'updateAccount',
333
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_INFO
334
+ );
335
+ } else {
336
+ $logger->addLog(
337
+ $tool->jsonEncode('Success'),
338
+ 'updateAccount',
339
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_INFO
340
+ );
341
+ }
342
+ } catch (Exception $ste) {
343
+ // Disable Account
344
+ $config->setGlobal('STEERFOX_ACCOUNT_STATUS', 0);
345
+ $logger->addLog(
346
+ $tool->jsonEncode($ste->getMessage()),
347
+ 'updateAccount',
348
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_ERROR
349
+ );
350
+ $success = false;
351
+ }
352
+
353
+ return $success;
354
+ }
355
+
356
+ /**
357
+ * Set request body parameters.
358
+ *
359
+ * @param array $requestParameters Request body parameters.
360
+ * @param array $parameters Parameters values.
361
+ *
362
+ * @return array
363
+ * @throws SteerfoxConnectorException
364
+ */
365
+ protected function setRequestBody($requestParameters, $parameters)
366
+ {
367
+ $body = array();
368
+ foreach ($requestParameters as $key => $requestParameter) {
369
+ if (array_key_exists($key, $parameters) && trim($parameters[$key]) !== '') {
370
+ $body[$key] = $parameters[$key];
371
+ } else {
372
+ if ($requestParameter['required']) {
373
+ throw new SteerfoxConnectorException(
374
+ $key.' is a required parameter',
375
+ '',
376
+ null,
377
+ E_ERROR
378
+ );
379
+ } else {
380
+ if (array_key_exists('default', $requestParameter)) {
381
+ $body[$key] = $requestParameter['default'];
382
+ }
383
+ }
384
+ }
385
+ }
386
+
387
+ return $body;
388
+ }
389
+
390
+ /**
391
+ * Return complete and formated url.
392
+ *
393
+ * @param string $path Api entry path
394
+ * @param array $params Url parameters.
395
+ *
396
+ * @return string
397
+ */
398
+ protected function getUrl($path, $params = array())
399
+ {
400
+ foreach ($params as $key => $value) {
401
+ $path = str_replace(':'.$key, $value, $path);
402
+ }
403
+
404
+ return $this->baseUrl.$path;
405
+ }
406
+
407
+ /**
408
+ * Set method (CURL or FOPEN).
409
+ *
410
+ * @throws SteerfoxConnectorException
411
+ */
412
+ protected function setMethod()
413
+ {
414
+ if ((bool)function_exists('curl_version')) {
415
+ $this->connector = new SteerfoxCurlConnector();
416
+ } elseif ((bool)ini_get('allow_url_fopen')) {
417
+ $this->connector = new SteerfoxFopenConnector();
418
+ } else {
419
+ throw new SteerfoxConnectorException(
420
+ 'Nor CURL nor FOPEN is activated on the server',
421
+ 'Api:Construct',
422
+ null,
423
+ E_ERROR
424
+ );
425
+ }
426
+ }
427
+
428
+ /**
429
+ * Set api base url.
430
+ */
431
+ protected function setBaseUrl()
432
+ {
433
+ if (getenv('STEERFOX_API_DEV') &&
434
+ getenv('STEERFOX_API_USER') &&
435
+ getenv('STEERFOX_API_PWD')
436
+ ) {
437
+ $this->baseUrl = 'http://'.
438
+ getenv('STEERFOX_API_USER').':'.
439
+ getenv('STEERFOX_API_PWD').
440
+ '@api.test.steerfox.com';
441
+ } else {
442
+ $this->baseUrl = 'http://api.steerfox.com';
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Create a new shop with API and shop Object.
448
+ *
449
+ * @param $apiKey
450
+ * @param SteerfoxShopAdapterInterface $shop
451
+ *
452
+ * @return array Create WS response.
453
+ *
454
+ * @throws SteerfoxConnectorException
455
+ */
456
+ protected function createShop($apiKey, SteerfoxShopAdapterInterface $shop)
457
+ {
458
+ $container = SteerfoxContainer::getInstance();
459
+ /** @var SteerfoxConfigurationInterface $config */
460
+ $config = $container->get('config');
461
+
462
+ $shopUrl = $this->getUrl('/shops?api_key='.$apiKey);
463
+ $params = array(
464
+ 'name' => $shop->getName(),
465
+ 'url' => $shop->getUrl(),
466
+ 'locale' => $shop->getLocale(),
467
+ 'email' => $config->getEmail(),
468
+ 'logo' => $shop->getLogo(),
469
+ 'currency' => $shop->getCurrency(),
470
+ );
471
+
472
+ $requestBody = $this->setRequestBody($this->requestParameters['shop']['cPOST'], $params);
473
+ $shopResponse = $this->connector->post($shopUrl, $requestBody, 'addShop');
474
+ $config->set('STEERFOX_SHOP_ID', $shopResponse['id'], $shop->getId());
475
+ $config->set('STEERFOX_EXPORT_LANG', $shop->getLanguage(), $shop->getId());
476
+ $config->set('STEERFOX_EXPORT_CURRENCY', $shopResponse['currency'], $shop->getId());
477
+
478
+ return $shopResponse;
479
+ }
480
+
481
+ /**
482
+ * Create a new Feed with API, shop API ID and shop Object.
483
+ *
484
+ * @param $apiKey
485
+ * @param $shopApiId
486
+ * @param SteerfoxShopAdapterInterface $localShop
487
+ *
488
+ * @return array Create WS response.
489
+ *
490
+ * @throws SteerfoxConnectorException
491
+ */
492
+ protected function createFeed($apiKey, $shopApiId, SteerfoxShopAdapterInterface $localShop)
493
+ {
494
+ $container = SteerfoxContainer::getInstance();
495
+ /** @var SteerfoxConfigurationInterface $config */
496
+ $config = $container->get('config');
497
+
498
+ $feedUrl = $this->getUrl('/feeds?api_key='.$apiKey);
499
+
500
+ $feedParams = array(
501
+ 'url' => $localShop->getShopFeedUrl(),
502
+ 'locale' => $localShop->getLocale(),
503
+ 'currency' => $localShop->getCurrency(),
504
+ 'shop_id' => $shopApiId,
505
+ );
506
+
507
+ $feedBody = $this->setRequestBody($this->requestParameters['feed']['cPOST'], $feedParams);
508
+ $feedResponse = $this->connector->post($feedUrl, $feedBody, 'addFeed');
509
+ $config->set('STEERFOX_FEED_ID', $feedResponse['id'], $localShop->getId());
510
+
511
+ return $feedResponse;
512
+ }
513
+
514
+ /**
515
+ * Retrieve APIshop who match with localShop
516
+ *
517
+ * @param $apiKey
518
+ * @param SteerfoxShopAdapterInterface $localShop
519
+ *
520
+ * @return array|null
521
+ */
522
+ protected function retrieveShop($apiKey, SteerfoxShopAdapterInterface $localShop)
523
+ {
524
+ $retrieveUrl = $this->getUrl('/shops?api_key='.$apiKey);
525
+ $accountShopList = $this->connector->get($retrieveUrl);
526
+
527
+ foreach ($accountShopList as $shop) {
528
+ if ($localShop->getUrl() == $shop['url']) {
529
+ return $shop;
530
+ }
531
+ }
532
+
533
+ return null;
534
+ }
535
+
536
+ /**
537
+ * Retrieve APIFeed who match with localShop
538
+ *
539
+ * @param $apiKey
540
+ * @param $shopIdApi
541
+ * @param SteerfoxShopAdapterInterface $localShop
542
+ *
543
+ * @return array|null
544
+ */
545
+ protected function retrieveFeed($apiKey, $shopIdApi, SteerfoxShopAdapterInterface $localShop)
546
+ {
547
+ $retrieveUrl = $this->getUrl('/feeds?api_key='.$apiKey.'&shop_id='.$shopIdApi);
548
+ $feedList = $this->connector->get($retrieveUrl);
549
+
550
+ foreach ($feedList as $feed) {
551
+ if ($localShop->getUrl() == $feed['url']) {
552
+ return $feed;
553
+ }
554
+ }
555
+
556
+ return null;
557
+ }
558
+
559
+ /**
560
+ * Update API Shop
561
+ *
562
+ * @param $apiKey
563
+ * @param $shopIdApi
564
+ * @param SteerfoxShopAdapterInterface $localShop
565
+ * @param SteerfoxConfigurationInterface $config
566
+ *
567
+ * @return void
568
+ *
569
+ * @throws SteerfoxConnectorException
570
+ */
571
+ protected function updateShop(
572
+ $apiKey,
573
+ $shopIdApi,
574
+ SteerfoxShopAdapterInterface $localShop,
575
+ SteerfoxConfigurationService $config
576
+ ) {
577
+ //UPDATE
578
+ $shopUrl = $this->getUrl('/shops/'.$shopIdApi.'?api_key='.$apiKey);
579
+ $params = array(
580
+ 'name' => $localShop->getName(),
581
+ 'url' => $localShop->getUrl(),
582
+ 'locale' => $localShop->getLocale(),
583
+ 'email' => $config->getEmail(),
584
+ 'logo' => $localShop->getLogo(),
585
+ 'currency' => $localShop->getCurrency(),
586
+ );
587
+
588
+ $requestBody = $this->setRequestBody($this->requestParameters['shop']['iPUT'], $params);
589
+ $this->connector->put($shopUrl, $requestBody, 'updateShop');
590
+ }
591
+
592
+ /**
593
+ * Update API Feed
594
+ *
595
+ * @param $apiKey
596
+ * @param $feedIdApi
597
+ * @param $shopIdApi
598
+ * @param SteerfoxShopAdapterInterface $localShop
599
+ *
600
+ * @return void
601
+ *
602
+ * @throws SteerfoxConnectorException
603
+ */
604
+ protected function updateFeed($apiKey, $feedIdApi, $shopIdApi, SteerfoxShopAdapterInterface $localShop)
605
+ {
606
+ $feedUrl = $this->getUrl('/feeds/'.$feedIdApi.'?api_key='.$apiKey);
607
+
608
+ $feedParams = array(
609
+ 'url' => $localShop->getShopFeedUrl(),
610
+ 'locale' => $localShop->getLocale(),
611
+ 'currency' => $localShop->getCurrency(),
612
+ 'shop_id' => $shopIdApi,
613
+ );
614
+
615
+ $feedBody = $this->setRequestBody($this->requestParameters['feed']['iPUT'], $feedParams);
616
+ $this->connector->put($feedUrl, $feedBody, 'updateFeed');
617
+ }
618
+ }
app/code/community/Steerfox/Plugins/lib/Configuration/SteerfoxConfigurationInterface.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * CMS Configuration interface.
24
+ */
25
+ interface SteerfoxConfigurationInterface
26
+ {
27
+ /**
28
+ * Return configuration value for specific shop. If shop id is null, set for current shop.
29
+ *
30
+ * @param string $key Configuration key.
31
+ * @param int|null $shopId Shop id.
32
+ *
33
+ * @return mixed
34
+ */
35
+ public function get($key, $shopId = null);
36
+
37
+ /**
38
+ * Return a global configuration value.
39
+ *
40
+ * @param string $key Configuration key.
41
+ *
42
+ * @return mixed
43
+ */
44
+ public function getGlobal($key);
45
+
46
+ /**
47
+ * Set a configuration value.
48
+ *
49
+ * @param string $key Configuration key.
50
+ * @param mixed $value Configuration value.
51
+ * @param int|null $shopId Shop id.
52
+ *
53
+ * @return mixed
54
+ */
55
+ public function set($key, $value, $shopId = null);
56
+
57
+ /**
58
+ * Set a global configuration value.
59
+ *
60
+ * @param string $key Configuration key.
61
+ * @param mixed $value Configuration value.
62
+ *
63
+ * @return mixed
64
+ */
65
+ public function setGlobal($key, $value);
66
+
67
+ /**
68
+ * Return CMS ID for API.
69
+ *
70
+ * @return int
71
+ */
72
+ public function getCmsId();
73
+
74
+ /**
75
+ * Return email. If connected user has email, this one, neither, global config email.
76
+ *
77
+ * @return string
78
+ */
79
+ public function getEmail();
80
+ }
app/code/community/Steerfox/Plugins/lib/Configuration/SteerfoxConfigurationService.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Configuration service.
24
+ *
25
+ * @method mixed get($key, $shopId)
26
+ * @method mixed getGlobal($key)
27
+ * @method mixed set($key, $value, $shopId)
28
+ * @method mixed setGlobal($key, $value)
29
+ * @method int getCmsId()
30
+ * @method string getEmail()
31
+ */
32
+ class SteerfoxConfigurationService
33
+ {
34
+ /**
35
+ * Configuration.
36
+ *
37
+ * @var SteerfoxConfigurationInterface
38
+ */
39
+ protected $configuration;
40
+
41
+ /**
42
+ * ConfigurationService constructor.
43
+ *
44
+ * @param string $configuration Configuration adapter class name.
45
+ *
46
+ * @throws SteerfoxException
47
+ */
48
+ public function __construct($configuration)
49
+ {
50
+ $reflexion = new ReflectionClass($configuration);
51
+ if ($reflexion->isSubclassOf('SteerfoxConfigurationInterface')) {
52
+ $this->configuration = $reflexion->newInstance();
53
+ } else {
54
+ throw new SteerfoxException('Invalid configuration adapter');
55
+ }
56
+
57
+ }
58
+
59
+ /**
60
+ * Passthru to configuration adapter.
61
+ *
62
+ * @param string $name Method name.
63
+ * @param array $arguments Arguments.
64
+ *
65
+ * @return mixed
66
+ */
67
+ public function __call($name, $arguments)
68
+ {
69
+ $reflexionMethod = new ReflectionMethod($this->configuration, $name);
70
+
71
+ return $reflexionMethod->invokeArgs($this->configuration, $arguments);
72
+ }
73
+ }
app/code/community/Steerfox/Plugins/lib/Exceptions/SteerfoxConnectorException.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Connector exception
24
+ */
25
+ class SteerfoxConnectorException extends Exception
26
+ {
27
+ /**
28
+ * SteerfoxConnectorException constructor.
29
+ *
30
+ * @param string $message The message.
31
+ * @param string $action The action executed.
32
+ * @param mixed $apiReturn The api return message.
33
+ * @param int $code The code.
34
+ * @param Exception|null $previous The previous exception.
35
+ */
36
+ public function __construct($message, $action, $apiReturn, $code = 0, Exception $previous = null)
37
+ {
38
+ /** @var SteerfoxLogService $logger */
39
+ $logger = SteerfoxContainer::getInstance()->get('logger');
40
+ /** @var SteerfoxToolsAdapterInterface $tool */
41
+ $tool = SteerfoxContainer::getInstance()->get('tools');
42
+
43
+ $messageToLog = $message;
44
+ if (!empty($apiReturn)) {
45
+ if (is_array($message)) {
46
+ $message['api-return'] = $apiReturn;
47
+ } else {
48
+ $messageToLog .= $tool->jsonEncode($apiReturn);
49
+ }
50
+ }
51
+
52
+ $logger->addLog(
53
+ $tool->jsonEncode($messageToLog),
54
+ 'ws::'.$action,
55
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_ERROR
56
+ );
57
+
58
+ parent::__construct(
59
+ $message.($previous ? "\n".$previous->getMessage() : ''),
60
+ $code
61
+ );
62
+ }
63
+ }
app/code/community/Steerfox/Plugins/lib/Exceptions/SteerfoxException.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ *
24
+ */
25
+ class SteerfoxException extends Exception
26
+ {
27
+
28
+ }
app/code/community/Steerfox/Plugins/lib/Export/Helper/SteerfoxExporterHelper.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: loic
5
+ * Date: 10/02/16
6
+ * Time: 15:18
7
+ */
app/code/community/Steerfox/Plugins/lib/Export/Model/SteerfoxProductExporter.php ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+
23
+ /**
24
+ * Export CMS data for Steerfox Api
25
+ */
26
+ class SteerfoxProductExporter
27
+ {
28
+ /**
29
+ * Length limtation for description
30
+ */
31
+ const GOOGLE_SHOPPING_DESC_LIMIT = 5000;
32
+
33
+ /**
34
+ * Authorize export formats.
35
+ */
36
+ public static $AUTHORIZED_FORMATS = array('gz', 'txt');
37
+
38
+ /**
39
+ * Export file name.
40
+ */
41
+ const EXPORT_SAVE_FILENAME = 'feed_';
42
+
43
+ /**
44
+ * Export mimetype for download.
45
+ *
46
+ * @var string
47
+ */
48
+ private $mimeType;
49
+
50
+ /**
51
+ * File extension.
52
+ *
53
+ * @var string.
54
+ */
55
+ private $extension;
56
+
57
+ /**
58
+ * File name.
59
+ *
60
+ * @var string.
61
+ */
62
+ private $fileName;
63
+
64
+ /**
65
+ * Export content.
66
+ *
67
+ * @var array
68
+ */
69
+ private $content;
70
+
71
+ /**
72
+ * SteerfoxProductExporter constructor.
73
+ *
74
+ * @param $shopId
75
+ * @param array $products
76
+ * @param $format
77
+ */
78
+ public function __construct($shopId, array $products, $format)
79
+ {
80
+ $this->mimeType = null;
81
+ $this->extension = null;
82
+ $this->content = null;
83
+ $this->render($shopId, $products, $format);
84
+ }
85
+
86
+ /**
87
+ * @param $shopId
88
+ * @param array $products
89
+ * @param $format
90
+ *
91
+ * @throws Exception
92
+ */
93
+ protected function render($shopId, array $products, $format)
94
+ {
95
+
96
+ switch ($format) {
97
+ case 'txt':
98
+ $this->renderPlainText($shopId, $products);
99
+ break;
100
+ case 'gz':
101
+ $this->renderGz($shopId, $products);
102
+ break;
103
+ default:
104
+ throw new Exception('Unavailable export format');
105
+ break;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Render Plaintext format.
111
+ *
112
+ * @param $shopId
113
+ * @param array $products
114
+ * @param $format
115
+ */
116
+ protected function renderPlainText($shopId, array $products)
117
+ {
118
+ $renderContent = '';
119
+ $this->mimeType = 'text/plain';
120
+ $this->extension = 'txt';
121
+ $this->fileName = self::EXPORT_SAVE_FILENAME.$shopId.'.'.$this->extension;
122
+ $contentArray = $this->generateContentArray($products);
123
+
124
+ foreach ($contentArray as $contentRow) {
125
+ $renderContent .= implode("\t", $contentRow)."\n";
126
+ }
127
+
128
+ $this->content = $renderContent;
129
+ }
130
+
131
+ /**
132
+ * Render Gz format.
133
+ *
134
+ * @param $shopId
135
+ * @param array $products
136
+ */
137
+ protected function renderGz($shopId, array $products)
138
+ {
139
+ $this->renderPlainText($shopId, $products);
140
+ $this->content = gzencode($this->content);
141
+ $this->mimeType = 'application/x-gzip';
142
+ $this->extension = 'txt.gz';
143
+ $this->fileName = self::EXPORT_SAVE_FILENAME.$shopId.'.'.$this->extension;
144
+ }
145
+
146
+ /**
147
+ * @param array $products
148
+ *
149
+ * @return array
150
+ */
151
+ protected function generateContentArray(array $products)
152
+ {
153
+ $contentArray = array();
154
+ $contentArray[] = $this->addHeaderContentRow();
155
+ foreach ($products as $product) {
156
+ /** @var SteerfoxProductAdapterInterface $product */
157
+
158
+ // Clean title and description
159
+ $title = $product->getTitle();
160
+
161
+ $description = $product->getDescription();
162
+
163
+ $description = $this->cleanAndTruncateText($description);
164
+ $contentArray[] = $this->getContentRow(
165
+ $product->getId(),
166
+ $title,
167
+ $description,
168
+ $product->getProductType(),
169
+ $product->getLink(),
170
+ $product->getImageLink(),
171
+ $product->getCondition(),
172
+ $product->getAvailability(),
173
+ $product->getAvailabilityDate(),
174
+ $product->getPrice(),
175
+ $product->getSalePrice(),
176
+ $product->getSalePriceEffectiveDate(),
177
+ $product->getGtin(),
178
+ $product->getBrand(),
179
+ $product->getMpn(),
180
+ $product->getIdentifierExists(),
181
+ $product->getItemGroupId(),
182
+ $product->getGender(),
183
+ $product->getAgeGroup(),
184
+ $product->getColor(),
185
+ $product->getSize(),
186
+ $product->getShipping(),
187
+ $product->getShippingWeight(),
188
+ $product->getGrossProfit(),
189
+ $product->getGrossMargin()
190
+ );
191
+ }
192
+
193
+ return $contentArray;
194
+ }
195
+
196
+ /**
197
+ * Clean and truncate text for google shopping integration.
198
+ *
199
+ * @param $text
200
+ *
201
+ * @return string
202
+ */
203
+ private function cleanAndTruncateText($text)
204
+ {
205
+ $cleanedText = html_entity_decode(strip_tags($text));
206
+
207
+ $tool = SteerfoxContainer::getInstance()->get('tools');
208
+ //Limit description to 5000 char for Google Shopping compliant.
209
+ if($tool->strlen($cleanedText) >= self::GOOGLE_SHOPPING_DESC_LIMIT){
210
+ $cleanedText = $tool->substr($cleanedText, 0, (self::GOOGLE_SHOPPING_DESC_LIMIT - 4));
211
+ $cleanedText .= ' ...';
212
+ }
213
+
214
+ $cleanedText = str_replace("\"", "\"\"", $cleanedText);
215
+
216
+ return '"'.$cleanedText.'"';
217
+ }
218
+
219
+ /**
220
+ * Add header for data export.
221
+ */
222
+ private function addHeaderContentRow()
223
+ {
224
+ return $this->getContentRow(
225
+ 'id',
226
+ 'title',
227
+ 'description',
228
+ 'product type',
229
+ 'link',
230
+ 'image link',
231
+ 'condition',
232
+ 'availability',
233
+ 'availability date',
234
+ 'price',
235
+ 'sale price',
236
+ 'sale price effective date',
237
+ 'gtin',
238
+ 'brand',
239
+ 'mpn',
240
+ 'identifier exists',
241
+ 'item group id',
242
+ 'gender',
243
+ 'age group',
244
+ 'color',
245
+ 'size',
246
+ 'shipping',
247
+ 'shipping weight',
248
+ 'c:gross_profit',
249
+ 'c:gross_margin'
250
+ );
251
+ }
252
+
253
+ /**
254
+ * Add line to content.
255
+ *
256
+ * @param mixed $id
257
+ * @param mixed $title
258
+ * @param mixed $description
259
+ * @param mixed $productType
260
+ * @param mixed $link
261
+ * @param mixed $imageLink
262
+ * @param null $condition
263
+ * @param mixed $availability
264
+ * @param mixed $availabilityDate
265
+ * @param mixed $price
266
+ * @param mixed $salePrice
267
+ * @param mixed $salePriceEffectiveDate
268
+ * @param mixed $gtin
269
+ * @param mixed $brand
270
+ * @param mixed $mpn
271
+ * @param mixed $identifierExists
272
+ * @param mixed $itemGroupId
273
+ * @param mixed $gender
274
+ * @param mixed $ageGroup
275
+ * @param mixed $color
276
+ * @param mixed $size
277
+ * @param mixed $shipping
278
+ * @param null $shippingWeight
279
+ * @param mixed $grossProfit
280
+ * @param mixed $grossMargin
281
+ *
282
+ * @return array
283
+ */
284
+ private function getContentRow(
285
+ $id = null,
286
+ $title = null,
287
+ $description = null,
288
+ $productType = null,
289
+ $link = null,
290
+ $imageLink = null,
291
+ $condition = null,
292
+ $availability = null,
293
+ $availabilityDate = null,
294
+ $price = null,
295
+ $salePrice = null,
296
+ $salePriceEffectiveDate = null,
297
+ $gtin = null,
298
+ $brand = null,
299
+ $mpn = null,
300
+ $identifierExists = null,
301
+ $itemGroupId = null,
302
+ $gender = null,
303
+ $ageGroup = null,
304
+ $color = null,
305
+ $size = null,
306
+ $shipping = null,
307
+ $shippingWeight = null,
308
+ $grossProfit = null,
309
+ $grossMargin = null
310
+ ) {
311
+ return array(
312
+ $id,
313
+ $title,
314
+ $description,
315
+ $productType,
316
+ $link,
317
+ $imageLink,
318
+ $condition,
319
+ $availability,
320
+ $availabilityDate,
321
+ $price,
322
+ $salePrice,
323
+ $salePriceEffectiveDate,
324
+ $gtin,
325
+ $brand,
326
+ $mpn,
327
+ $identifierExists,
328
+ $itemGroupId,
329
+ $gender,
330
+ $ageGroup,
331
+ $color,
332
+ $size,
333
+ $shipping,
334
+ $shippingWeight,
335
+ $grossProfit,
336
+ $grossMargin,
337
+ );
338
+ }
339
+
340
+ /**
341
+ * @return string
342
+ */
343
+ public function getMimeType()
344
+ {
345
+ return $this->mimeType;
346
+ }
347
+
348
+ /**
349
+ * @return string
350
+ */
351
+ public function getExtension()
352
+ {
353
+ return $this->extension;
354
+ }
355
+
356
+ /**
357
+ * @return string
358
+ */
359
+ public function getFileName()
360
+ {
361
+ return $this->fileName;
362
+ }
363
+
364
+ /**
365
+ * @return array
366
+ */
367
+ public function getContent()
368
+ {
369
+ return $this->content;
370
+ }
371
+ }
app/code/community/Steerfox/Plugins/lib/Export/SteerfoxExportService.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+
23
+ /**
24
+ * Export CMS data for Steerfox Api
25
+ */
26
+ class SteerfoxExportService
27
+ {
28
+ /**
29
+ * @param SteerfoxShopAdapterInterface $shop
30
+ * @param string $format
31
+ *
32
+ * @return SteerfoxProductExporter
33
+ * @throws Exception
34
+ * @throws SteerfoxException
35
+ */
36
+ public function getProductExporter(SteerfoxShopAdapterInterface $shop, $format = 'gz')
37
+ {
38
+ if (false == in_array($format, SteerfoxProductExporter::$AUTHORIZED_FORMATS)) {
39
+ throw new Exception('Unrecognized format.');
40
+ }
41
+
42
+ $container = SteerfoxContainer::getInstance();
43
+ /** @var SteerfoxAbstractShopService $shopService */
44
+ $shopService = $container->get('shop');
45
+ /** @var SteerfoxToolsAdapterInterface $tool */
46
+ $tool = $container->get('tools');
47
+ /** @var SteerfoxAbstractLoggerService $logger */
48
+ $logger = $container->get('logger');
49
+
50
+
51
+ $products = $shopService->getProductsToExport($shop);
52
+ $productExporter = new SteerfoxProductExporter($shop->getId(), $products, $format);
53
+ $logger->addLog(
54
+ $tool->jsonEncode('Success'),
55
+ 'exportProduct',
56
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_INFO
57
+ );
58
+
59
+ return $productExporter;
60
+ }
61
+
62
+
63
+ /**
64
+ * @param SteerfoxShopAdapterInterface $shop
65
+ * @param string $format
66
+ *
67
+ * @throws Exception
68
+ * @throws SteerfoxException
69
+ */
70
+ public function saveProductExporter(SteerfoxShopAdapterInterface $shop, $format = 'gz')
71
+ {
72
+ /** @var SteerfoxProductExporter $productExporter */
73
+ $productExporter = $this->getProductExporter($shop, $format);
74
+
75
+ $container = SteerfoxContainer::getInstance();
76
+ /** @var SteerfoxToolsAdapterInterface $tool */
77
+ $tool = $container->get('tools');
78
+ /** @var SteerfoxAbstractLoggerService $logger */
79
+ $logger = $container->get('logger');
80
+ $tool->saveExportFile(
81
+ $productExporter->getFileName(),
82
+ $productExporter->getContent()
83
+ );
84
+ $logger->addLog(
85
+ $tool->jsonEncode('Success'),
86
+ 'saveExportProduct',
87
+ SteerfoxAbstractLoggerService::STEERFOX_LOG_TYPE_INFO
88
+ );
89
+ }
90
+ }
app/code/community/Steerfox/Plugins/lib/Logger/SteerfoxAbstractLoggerService.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Logger service
24
+ */
25
+ abstract class SteerfoxAbstractLoggerService
26
+ {
27
+ const STEERFOX_LOG_TYPE_INFO = 'info';
28
+ const STEERFOX_LOG_TYPE_ERROR = 'error';
29
+ const STEERFOX_LOG_TYPE_WARNING = 'warning';
30
+
31
+ /**
32
+ * Add a log in database.
33
+ *
34
+ * @param string $message The message.
35
+ * @param string $action The action.
36
+ * @param int $level The level.
37
+ */
38
+ abstract public function addLog($message, $action, $level);
39
+
40
+ /**
41
+ * Return all logs.
42
+ *
43
+ * @return array
44
+ */
45
+ abstract public function getAllLogs();
46
+
47
+ /**
48
+ * Return environment informations
49
+ *
50
+ * @return string
51
+ */
52
+ protected function getEnvironementInformations()
53
+ {
54
+ return array(
55
+ 'plugin' => $this->getPluginVersion(),
56
+ 'cms' => $this->getCmsVersion(),
57
+ 'php' => array(
58
+ 'version' => phpversion(),
59
+ 'memory_limit' => ini_get('memory_limit'),
60
+ 'max_execution_time' => ini_get('max_execution_time'),
61
+ ),
62
+ );
63
+ }
64
+
65
+ /**
66
+ * Return plugin version.
67
+ *
68
+ * @return string
69
+ */
70
+ abstract protected function getPluginVersion();
71
+
72
+ /**
73
+ * Return cms version.
74
+ *
75
+ * @return string
76
+ */
77
+ abstract protected function getCmsVersion();
78
+ }
app/code/community/Steerfox/Plugins/lib/Model/SteerfoxAbstractShopService.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Shop service
24
+ */
25
+ abstract class SteerfoxAbstractShopService
26
+ {
27
+ protected $shopAdapterClass;
28
+
29
+ /**
30
+ * AbstractShopService constructor.
31
+ *
32
+ * @param string $shopAdapterClass Shop adapter class name.
33
+ *
34
+ * @throws SteerfoxException
35
+ */
36
+ public function __construct($shopAdapterClass)
37
+ {
38
+ $reflexion = new ReflectionClass($shopAdapterClass);
39
+ if ($reflexion->isSubclassOf('SteerfoxShopAdapterInterface')) {
40
+ $this->shopAdapterClass = $shopAdapterClass;
41
+ } else {
42
+ throw new SteerfoxException('Adapter class is not valid');
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Return all shops.
48
+ *
49
+ * @return array
50
+ */
51
+ abstract public function getShops();
52
+
53
+ /**
54
+ * Return main shop.
55
+ *
56
+ * @return SteerfoxShopAdapterInterface
57
+ */
58
+ abstract public function getMainShop();
59
+
60
+ /**
61
+ * Return current shop.
62
+ *
63
+ * @return SteerfoxShopAdapterInterface
64
+ */
65
+ abstract public function getCurrentShop();
66
+
67
+
68
+ /**
69
+ * Return current shop.
70
+ *
71
+ * @param SteerfoxShopAdapterInterface $shop
72
+ *
73
+ * @return SteerfoxProductAdapterInterface[]
74
+ */
75
+ abstract public function getProductsToExport(SteerfoxShopAdapterInterface $shop);
76
+ }
app/code/community/Steerfox/Plugins/lib/Model/SteerfoxProductAdapterInterface.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Product adapter interface.
24
+ */
25
+ interface SteerfoxProductAdapterInterface
26
+ {
27
+ /**
28
+ * Return id.
29
+ *
30
+ * @return mixed
31
+ */
32
+ public function getId();
33
+
34
+ /**
35
+ * Return Title
36
+ *
37
+ * @return mixed
38
+ */
39
+ public function getTitle();
40
+
41
+ /**
42
+ * Return Description
43
+ *
44
+ * @return mixed
45
+ */
46
+ public function getDescription();
47
+
48
+ /**
49
+ * Return ProductType
50
+ *
51
+ * @return mixed
52
+ */
53
+ public function getProductType();
54
+
55
+ /**
56
+ * Return Link
57
+ *
58
+ * @return mixed
59
+ */
60
+ public function getLink();
61
+
62
+ /**
63
+ * Return Image Link
64
+ *
65
+ * @return mixed
66
+ */
67
+ public function getImageLink();
68
+
69
+ /**
70
+ * Return Condition
71
+ *
72
+ * @return mixed
73
+ */
74
+ public function getCondition();
75
+
76
+ /**
77
+ * Return Availability
78
+ *
79
+ * @return mixed
80
+ */
81
+ public function getAvailability();
82
+
83
+ /**
84
+ * Return Availability Date
85
+ *
86
+ * @return mixed
87
+ */
88
+ public function getAvailabilityDate();
89
+
90
+ /**
91
+ * Return Price
92
+ *
93
+ * @return mixed
94
+ */
95
+ public function getPrice();
96
+
97
+ /**
98
+ * Return Sale Price
99
+ *
100
+ * @return mixed
101
+ */
102
+ public function getSalePrice();
103
+
104
+ /**
105
+ * Return Sale Price Effective Date
106
+ *
107
+ * @return mixed
108
+ */
109
+ public function getSalePriceEffectiveDate();
110
+
111
+ /**
112
+ * Return Gtin
113
+ *
114
+ * @return mixed
115
+ */
116
+ public function getGtin();
117
+
118
+ /**
119
+ * Return Brand
120
+ *
121
+ * @return mixed
122
+ */
123
+ public function getBrand();
124
+
125
+ /**
126
+ * Return Mpn
127
+ *
128
+ * @return mixed
129
+ */
130
+ public function getMpn();
131
+
132
+ /**
133
+ * Return Identifier Exists
134
+ *
135
+ * @return mixed
136
+ */
137
+ public function getIdentifierExists();
138
+
139
+ /**
140
+ * Return Item Group Id
141
+ *
142
+ * @return mixed
143
+ */
144
+ public function getItemGroupId();
145
+
146
+ /**
147
+ * Return Gender
148
+ *
149
+ * @return mixed
150
+ */
151
+ public function getGender();
152
+
153
+ /**
154
+ * Return Age Group
155
+ *
156
+ * @return mixed
157
+ */
158
+ public function getAgeGroup();
159
+
160
+ /**
161
+ * Return Color
162
+ *
163
+ * @return mixed
164
+ */
165
+ public function getColor();
166
+
167
+ /**
168
+ * Return Size
169
+ *
170
+ * @return mixed
171
+ */
172
+ public function getSize();
173
+
174
+ /**
175
+ * Return Shipping
176
+ *
177
+ * @return mixed
178
+ */
179
+ public function getShipping();
180
+
181
+ /**
182
+ * Return Shipping Weight
183
+ *
184
+ * @return mixed
185
+ */
186
+ public function getShippingWeight();
187
+
188
+ /**
189
+ * Return GrossProfit
190
+ *
191
+ * @return mixed
192
+ */
193
+ public function getGrossProfit();
194
+
195
+ /**
196
+ * Return Gross Margin
197
+ *
198
+ * @return mixed
199
+ */
200
+ public function getGrossMargin();
201
+ }
app/code/community/Steerfox/Plugins/lib/Model/SteerfoxShopAdapterInterface.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Shop adapter interface.
24
+ */
25
+ interface SteerfoxShopAdapterInterface
26
+ {
27
+ /**
28
+ * Return id.
29
+ *
30
+ * @return mixed
31
+ */
32
+ public function getId();
33
+
34
+ /**
35
+ * Return URL.
36
+ *
37
+ * @return string
38
+ */
39
+ public function getUrl();
40
+
41
+ /**
42
+ * Return name.
43
+ *
44
+ * @return string
45
+ */
46
+ public function getName();
47
+
48
+ /**
49
+ * Return language.
50
+ *
51
+ * @return string
52
+ */
53
+ public function getLanguage();
54
+
55
+ /**
56
+ * Return locale.
57
+ *
58
+ * @return string
59
+ */
60
+ public function getLocale();
61
+
62
+ /**
63
+ * Return logo.
64
+ *
65
+ * @return string
66
+ */
67
+ public function getLogo();
68
+
69
+ /**
70
+ * Return currency code.
71
+ *
72
+ * @return string
73
+ */
74
+ public function getCurrency();
75
+
76
+ /**
77
+ * return feed Url.
78
+ *
79
+ * @return string
80
+ */
81
+ public function getShopFeedUrl();
82
+ }
app/code/community/Steerfox/Plugins/lib/Model/SteerfoxToolsAdapterInterface.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ /**
23
+ * Tools adapter interface
24
+ */
25
+ interface SteerfoxToolsAdapterInterface
26
+ {
27
+ /**
28
+ * Encode as json.
29
+ *
30
+ * @param mixed $value Value to encode.
31
+ *
32
+ * @return string
33
+ */
34
+ public function jsonEncode($value);
35
+
36
+ /**
37
+ * Decode JSON string
38
+ *
39
+ * @param string $json Json value to décode
40
+ * @param bool $assoc Return an assoc array
41
+ *
42
+ * @return mixed
43
+ */
44
+ public function jsonDecode($json, $assoc = false);
45
+
46
+ /**
47
+ * Return string length.
48
+ *
49
+ * @param string $string
50
+ *
51
+ * @return int
52
+ */
53
+ public function strlen($string);
54
+
55
+ /**
56
+ * Return part of string.
57
+ *
58
+ * @param string $string Source string.
59
+ * @param int $start Start position.
60
+ * @param int|bool $length Length.
61
+ *
62
+ * @return mixed
63
+ */
64
+ public function substr($string, $start, $length = false);
65
+
66
+ /**
67
+ * Return content file
68
+ *
69
+ * @param string $url URL.
70
+ * @param bool $useIncludePath Use php include path.
71
+ * @param null $streamContext Stream context
72
+ *
73
+ * @return mixed
74
+ */
75
+ public function fileGetContents($url, $useIncludePath = false, $streamContext = null);
76
+
77
+ /**
78
+ * Save export file on disk
79
+ *
80
+ * @param string $filename File Name
81
+ * @param string $fileContent File Content
82
+ *
83
+ * @return void
84
+ */
85
+ public function saveExportFile($filename, $fileContent);
86
+ }
app/code/community/Steerfox/Plugins/lib/README.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Steerfox Plugins Library
2
+
3
+ ## Requirements
4
+ * PHP 5.3+
5
+
6
+ ## Installation
7
+ 1. Clone this repository in your application
8
+ 2. add require_once in your application on SteerfoxContainer.php
9
+ 3. Set the configuration file
10
+
11
+ ## Adapters
12
+ ### Models
13
+ Models adapters are used to access specific data CMS through data abstraction.
14
+
15
+ ### Services
16
+ Adapters services used to implement specific CMS treatments to be used by the overall functionality of the library
17
+
18
+ ## Configuration File
19
+ The configuration file must be define in you application
20
+ This file contains every adapters declaration
21
+ A sample configuration file is available in "Samples" folder
22
+
23
+ ## Container Instantiation
24
+ Container must be instantiate with a specific CMS configuration (for adapters).
25
+ After th first instantiation, every services can be loaded with a simple call on container : get('serviceName')
26
+ A sample use is available in "Samples" folder
27
+
28
+ ## Samples
29
+ Many samples adapters are available in "Sample" folder.
30
+
31
+ ## License
32
+ This project is released under version 2.0 of the [Apache License](http://www.apache.org/licenses/LICENSE-2.0).
app/code/community/Steerfox/Plugins/lib/Samples/ContainerUse.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ //Add Steerfox Librarie
23
+ require_once dirname(__FILE__).'/../SteerfoxContainer.php';
24
+
25
+ SteerfoxContainer::createInstance('conf.xml');
26
+
27
+ $container = SteerfoxContainer::getInstance();
28
+ /** @var SteerfoxConfigurationInterface $config */
29
+ $config = $container->get('config');
30
+ /** @var SteerfoxAbstractShopService $shopService */
31
+ $shopService = $container->get('shop');
32
+ /** @var SteerfoxAbstractLog $logger */
33
+ $logger = $container->get('logger');
34
+ /** @var SteerfoxToolsAdapterInterface $tool */
35
+ $tool = $container->get('tools');
app/code/community/Steerfox/Plugins/lib/Samples/ModelAdapters/Configuration.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins').'/lib/SteerfoxContainer.php';
23
+
24
+ class Steerfox_Plugins_Model_Adapter_Configuration implements SteerfoxConfigurationInterface
25
+ {
26
+
27
+ protected static $nameMapping = array(
28
+ 'STEERFOX_ACCOUNT_API_KEY' => array(
29
+ 'key' => 'steerfox_plugins/account/api_key',
30
+ 'scope' => 'default',
31
+ ),
32
+ 'STEERFOX_ACCOUNT_STATUS' => array(
33
+ 'key' => 'steerfox_plugins/account/status',
34
+ 'scope' => 'default',
35
+ ),
36
+ 'STEERFOX_SHOP_ID' => array(
37
+ 'key' => 'steerfox_plugins/catalog/shop_id',
38
+ 'scope' => 'websites',
39
+ ),
40
+ 'STEERFOX_EXPORT_LANG' => array(
41
+ 'key' => 'steerfox_plugins/catalog/export_lang',
42
+ 'scope' => 'websites',
43
+ ),
44
+ 'STEERFOX_EXPORT_CURRENCY' => array(
45
+ 'key' => 'steerfox_plugins/catalog/export_currency',
46
+ 'scope' => 'websites',
47
+ ),
48
+ 'STEERFOX_FEED_ID' => array(
49
+ 'key' => 'steerfox_plugins/catalog/feed_id',
50
+ 'scope' => 'websites',
51
+ ),
52
+ );
53
+
54
+ const STEERFOX_SOURCE_MAGENTO = 2;
55
+
56
+ /**
57
+ * @inheritDoc
58
+ */
59
+ public function get($key, $shopId = null)
60
+ {
61
+ $key = $this->getMappedKey($key);
62
+
63
+ return Mage::getStoreConfig($key, $shopId);
64
+ }
65
+
66
+ /**
67
+ * @inheritDoc
68
+ */
69
+ public function getGlobal($key)
70
+ {
71
+ $key = $this->getMappedKey($key);
72
+
73
+ return Mage::getStoreConfig($key);
74
+ }
75
+
76
+ /**
77
+ * @inheritDoc
78
+ */
79
+ public function set($key, $value, $shopId = 0)
80
+ {
81
+ $key = $this->getMappedKey($key);
82
+ $scope = $this->getMappedScope($key);
83
+ $this->assertScope();
84
+
85
+ return Mage::helper('steerfox_plugins')->updateConfig($key, $value, $scope, $shopId);
86
+ }
87
+
88
+ /**
89
+ * @inheritDoc
90
+ */
91
+ public function setGlobal($key, $value)
92
+ {
93
+ $key = $this->getMappedKey($key);
94
+
95
+ return Mage::helper('steerfox_plugins')->updateConfig($key, $value);
96
+ }
97
+
98
+ /**
99
+ * @inheritDoc
100
+ */
101
+ public function getCmsId()
102
+ {
103
+ return self::STEERFOX_SOURCE_MAGENTO;
104
+ }
105
+
106
+ /**
107
+ * @inheritDoc
108
+ */
109
+ public function getEmail()
110
+ {
111
+ $user = Mage::getSingleton('admin/session');
112
+ $userEmail = $user->getUser()->getEmail();
113
+ if (empty($userEmail)) {
114
+ $userEmail = Mage::getStoreConfig('trans_email/ident_general/email');
115
+ }
116
+
117
+ if (getenv('STEERFOX_API_DEV') &&
118
+ getenv('STEERFOX_API_USER') &&
119
+ getenv('STEERFOX_API_PWD')
120
+ ) {
121
+ $userEmail = uniqid().'@test.com';
122
+ // $userEmail = 'contact@madison.com';
123
+ }
124
+
125
+ return $userEmail;
126
+ }
127
+
128
+ /**
129
+ * Resolve the good key config if parameters keys is in mapping config.
130
+ *
131
+ * @param string $key
132
+ *
133
+ * @return string
134
+ */
135
+ private function getMappedKey($key)
136
+ {
137
+
138
+ if (array_key_exists($key, self::$nameMapping)) {
139
+ $key = self::$nameMapping[$key]['key'];
140
+ }
141
+
142
+ return $key;
143
+ }
144
+
145
+ /**
146
+ * Resolve the good scope config if parameters keys is in mapping config.
147
+ *
148
+ * @param string $key
149
+ *
150
+ * @return string
151
+ */
152
+ private function getMappedScope($key)
153
+ {
154
+ $scope = 'default';
155
+
156
+ if (array_key_exists($key, self::$nameMapping)) {
157
+ $scope = self::$nameMapping[$key]['scope'];
158
+ }
159
+
160
+ return $scope;
161
+ }
162
+
163
+ /**
164
+ * Assert if scope is website, shopid cannot be empty.
165
+ *
166
+ * @param string $scope
167
+ * @param integer $shopId
168
+ * @throws Mage_Core_Exception
169
+ */
170
+ private function assertScope($scope, $shopId)
171
+ {
172
+ if ('websites' == $scope && (null == $shopId || 0 == $shopId)) {
173
+ Mage::throwException('shopId cannot be empty if scope is "websites".');
174
+ }
175
+ }
176
+
177
+ }
app/code/community/Steerfox/Plugins/lib/Samples/ModelAdapters/Product.php ADDED
@@ -0,0 +1,380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins').'/lib/SteerfoxContainer.php';
23
+
24
+ class Steerfox_Plugins_Model_Adapter_Product implements SteerfoxProductAdapterInterface
25
+ {
26
+ /**
27
+ * Store Magento.
28
+ *
29
+ * @var Steerfox_Plugins_Model_Product
30
+ */
31
+ private $steerfoxProduct;
32
+
33
+ /**
34
+ * Store Magento.
35
+ *
36
+ * @var Mage_Catalog_Model_Product
37
+ */
38
+ private $product;
39
+
40
+ public function __construct(Steerfox_Plugins_Model_Product $steerfoxProduct)
41
+ {
42
+ $this->$steerfoxProduct = $steerfoxProduct;
43
+ $this->product = Mage::getModel('catalog/product')->load($steerfoxProduct->getIdProduct());
44
+ }
45
+
46
+ /**
47
+ * Return id.
48
+ *
49
+ * @return mixed
50
+ */
51
+ public function getId()
52
+ {
53
+ return $this->product->getId();
54
+ }
55
+
56
+ /**
57
+ * Return Title
58
+ *
59
+ * @return mixed
60
+ */
61
+ public function getTitle()
62
+ {
63
+ return $this->product->getName();
64
+ }
65
+
66
+ /**
67
+ * Return Description
68
+ *
69
+ * @return mixed
70
+ */
71
+ public function getDescription()
72
+ {
73
+ return $this->product->getDescription();
74
+ }
75
+
76
+ /**
77
+ * Return ProductType
78
+ *
79
+ * @return mixed
80
+ */
81
+ public function getProductType()
82
+ {
83
+ $type = null;
84
+ if (null != $this->product->getApparelType()) {
85
+ //Cas pour le jeu produit des vêtements
86
+ $type = $this->product->getResource()
87
+ ->getAttribute('apparel_type')
88
+ ->getSource()
89
+ ->getOptionText($this->product->getApparelType());
90
+ } else {
91
+ if (null != $this->product->getAttributeSetId()) {
92
+ // Cas par défaut
93
+ $attributeSetModel = Mage::getModel("eav/entity_attribute_set");
94
+ $attributeSetModel->load($this->product->getAttributeSetId());
95
+ $type = $attributeSetModel->getAttributeSetName();
96
+ }
97
+ }
98
+
99
+ return $type;
100
+ }
101
+
102
+ /**
103
+ * Return Link
104
+ *
105
+ * @return mixed
106
+ */
107
+ public function getLink()
108
+ {
109
+ return $this->product->getProductUrl();
110
+ }
111
+
112
+ /**
113
+ * Return Image Link
114
+ *
115
+ * @return mixed
116
+ */
117
+ public function getImageLink()
118
+ {
119
+ return $this->product->getImageUrl();
120
+ }
121
+
122
+ /**
123
+ * Return Condition
124
+ *
125
+ * @return mixed
126
+ */
127
+ public function getCondition()
128
+ {
129
+ $currentDate = Mage::getModel('core/date')->date('Y-m-d');
130
+ $fromDate = substr($this->product->getNewsFromDate(), 0, 10);
131
+ $toDate = substr($this->product->getNewsToDate(), 0, 10);
132
+
133
+ $isNew = ($currentDate >= $fromDate && $currentDate <= $toDate) || ($fromDate == '' && $currentDate <= $toDate && $toDate != '') || ($fromDate != '' && $currentDate >= $fromDate && $toDate == '');
134
+
135
+ return ($isNew) ? 'new' : null;
136
+ }
137
+
138
+ /**
139
+ * Return Availability
140
+ *
141
+ * @return mixed
142
+ */
143
+ public function getAvailability()
144
+ {
145
+ $availability = 'out of stock';
146
+ $productStock = $this->product->getStockItem();
147
+ if (null != $productStock) {
148
+ if ($productStock->getIsInStock()) {
149
+ $availability = 'in stock';
150
+ }
151
+ }
152
+
153
+ return $availability;
154
+ }
155
+
156
+ /**
157
+ * Return Availability Date
158
+ *
159
+ * @return mixed
160
+ */
161
+ public function getAvailabilityDate()
162
+ {
163
+ return null;
164
+ }
165
+
166
+ /**
167
+ * Return Price
168
+ *
169
+ * @return mixed
170
+ */
171
+ public function getPrice()
172
+ {
173
+ return $this->product->getPrice();
174
+ }
175
+
176
+ /**
177
+ * Return Sale Price
178
+ *
179
+ * @return mixed
180
+ */
181
+ public function getSalePrice()
182
+ {
183
+ return $this->product->getFinalPrice();
184
+ }
185
+
186
+ /**
187
+ * Return Sale Price Effective Date
188
+ *
189
+ * @return mixed
190
+ */
191
+ public function getSalePriceEffectiveDate()
192
+ {
193
+ $salesPriceAvailabilityDates = null;
194
+
195
+ // si le produit à un prix et des dates de promotion
196
+ if (null != $this->product->getSpecialPrice() && null != $this->product->getSpecialFromDate(
197
+ ) && null != $this->product->getSpecialToDate()
198
+ ) {
199
+ $fromDate = new DateTime($this->product->getSpecialFromDate());
200
+ $toDate = new DateTime($this->product->getSpecialToDate());
201
+ $salesPriceAvailabilityDates = $fromDate->format(DateTime::ISO8601).'/'.$toDate->format(DateTime::ISO8601);
202
+ }
203
+
204
+ return $salesPriceAvailabilityDates;
205
+ }
206
+
207
+ /**
208
+ * Return Gtin
209
+ *
210
+ * @return mixed
211
+ */
212
+ public function getGtin()
213
+ {
214
+ return $this->product->getSku();
215
+ }
216
+
217
+ /**
218
+ * Return Brand
219
+ *
220
+ * @return mixed
221
+ */
222
+ public function getBrand()
223
+ {
224
+ $manufacturer = null;
225
+ if (null != $this->product->getManufacturer()) {
226
+ $manufacturer = $this->product->getResource()
227
+ ->getAttribute('manufacturer')
228
+ ->getSource()
229
+ ->getOptionText($this->product->getManufacturer());
230
+ }
231
+
232
+ return $manufacturer;
233
+ }
234
+
235
+ /**
236
+ * Return Mpn
237
+ *
238
+ * @return mixed
239
+ */
240
+ public function getMpn()
241
+ {
242
+ // Not available in Magento
243
+ return null;
244
+ }
245
+
246
+ /**
247
+ * Return Identifier Exists
248
+ *
249
+ * @return mixed
250
+ */
251
+ public function getIdentifierExists()
252
+ {
253
+ // Not available in Magento
254
+ return null;
255
+ }
256
+
257
+ /**
258
+ * Return Item Group Id
259
+ *
260
+ * @return mixed
261
+ */
262
+ public function getItemGroupId()
263
+ {
264
+ // Not available in Magento
265
+ return null;
266
+ }
267
+
268
+ /**
269
+ * Return Gender
270
+ *
271
+ * @return mixed
272
+ */
273
+ public function getGender()
274
+ {
275
+ $gender = null;
276
+ if (null != $this->product->getGender()) {
277
+ $gender = $this->product->getResource()
278
+ ->getAttribute('gender')
279
+ ->getSource()
280
+ ->getOptionText($this->product->getGender());
281
+ }
282
+
283
+ return $gender;
284
+ }
285
+
286
+ /**
287
+ * Return Age Group
288
+ *
289
+ * @return mixed
290
+ */
291
+ public function getAgeGroup()
292
+ {
293
+ // Not available in Magento
294
+ return null;
295
+ }
296
+
297
+ /**
298
+ * Return Color
299
+ *
300
+ * @return mixed
301
+ */
302
+ public function getColor()
303
+ {
304
+ $color = null;
305
+ if (null != $this->product->getColor()) {
306
+ $color = $this->product->getResource()
307
+ ->getAttribute('color')
308
+ ->getSource()
309
+ ->getOptionText($this->product->getColor());
310
+ }
311
+
312
+ return $color;
313
+ }
314
+
315
+ /**
316
+ * Return Size
317
+ *
318
+ * @return mixed
319
+ */
320
+ public function getSize()
321
+ {
322
+ $size = null;
323
+ if (null != $this->product->getSize()) {
324
+ $size = $this->product->getResource()
325
+ ->getAttribute('size')
326
+ ->getSource()
327
+ ->getOptionText($this->product->getSize());
328
+ }
329
+
330
+ return $size;
331
+ }
332
+
333
+ /**
334
+ * Return Shipping
335
+ *
336
+ * @return mixed
337
+ */
338
+ public function getShipping()
339
+ {
340
+ // Not implement because it's heavy treatment on Magento for each product.
341
+ return null;
342
+ }
343
+
344
+ /**
345
+ * Return Shipping Weight
346
+ *
347
+ * @return mixed
348
+ */
349
+ public function getShippingWeight()
350
+ {
351
+ return $this->product->getWeight();
352
+ }
353
+
354
+ /**
355
+ * Return GrossProfit
356
+ *
357
+ * @return mixed
358
+ */
359
+ public function getGrossProfit()
360
+ {
361
+ return $this->product->getProductProfit();
362
+ }
363
+
364
+ /**
365
+ * Return Gross Margin
366
+ *
367
+ * @return mixed
368
+ */
369
+ public function getGrossMargin()
370
+ {
371
+ $margin = null;
372
+ if (null != $this->product->getProductCost()) {
373
+ $margin = $this->product->getFinalPrice() - $this->product->getProductCost();
374
+ }
375
+
376
+ return $margin;
377
+ }
378
+
379
+
380
+ }
app/code/community/Steerfox/Plugins/lib/Samples/ModelAdapters/Shop.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins').'/lib/SteerfoxContainer.php';
23
+
24
+ class Steerfox_Plugins_Model_Adapter_Shop implements SteerfoxShopAdapterInterface
25
+ {
26
+ /**
27
+ * Store Magento.
28
+ *
29
+ * @var Mage_Core_Model_Store
30
+ */
31
+ private $shop;
32
+
33
+ public function __construct(Mage_Core_Model_Store $store)
34
+ {
35
+ $this->shop = $store;
36
+ }
37
+
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ public function getId()
42
+ {
43
+ return $this->shop->getId();
44
+ }
45
+
46
+ /**
47
+ * @inheritDoc
48
+ */
49
+ public function getUrl()
50
+ {
51
+ $url = Mage::app()->getStore($this->shop->getId())->getBaseUrl();
52
+
53
+ if (getenv('STEERFOX_API_DEV') &&
54
+ getenv('STEERFOX_API_USER') &&
55
+ getenv('STEERFOX_API_PWD')
56
+ ) {
57
+
58
+
59
+ $url = 'http://test.'.uniqid().'.com/';
60
+ //
61
+ // if(1== $this->shop->getId()){
62
+ // $url = 'http://www.madison.com';
63
+ // }else{
64
+ // $url = 'http://www.second.com';
65
+ // }
66
+ }
67
+
68
+ return $url;
69
+ }
70
+
71
+ /**
72
+ * @inheritDoc
73
+ */
74
+ public function getName()
75
+ {
76
+ return $this->shop->getGroup()->getName();
77
+ }
78
+
79
+ /**
80
+ * @inheritDoc
81
+ */
82
+ public function getLanguage()
83
+ {
84
+ return Mage::getStoreConfig('general/locale/code', $this->shop);
85
+ }
86
+
87
+ /**
88
+ * @inheritDoc
89
+ */
90
+ public function getLogo()
91
+ {
92
+ // Emulate front store env to get logo
93
+ $appEmulation = Mage::getSingleton('core/app_emulation');
94
+ $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($this->shop->getId());
95
+ $logoUrl = Mage::getDesign()->getSkinUrl().Mage::getStoreConfig('design/header/logo_src', $this->shop);
96
+ $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
97
+
98
+ return $logoUrl;
99
+ }
100
+
101
+ /**
102
+ * @inheritDoc
103
+ */
104
+ public function getCurrency()
105
+ {
106
+ return Mage::app()->getStore($this->shop->getId())->getCurrentCurrencyCode();
107
+ }
108
+ }
app/code/community/Steerfox/Plugins/lib/Samples/ModelAdapters/Tools.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins').'/lib/SteerfoxContainer.php';
23
+
24
+ /**
25
+ * Tool adapter.
26
+ */
27
+ class Steerfox_Plugins_Model_Adapter_Tools implements SteerfoxToolsAdapterInterface
28
+ {
29
+ /**
30
+ * Encode as json.
31
+ *
32
+ * @param mixed $value Value to encode.
33
+ *
34
+ * @return string
35
+ */
36
+ public function jsonEncode($value)
37
+ {
38
+ return json_encode($value);
39
+ }
40
+
41
+ /**
42
+ * Decode JSON string
43
+ *
44
+ * @param string $json Json value to decode
45
+ * @param bool $assoc Return an assoc array
46
+ *
47
+ * @return mixed
48
+ */
49
+ public function jsonDecode($json, $assoc = false)
50
+ {
51
+ return json_decode($json, $assoc);
52
+ }
53
+
54
+ /**
55
+ * Return sting length.
56
+ *
57
+ * @param string $string
58
+ *
59
+ * @return bool|int
60
+ */
61
+ public function strlen($string)
62
+ {
63
+ return strlen($string);
64
+ }
65
+
66
+ /**
67
+ * Return part of string.
68
+ *
69
+ * @param string $string Source string.
70
+ * @param int $start Start position.
71
+ * @param int|bool $length Length.
72
+ *
73
+ * @return mixed
74
+ */
75
+ public function substr($string, $start, $length = false)
76
+ {
77
+ return substr($string, $start, $length);
78
+ }
79
+
80
+ /**
81
+ * Return content file
82
+ *
83
+ * @param string $url URL.
84
+ * @param bool $useIncludePath Use php include path.
85
+ * @param null $streamContext Stream context
86
+ *
87
+ * @return mixed
88
+ */
89
+ public function fileGetContents($url, $useIncludePath = false, $streamContext = null)
90
+ {
91
+ return file_get_contents($url, $useIncludePath, $streamContext);
92
+ }
93
+
94
+ /**
95
+ * Save export file on disk
96
+ *
97
+ * @param $filename File Name
98
+ * @param $fileContent File Content
99
+ *
100
+ * @return void
101
+ */
102
+ public function saveExportFile($filename, $fileContent)
103
+ {
104
+ $folderPath = Mage::getBaseDir('var').DS.Mage::getStoreConfig('steerfox_plugins/export/folder_name');
105
+ $file = new Varien_Io_File();
106
+
107
+ //Si le dossier n'existe pas on le crée
108
+ if (!is_dir($folderPath)) {
109
+ $folderCreate = $file->mkdir($folderPath);
110
+ if (!$folderCreate) {
111
+ Mage::throwException('Can\'t create folder');
112
+ }
113
+ }
114
+
115
+ $filePath = $folderPath.DS.$filename;
116
+
117
+ //Si un ancien fichier existe on le supprime.
118
+ if (file_exists($filePath)) {
119
+ unlink($filePath);
120
+ }
121
+
122
+ //On écrit le fichier sur disque.
123
+ if (!$file->write($filePath, $fileContent)) {
124
+ Mage::throwException('Can\'t create file');
125
+ }
126
+ }
127
+
128
+
129
+ }
app/code/community/Steerfox/Plugins/lib/Samples/ServiceAdapters/Log.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins').'/lib/SteerfoxContainer.php';
23
+
24
+ class Steerfox_Plugins_Model_Adapter_Service_Log extends SteerfoxAbstractLoggerService
25
+ {
26
+ /**
27
+ * Return all logs.
28
+ *
29
+ * @return array
30
+ */
31
+ public function getAllLogs()
32
+ {
33
+ $logList = array();
34
+ $logCollection = Mage::getModel('steerfox_plugins/log')->getCollection();
35
+
36
+ foreach ($logCollection as $log) {
37
+ $logInfo = array(
38
+ 'action' => $log->getAction(),
39
+ 'type' => $log->getType(),
40
+ 'feed_id' => $log->getFeedId(),
41
+ 'shop' => $log->getShop(),
42
+ 'locale' => $log->getLocale(),
43
+ 'message' => json_decode($log->getMessage()),
44
+ 'created_at' => $log->getCreatedAt(),
45
+ 'created_at_zone' => date('O'),
46
+ );
47
+ $logList[] = $logInfo;
48
+ }
49
+
50
+ return $logList;
51
+ }
52
+
53
+ /**
54
+ * @inheritDoc
55
+ */
56
+ protected function getPluginVersion()
57
+ {
58
+ return (string)Mage::helper('steerfox_plugins')->getExtensionVersion();
59
+ }
60
+
61
+ /**
62
+ * @inheritDoc
63
+ */
64
+ protected function getCmsVersion()
65
+ {
66
+ return Mage::getVersion();
67
+ }
68
+
69
+
70
+ /**
71
+ * Add a log in database.
72
+ *
73
+ * @param string $message The message.
74
+ * @param string $action The action.
75
+ * @param int $level The level.
76
+ */
77
+ public function addLog($message, $action, $level)
78
+ {
79
+ $log = Mage::getModel('steerfox_plugins/log');
80
+ $log->setData(
81
+ array(
82
+ 'action' => $action,
83
+ 'type' => $level,
84
+ 'message' => $message,
85
+ )
86
+ )->setOrigData()->save();
87
+ }
88
+ }
app/code/community/Steerfox/Plugins/lib/Samples/ServiceAdapters/Shop.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ require_once Mage::getModuleDir('', 'Steerfox_Plugins').'/lib/SteerfoxContainer.php';
23
+
24
+ /**
25
+ * Tool adapter.
26
+ */
27
+ class Steerfox_Plugins_Model_Adapter_Service_Shop extends SteerfoxAbstractShopService
28
+ {
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ public function getShops()
33
+ {
34
+ $websiteList = Mage::app()->getWebsites();
35
+ $shopList = array();
36
+
37
+ foreach ($websiteList as $website) {
38
+ $shopList[] = new Steerfox_Plugins_Model_Adapter_Shop($website->getDefaultStore());
39
+ }
40
+
41
+ return $shopList;
42
+ }
43
+
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ public function getMainShop()
48
+ {
49
+ $websiteList = Mage::app()->getWebsites();
50
+ //On récupère le premier webstite
51
+ $websites = array_values($websiteList);
52
+ $website = $websites[0];
53
+
54
+ // on récupère son premier store
55
+ $store = $website->getDefaultStore();
56
+
57
+ return new Steerfox_Plugins_Model_Adapter_Shop($store);
58
+ }
59
+
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ public function getCurrentShop()
64
+ {
65
+ return new Steerfox_Plugins_Model_Adapter_Shop(Mage::app()->getStore());
66
+ }
67
+
68
+ /**
69
+ * Return current shop.
70
+ *
71
+ * @return SteerfoxProductAdapterInterface[]
72
+ */
73
+ public function getProductsToExport(SteerfoxShopAdapterInterface $shop)
74
+ {
75
+ //On charge les produits à exporter.
76
+ $steerfoxProductCollection = Mage::getModel('steerfox_plugins/product')->getCollection();
77
+ $steerfoxProductCollection->addFilter('active', 1);
78
+ $steerfoxProductCollection->addFilter('id_shop', $shop->getId());
79
+
80
+ $productsToExport = array();
81
+
82
+ foreach ($steerfoxProductCollection as $steerfoxProduct) {
83
+ $productsToExport[] = new Steerfox_Plugins_Model_Adapter_Product($steerfoxProduct);
84
+ }
85
+
86
+ return $productsToExport;
87
+ }
88
+
89
+
90
+ }
app/code/community/Steerfox/Plugins/lib/Samples/conf.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!--
3
+ ~ Copyright 2015 SteerFox SAS.
4
+ ~
5
+ ~ Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ ~ not use this file except in compliance with the License. You may obtain
7
+ ~ a copy of the License at
8
+ ~
9
+ ~ http://www.apache.org/licenses/LICENSE-2.0
10
+ ~
11
+ ~ Unless required by applicable law or agreed to in writing, software
12
+ ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ ~ License for the specific language governing permissions and limitations
15
+ ~ under the License.
16
+ ~
17
+ ~ @author SteerFox <tech@steerfox.com>
18
+ ~ @copyright 2015 SteerFox SAS
19
+ ~ @license http://www.apache.org/licenses/LICENSE-2.0
20
+ -->
21
+
22
+ <container>
23
+ <parameters>
24
+ <!--Adapters-->
25
+ <parameter id="configuration_class">Steerfox_Plugins_Model_Adapter_Configuration</parameter>
26
+ <parameter id="shop_service_class">Steerfox_Plugins_Model_Adapter_Service_Shop</parameter>
27
+ <parameter id="log_service_class">Steerfox_Plugins_Model_Adapter_Service_Log</parameter>
28
+ <parameter id="shop_class">Steerfox_Plugins_Model_Adapter_Shop</parameter>
29
+ <parameter id="tools_service_class">Steerfox_Plugins_Model_Adapter_Tools</parameter>
30
+
31
+ <!--Core Steerfox-->
32
+ <parameter id="api_service_class">SteerfoxApiService</parameter>
33
+ <parameter id="export_service_class">SteerfoxExportService</parameter>
34
+ </parameters>
35
+ <services>
36
+ <service id="config" class="SteerfoxConfigurationService">
37
+ <argument>%configuration_class%</argument>
38
+ </service>
39
+ <service id="logger" class="%log_service_class%">
40
+ </service>
41
+ <service id="api" class="%api_service_class%">
42
+ </service>
43
+ <service id="export" class="%export_service_class%">
44
+ </service>
45
+ <service id="shop" class="%shop_service_class%">
46
+ <argument>%shop_class%</argument>
47
+ </service>
48
+ <service id="tools" class="%tools_service_class%"/>
49
+ </services>
50
+ </container>
app/code/community/Steerfox/Plugins/lib/SteerfoxContainer.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 SteerFox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author SteerFox <tech@steerfox.com>
18
+ * @copyright 2015 SteerFox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ require_once dirname(__FILE__).'/Exceptions/SteerfoxConnectorException.php';
23
+ require_once dirname(__FILE__).'/Exceptions/SteerfoxException.php';
24
+ require_once dirname(__FILE__).'/Logger/SteerfoxAbstractLoggerService.php';
25
+ require_once dirname(__FILE__).'/Api/Connectors/SteerfoxAbstractConnector.php';
26
+ require_once dirname(__FILE__).'/Api/Connectors/SteerfoxCurlConnector.php';
27
+ require_once dirname(__FILE__).'/Api/Connectors/SteerfoxFopenConnector.php';
28
+ require_once dirname(__FILE__).'/Api/SteerfoxApiService.php';
29
+ require_once dirname(__FILE__).'/Export/SteerfoxExportService.php';
30
+ require_once dirname(__FILE__).'/Export/Model/SteerfoxProductExporter.php';
31
+ require_once dirname(__FILE__).'/Configuration/SteerfoxConfigurationInterface.php';
32
+ require_once dirname(__FILE__).'/Configuration/SteerfoxConfigurationService.php';
33
+ require_once dirname(__FILE__).'/Model/SteerfoxShopAdapterInterface.php';
34
+ require_once dirname(__FILE__).'/Model/SteerfoxAbstractShopService.php';
35
+ require_once dirname(__FILE__).'/Model/SteerfoxToolsAdapterInterface.php';
36
+ require_once dirname(__FILE__).'/Model/SteerfoxProductAdapterInterface.php';
37
+
38
+
39
+ /**
40
+ * SteerfoxContainer.
41
+ */
42
+ class SteerfoxContainer
43
+ {
44
+ /**
45
+ * Instance.
46
+ *
47
+ * @var SteerfoxContainer
48
+ */
49
+ protected static $instance;
50
+
51
+ /**
52
+ * Active services
53
+ * @var array
54
+ */
55
+ protected $services;
56
+
57
+ /**
58
+ * SteerfoxContainer constructor.
59
+ *
60
+ * @param string $configFile XML configuration file.
61
+ *
62
+ * @throws SteerfoxException
63
+ */
64
+ final private function __construct($configFile)
65
+ {
66
+ $this->services = array();
67
+ if (file_exists($configFile) && is_readable($configFile)) {
68
+ $xml = simplexml_load_file($configFile);
69
+ $this->loadServices($xml, $this->loadParameters($xml));
70
+ } else {
71
+ throw new SteerfoxException('XML configuration doesn\'t exist or isn\t readable');
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Create instance from xml file.
77
+ *
78
+ * @param string $configFile XML configuration file.
79
+ *
80
+ * @return SteerfoxContainer
81
+ */
82
+ public static function createInstance($configFile)
83
+ {
84
+ self::$instance = new SteerfoxContainer($configFile);
85
+
86
+ return self::$instance;
87
+ }
88
+
89
+ /**
90
+ * Return created instance.
91
+ *
92
+ * @return SteerfoxContainer
93
+ *
94
+ * @throws SteerfoxException
95
+ */
96
+ public static function getInstance()
97
+ {
98
+ if (null === self::$instance) {
99
+ throw new SteerfoxException('SteerfoxContainer was not instanciated');
100
+ }
101
+
102
+ return self::$instance;
103
+ }
104
+
105
+ /**
106
+ * Return a service.
107
+ *
108
+ * @param string $serviceName The service name.
109
+ *
110
+ * @return mixed
111
+ */
112
+ public function get($serviceName)
113
+ {
114
+ if (array_key_exists($serviceName, $this->services)) {
115
+ return $this->services[$serviceName];
116
+ } else {
117
+ throw new SteerfoxException('Invalid service name : '.$serviceName);
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Load parameters from xml.
123
+ *
124
+ * @param SimpleXMLElement $xml xml
125
+ *
126
+ * @return array
127
+ */
128
+ protected function loadParameters($xml)
129
+ {
130
+ $xmlParameters = $xml->xpath('/container/parameters/parameter');
131
+ $parameters = array();
132
+ if (is_array($xmlParameters)) {
133
+ foreach ($xmlParameters as $parameter) {
134
+ $parameters[(string)$parameter->attributes()->{'id'}] = (string)$parameter;
135
+ if (file_exists(dirname(__FILE__).'/../libadapters/'.$parameter.'.php')) {
136
+ /** @noinspection PhpIncludeInspection */
137
+ require_once dirname(__FILE__).'/../libadapters/'.$parameter.'.php';
138
+ }
139
+ }
140
+ }
141
+
142
+ return $parameters;
143
+ }
144
+
145
+ /**
146
+ * Load services from xml.
147
+ *
148
+ * @param SimpleXMLElement $xml xml.
149
+ * @param array $parameters Services parameters.
150
+ *
151
+ * @throws SteerfoxException
152
+ */
153
+ protected function loadServices($xml, $parameters)
154
+ {
155
+ $services = $xml->xpath('/container/services/service');
156
+ if (is_array($services)) {
157
+ /** @var SimpleXMLElement $service */
158
+ foreach ($services as $service) {
159
+ $class = (string)$service->attributes()->{'class'};
160
+ $isParameter = preg_match('/%(.*)%/', $class, $matches);
161
+ if ($isParameter) {
162
+ if (array_key_exists($matches[1], $parameters)) {
163
+ $class = $parameters[$matches[1]];
164
+ } else {
165
+ throw new SteerfoxException('Invalid service class : '.$class);
166
+ }
167
+ }
168
+ if (file_exists(dirname(__FILE__).'/../libadapters/'.$class.'.php')) {
169
+ /** @noinspection PhpIncludeInspection */
170
+ require_once dirname(__FILE__).'/../libadapters/'.$class.'.php';
171
+ }
172
+ $arguments = array();
173
+ foreach ($service->children() as $child) {
174
+ $isParameter = preg_match('/%(.*)%/', (string)$child, $matches);
175
+ if ($isParameter) {
176
+ if (array_key_exists($matches[1], $parameters)) {
177
+ $arguments[] = $parameters[$matches[1]];
178
+ } else {
179
+ throw new SteerfoxException('Invalid argment : '.$child);
180
+ }
181
+ }
182
+ }
183
+ $reflexion = new ReflectionClass($class);
184
+ if (count($arguments) > 0) {
185
+ $this->services[(string)$service->attributes()->{'id'}]
186
+ = $reflexion->newInstanceArgs($arguments);
187
+ } else {
188
+ $this->services[(string)$service->attributes()->{'id'}]
189
+ = $reflexion->newInstance();
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
app/code/community/Steerfox/Plugins/sql/steerfox_plugins_setup/install-0.1.0.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ // Open
23
+ /**
24
+ * @var $installer Mage_Core_Model_Resource_Setup
25
+ */
26
+ $installer = $this;
27
+ $installer->startSetup();
28
+ $sql = array();
29
+
30
+ // steerfox_products table : list of products for flow export
31
+ $table = $installer->getConnection()
32
+ ->newTable($installer->getTable('steerfox_plugins/product'))
33
+ ->addColumn(
34
+ 'entity_id',
35
+ Varien_Db_Ddl_Table::TYPE_INTEGER,
36
+ null,
37
+ array(
38
+ 'unsigned' => true,
39
+ 'identity' => true,
40
+ 'nullable' => false,
41
+ 'primary' => true,
42
+ ),
43
+ 'Entity Id'
44
+ )
45
+ ->addColumn(
46
+ 'id_product',
47
+ Varien_Db_Ddl_Table::TYPE_INTEGER,
48
+ null,
49
+ array(
50
+ 'nullable' => false,
51
+ 'unsigned' => true,
52
+ ),
53
+ 'Id of shared product'
54
+ )
55
+ ->addColumn(
56
+ 'id_lang',
57
+ Varien_Db_Ddl_Table::TYPE_INTEGER,
58
+ null,
59
+ array(
60
+ 'nullable' => true,
61
+ 'unsigned' => true,
62
+ 'default' => null,
63
+ ),
64
+ 'Share language'
65
+ )
66
+ ->addColumn(
67
+ 'id_shop',
68
+ Varien_Db_Ddl_Table::TYPE_INTEGER,
69
+ null,
70
+ array(
71
+ 'nullable' => false,
72
+ 'unsigned' => true,
73
+ 'default' => 1,
74
+ ),
75
+ 'Shop id'
76
+ )
77
+ ->addColumn(
78
+ 'active',
79
+ Varien_Db_Ddl_Table::TYPE_BOOLEAN,
80
+ null,
81
+ array(
82
+ 'nullable' => false,
83
+ 'default' => true,
84
+ ),
85
+ 'Set share active or not'
86
+ )
87
+ ->addColumn(
88
+ 'created_at',
89
+ Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
90
+ null,
91
+ array(
92
+ 'nullable' => false,
93
+ 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT,
94
+ ),
95
+ 'Creation time'
96
+ )
97
+ ->addColumn(
98
+ 'updated_at',
99
+ Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
100
+ null,
101
+ array(
102
+ 'nullable' => false,
103
+ ),
104
+ 'Update time'
105
+ )
106
+ ->addIndex(
107
+ $installer->getIdxName(
108
+ $installer->getTable('steerfox_plugins/product'),
109
+ array('id_product'),
110
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
111
+ ),
112
+ array('id_product'),
113
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
114
+ )
115
+ ->addIndex(
116
+ $installer->getIdxName(
117
+ $installer->getTable('steerfox_plugins/product'),
118
+ array('id_shop'),
119
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
120
+ ),
121
+ array('id_shop'),
122
+ Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
123
+ )
124
+ ->setComment('Steerfox product publish list');
125
+
126
+ $installer->getConnection()->createTable($table);
127
+
128
+ // steerfox_logs table : module logs
129
+
130
+ $table = $installer->getConnection()
131
+ ->newTable($installer->getTable('steerfox_plugins/log'))
132
+ ->addColumn(
133
+ 'id_log',
134
+ Varien_Db_Ddl_Table::TYPE_INTEGER,
135
+ null,
136
+ array(
137
+ 'unsigned' => true,
138
+ 'identity' => true,
139
+ 'nullable' => false,
140
+ 'primary' => true,
141
+ ),
142
+ 'Entity Id'
143
+ )
144
+ ->addColumn(
145
+ 'action',
146
+ Varien_Db_Ddl_Table::TYPE_VARCHAR,
147
+ 255,
148
+ array(
149
+ 'nullable' => true,
150
+ 'default' => true,
151
+ ),
152
+ 'Action'
153
+ )
154
+ ->addColumn(
155
+ 'type',
156
+ Varien_Db_Ddl_Table::TYPE_VARCHAR,
157
+ 20,
158
+ array(
159
+ 'nullable' => false,
160
+ ),
161
+ 'Log type'
162
+ )
163
+ ->addColumn(
164
+ 'feed_id',
165
+ Varien_Db_Ddl_Table::TYPE_INTEGER,
166
+ null,
167
+ array(
168
+ 'unsigned' => true,
169
+ 'nullable' => true,
170
+ 'default' => null,
171
+ ),
172
+ 'Feed'
173
+ )
174
+ ->addColumn(
175
+ 'shop',
176
+ Varien_Db_Ddl_Table::TYPE_VARCHAR,
177
+ 255,
178
+ array(
179
+ 'nullable' => true,
180
+ 'default' => null,
181
+ ),
182
+ 'Shop'
183
+ )
184
+ ->addColumn(
185
+ 'locale',
186
+ Varien_Db_Ddl_Table::TYPE_VARCHAR,
187
+ 5,
188
+ array(
189
+ 'nullable' => true,
190
+ 'default' => null,
191
+ ),
192
+ 'Locale'
193
+ )
194
+ ->addColumn(
195
+ 'message',
196
+ Varien_Db_Ddl_Table::TYPE_TEXT,
197
+ null,
198
+ array(
199
+ 'nullable' => false,
200
+ ),
201
+ 'Message'
202
+ )
203
+ ->addColumn(
204
+ 'created_at',
205
+ Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
206
+ null,
207
+ array(
208
+ 'nullable' => false,
209
+ 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT,
210
+ ),
211
+ 'Creation time'
212
+ )
213
+ ->setComment('Steerfox logs');
214
+
215
+ $installer->getConnection()->createTable($table);
216
+
217
+ $installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
218
+
219
+ $installer->addAttribute(
220
+ 'catalog_product',
221
+ 'product_profit',
222
+ array(
223
+ 'group' => 'Prices',
224
+ 'type' => 'decimal',
225
+ 'label' => 'Product Profit',
226
+ 'class' => '',
227
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
228
+ 'backend' => 'steerfox_plugins/entity_attribute_backend_profit',
229
+ 'visible' => true,
230
+ 'required' => false,
231
+ 'user_defined' => false,
232
+ // this is what determines if it will be a system attribute or not
233
+ 'default' => '',
234
+ 'searchable' => false,
235
+ 'filterable' => false,
236
+ 'comparable' => false,
237
+ 'visible_on_front' => false,
238
+ 'unique' => false,
239
+ )
240
+ );
241
+
242
+ $installer->addAttribute(
243
+ 'catalog_product',
244
+ 'product_profit_ratio',
245
+ array(
246
+ 'group' => 'Prices',
247
+ 'type' => 'decimal',
248
+ 'label' => 'Product Profit Ratio',
249
+ 'class' => '',
250
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
251
+ 'backend' => 'steerfox_plugins/entity_attribute_backend_profit_ratio',
252
+ 'visible' => true,
253
+ 'required' => false,
254
+ 'user_defined' => false,
255
+ // this is what determines if it will be a system attribute or not
256
+ 'default' => '',
257
+ 'searchable' => false,
258
+ 'filterable' => false,
259
+ 'comparable' => false,
260
+ 'visible_on_front' => false,
261
+ 'unique' => false,
262
+ )
263
+ );
264
+
265
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/steerfox_plugins.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_steerfoxproduct_index>
4
+ <reference name="content">
5
+ <block type="steerfox_plugins/adminhtml_steerfoxproduct" name="steerfoxproduct"/>
6
+ </reference>
7
+ </adminhtml_steerfoxproduct_index>
8
+ <adminhtml_steerfoxproduct_grid>
9
+ <block type="steerfox_plugins/adminhtml_steerfoxproduct_grid" name="root"/>
10
+ </adminhtml_steerfoxproduct_grid>
11
+ <default>
12
+ <reference name="head">
13
+ <action method="addCss">
14
+ <name>steerfox/steerfox.css</name>
15
+ </action>
16
+ <action method="addItem">
17
+ <type>skin_js</type>
18
+ <name>steerfox/steerfox.js</name>
19
+ </action>
20
+ </reference>
21
+ </default>
22
+ </layout>
app/design/adminhtml/default/default/template/steerfox/plugins/dashboard.phtml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+ $steerfox_helper = Mage::helper('steerfox_plugins');
22
+ ?>
23
+ <div class="panel steerfox-panel">
24
+ <div class="row">
25
+ <div class="col-xs-12 col-sm-6 col-md-4">
26
+ <div class="row">
27
+ <div class="col-xs-12 text-center">
28
+ <img class="img-responsive" style="margin:auto; max-width: 100%"
29
+ src="<?php echo $this->getSkinUrl('images/steerfox/steerfox-logo.png'); ?>"/>
30
+ </div>
31
+
32
+ <div class="col-xs-12 text-center">
33
+ <hr/>
34
+ <h2><?php echo $this->__('Configuration dashboard'); ?></h2>
35
+ <h4>
36
+ <?php echo $this->__('Configuration checklist for your Steerfox module.'); ?>
37
+ </h4>
38
+ </div>
39
+ </div>
40
+ </div>
41
+
42
+ <div class="col-xs-12 col-sm-6 col-md-8">
43
+ <?php if (isset($checklist) && !empty($checklist)) { ?>
44
+ <div class="table-responsive">
45
+ <table class="table table-striped table-steerfoxcheck" cellpadding="0" cellspacing="0">
46
+ <tr>
47
+ <th><?php echo $this->__('Setting indicator'); ?></th>
48
+ <th class="text-center"><?php echo $this->__('Status'); ?></th>
49
+ </tr>
50
+ <?php foreach ($checklist as $key => $value) { ?>
51
+ <tr>
52
+ <td><?php print $value['title'] ?></td>
53
+ <td class="text-center">
54
+ <?php if (isset($value['state']) && $value['state'] == true) : ?>
55
+ <img src="<?php echo $this->getSkinUrl('images/success-msg.png'); ?>" alt="<?php echo $this->__('Enabled'); ?>" />
56
+ <?php else : ?>
57
+ <img src="<?php echo $this->getSkinUrl('images/error-msg.png'); ?>" alt="<?php echo $this->__('Disabled'); ?>" />
58
+ <?php endif; ?>
59
+ <?php /*/ ?>
60
+ <img src="../img/admin/{if isset($value['state']) && $value['state'] == true}enabled.gif{else}disabled.gif{/if}"
61
+ alt="{if $tr.$key}<?php echo $this->__('Enabled'); ?>{else}<?php echo $this->__('Disabled'); ?>{/if}"
62
+ title="{if $tr.$key}<?php echo $this->__('Enabled'); ?>{else}<?php echo $this->__('Disabled'); ?>{/if}"/>
63
+ <?php /**/ ?>
64
+ </td>
65
+ </tr>
66
+ <?php } ?>
67
+ </table>
68
+ </div>
69
+ <?php } else { ?>
70
+ <i>
71
+ <?php echo $this->__('No checklist available for the moment.'); ?><br/>
72
+ <?php echo $this->__('If the problem persist, please contact Steerfox : '); ?>
73
+ <strong><?php echo $this->__('contact@steerfox.com'); ?></strong>
74
+ </i>
75
+ <?php } ?>
76
+
77
+ <div class="row">
78
+ <div class="col-xs-12 text-center mtop-20">
79
+ <a href="<?php print $steerfox_helper->getDashboardAction(); ?>" target="_blank" role="button"
80
+ class="btn btn-lg btn-primary btn-steerfox"><?php echo $this->__('My ads control panel'); ?></a>
81
+ </div>
82
+ </div>
83
+ <div class="row">
84
+ <div class="col-xs-12 text-center mtop-20">
85
+ <hr />
86
+ <h4><?php echo $this->__('To access the magento module configuration you have to be in a website context.'); ?></h4>
87
+ </div>
88
+ </div>
89
+ </div>
90
+ </div>
91
+ </div>
app/design/adminhtml/default/default/template/steerfox/plugins/welcome.phtml ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Steerfox SAS.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ *
17
+ * @author Steerfox <tech@steerfox.com>
18
+ * @copyright 2015 Steerfox SAS
19
+ * @license http://www.apache.org/licenses/LICENSE-2.0
20
+ */
21
+
22
+ $steerfox_helper = Mage::helper('steerfox_plugins');
23
+ ?>
24
+ <div class="panel steerfox-panel">
25
+ <div class="row">
26
+ <div class="col-xs-12 col-sm-12 col-md-7">
27
+ <div class="row">
28
+ <div class="col-xs-12 text-center">
29
+ <img src="<?php echo $this->getSkinUrl('images/steerfox/steerfox-logo.png'); ?>"
30
+ style="margin:auto; max-width: 100%"/>
31
+ </div>
32
+ <div class="col-xs-12 text-center">
33
+ <h2><?php echo $this->__('The Easiest Buying Traffic Solution on the Market'); ?></h2>
34
+ <h4>
35
+ <?php echo $this->__('Our buying Robot connects you to multiple traffic sources'); ?>
36
+ <br/>
37
+ <?php echo $this->__(
38
+ 'It determines the optimal combination of assets to catch shoppers to your online shopping'
39
+ ); ?>
40
+ </h4>
41
+ </div>
42
+ </div>
43
+
44
+ <hr/>
45
+
46
+ <div class="row">
47
+ <div class="col-xs-12 col-sm-12 col-md-4 text-left">
48
+ <div class="row">
49
+ <div class="col-xs-2 text-right"><h4 class="icon-steerfox-container"><img
50
+ src="<?php echo $this->getSkinUrl('images/steerfox/icon-file-text.png'); ?>"
51
+ class="img-responsive"/></h4></div>
52
+ <div class="col-xs-10">
53
+ <h4><?php echo $this->__('Product catalog'); ?></h4>
54
+
55
+ <p class="text-justify"><?php echo $this->__(
56
+ 'The strength of our solutions is to generate campaigns automatically from your product catalog. Our robots analyze its composition and your competitors, then they generate the best advertising campaigns with suitable ads : texts or banners.'
57
+ ); ?></p>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ <div class="col-xs-12 col-sm-12 col-md-4 text-left">
62
+ <div class="row">
63
+ <div class="col-xs-2 text-right"><h4 class="icon-steerfox-container"><img
64
+ src="<?php echo $this->getSkinUrl('images/steerfox/icon-road.png'); ?>"
65
+ class="img-responsive"/></h4></div>
66
+ <div class="col-xs-10">
67
+ <h4><?php echo $this->__('Generate traffic'); ?></h4>
68
+
69
+ <p class="text-justify"><?php echo $this->__(
70
+ 'You choose your budget at anytime depending on the wanted traffic for your shop. Whatever your budget, no commitment is required. Our robots boost sales of your e-commerce.'
71
+ ); ?></p>
72
+ </div>
73
+ </div>
74
+ </div>
75
+ <div class="col-xs-12 col-sm-12 col-md-4 text-left">
76
+ <div class="row">
77
+ <div class="col-xs-2 text-right"><h4 class="icon-steerfox-container"><img
78
+ src="<?php echo $this->getSkinUrl('images/steerfox/icon-globe.png'); ?>"
79
+ class="img-responsive"/></h4></div>
80
+ <div class="col-xs-10">
81
+ <h4><?php echo $this->__('Multiples sources'); ?></h4>
82
+
83
+ <p class="text-justify"><?php echo $this->__(
84
+ 'Our buying robot connects to multiple sources of traffic (Google Adwords, Google Shopping, Bing Ads, Amazon Product Ads, Facebook Product Ads...). It will create, manage and optimize your campaigns in permanent interaction with the back office of suppliers. SteerFox provides a report of the results, consolidated on a single page.'
85
+ ); ?></p>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ </div>
90
+
91
+ <hr/>
92
+
93
+ <div class="row">
94
+ <div class="col-xs-12 text-center">
95
+ <a href="<?php print $steerfox_helper->getRegisterAction(); ?>" data-toggle="collapse" role="button"
96
+ class="btn btn-default btn-steerfox"
97
+ id=""><?php echo $this->__('Start the test'); ?></a>
98
+ <a href="#steerfox_forms" data-toggle="collapse" role="button" class="btn btn-default btn-steerfox"
99
+ id="already_customer"><?php echo $this->__('Advanced Settings'); ?></a>
100
+ </div>
101
+ </div>
102
+ </div>
103
+
104
+ <div class="col-xs-12 col-sm-12 col-md-5">
105
+ <img class="img-responsive"
106
+ src="<?php echo $this->getSkinUrl('images/steerfox/steerfox-reporting.png'); ?>"/>
107
+ </div>
108
+ </div>
109
+ </div>
app/design/frontend/base/default/layout/steerfox_plugins.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head" before="-">
5
+ <block type="steerfox_plugins/tags" name="steerfox_fb_head_tags" as="steerfox_fb_head_tags" template="steerfox_plugins/fb_header_tag.phtml"/>
6
+ <block type="steerfox_plugins/tags" name="steerfox_bing_head_tags" as="steerfox_bing_head_tags" template="steerfox_plugins/bing_header_tag.phtml"/>
7
+ <block type="steerfox_plugins/tags" name="steerfox_gtm" as="steerfox_gtm" template="steerfox_plugins/gtm_tag.phtml"/>
8
+ <block type="steerfox_plugins/tags" name="steerfox_gsv" as="steerfox_gsv" template="steerfox_plugins/gsv_tag.phtml"/>
9
+ <!-- TODO retrait du foxtag de la version -->
10
+ <!--<block type="steerfox_plugins/tags" name="steerfox_foxtag_head_tags" as="steerfox_foxtag_head_tags" template="steerfox_plugins/foxtag_header_tag.phtml"/>-->
11
+ <!-- END TODO -->
12
+ </reference>
13
+ <reference name="before_body_end">
14
+ <block type="steerfox_plugins/tags" name="steerfox_fb_order_tags" as="steerfox_fb_order_tags" template="steerfox_plugins/fb_order_tag.phtml" />
15
+ <block type="steerfox_plugins/tags" name="steerfox_bing_order_tags" as="steerfox_bing_order_tags" template="steerfox_plugins/bing_order_tag.phtml" />
16
+ <block type="steerfox_plugins/tags" name="steerfox_adwords_order_tags" as="steerfox_adwords_order_tags" template="steerfox_plugins/adwords_order_tag.phtml" />
17
+ <!-- TODO retrait du foxtag de la version -->
18
+ <!--<block type="steerfox_plugins/tags" name="steerfox_foxtag_order_tags" as="steerfox_foxtag_order_tags" template="steerfox_plugins/foxtag_order_tag.phtml" />-->
19
+ <!-- END TODO -->
20
+ </reference>
21
+ </default>
22
+ </layout>
app/design/frontend/base/default/template/steerfox_plugins/adwords_order_tag.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $googleAdwordsId = $this->getGoogleAdwordsId();
3
+ $googleAdwordsLabel = $this->getGoogleAdwordsLabel();
4
+ $orders = $this->getOrders();
5
+
6
+ if (!empty($googleAdwordsId) && !empty($googleAdwordsLabel) && !empty($orders)) :
7
+ ?>
8
+ <!-- Adwords conversion -->
9
+ <?php foreach ($orders as $order) : ?>
10
+ <script type="text/javascript">
11
+ /* <![CDATA[ */
12
+ var google_conversion_id = "<?php echo $googleAdwordsId; ?>";
13
+ var google_conversion_language = "<?php $this->getLocaleCode(); ?>";
14
+ var google_conversion_format = "3";
15
+ var google_conversion_color = "ffffff";
16
+ var google_conversion_label = "<?php echo $googleAdwordsLabel; ?>";
17
+ var google_conversion_value = "<?php echo $this->getConvertionAmount($order); ?>";
18
+ var google_conversion_currency = "<?php echo $order->getOrderCurrencyCode(); ?>";
19
+ /* ]]> */
20
+ </script>
21
+ <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script>
22
+ <noscript>
23
+ <img height=1 width=1 border=0 src="//www.googleadservices.com/pagead/conversion/<?php echo $googleAdwordsId; ?>/?value=<?php echo $this->getConvertionAmount($order); ?>&conversion_currency=<?php echo $order->getOrderCurrencyCode(); ?>&label=<?php echo $googleAdwordsLabel; ?>&script=0">
24
+ </noscript>
25
+ <?php endforeach; ?>
26
+ <?php endif; ?>
app/design/frontend/base/default/template/steerfox_plugins/bing_header_tag.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- Bing tracking -->
2
+ <?php
3
+ $bingId = $this->getBingId();
4
+ if (!empty($bingId)) : ?>
5
+ <!--suppress JSUnresolvedFunction -->
6
+ <!--suppress CommaExpressionJS -->
7
+ <script>
8
+ (function (w, d, t, r, u) {
9
+ var f, n, i;
10
+ w[u] = w[u] || [], f = function () {
11
+ var o = {ti: "<?php echo $bingId; ?>"};
12
+ o.q = w[u], w[u] = new UET(o), w[u].push("pageLoad")
13
+ }, n = d.createElement(t), n.src = r, n.async = 1,
14
+ n.onload = n.onreadystatechange = function () {
15
+ var s = this.readyState;
16
+ s && s !== "loaded" && s !== "complete" || (f(), n.onload = n.onreadystatechange = null)
17
+ },
18
+ i = d.getElementsByTagName(t)[0], i.parentNode.insertBefore(n, i)
19
+ })
20
+ (window, document, "script", "//bat.bing.com/bat.js", "uetq");
21
+ </script>
22
+ <noscript>
23
+ <img src="//bat.bing.com/action/0?ti=<?php echo $bingId; ?>&Ver=2" height="0" width="0" style="display:none; visibility: hidden;"/>
24
+ </noscript>
25
+ <?php endif; ?>
26
+ <!-- end Bing tracking -->
app/design/frontend/base/default/template/steerfox_plugins/bing_order_tag.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $bingId = $this->getBingId();
3
+ $orders = $this->getOrders();
4
+
5
+ if (!empty($bingId) && !empty($orders)) :
6
+ ?>
7
+ <!-- Bing conversion -->
8
+ <!--suppress JSUnresolvedVariable -->
9
+ <script>
10
+ <?php foreach ($orders as $order) : ?>
11
+ var uetq = uetq || [];
12
+ uetq.push({'gv': '<?php echo $this->getConvertionAmount($order); ?>' });
13
+ <?php endforeach; ?>
14
+ </script>
15
+
16
+ <noscript>
17
+ <?php foreach ($orders as $order) : ?>
18
+ <img src="//bat.bing.com/action/0?ti=<?php echo $bingId; ?>&Ver=2&gv=<?php echo $this->getConvertionAmount($order); ?>" height="0" width="0" style="display:none; visibility:hidden;"/>
19
+ <?php endforeach; ?>
20
+ </noscript>
21
+ <?php endif; ?>
app/design/frontend/base/default/template/steerfox_plugins/fb_header_tag.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $facebookId = $this->getFacebookId();
3
+ $currentProduct = $this->getCurrentProduct();
4
+ $productAddToCart = $this->getFacebookProductAddToCart();
5
+
6
+ if (!empty($facebookId)):
7
+ ?>
8
+ <!-- Facebook Pixel Code -->
9
+ <script>
10
+ !function (f, b, e, v, n, t, s) {
11
+ if (f.fbq)return;
12
+ n = f.fbq = function () {
13
+ n.callMethod ?
14
+ n.callMethod.apply(n, arguments) : n.queue.push(arguments)
15
+ };
16
+ if (!f._fbq)f._fbq = n;
17
+ n.push = n;
18
+ n.loaded = !0;
19
+ n.version = '2.0';
20
+ n.queue = [];
21
+ t = b.createElement(e);
22
+ t.async = !0;
23
+ t.src = v;
24
+ s = b.getElementsByTagName(e)[0];
25
+ s.parentNode.insertBefore(t, s)
26
+ }(window,
27
+ document, 'script', '//connect.facebook.net/en_US/fbevents.js');
28
+ fbq('init', '<?php echo $facebookId; ?>');
29
+ fbq('track', "PageView");
30
+
31
+ <?php if (null !== $currentProduct):
32
+ $categories = $currentProduct->getCategoryIds();
33
+ $catName = null;
34
+ if (0 < count($categories)) {
35
+ $category = Mage::getModel('catalog/category')->load($categories[0]);
36
+ $catName = $category->getName();
37
+ }?>
38
+ fbq('track', 'ViewContent', {
39
+ content_name : '<?php echo $currentProduct->getName(); ?>',
40
+ content_category : '<?php echo $catName; ?>',
41
+ content_ids : ['<?php echo $currentProduct->getId(); ?>'],
42
+ content_type : 'product',
43
+ value: '<?php echo $currentProduct->getPrice(); ?>',
44
+ currency: '<?php echo $this->getCurrencyCode(); ?>'
45
+ });
46
+ <?php endif; ?>
47
+
48
+
49
+ <?php if (is_array($productAddToCart) && 0 < count($productAddToCart)) : ?>
50
+ fbq('track', 'AddToCart', {
51
+ content_name: '<?php echo $productAddToCart['name']; ?>',
52
+ content_category: '<?php echo $productAddToCart['cat']; ?>',
53
+ content_ids: ['<?php echo $productAddToCart['id']; ?>'],
54
+ content_type: 'product',
55
+ value: '<?php echo $productAddToCart['price']; ?>',
56
+ currency: '<?php echo $this->getCurrencyCode(); ?>'
57
+ });
58
+ <?php endif; ?>
59
+
60
+ </script>
61
+ <noscript>
62
+ <img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=<?php echo $facebookId; ?>&ev=PageView&noscript=1"/>
63
+ </noscript>
64
+ <!-- End Facebook Pixel Code -->
65
+ <?php endif; ?>
app/design/frontend/base/default/template/steerfox_plugins/fb_order_tag.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $facebookId = $this->getFacebookId();
3
+ $order = $this->getOrder();
4
+ if (!empty($facebookId) && null !== $order) :
5
+ ?>
6
+ <script>
7
+ fbq('track', 'Purchase', {
8
+ content_ids: '<?php echo $this->getProductsIdsString($order); ?>',
9
+ content_type: 'product',
10
+ value: '<?php echo $this->getConvertionAmount($order); ?>',
11
+ currency: '<?php echo $order->getOrderCurrencyCode(); ?>'
12
+ });
13
+ </script>
14
+ <?php endif; ?>
app/design/frontend/base/default/template/steerfox_plugins/foxtag_header_tag.phtml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $foxtagId = $this->getFoxtagId();
3
+ $userId = $this->getUserId();
4
+ $pageType = $this->getFoxtagPage();
5
+ $currentProduct = $this->getCurrentProduct();
6
+ $currentCategory = $this->getCurrentCategory();
7
+ $productAddToCart = $this->getFoxtagProductAddToCart();
8
+ $order = $this->getOrder();
9
+
10
+ // If there is a foxtag id and we are not on success page
11
+ if (!empty($foxtagId) && null === $order) :
12
+ ?>
13
+ <!-- Foxtag tracking -->
14
+ <script type="text/javascript">
15
+ var _foxtag = _foxtag || {};
16
+ _foxtag.sa = '<?php echo $foxtagId; ?>';
17
+ _foxtag.tagEvents = ['view'];
18
+ _foxtag.pageType = '<?= $pageType; ?>';
19
+ _foxtag.userId = '<?= $userId; ?>';
20
+
21
+ <?php if (null !== $currentProduct) : ?>
22
+ _foxtag.productId = '<?php echo $currentProduct->getId(); ?>';
23
+ _foxtag.productName = '<?php echo htmlspecialchars($currentProduct->getName(), ENT_QUOTES); ?>';
24
+ <?php endif; ?>
25
+
26
+ <?php if (null !== $currentCategory) : ?>
27
+ _foxtag.categoryId = '<?php echo $currentCategory->getId(); ?>';
28
+ _foxtag.categoryName = '<?php echo htmlspecialchars($currentCategory->getName(), ENT_QUOTES); ?>';
29
+ <?php endif; ?>
30
+
31
+ <?php if (is_array($productAddToCart) && 0 < count($productAddToCart)) : ?>
32
+ _foxtag.tagEvents.push('addtocart');
33
+ _foxtag.cartItem = {
34
+ 'id': '<?php echo htmlspecialchars($productAddToCart['id'], ENT_QUOTES); ?>',
35
+ 'sku': '<?php echo htmlspecialchars($productAddToCart['sku'], ENT_QUOTES); ?>',
36
+ 'name': '<?php echo htmlspecialchars($productAddToCart['name'], ENT_QUOTES); ?>',
37
+ 'cat': '<?php echo htmlspecialchars($productAddToCart['cat'], ENT_QUOTES); ?>',
38
+ 'price': '<?php echo htmlspecialchars($productAddToCart['price'], ENT_QUOTES); ?>',
39
+ 'margin': '<?php echo htmlspecialchars($productAddToCart['margin'], ENT_QUOTES); ?>',
40
+ 'qty': '<?php echo htmlspecialchars($productAddToCart['qty'], ENT_QUOTES); ?>'
41
+ };
42
+ <?php endif; ?>
43
+
44
+ (function () {
45
+ var fxt = document.createElement('script');
46
+ fxt.type = 'text/javascript';
47
+ fxt.async = true;
48
+ fxt.src = '<?php echo $this->getFoxtagJsUrl(); ?>';
49
+ var s = document.getElementsByTagName('script')[0];
50
+ s.parentNode.insertBefore(fxt, s);
51
+ })();
52
+
53
+ </script>
54
+ <noscript>
55
+ <?php
56
+ $foxtagEvent = "'view'";
57
+ if (is_array($productAddToCart) && 0 < count($productAddToCart)) {
58
+ $foxtagEvent .= ",'addtocart'";
59
+ }
60
+ ?>
61
+ <img height="1" width="1" style="display:none"
62
+ src="<?php echo $this->getFoxtagUrl(); ?>?sa=<?php echo $foxtagId; ?>&e=%7B%22e%22%3A%5B<?php echo urlencode($foxtagEvent); ?>%5D%7D&noscript=1"/>
63
+ </noscript>
64
+ <!-- End Foxtag tracking -->
65
+ <?php endif; ?>
66
+
app/design/frontend/base/default/template/steerfox_plugins/foxtag_order_tag.phtml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $foxtagId = $this->getFoxtagId();
3
+ /* @var $order Mage_Sales_Model_Order */
4
+ $order = $this->getOrder();
5
+ $userId = $this->getUserId();
6
+ // If there is no order we stop here
7
+ if (null === $order) return ;
8
+
9
+ $itemList = $this->getItemList($order);
10
+
11
+ if (!empty($foxtagId) && 0 < count($itemList)) :
12
+ ?>
13
+ <!-- Foxtag tracking -->
14
+ <script type="text/javascript">
15
+ var _foxtag = _foxtag || {};
16
+ _foxtag.sa = '<?php echo $foxtagId; ?>';
17
+ _foxtag.tagEvents = ['order','view'];
18
+ _foxtag.pageType = 'purchase';
19
+ _foxtag.userId = '<?= $userId; ?>';
20
+ _foxtag.transaction = {
21
+ 'id': '<?php echo $order->getId(); ?>',
22
+ 'order_id': '<?php echo $order->getId(); ?>',
23
+ 'items': [
24
+ <?php foreach ($itemList as $item): ?>
25
+ {
26
+ 'id': '<?php echo $item['id']; ?>',
27
+ 'sku': '<?php echo $item['sku']; ?>',
28
+ 'name': '<?php echo htmlspecialchars($item['name'], ENT_QUOTES); ?>',
29
+ 'cat': '<?php echo $item['cat']; ?>',
30
+ 'price': '<?php echo $item['price']; ?>',
31
+ 'margin': '<?php echo $item['margin']; ?>',
32
+ 'qty': '<?php echo $item['qty']; ?>'
33
+ },
34
+ <?php endforeach; ?>
35
+ ],
36
+ 'total': '<?php echo $this->getConvertionAmount($order); ?>',
37
+ 'subtotal': '<?php echo $this->getConvertionSubtotal($order); ?>',
38
+ 'margin': '<?php echo $this->getConvertionMargin($order); ?>',
39
+ 'tax': '<?php echo $this->getConvertionTax($order); ?>',
40
+ 'shipping': '<?php echo $this->getConvertionShipping($order); ?>',
41
+ 'discount': '<?php echo $this->getConvertionDiscount($order); ?>',
42
+ 'status': '<?php echo $order->getStatus(); ?>',
43
+ 'currency': '<?php echo $order->getOrderCurrencyCode(); ?>'
44
+ };
45
+
46
+ (function () {
47
+ var fxt = document.createElement('script');
48
+ fxt.type = 'text/javascript';
49
+ fxt.async = true;
50
+ fxt.src = '<?php echo $this->getFoxtagJsUrl(); ?>';
51
+ var s = document.getElementsByTagName('script')[0];
52
+ s.parentNode.insertBefore(fxt, s);
53
+ })();
54
+ </script>
55
+
56
+ <noscript>
57
+ <img height="1" width="1" style="display:none"
58
+ src="<?php echo $this->getFoxtagUrl(); ?>?sa=<?php echo $foxtagId; ?>&e=%7B%22e%22%3A%5B<?php echo urlencode("'view','order'"); ?>%5D%7D&noscript=1"/>
59
+ </noscript>
60
+ <?php endif; ?>
app/design/frontend/base/default/template/steerfox_plugins/gsv_tag.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ $gsv = $this->getGsv();
3
+ if (!empty($gsv)) :
4
+ ?>
5
+ <meta name="google-site-verification" content="<?php echo $gsv; ?>"/>
6
+ <?php endif; ?>
app/design/frontend/base/default/template/steerfox_plugins/gtm_tag.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- GTM tracking -->
2
+ <?php
3
+ $gtmId = $this->getGtmId();
4
+ if (!empty($gtmId)) :
5
+ ?>
6
+ <?php
7
+ $order = $this->getOrder();
8
+ if (!empty($order)) : ?>
9
+ <script type="text/javascript">
10
+ dataLayer=[{
11
+ 'conversionLanguage': '<?php echo $this->getLocaleCode(); ?>',
12
+ 'conversionTotal': '<?php echo $this->getConvertionAmount($order); ?>',
13
+ 'conversionCurrency': '<?php echo $order->getOrderCurrencyCode(); ?>'
14
+ }];
15
+ </script>
16
+
17
+ <?php endif; ?>
18
+ <!-- Google Tag Manager -->
19
+ <noscript><iframe src="//www.googletagmanager.com/ns.html?id=<?php echo $gtmId;?>"
20
+ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
21
+ <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
22
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
23
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
24
+ '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
25
+ })(window,document,'script','dataLayer','<?php echo $gtmId;?>');</script>
26
+ <!-- End Google Tag Manager -->
27
+ <?php endif; ?>
app/etc/modules/Steerfox_Plugins.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Steerfox_Plugins>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Adminhtml />
9
+ </depends>
10
+ </Steerfox_Plugins>
11
+ </modules>
12
+ </config>
app/locale/en_US/Steerfox_Plugins.csv ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "A new version of Steerfox plugins is available. Please update to take advantage of new features.","A new version of Steerfox plugins is available. Please update to take advantage of new features."
2
+ "Account settings","Account settings"
3
+ "Active","Active"
4
+ "Advanced Settings","Advanced Settings"
5
+ "An error occured during the form validation","An error occured during the form validation"
6
+ "API key","API key"
7
+ "Are you sure you want to uninstall SteerFox module ?","Are you sure you want to uninstall SteerFox module ?"
8
+ "Automated traffic buying","Automated traffic buying by Steerfox"
9
+ "Base price","Base price"
10
+ "Bing tracking ID","Bing tracking ID"
11
+ "Catalog settings","Catalog settings"
12
+ "Category","Category"
13
+ "Choose currency of products in your catalog","Choose currency of products in your catalog"
14
+ "Choose language of your catalog","Choose language of your catalog"
15
+ "Choose to export the margin on your products in Steerfox products' flow","Choose to export the margin on your products in Steerfox products' flow"
16
+ "Choose to use the SKU value to fill MPN","Choose to use the SKU value to fill MPN"
17
+ "Configuration checklist for your Steerfox module.","Configuration checklist for your Steerfox module."
18
+ "Configuration dashboard","Configuration dashboard"
19
+ "Configuration updated","Configuration updated"
20
+ "Connector status : Steerfox can be reached","Connector status : Steerfox can be reached"
21
+ "contact@steerfox.com","contact@steerfox.com"
22
+ "Conversion tracking settings","Conversion tracking settings"
23
+ "Created","Created"
24
+ "Currency","Currency"
25
+ "Default shop","Default shop"
26
+ "Disabled","Disabled"
27
+ "Display margin in export","Display margin in export"
28
+ "Down","Down"
29
+ "Enabled","Enabled"
30
+ "Enter the google_conversion_id and google_conversion_label of your Google Adwords conversion tracking tag if you wish to install it automatically","Enter the google_conversion_id and google_conversion_label of your Google Adwords conversion tracking tag if you wish to install it automatically"
31
+ "Enter the Google site verification if you want to link your account and website","Enter the Google site verification if you want to link your account and website"
32
+ "Enter the ID of your Bing UET tracking tag if you wish to install it automatically","Enter the ID of your Bing UET tracking tag if you wish to install it automatically"
33
+ "Enter the ID of your Facebook tracking pixel if you wish to install it automatically","Enter the ID of your Facebook tracking pixel if you wish to install it automatically"
34
+ "Enter the ID of your Foxtag account if you wish to install it automatically","Enter the ID of your Foxtag account if you wish to install it automatically"
35
+ "Enter the ID of your Google Tag Manager container ID if you wish to install it automatically","Enter the ID of your Google Tag Manager container ID if you wish to install it automatically"
36
+ "Enter your API key if you already have a SteerFox account","Enter your API key if you already have a SteerFox account"
37
+ "Export status","Export status"
38
+ "Facebook tracking ID","Facebook tracking ID"
39
+ "Filter by category","Filter by category"
40
+ "Final price","Final price"
41
+ "Generate traffic","Generate traffic"
42
+ "Google Adwords conversion tracking ID","Google Adwords conversion tracking ID"
43
+ "Google Adwords conversion tracking label","Google Adwords conversion tracking label"
44
+ "Gross profit","Gross profit"
45
+ "ID","ID"
46
+ "ID language","ID language"
47
+ "ID product","ID product"
48
+ "If the problem persist, please contact Steerfox : ","If the problem persist, please contact SteerFox :"
49
+ "Image","Image"
50
+ "Inactive","Inactive"
51
+ "Include shipping in conversion","Include shipping in conversion"
52
+ "Include shipping price in conversion value.","Include shipping price in conversion value."
53
+ "It determines the optimal combination of assets to catch shoppers to your online shopping","It determines the optimal combination of assets to catch shoppers to your online shopping"
54
+ "Language","Language"
55
+ "Manage export Products","Manage export Products"
56
+ "Manage exported Products","Manage exported Products"
57
+ "Manage Steerfox products export","Manage Steerfox products export"
58
+ "MPN attribute code","MPN attribute code"
59
+ "Multiples sources","Multiples sources"
60
+ "My ads control panel","My ads control panel"
61
+ "Name","Name"
62
+ "No checklist available for the moment.","No checklist available for the moment."
63
+ "No items found","No items found"
64
+ "Our buying robot connects to multiple sources of traffic (Google Adwords, Google Shopping, Bing Ads, Amazon Product Ads, Facebook Product Ads...). It will create, manage and optimize your campaigns in permanent interaction with the back office of suppliers. SteerFox provides a report of the results, consolidated on a single page.","Our buying robot connects to multiple sources of traffic (Google Adwords, Google Shopping, Bing Ads, Amazon Product Ads, Facebook Product Ads...). It will create, manage and optimize your campaigns in permanent interaction with the back office of suppliers. SteerFox provides a report of the results, consolidated on a single page."
65
+ "Our buying Robot connects you to multiple traffic sources","Our buying Robot connects you to multiple traffic sources"
66
+ "Photo","Photo"
67
+ "Please ensure the wholesale price is filled for this value .","Please ensure the wholesale price is filled for this value."
68
+ "Please select product(s)","Please select product(s)"
69
+ "Position","Position"
70
+ "Products","Products"
71
+ "Product catalog","Product catalog"
72
+ "Product cost","Product cost"
73
+ "Product name","Product name"
74
+ "Product price","Product price"
75
+ "Product profit","Product profit"
76
+ "Product profit ratio","Product profit ratio"
77
+ "Publish on Steerfox","Publish on Steerfox"
78
+ "Quantity","Quantity"
79
+ "Reference","Reference"
80
+ "Save","Save"
81
+ "Settings","Settings"
82
+ "Setting indicator","Setting indicator"
83
+ "SKU product","SKU product"
84
+ "Start the test","Start the test"
85
+ "Status","Status"
86
+ "Steerfox authentication : API_KEY validity","Steerfox authentication : API_KEY validity"
87
+ "SteerFox helps e-merchants and agencies to initiate, automate and optimize their Adwords, Bing, ... traffic purchases. Our solutions simplify multi-source traffic buying, and improve ROI. With robots and algorithms developed by SteerFox, the management of advertising campaigns has never been easier.","SteerFox helps e-merchants and agencies to initiate, automate and optimize their Adwords, Bing, ... traffic purchases. Our solutions simplify multi-source traffic buying, and improve ROI. With robots and algorithms developed by SteerFox, the management of advertising campaigns has never been easier."
88
+ "The attribute code to use to fill MPN. (used only if SKU for MPN is false)","The attribute code to use to fill MPN. (used only if SKU for MPN is false)"
89
+ "The Easiest Buying Traffic Solution on the Market","The Easiest Buying Traffic Solution on the Market"
90
+ "The module faced an issue, please contact SteerFox (error code : 2).","The module faced an issue, please contact SteerFox (error code : 2)."
91
+ "The module faced an issue, please contact SteerFox (error code : 3).","The module faced an issue, please contact SteerFox (error code : 3)."
92
+ "The module faced an issue, please contact SteerFox (error code : 4).","The module faced an issue, please contact SteerFox (error code : 4)."
93
+ "The module faced an issue, please contact SteerFox (error code : 5).","The module faced an issue, please contact SteerFox (error code : 5)."
94
+ "The module faced an issue, please contact SteerFox (error code : 6).","The module faced an issue, please contact SteerFox (error code : 6)."
95
+ "The module faced an issue, please contact SteerFox (error code : 7).","The module faced an issue, please contact SteerFox (error code : 7)."
96
+ "The module faced an issue, please contact SteerFox (error code : 9).","The module faced an issue, please contact SteerFox (error code : 9)."
97
+ "The strength of our solutions is to generate campaigns automatically from your product catalog. Our robots analyze its composition and your competitors, then they generate the best advertising campaigns with suitable ads : texts or banners.","The strength of our solutions is to generate campaigns automatically from your product catalog. Our robots analyze its composition and your competitors, then they generate the best advertising campaigns with suitable ads : texts or banners."
98
+ "To access the magento module configuration you have to be in a website context.","To access the magento module configuration you have to be in a website context."
99
+ "Trial account created with success.","Trial account created with success."
100
+ "Unpublish on Steerfox","Unpublish on Steerfox"
101
+ "Updated","Updated"
102
+ "Use SKU for MPN","Use SKU for MPN"
103
+ "Whether or not the product will be exported .","Whether or not the product will be exported ."
104
+ "You are selecting values for this shop :","You are selecting values for this shop :"
105
+ "You choose your budget at anytime depending on the wanted traffic for your shop. Whatever your budget, no commitment is required. Our robots boost sales of your e-commerce.","You choose your budget at anytime depending on the wanted traffic for your shop. Whatever your budget, no commitment is required. Our robots boost sales of your e-commerce."
106
+ "%d product(s) published","%d product(s) published"
107
+ "%d product(s) unpublished","%d product(s) unpublished"
app/locale/fr_FR/Steerfox_Plugins.csv ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "A new version of Steerfox plugins is available. Please update to take advantage of new features.","Une nouvelle version du module Steerfox est disponible. Mettez-le à jour pour profiter des nouvelles fonctionnalités."
2
+ "Account settings","Paramètres du compte"
3
+ "Active","Actif"
4
+ "Advanced Settings","Paramètres avancés"
5
+ "An error occured during the form validation","Une erreur est survenue lors de la validation du formulaire"
6
+ "API key","Clé API"
7
+ "Are you sure you want to uninstall SteerFox module ?","Etes vous sûr de vouloir désinstaller le module Steerfox ?"
8
+ "Automated traffic buying","Ads by SteerFox, automatisation des achats de trafic"
9
+ "Base price","Prix de base"
10
+ "Bing tracking ID","Identifiant de suivi Bing"
11
+ "Catalog settings","Paramètres du catalogue"
12
+ "Category","Catégorie"
13
+ "Choose currency of products in your catalog","Choisissez la monnaie des produits de votre catalogue"
14
+ "Choose language of your catalog","Choisissez la langue de votre catalogue"
15
+ "Choose to export the margin on your products in Steerfox products' flow","Choisissez si vous voulez exporter la marge de vos produits dans le flux Steerfox"
16
+ "Choose to use the SKU value to fill MPN","Choisissez d'utiliser la valeur du SKU dans le champ MPN"
17
+ "Configuration checklist for your Steerfox module.","Vérifications de la configuration de votre module Steerfox"
18
+ "Configuration dashboard","Tableau de bord de configuration"
19
+ "Configuration updated","Configuration mise à jour"
20
+ "Connector status : Steerfox can be reached","Status de connexion : Steerfox est en ligne"
21
+ "contact@steerfox.com","contact@steerfox.com"
22
+ "Conversion tracking settings","Paramètres de suivi des conversions"
23
+ "Created","Créé le"
24
+ "Currency","Monnaie"
25
+ "Default shop","Boutique par défaut"
26
+ "Disabled","Inactif"
27
+ "Display margin in export","Afficher la marge dans l'export"
28
+ "Down","Remonter"
29
+ "Enabled","Actif"
30
+ "Enter the google_conversion_id and google_conversion_label of your Google Adwords conversion tracking tag if you wish to install it automatically","Renseignez la valeur des paramètres google_conversion_id et google_conversion_label de votre tag de suivi de conversion Google Adwords si vous souhaitez l'installer automatiquement"
31
+ "Enter the Google site verification if you want to link your account and website","Entrez votre identifiant Google site verification pour lier votre compte à votre site web."
32
+ "Enter the ID of your Bing UET tracking tag if you wish to install it automatically","Renseignez l'identifiant du tag de suivi de Bing UET si vous souhaitez l'installer automatiquement"
33
+ "Enter the ID of your Facebook tracking pixel if you wish to install it automatically","Renseignez l'identifiant du tag de suivi de Facebook si vous souhaitez l'installer automatiquement"
34
+ "Enter the ID of your Foxtag account if you wish to install it automatically","Renseignez l'identifiant de votre compte Foxtag si vous souhaitez l'installer automatiquement"
35
+ "Enter the ID of your Google Tag Manager container ID if you wish to install it automatically","Renseignez l'identifiant du tag de conteneur Google Tag Manager si vous souhaitez l'installer automatiquement"
36
+ "Enter your API key if you already have a SteerFox account","Renseignez votre clef API si vous possédez un compte Steerfox"
37
+ "Export status","Statut d'export"
38
+ "Facebook tracking ID","Identifiant de suivi Facebook"
39
+ "Filter by category","Filtrer par catégorie"
40
+ "Final price","Prix final"
41
+ "Generate traffic","Générer du trafic"
42
+ "Google Adwords conversion tracking ID","Identifiant de suivi de conversions Google Adwords"
43
+ "Google Adwords conversion tracking label","Label de suivi de conversions Google Adwords"
44
+ "Gross profit","Marge brut"
45
+ "ID","ID"
46
+ "ID language","Identifiant de langue"
47
+ "ID product","Identifiant de produit"
48
+ "If the problem persist, please contact Steerfox : ","Si le problème persiste, merci de contacter Steerfox : "
49
+ "Image","Photo"
50
+ "Inactive","Inactif"
51
+ "Include shipping in conversion","Inclure les frais de port lors de la conversion"
52
+ "Include shipping price in conversion value.","Inclure les frais de port dans la valeur de conversion."
53
+ "It determines the optimal combination of assets to catch shoppers to your online shopping","Il détermine la combinaison optimale pour diriger des acheteurs actifs vers votre site e-commerce"
54
+ "Language","Langue"
55
+ "Manage export Products","Gestion des produits à exporter"
56
+ "Manage exported Products","Gestion des produits à exporter"
57
+ "Manage Steerfox products export","Gestion des produits à exporter"
58
+ "MPN attribute code","Code d'attribut pour le MPN"
59
+ "Multiples sources","Sources multiples"
60
+ "My ads control panel","Accéder au gestionnaire de campagnes"
61
+ "Name","Nom"
62
+ "No checklist available for the moment.","Aucune liste de vérifications pour le moment"
63
+ "No items found","Aucun élément trouvé"
64
+ "Our buying robot connects to multiple sources of traffic (Google Adwords, Google Shopping, Bing Ads, Amazon Product Ads, Facebook Product Ads...). It will create, manage and optimize your campaigns in permanent interaction with the back office of suppliers. SteerFox provides a report of the results, consolidated on a single page.","Notre robot d'achat se connecte à de multiples sources d\'audiences (Google Adwords, Google Shopping, Bing Ads, Amazon Product Ads, Facebook Product Ads…). Il va créer, gérer et optimiser vos campagnes en liaison permanente avec le back office des fournisseurs. SMB Catalog fournit un rapport des performances consolidées en une seule page."
65
+ "Our buying Robot connects you to multiple traffic sources","Notre Robot d’achat vous connecte à de multiples sources d’audience"
66
+ "Photo","Photo"
67
+ "Please ensure the wholesale price is filled for this value .","Merci de vérifier que le prix de vente en gros est renseigné"
68
+ "Please select product(s)","Veuillez selectionner des produits"
69
+ "Position","Position"
70
+ "Products","Produits"
71
+ "Product catalog","Catalogues produits"
72
+ "Product cost","Coût du produit"
73
+ "Product name","Nom du produit"
74
+ "Product price","Prix du produit"
75
+ "Product profit","Profit du produit"
76
+ "Product profit ratio","Ratio de profit du produit"
77
+ "Publish on Steerfox","Publier sur Steerfox"
78
+ "Quantity","Quantité"
79
+ "Reference","Référence"
80
+ "Save","Enregistrer"
81
+ "Settings","Configuration"
82
+ "Setting indicator","Paramètre"
83
+ "SKU product","SKU du produit"
84
+ "Start the test","Démarrer l'essai"
85
+ "Status","Statut"
86
+ "Steerfox authentication : API_KEY validity","Connexion à Steerfox: Validité de la clef API"
87
+ "SteerFox helps e-merchants and agencies to initiate, automate and optimize their Adwords, Bing, ... traffic purchases. Our solutions simplify multi-source traffic buying, and improve ROI. With robots and algorithms developed by SteerFox, the management of advertising campaigns has never been easier.","SteerFox aide les e-commercants et les Agences à initialiser, automatiser et optimiser leurs achats de trafic sur Adwords, Bing, ... Nos solutions simplifient les achats multi-sources, et en améliorent le retour sur investissement. Grâce aux robots et aux algorithmes développés par SteerFox, la gestion des campagnes publicitaires n'a jamais été aussi simple."
88
+ "The attribute code to use to fill MPN. (used only if SKU for MPN is false)","Le code d'attribut à utiliser pour remplir le champ MPN. (utilisé seulement si ""Utiliser le SKU pour remplir le MPN"" est à faux)"
89
+ "The Easiest Buying Traffic Solution on the Market","La solution d'achat de Trafic la plus simple du marché"
90
+ "The module faced an issue, please contact SteerFox (error code : 2).","Le module a rencontré un erreur, merci de contacter SteerFox (code d'erreur : 2)"
91
+ "The module faced an issue, please contact SteerFox (error code : 3).","Le module a rencontré un erreur, merci de contacter SteerFox (code d'erreur : 3)"
92
+ "The module faced an issue, please contact SteerFox (error code : 4).","Le module a rencontré un erreur, merci de contacter SteerFox (code d'erreur : 4)"
93
+ "The module faced an issue, please contact SteerFox (error code : 5).","Le module a rencontré un erreur, merci de contacter SteerFox (code d'erreur : 5)"
94
+ "The module faced an issue, please contact SteerFox (error code : 6).","Le module a rencontré un erreur, merci de contacter SteerFox (code d'erreur : 6)"
95
+ "The module faced an issue, please contact SteerFox (error code : 7).","Le module a rencontré un erreur, merci de contacter SteerFox (code d'erreur : 7)"
96
+ "The module faced an issue, please contact SteerFox (error code : 9).","Le module a rencontré un erreur, merci de contacter SteerFox (code d'erreur : 9)"
97
+ "The strength of our solutions is to generate campaigns automatically from your product catalog. Our robots analyze its composition and your competitors, then they generate the best advertising campaigns with suitable ads : texts or banners.","La force de notre offre est de générer des campagnes automatiquement à partir de votre catalogue produits. Nos robots vont analyser la composition de celui-ci ainsi que votre concurrence, afin de générer les meilleures campagnes publicitaires dans des formats adaptés : annonces textes ou bannières"
98
+ "To access the magento module configuration you have to be in a website context.","Pour accéder à la configuration du module magento vous devez être dans un contexte de website."
99
+ "Trial account created with success.","Votre compte d'essai a été créé avec succès."
100
+ "Unpublish on Steerfox","Dépublier de Steerfox"
101
+ "Updated","Mit à jour le"
102
+ "Use SKU for MPN","Utiliser le SKU pour remplir le MPN"
103
+ "Whether or not the product will be exported .","Indique si oui ou non le produit est exporté"
104
+ "You are selecting values for this shop :","Vous configurer votre module pour la boutique :"
105
+ "You choose your budget at anytime depending on the wanted traffic for your shop. Whatever your budget, no commitment is required. Our robots boost sales of your e-commerce.","Vous choisissez à tout moment votre budget en fonction du trafic souhaité sur votre ou vos boutiques. Quel que soit votre budget, aucun engagement n'est nécessaire. Nos robots boostent les ventes de votre site e-commerce"
106
+ "%d product(s) published","%d produit(s) publié(s)"
107
+ "%d product(s) unpublished","%d produit(s) dépublié(s)"
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Steerfox_Plugins</name>
4
+ <version>1.0.5</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Easiest Buying Traffic Solution on the Market</summary>
10
+ <description>SteerFox helps e-merchants and agencies to initiate, automate and optimize their Adwords, Bing, traffic purchases. Our solutions simplify multi-source traffic buying, and improve ROI. With robots and algorithms developed by SteerFox, the management of advertising campaigns has never been easier.</description>
11
+ <notes>- Before release</notes>
12
+ <authors><author><name>Steerfox</name><user>Steerfox</user><email>magento@steerfox.com</email></author></authors>
13
+ <date>2016-09-01</date>
14
+ <time>07:15:19</time>
15
+ <contents><target name="magecommunity"><dir name="Steerfox"><dir name="Plugins"><dir name="Block"><dir name="Adminhtml"><dir name="Steerfoxproduct"><file name="Grid.php" hash="349688fb0d09c5d803d9dbae63f51c6f"/></dir><file name="Steerfoxproduct.php" hash="ecb4887a6eee18f686f937eba68abae9"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Fieldset"><file name="Steerfoxform.php" hash="24a9a1d1a790ce4f77db87ab9405ce57"/></dir></dir></dir></dir></dir><file name="Tags.php" hash="5f994d77f03170c4b765ae1cd23fc4b0"/></dir><dir name="Enum"><file name="Tags.php" hash="9d484a6672e30803cd9b5feb8e3224bb"/></dir><dir name="Helper"><dir name="Core"><file name="Data.php" hash="f195a713d992004d56908dfdbf9020df"/><file name="Exception.php" hash="8cd94a317dfecc7b5200b0c8bd1bd4b5"/></dir><file name="Data.php" hash="3770f932a325c9288f9fb91f1c1cbc96"/></dir><dir name="Model"><dir name="Adapter"><file name="Configuration.php" hash="8ea074182d25b2b19cf62d4ca9e82727"/><file name="Product.php" hash="082e221c7ab1a442a851327da1010a1a"/><dir name="Service"><file name="Log.php" hash="c24f94cdff91c47f9a9c27ec57e062c1"/><file name="Shop.php" hash="478f1694bdeaaddf5fee5216cd88d94e"/></dir><file name="Shop.php" hash="a9001b461218fa50ccc73f3ed513fd0a"/><file name="Tools.php" hash="fe82a2d740c5f73357396aa9af863620"/></dir><file name="Apikey.php" hash="87b84ab31edd88d068db11f3045ab34a"/><file name="Currencies.php" hash="64717870d9e27f6dc30764c50e4a808b"/><dir name="Entity"><dir name="Attribute"><dir name="Backend"><dir name="Profit"><file name="Ratio.php" hash="6bc443bbc1e311089ff9eaaa2f07567a"/></dir><file name="Profit.php" hash="d2211fcf09b60d97095a524217088f1f"/></dir></dir></dir><file name="Languages.php" hash="25762139c916b1a45b943e3d1bf65df2"/><file name="Log.php" hash="9952df470fac18c68be371dd1ff9e9b0"/><file name="Observer.php" hash="fe842aa1d0ac2e5fed5d2cfa509d356c"/><file name="Product.php" hash="afe1de0b11fcb4e135311c7fece8e4a3"/><dir name="Resource"><dir name="Log"><file name="Collection.php" hash="b944d97301c9f1a247663aaa176e13be"/></dir><file name="Log.php" hash="f02b8f0eaf008312a57db587df104542"/><dir name="Product"><file name="Collection.php" hash="8117a3f0c24f168838687783f665ec8f"/></dir><file name="Product.php" hash="0ef9c9a69f0b705de1d22a1718b41f78"/><file name="Setup.php" hash="2763f2b42a706ba1ceb6ab6c0f8ff233"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Group.php" hash="bdd67dcda4c78404a74ad36a850092d7"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="SteerfoxindexController.php" hash="4957a0ca9c97865e07db58a169635a2b"/><file name="SteerfoxproductController.php" hash="50158bdd784d2e124ea097e55f755acb"/></dir><file name="LogsController.php" hash="856dff2d75e269e1632e1c9b1b414e4c"/><file name="ProductController.php" hash="806436c21a635550bf08a7423ab65a9f"/></dir><dir name="data"><dir name="steerfox_plugins_setup"><file name="data-install-0.1.0.php" hash="a57206dbc6c0562923b7e18f8d22f4aa"/><file name="data-upgrade-0.1.2-0.1.3.php" hash="05ac18ce5ab4c14cbe5fe481128d762d"/><file name="data-upgrade-0.1.3-0.1.4.php" hash="eeac03a3ea18300f46ee09c1f84698ca"/><file name="data-upgrade-0.1.4-1.0.5.php" hash="fa15d85126b0e3db788c4a56b9cb1b72"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="963880ba8e8bb1ce09c1ca4469fb57c0"/><file name="config.xml" hash="1a9e3d08c4a3b13e5a0a2c1fb4904c82"/><file name="steerfox.xml" hash="a3e43c070c0c8546ed838bbb8eeca02f"/><file name="system.xml" hash="e92815018524df90df08dd1e6d7921ba"/><file name="widget.xml" hash="aa532751974a2bdc8b2ce1d703045a02"/></dir><dir name="lib"><dir name="Api"><dir name="Connectors"><file name="SteerfoxAbstractConnector.php" hash="3552498f04d9486ac37265fb00e163bc"/><file name="SteerfoxCurlConnector.php" hash="47082ee0b720c4d3f367ca3dfe5e05ea"/><file name="SteerfoxFopenConnector.php" hash="4365eb63362f20a9011e4ad934827cea"/></dir><file name="SteerfoxApiService.php" hash="63dafacf7a2abf65e37b61f16dfd23ba"/></dir><dir name="Configuration"><file name="SteerfoxConfigurationInterface.php" hash="a9ae62bfddacc3f64a940608d9fb905b"/><file name="SteerfoxConfigurationService.php" hash="9fa1a1cdd8a5dce58728b19acbb56d68"/></dir><dir name="Exceptions"><file name="SteerfoxConnectorException.php" hash="a4a937aa3fe0d21b30e63afd3782941a"/><file name="SteerfoxException.php" hash="424c8c41798abbfdc7808894fba33306"/></dir><dir name="Export"><dir name="Helper"><file name="SteerfoxExporterHelper.php" hash="c0149a0d7b6af7a060ff08c2298f3fe9"/></dir><dir name="Model"><file name="SteerfoxProductExporter.php" hash="81b3e2b06825d979f4d12346895ee79f"/></dir><file name="SteerfoxExportService.php" hash="702a0c4b5c553e3aabfee230fd482542"/></dir><dir name="Logger"><file name="SteerfoxAbstractLoggerService.php" hash="63efbb988136bf3f3c94f008d55d3538"/></dir><dir name="Model"><file name="SteerfoxAbstractShopService.php" hash="3bcb95d72421e060de4ed55548a6e37c"/><file name="SteerfoxProductAdapterInterface.php" hash="d9cf05ed31ef372cc5cdf706bce0889f"/><file name="SteerfoxShopAdapterInterface.php" hash="1c3d1a704dabbfd43a80d4bac26a948c"/><file name="SteerfoxToolsAdapterInterface.php" hash="2fda1e49389cefb9ef9b7d1c7900f123"/></dir><file name="README.md" hash="e914117913dad5bd5b80bc89e14ae165"/><dir name="Samples"><file name="ContainerUse.php" hash="8234a56f116438da45e115af58b521c7"/><dir name="ModelAdapters"><file name="Configuration.php" hash="a32be9b7483386d198ad014519dedfa7"/><file name="Product.php" hash="7138b8f2522d94a1367b99c0aa95da3b"/><file name="Shop.php" hash="5754c020d65df3e9598bf08c87c7dfd2"/><file name="Tools.php" hash="135188ea71fd712575c4391f04e81dc3"/></dir><dir name="ServiceAdapters"><file name="Log.php" hash="af6b7852e52eb36c396409bda0559d21"/><file name="Shop.php" hash="a4a243860bd570f2ac97e564b6339f3e"/></dir><file name="conf.xml" hash="6648858e4ec68ac99968c6f23bcd4435"/></dir><file name="SteerfoxContainer.php" hash="d0fa988d76352b2718ef9a3767da9456"/><file name=".git" hash="4b341e9fb552a338c16bd5f44625766d"/></dir><dir name="sql"><dir name="steerfox_plugins_setup"><file name="install-0.1.0.php" hash="70ceffec9f0b240fa34dd534f0369e87"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Steerfox_Plugins.csv" hash="b995716bf8fd2a93caccf94f0c515248"/></dir><dir name="fr_FR"><file name="Steerfox_Plugins.csv" hash="07886da1165747ec45fc2e0793107e86"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="steerfox_plugins.xml" hash="8c5485bd69b7cdfe376d94f05f9aedef"/></dir><dir name="template"><dir name="steerfox"><dir><dir name="plugins"><file name="dashboard.phtml" hash="bffe2f2c45590c66e9e8767e22c04691"/><file name="welcome.phtml" hash="7c988b76c10cb59c18f040fa4aa4e92b"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="steerfox_plugins.xml" hash="ff6724ea320f3fcbcc03c82da860940d"/></dir><dir name="template"><dir name="steerfox_plugins"><file name="adwords_order_tag.phtml" hash="f537030f241f1404de8e9fa39747cd34"/><file name="bing_header_tag.phtml" hash="8089ba25d5a005e1fe3389dd03d17ef0"/><file name="bing_order_tag.phtml" hash="e863da490f009de9857ba7318e7b7543"/><file name="fb_header_tag.phtml" hash="85034cf5f0e3a5984bcc992bf41f6f85"/><file name="fb_order_tag.phtml" hash="12f34e59b35ca17d947f7be5234f75e3"/><file name="foxtag_header_tag.phtml" hash="508ee59c9a6ced9aabbd7e985f257fae"/><file name="foxtag_order_tag.phtml" hash="16ca581f35c8b4a3a892a015f8f33517"/><file name="gsv_tag.phtml" hash="b522f0483e765209f07865cd2963f351"/><file name="gtm_tag.phtml" hash="35ae2e63ba3474969fde8a0a755dadd7"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Steerfox_Plugins.xml" hash="c1be6fd4b1ddd7dcf878ac62cb7c23b5"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="steerfox"><file name="icon-file-text.png" hash="3e400723836794172ba18bc67f451829"/><file name="icon-globe.png" hash="a2277dbcbafc2752863e1eea3152a183"/><file name="icon-road.png" hash="746f9f25b9f6c79b03710c58cf27eebe"/><file name="icon-warning.png" hash="a383b701b236bf1b778bc0e9fb6db1c9"/><file name="steerfox-logo.png" hash="2c6660a3584f5da52b4b1728d3a3cc3f"/><file name="steerfox-reporting.png" hash="ac36aa8d7210b94c3a8fce698d5ca424"/></dir></dir><dir name="steerfox"><file name="steerfox.css" hash="e9fad76a3ccb13a264b5c4d41f39a611"/><file name="steerfox.js" hash="aff66aeadd2e8bfd424fd7a7f6654293"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/images/steerfox/icon-file-text.png ADDED
Binary file
skin/adminhtml/default/default/images/steerfox/icon-globe.png ADDED
Binary file
skin/adminhtml/default/default/images/steerfox/icon-road.png ADDED
Binary file
skin/adminhtml/default/default/images/steerfox/icon-warning.png ADDED
Binary file
skin/adminhtml/default/default/images/steerfox/steerfox-logo.png ADDED
Binary file
skin/adminhtml/default/default/images/steerfox/steerfox-reporting.png ADDED
Binary file
skin/adminhtml/default/default/steerfox/steerfox.css ADDED
@@ -0,0 +1,856 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2015 Steerfox SAS.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+ * not use this file except in compliance with the License. You may obtain
6
+ * a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ * License for the specific language governing permissions and limitations
14
+ * under the License.
15
+ *
16
+ * @author Steerfox <tech@steerfox.com>
17
+ * @copyright 2015 Steerfox SAS
18
+ * @license http://www.apache.org/licenses/LICENSE-2.0
19
+ */
20
+ /* btn */
21
+ .btn {
22
+ display: inline-block;
23
+ padding: 6px 12px;
24
+ margin-bottom: 0;
25
+ font-size: 13px;
26
+ font-weight: normal;
27
+ line-height: 1.42857;
28
+ text-align: center;
29
+ vertical-align: middle;
30
+ cursor: pointer;
31
+ border: 1px solid transparent;
32
+ border-radius: 0px;
33
+ white-space: nowrap;
34
+ -webkit-user-select: none;
35
+ -moz-user-select: none;
36
+ -ms-user-select: none;
37
+ -o-user-select: none;
38
+ user-select: none;
39
+ border-radius: 3px;
40
+ text-decoration: none;
41
+ }
42
+ .btn:hover, .btn:focus {
43
+ color: #000;
44
+ text-decoration: none;
45
+ }
46
+ .btn:active, .btn.active {
47
+ outline: 0;
48
+ background-image: none;
49
+ }
50
+
51
+ /* btn-primary */
52
+ .btn-primary {
53
+ color: #fff;
54
+ background-color: #FF6B1A;
55
+ border-color: #FF6B1A;
56
+ text-transform: uppercase;
57
+ }
58
+ .btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active {
59
+ color: #fff;
60
+ background-color: #EB711E;
61
+ border-color: #EB711E;
62
+ }
63
+ .btn-primary:active, .btn-primary.active {
64
+ background-image: none;
65
+ }
66
+
67
+ /* btn-default */
68
+ .btn-default {
69
+ color: #333;
70
+ background-color: #fff;
71
+ border-color: #ccc;
72
+ }
73
+ .btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active {
74
+ color: #fff;
75
+ background-color: #FF6B1A;
76
+ border-color: #FF6B1A;
77
+ }
78
+ .btn-default:active, .btn-default.active {
79
+ background-image: none;
80
+ }
81
+
82
+ /* btn size */
83
+ .btn-lg {
84
+ padding: 10px 16px;
85
+ font-size: 17px;
86
+ line-height: 1.33; }
87
+
88
+ .btn-sm,
89
+ .btn-xs {
90
+ padding: 5px 10px;
91
+ font-size: 12px;
92
+ line-height: 1.5; }
93
+
94
+ .btn-xs {
95
+ padding: 1px 5px; }
96
+
97
+ /* Collapse */
98
+ .collapse {
99
+ display: none;
100
+ }
101
+
102
+ /* Grid col system */
103
+ .row:before, .row:after {
104
+ content: " ";
105
+ /* 1 */
106
+ display: table;
107
+ /* 2 */ }
108
+ .row:after {
109
+ clear: both; }
110
+
111
+ .col-xs-1,
112
+ .col-xs-2,
113
+ .col-xs-3,
114
+ .col-xs-4,
115
+ .col-xs-5,
116
+ .col-xs-6,
117
+ .col-xs-7,
118
+ .col-xs-8,
119
+ .col-xs-9,
120
+ .col-xs-10,
121
+ .col-xs-11,
122
+ .col-xs-12,
123
+ .col-sm-1,
124
+ .col-sm-2,
125
+ .col-sm-3,
126
+ .col-sm-4,
127
+ .col-sm-5,
128
+ .col-sm-6,
129
+ .col-sm-7,
130
+ .col-sm-8,
131
+ .col-sm-9,
132
+ .col-sm-10,
133
+ .col-sm-11,
134
+ .col-sm-12,
135
+ .col-md-1,
136
+ .col-md-2,
137
+ .col-md-3,
138
+ .col-md-4,
139
+ .col-md-5,
140
+ .col-md-6,
141
+ .col-md-7,
142
+ .col-md-8,
143
+ .col-md-9,
144
+ .col-md-10,
145
+ .col-md-11,
146
+ .col-md-12,
147
+ .col-lg-1,
148
+ .col-lg-2,
149
+ .col-lg-3,
150
+ .col-lg-4,
151
+ .col-lg-5,
152
+ .col-lg-6,
153
+ .col-lg-7,
154
+ .col-lg-8,
155
+ .col-lg-9,
156
+ .col-lg-10,
157
+ .col-lg-11,
158
+ .col-lg-12 {
159
+ position: relative;
160
+ min-height: 1px; }
161
+
162
+ .col-xs-1,
163
+ .col-xs-2,
164
+ .col-xs-3,
165
+ .col-xs-4,
166
+ .col-xs-5,
167
+ .col-xs-6,
168
+ .col-xs-7,
169
+ .col-xs-8,
170
+ .col-xs-9,
171
+ .col-xs-10,
172
+ .col-xs-11 {
173
+ float: left; }
174
+
175
+ .col-xs-1 {
176
+ width: 8.33333%; }
177
+
178
+ .col-xs-2 {
179
+ width: 16.66667%; }
180
+
181
+ .col-xs-3 {
182
+ width: 25%; }
183
+
184
+ .col-xs-4 {
185
+ width: 33.33333%; }
186
+
187
+ .col-xs-5 {
188
+ width: 41.66667%; }
189
+
190
+ .col-xs-6 {
191
+ width: 50%; }
192
+
193
+ .col-xs-7 {
194
+ width: 58.33333%; }
195
+
196
+ .col-xs-8 {
197
+ width: 66.66667%; }
198
+
199
+ .col-xs-9 {
200
+ width: 75%; }
201
+
202
+ .col-xs-10 {
203
+ width: 83.33333%; }
204
+
205
+ .col-xs-11 {
206
+ width: 91.66667%; }
207
+
208
+ .col-xs-12 {
209
+ width: 100%; }
210
+
211
+ @media (min-width: 768px) {
212
+ .col-sm-1,
213
+ .col-sm-2,
214
+ .col-sm-3,
215
+ .col-sm-4,
216
+ .col-sm-5,
217
+ .col-sm-6,
218
+ .col-sm-7,
219
+ .col-sm-8,
220
+ .col-sm-9,
221
+ .col-sm-10,
222
+ .col-sm-11 {
223
+ float: left; }
224
+
225
+ .col-sm-1 {
226
+ width: 8.33333%; }
227
+
228
+ .col-sm-2 {
229
+ width: 16.66667%; }
230
+
231
+ .col-sm-3 {
232
+ width: 25%; }
233
+
234
+ .col-sm-4, header .row #header_logo {
235
+ width: 33.33333%; }
236
+
237
+ .col-sm-5 {
238
+ width: 41.66667%; }
239
+
240
+ .col-sm-6 {
241
+ width: 50%; }
242
+
243
+ .col-sm-7 {
244
+ width: 58.33333%; }
245
+
246
+ .col-sm-8 {
247
+ width: 66.66667%; }
248
+
249
+ .col-sm-9 {
250
+ width: 75%; }
251
+
252
+ .col-sm-10 {
253
+ width: 83.33333%; }
254
+
255
+ .col-sm-11 {
256
+ width: 91.66667%; }
257
+
258
+ .col-sm-12 {
259
+ width: 100%; }
260
+
261
+ .col-sm-push-1 {
262
+ left: 8.33333%; }
263
+
264
+ .col-sm-push-2 {
265
+ left: 16.66667%; }
266
+
267
+ .col-sm-push-3 {
268
+ left: 25%; }
269
+
270
+ .col-sm-push-4 {
271
+ left: 33.33333%; }
272
+
273
+ .col-sm-push-5 {
274
+ left: 41.66667%; }
275
+
276
+ .col-sm-push-6 {
277
+ left: 50%; }
278
+
279
+ .col-sm-push-7 {
280
+ left: 58.33333%; }
281
+
282
+ .col-sm-push-8 {
283
+ left: 66.66667%; }
284
+
285
+ .col-sm-push-9 {
286
+ left: 75%; }
287
+
288
+ .col-sm-push-10 {
289
+ left: 83.33333%; }
290
+
291
+ .col-sm-push-11 {
292
+ left: 91.66667%; }
293
+
294
+ .col-sm-pull-1 {
295
+ right: 8.33333%; }
296
+
297
+ .col-sm-pull-2 {
298
+ right: 16.66667%; }
299
+
300
+ .col-sm-pull-3 {
301
+ right: 25%; }
302
+
303
+ .col-sm-pull-4 {
304
+ right: 33.33333%; }
305
+
306
+ .col-sm-pull-5 {
307
+ right: 41.66667%; }
308
+
309
+ .col-sm-pull-6 {
310
+ right: 50%; }
311
+
312
+ .col-sm-pull-7 {
313
+ right: 58.33333%; }
314
+
315
+ .col-sm-pull-8 {
316
+ right: 66.66667%; }
317
+
318
+ .col-sm-pull-9 {
319
+ right: 75%; }
320
+
321
+ .col-sm-pull-10 {
322
+ right: 83.33333%; }
323
+
324
+ .col-sm-pull-11 {
325
+ right: 91.66667%; }
326
+
327
+ .col-sm-offset-1 {
328
+ margin-left: 8.33333%; }
329
+
330
+ .col-sm-offset-2 {
331
+ margin-left: 16.66667%; }
332
+
333
+ .col-sm-offset-3 {
334
+ margin-left: 25%; }
335
+
336
+ .col-sm-offset-4 {
337
+ margin-left: 33.33333%; }
338
+
339
+ .col-sm-offset-5 {
340
+ margin-left: 41.66667%; }
341
+
342
+ .col-sm-offset-6 {
343
+ margin-left: 50%; }
344
+
345
+ .col-sm-offset-7 {
346
+ margin-left: 58.33333%; }
347
+
348
+ .col-sm-offset-8 {
349
+ margin-left: 66.66667%; }
350
+
351
+ .col-sm-offset-9 {
352
+ margin-left: 75%; }
353
+
354
+ .col-sm-offset-10 {
355
+ margin-left: 83.33333%; }
356
+
357
+ .col-sm-offset-11 {
358
+ margin-left: 91.66667%; }
359
+ }
360
+ @media (min-width: 992px) {
361
+ .col-md-1,
362
+ .col-md-2,
363
+ .col-md-3,
364
+ .col-md-4,
365
+ .col-md-5,
366
+ .col-md-6,
367
+ .col-md-7,
368
+ .col-md-8,
369
+ .col-md-9,
370
+ .col-md-10,
371
+ .col-md-11 {
372
+ float: left; }
373
+
374
+ .col-md-1 {
375
+ width: 8.33333%; }
376
+
377
+ .col-md-2 {
378
+ width: 16.66667%; }
379
+
380
+ .col-md-3 {
381
+ width: 25%; }
382
+
383
+ .col-md-4 {
384
+ width: 33.33333%; }
385
+
386
+ .col-md-5 {
387
+ width: 41.66667%; }
388
+
389
+ .col-md-6 {
390
+ width: 50%; }
391
+
392
+ .col-md-7 {
393
+ width: 58.33333%; }
394
+
395
+ .col-md-8 {
396
+ width: 66.66667%; }
397
+
398
+ .col-md-9 {
399
+ width: 75%; }
400
+
401
+ .col-md-10 {
402
+ width: 83.33333%; }
403
+
404
+ .col-md-11 {
405
+ width: 91.66667%; }
406
+
407
+ .col-md-12 {
408
+ width: 100%; }
409
+
410
+ .col-md-push-0 {
411
+ left: auto; }
412
+
413
+ .col-md-push-1 {
414
+ left: 8.33333%; }
415
+
416
+ .col-md-push-2 {
417
+ left: 16.66667%; }
418
+
419
+ .col-md-push-3 {
420
+ left: 25%; }
421
+
422
+ .col-md-push-4 {
423
+ left: 33.33333%; }
424
+
425
+ .col-md-push-5 {
426
+ left: 41.66667%; }
427
+
428
+ .col-md-push-6 {
429
+ left: 50%; }
430
+
431
+ .col-md-push-7 {
432
+ left: 58.33333%; }
433
+
434
+ .col-md-push-8 {
435
+ left: 66.66667%; }
436
+
437
+ .col-md-push-9 {
438
+ left: 75%; }
439
+
440
+ .col-md-push-10 {
441
+ left: 83.33333%; }
442
+
443
+ .col-md-push-11 {
444
+ left: 91.66667%; }
445
+
446
+ .col-md-pull-0 {
447
+ right: auto; }
448
+
449
+ .col-md-pull-1 {
450
+ right: 8.33333%; }
451
+
452
+ .col-md-pull-2 {
453
+ right: 16.66667%; }
454
+
455
+ .col-md-pull-3 {
456
+ right: 25%; }
457
+
458
+ .col-md-pull-4 {
459
+ right: 33.33333%; }
460
+
461
+ .col-md-pull-5 {
462
+ right: 41.66667%; }
463
+
464
+ .col-md-pull-6 {
465
+ right: 50%; }
466
+
467
+ .col-md-pull-7 {
468
+ right: 58.33333%; }
469
+
470
+ .col-md-pull-8 {
471
+ right: 66.66667%; }
472
+
473
+ .col-md-pull-9 {
474
+ right: 75%; }
475
+
476
+ .col-md-pull-10 {
477
+ right: 83.33333%; }
478
+
479
+ .col-md-pull-11 {
480
+ right: 91.66667%; }
481
+
482
+ .col-md-offset-0 {
483
+ margin-left: 0; }
484
+
485
+ .col-md-offset-1 {
486
+ margin-left: 8.33333%; }
487
+
488
+ .col-md-offset-2 {
489
+ margin-left: 16.66667%; }
490
+
491
+ .col-md-offset-3 {
492
+ margin-left: 25%; }
493
+
494
+ .col-md-offset-4 {
495
+ margin-left: 33.33333%; }
496
+
497
+ .col-md-offset-5 {
498
+ margin-left: 41.66667%; }
499
+
500
+ .col-md-offset-6 {
501
+ margin-left: 50%; }
502
+
503
+ .col-md-offset-7 {
504
+ margin-left: 58.33333%; }
505
+
506
+ .col-md-offset-8 {
507
+ margin-left: 66.66667%; }
508
+
509
+ .col-md-offset-9 {
510
+ margin-left: 75%; }
511
+
512
+ .col-md-offset-10 {
513
+ margin-left: 83.33333%; }
514
+
515
+ .col-md-offset-11 {
516
+ margin-left: 91.66667%; }
517
+ }
518
+ @media (min-width: 1200px) {
519
+ .col-lg-1,
520
+ .col-lg-2,
521
+ .col-lg-3,
522
+ .col-lg-4,
523
+ .col-lg-5,
524
+ .col-lg-6,
525
+ .col-lg-7,
526
+ .col-lg-8,
527
+ .col-lg-9,
528
+ .col-lg-10,
529
+ .col-lg-11 {
530
+ float: left; }
531
+
532
+ .col-lg-1 {
533
+ width: 8.33333%; }
534
+
535
+ .col-lg-2 {
536
+ width: 16.66667%; }
537
+
538
+ .col-lg-3 {
539
+ width: 25%; }
540
+
541
+ .col-lg-4 {
542
+ width: 33.33333%; }
543
+
544
+ .col-lg-5 {
545
+ width: 41.66667%; }
546
+
547
+ .col-lg-6 {
548
+ width: 50%; }
549
+
550
+ .col-lg-7 {
551
+ width: 58.33333%; }
552
+
553
+ .col-lg-8 {
554
+ width: 66.66667%; }
555
+
556
+ .col-lg-9 {
557
+ width: 75%; }
558
+
559
+ .col-lg-10 {
560
+ width: 83.33333%; }
561
+
562
+ .col-lg-11 {
563
+ width: 91.66667%; }
564
+
565
+ .col-lg-12 {
566
+ width: 100%; }
567
+
568
+ .col-lg-push-0 {
569
+ left: auto; }
570
+
571
+ .col-lg-push-1 {
572
+ left: 8.33333%; }
573
+
574
+ .col-lg-push-2 {
575
+ left: 16.66667%; }
576
+
577
+ .col-lg-push-3 {
578
+ left: 25%; }
579
+
580
+ .col-lg-push-4 {
581
+ left: 33.33333%; }
582
+
583
+ .col-lg-push-5 {
584
+ left: 41.66667%; }
585
+
586
+ .col-lg-push-6 {
587
+ left: 50%; }
588
+
589
+ .col-lg-push-7 {
590
+ left: 58.33333%; }
591
+
592
+ .col-lg-push-8 {
593
+ left: 66.66667%; }
594
+
595
+ .col-lg-push-9 {
596
+ left: 75%; }
597
+
598
+ .col-lg-push-10 {
599
+ left: 83.33333%; }
600
+
601
+ .col-lg-push-11 {
602
+ left: 91.66667%; }
603
+
604
+ .col-lg-pull-0 {
605
+ right: auto; }
606
+
607
+ .col-lg-pull-1 {
608
+ right: 8.33333%; }
609
+
610
+ .col-lg-pull-2 {
611
+ right: 16.66667%; }
612
+
613
+ .col-lg-pull-3 {
614
+ right: 25%; }
615
+
616
+ .col-lg-pull-4 {
617
+ right: 33.33333%; }
618
+
619
+ .col-lg-pull-5 {
620
+ right: 41.66667%; }
621
+
622
+ .col-lg-pull-6 {
623
+ right: 50%; }
624
+
625
+ .col-lg-pull-7 {
626
+ right: 58.33333%; }
627
+
628
+ .col-lg-pull-8 {
629
+ right: 66.66667%; }
630
+
631
+ .col-lg-pull-9 {
632
+ right: 75%; }
633
+
634
+ .col-lg-pull-10 {
635
+ right: 83.33333%; }
636
+
637
+ .col-lg-pull-11 {
638
+ right: 91.66667%; }
639
+
640
+ .col-lg-offset-0 {
641
+ margin-left: 0; }
642
+
643
+ .col-lg-offset-1 {
644
+ margin-left: 8.33333%; }
645
+
646
+ .col-lg-offset-2 {
647
+ margin-left: 16.66667%; }
648
+
649
+ .col-lg-offset-3 {
650
+ margin-left: 25%; }
651
+
652
+ .col-lg-offset-4 {
653
+ margin-left: 33.33333%; }
654
+
655
+ .col-lg-offset-5 {
656
+ margin-left: 41.66667%; }
657
+
658
+ .col-lg-offset-6 {
659
+ margin-left: 50%; }
660
+
661
+ .col-lg-offset-7 {
662
+ margin-left: 58.33333%; }
663
+
664
+ .col-lg-offset-8 {
665
+ margin-left: 66.66667%; }
666
+
667
+ .col-lg-offset-9 {
668
+ margin-left: 75%; }
669
+
670
+ .col-lg-offset-10 {
671
+ margin-left: 83.33333%; }
672
+
673
+ .col-lg-offset-11 {
674
+ margin-left: 91.66667%; }
675
+ }
676
+
677
+ /* img responsive */
678
+ img {
679
+ vertical-align: middle; }
680
+
681
+ .img-responsive {
682
+ display: block;
683
+ max-width: 100%;
684
+ height: auto; }
685
+
686
+ /* text */
687
+ .text-left {
688
+ text-align: left !important; }
689
+
690
+ .text-right {
691
+ text-align: right !important; }
692
+
693
+ .text-center {
694
+ text-align: center !important; }
695
+
696
+ /* hr */
697
+ hr {
698
+ margin-top: 18px !important;
699
+ margin-bottom: 18px !important;
700
+ border: 0 !important;
701
+ border-top: 1px solid #eeeeee !important; }
702
+
703
+ /* table */
704
+ .steerfox-panel table {
705
+ border: none;
706
+ max-width: 100%;
707
+ background-color: transparent; }
708
+
709
+ th {
710
+ text-align: left; }
711
+
712
+ .steerfox-panel .table {
713
+ width: 100%;
714
+ margin-bottom: 18px; }
715
+ .steerfox-panel .table thead > tr > th,
716
+ .steerfox-panel .table thead > tr > td,
717
+ .steerfox-panel .table tbody > tr > th,
718
+ .steerfox-panel .table tbody > tr > td,
719
+ .steerfox-panel .table tfoot > tr > th,
720
+ .steerfox-panel .table tfoot > tr > td {
721
+ line-height: 1.42857;
722
+ vertical-align: top;
723
+ border-bottom: 1px solid #d6d4d4;
724
+ border-top: none; }
725
+ .steerfox-panel .table thead > tr > th {
726
+ vertical-align: bottom;
727
+ border-bottom: 2px solid #d6d4d4; }
728
+ .steerfox-panel .table tbody > tr > th {
729
+ border-top: 1px solid #d6d4d4;
730
+ }
731
+ .steerfox-panel .table caption + thead tr:first-child th, .steerfox-panel .table caption + thead tr:first-child td,
732
+ .steerfox-panel .table colgroup + thead tr:first-child th,
733
+ .steerfox-panel .table colgroup + thead tr:first-child td,
734
+ .steerfox-panel .table thead:first-child tr:first-child th,
735
+ .steerfox-panel .table thead:first-child tr:first-child td {
736
+ border-top: 0; }
737
+ .steerfox-panel .table tbody + tbody {
738
+ border-top: 2px solid #d6d4d4; }
739
+ .steerfox-panel .table .table{
740
+ background-color: #fff; }
741
+
742
+ .table-condensed thead > tr > th,
743
+ .table-condensed thead > tr > td,
744
+ .table-condensed tbody > tr > th,
745
+ .table-condensed tbody > tr > td,
746
+ .table-condensed tfoot > tr > th,
747
+ .table-condensed tfoot > tr > td {
748
+ padding: 5px; }
749
+
750
+ .table-bordered {
751
+ border: 1px solid #d6d4d4; }
752
+ .table-bordered > thead > tr > th,
753
+ .table-bordered > thead > tr > td,
754
+ .table-bordered > tbody > tr > th,
755
+ .table-bordered > tbody > tr > td,
756
+ .table-bordered > tfoot > tr > th,
757
+ .table-bordered > tfoot > tr > td {
758
+ border: 1px solid #d6d4d4; }
759
+ .table-bordered > thead > tr > th,
760
+ .table-bordered > thead > tr > td {
761
+ border-bottom-width: 2px; }
762
+
763
+ .table-striped > tbody > tr:nth-child(odd) > td,
764
+ .table-striped > tbody > tr:nth-child(odd) > th {
765
+ background: none;
766
+ background-color: #f9f9f9; }
767
+
768
+ .table-hover > tbody > tr:hover > td,
769
+ .table-hover > tbody > tr:hover > th {
770
+ background: none;
771
+ background-color: #f5f5f5; }
772
+
773
+ table col[class*="col-"] {
774
+ float: none;
775
+ display: table-column; }
776
+
777
+ table td[class*="col-"],
778
+ table th[class*="col-"] {
779
+ float: none;
780
+ display: table-cell; }
781
+ .table-steerfoxcheck {
782
+ padding-left: 30px;
783
+ }
784
+ @media (max-width: 768px) {
785
+ .table-steerfoxcheck {
786
+ padding-left: 0;
787
+ }
788
+ .table-responsive {
789
+ width: 100%;
790
+ margin-bottom: 15px;
791
+ overflow-y: hidden;
792
+ overflow-x: scroll;
793
+ border: 1px solid #d6d4d4; }
794
+ .table-responsive > .table {
795
+ margin-bottom: 0;
796
+ background-color: #fff; }
797
+ .table-responsive > .table > thead > tr > th,
798
+ .table-responsive > .table > thead > tr > td,
799
+ .table-responsive > .table > tbody > tr > th,
800
+ .table-responsive > .table > tbody > tr > td,
801
+ .table-responsive > .table > tfoot > tr > th,
802
+ .table-responsive > .table > tfoot > tr > td {
803
+ white-space: nowrap; }
804
+ .table-responsive > .table-bordered {
805
+ border: 0; }
806
+ .table-responsive > .table-bordered > thead > tr > th:first-child,
807
+ .table-responsive > .table-bordered > thead > tr > td:first-child,
808
+ .table-responsive > .table-bordered > tbody > tr > th:first-child,
809
+ .table-responsive > .table-bordered > tbody > tr > td:first-child,
810
+ .table-responsive > .table-bordered > tfoot > tr > th:first-child,
811
+ .table-responsive > .table-bordered > tfoot > tr > td:first-child {
812
+ border-left: 0; }
813
+ .table-responsive > .table-bordered > thead > tr > th:last-child,
814
+ .table-responsive > .table-bordered > thead > tr > td:last-child,
815
+ .table-responsive > .table-bordered > tbody > tr > th:last-child,
816
+ .table-responsive > .table-bordered > tbody > tr > td:last-child,
817
+ .table-responsive > .table-bordered > tfoot > tr > th:last-child,
818
+ .table-responsive > .table-bordered > tfoot > tr > td:last-child {
819
+ border-right: 0; }
820
+ .table-responsive > .table-bordered > thead > tr:last-child > th,
821
+ .table-responsive > .table-bordered > thead > tr:last-child > td,
822
+ .table-responsive > .table-bordered > tbody > tr:last-child > th,
823
+ .table-responsive > .table-bordered > tbody > tr:last-child > td,
824
+ .table-responsive > .table-bordered > tfoot > tr:last-child > th,
825
+ .table-responsive > .table-bordered > tfoot > tr:last-child > td {
826
+ border-bottom: 0; } }
827
+
828
+ /* steerfox panel */
829
+ .steerfox-panel {
830
+ background-color: white;
831
+ border: 1px solid #ccc;
832
+ padding: 10px;
833
+ color: #555;
834
+ margin-bottom: 15px;
835
+ }
836
+ .steerfox-panel .row {
837
+ background-color: white;
838
+ }
839
+
840
+ /* form helper free field */
841
+ .free-field {
842
+ padding-top: 4px;
843
+ }
844
+
845
+ .warning-field {
846
+ color: #8a6d3b;
847
+ }
848
+
849
+ .steerfox_account_form {
850
+ display: inline;
851
+ }
852
+
853
+ /* icon */
854
+ .icon-steerfox-container {
855
+ padding: 0 12px;
856
+ }
skin/adminhtml/default/default/steerfox/steerfox.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2015 Steerfox SAS.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+ * not use this file except in compliance with the License. You may obtain
6
+ * a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ * License for the specific language governing permissions and limitations
14
+ * under the License.
15
+ *
16
+ * @author Steerfox <tech@steerfox.com>
17
+ * @copyright 2015 Steerfox SAS
18
+ * @license http://www.apache.org/licenses/LICENSE-2.0
19
+ */
20
+ document.addEventListener("DOMContentLoaded",
21
+ function (e) {
22
+
23
+ // Enable only on welcome page
24
+ if(null != $('already_customer')){
25
+
26
+ if($('steerfox_plugins_account').up('div.section-config') != undefined){
27
+ $('steerfox_plugins_account').up('div.section-config').hide();
28
+ }else{
29
+ // Case for Older Magento
30
+ $('steerfox_plugins_account').hide();
31
+ $('steerfox_plugins_account-head').up('div.entry-edit-head').hide();
32
+ }
33
+
34
+
35
+ $('already_customer').observe('click', function(e){
36
+ e.preventDefault();
37
+ e.stopPropagation();
38
+ if($('steerfox_plugins_account').up('div.section-config') != undefined){
39
+ $('steerfox_plugins_account').up('div.section-config').show();
40
+ }else{
41
+ // Case for Older Magento
42
+ $('steerfox_plugins_account').show();
43
+ $('steerfox_plugins_account-head').up('div.entry-edit-head').show();
44
+ }
45
+
46
+ $('already_customer').scrollTo();
47
+
48
+ // Focus
49
+ document.getElementById('steerfox_plugins_account_api_key').focus();
50
+ });
51
+ }
52
+ }
53
+ );