Profileolabs_Shoppingflux - Version 0.6.7

Version Notes

- Minor bugfixes & improvements

Download this release

Release Info

Developer ShoppingFlux
Extension Profileolabs_Shoppingflux
Version 0.6.7
Comparing to
See all releases


Version 0.6.7

Files changed (99) hide show
  1. app/code/community/Profileolabs/.DS_Store +0 -0
  2. app/code/community/Profileolabs/Shoppingflux/Block/Export/.DS_Store +0 -0
  3. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Catalog/Category/Edit/Form.php +39 -0
  4. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Catalog/Category/Tab/Default.php +192 -0
  5. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Process.php +150 -0
  6. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Product.php +64 -0
  7. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Product/Grid.php +228 -0
  8. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Widget/Grid/Column/Renderer/Bool.php +33 -0
  9. app/code/community/Profileolabs/Shoppingflux/Block/Export/Flow.php +982 -0
  10. app/code/community/Profileolabs/Shoppingflux/Block/Export/Flux.php +65 -0
  11. app/code/community/Profileolabs/Shoppingflux/Block/Export/Tracking.php +68 -0
  12. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Cron.php +21 -0
  13. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Cron/Grid.php +107 -0
  14. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Import.php +12 -0
  15. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Log.php +25 -0
  16. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Log/Grid.php +64 -0
  17. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Order.php +20 -0
  18. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Order/Grid.php +235 -0
  19. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/System/Config/Form/Fieldset/Shipping/Method.php +92 -0
  20. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Payment/Info/Purchaseorder.php +17 -0
  21. app/code/community/Profileolabs/Shoppingflux/Block/Tracking/Buyline.php +19 -0
  22. app/code/community/Profileolabs/Shoppingflux/Block/Tracking/Roi.php +44 -0
  23. app/code/community/Profileolabs/Shoppingflux/Helper/Data.php +331 -0
  24. app/code/community/Profileolabs/Shoppingflux/Model/Attribute/Source/Category.php +67 -0
  25. app/code/community/Profileolabs/Shoppingflux/Model/Config.php +265 -0
  26. app/code/community/Profileolabs/Shoppingflux/Model/Export/Convert/Parser/Product.php +42 -0
  27. app/code/community/Profileolabs/Shoppingflux/Model/Export/Flow.php +800 -0
  28. app/code/community/Profileolabs/Shoppingflux/Model/Export/Flux.php +898 -0
  29. app/code/community/Profileolabs/Shoppingflux/Model/Export/Observer.php +414 -0
  30. app/code/community/Profileolabs/Shoppingflux/Model/Export/Rewrite/Catalog/Config.php +58 -0
  31. app/code/community/Profileolabs/Shoppingflux/Model/Export/Rewrite/CatalogInventory/Stock/Item.php +33 -0
  32. app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Attributes.php +48 -0
  33. app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Attributesprice.php +31 -0
  34. app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Category/Level.php +18 -0
  35. app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Visibility.php +21 -0
  36. app/code/community/Profileolabs/Shoppingflux/Model/Export/Updates.php +32 -0
  37. app/code/community/Profileolabs/Shoppingflux/Model/Export/Xml.php +150 -0
  38. app/code/community/Profileolabs/Shoppingflux/Model/Export/Xmlflow.deprecated.php +251 -0
  39. app/code/community/Profileolabs/Shoppingflux/Model/Export/Xmlflow.php +140 -0
  40. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Convert/Customer.php +108 -0
  41. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Export/Shipments.php +20 -0
  42. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Log.php +36 -0
  43. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Observer.php +180 -0
  44. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Order.php +817 -0
  45. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/OrderOLD.php +683 -0
  46. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Payment/Method/Purchaseorder.php +45 -0
  47. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Product.php +18 -0
  48. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Shipping/Carrier/Shoppingflux.php +81 -0
  49. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Shipping/Method.php +46 -0
  50. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Flux.php +17 -0
  51. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Flux/Collection.php +15 -0
  52. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Updates.php +17 -0
  53. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Updates/Collection.php +15 -0
  54. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Export/Shipments.php +13 -0
  55. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Export/Shipments/Collection.php +14 -0
  56. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Log.php +15 -0
  57. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Log/Collection.php +15 -0
  58. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Shipping/Method.php +15 -0
  59. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Shipping/Method/Collection.php +15 -0
  60. app/code/community/Profileolabs/Shoppingflux/Model/Service.php +286 -0
  61. app/code/community/Profileolabs/Shoppingflux/Model/Service/Http/Client/Adapter/Curl.php +507 -0
  62. app/code/community/Profileolabs/Shoppingflux/Model/Service/Http/Client/Adapter/Stream.php +46 -0
  63. app/code/community/Profileolabs/Shoppingflux/Model/System/Config/Backend/Apikey.php +39 -0
  64. app/code/community/Profileolabs/Shoppingflux/Model/System/Config/Backend/Refresh.php +61 -0
  65. app/code/community/Profileolabs/Shoppingflux/controllers/Adminhtml/GeneralController.php +24 -0
  66. app/code/community/Profileolabs/Shoppingflux/controllers/Export/Adminhtml/CategoryController.php +29 -0
  67. app/code/community/Profileolabs/Shoppingflux/controllers/Export/Adminhtml/ExportController.php +124 -0
  68. app/code/community/Profileolabs/Shoppingflux/controllers/Export/FluxController.php +150 -0
  69. app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/CronController.php +38 -0
  70. app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/ImportController.php +55 -0
  71. app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/LogController.php +48 -0
  72. app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/OrderController.php +57 -0
  73. app/code/community/Profileolabs/Shoppingflux/doc/doc_module_1.4.pdf +0 -0
  74. app/code/community/Profileolabs/Shoppingflux/etc/config.xml +551 -0
  75. app/code/community/Profileolabs/Shoppingflux/etc/system.xml +1137 -0
  76. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-install-0.1.0.php +121 -0
  77. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.1.0-0.1.1.php +37 -0
  78. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.3.13-0.3.14.php +51 -0
  79. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.3.14-0.3.15.php +20 -0
  80. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.3.17-0.3.18.php +37 -0
  81. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.4.2-0.4.3.php +44 -0
  82. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.4.6-0.5.0.php +46 -0
  83. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.5.1-0.5.2.php +42 -0
  84. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.5.3-0.5.4.php +30 -0
  85. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.5.5-0.5.6.php +28 -0
  86. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.6.5-0.6.6.php +25 -0
  87. app/design/adminhtml/default/default/layout/profileolabs_shoppingflux.xml +65 -0
  88. app/design/adminhtml/default/default/template/profileolabs/shoppingflux/export/category/edit.phtml +77 -0
  89. app/design/adminhtml/default/default/template/profileolabs/shoppingflux/export/edit.phtml +33 -0
  90. app/design/adminhtml/default/default/template/profileolabs/shoppingflux/export/process.phtml +178 -0
  91. app/design/adminhtml/default/default/template/profileolabs/shoppingflux/export/product.phtml +22 -0
  92. app/design/adminhtml/default/default/template/profileolabs/shoppingflux/manageorders/import.phtml +17 -0
  93. app/design/adminhtml/default/default/template/profileolabs/shoppingflux/manageorders/payment/info/purchaseorder.phtml +28 -0
  94. app/design/adminhtml/default/default/template/profileolabs/shoppingflux/manageorders/sales/order/total.phtml +9 -0
  95. app/design/frontend/base/default/layout/profileolabs_shoppingflux.xml +13 -0
  96. app/design/frontend/default/default/layout/profileolabs_shoppingflux.xml +13 -0
  97. app/etc/modules/Profileolabs_Shoppingflux.xml +9 -0
  98. app/locale/fr_FR/Profileolabs_Shoppingflux.csv +60 -0
  99. package.xml +19 -0
app/code/community/Profileolabs/.DS_Store ADDED
Binary file
app/code/community/Profileolabs/Shoppingflux/Block/Export/.DS_Store ADDED
Binary file
app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Catalog/Category/Edit/Form.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Block for category page to assiocate products.
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author Vincent Enjalbert @ Web-cooking.net
8
+ */
9
+
10
+ class Profileolabs_Shoppingflux_Block_Export_Adminhtml_Catalog_Category_Edit_Form extends Mage_Adminhtml_Block_Template {
11
+
12
+ public function __construct() {
13
+ parent::__construct();
14
+ $this->setTemplate('profileolabs/shoppingflux/export/category/edit.phtml');
15
+ }
16
+
17
+ public function getCategory() {
18
+ return Mage::registry('category');
19
+ }
20
+
21
+ public function getProductsJson() {
22
+ $products = array();
23
+ $collection = Mage::getModel('catalog/product')->getCollection()
24
+ ->addAttributeToFilter('shoppingflux_default_category', $this->getCategory()->getId())
25
+ ->addStoreFilter($this->getRequest()->getParam('store'));
26
+ foreach ($collection as $_product) {
27
+ $products[$_product->getId()] = 1;
28
+ }
29
+ if(!empty($products)) {
30
+ $currentVersion = Mage::getVersion();
31
+ if (version_compare($currentVersion, '1.4.0') < 0) {
32
+ return Zend_Json::encode($products);
33
+ }
34
+ return Mage::helper('core')->jsonEncode($products);
35
+ }
36
+ return '{}';
37
+ }
38
+
39
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Catalog/Category/Tab/Default.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Block for category page to assiocate products.
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author Vincent Enjalbert @ Web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Block_Export_Adminhtml_Catalog_Category_Tab_Default extends Mage_Adminhtml_Block_Widget_Grid {
10
+
11
+ public function __construct() {
12
+ parent::__construct();
13
+ $this->setId('shoppingflux_default_category_products');
14
+ $this->setDefaultSort('entity_id');
15
+ $this->setUseAjax(true);
16
+ }
17
+
18
+ public function getCategory()
19
+ {
20
+ return Mage::registry('category');
21
+ }
22
+
23
+ protected function _afterToHtml($html) {
24
+ $html = parent::_afterToHtml($html);
25
+ if($this->getRequest()->getActionName() != 'edit') return $html;
26
+ $scriptData = $this->getLayout()->createBlock('profileolabs_shoppingflux/export_adminhtml_catalog_category_edit_form', 'category.edit.shoppingflux')->toHtml();
27
+ //Mage::log($html .
28
+ // $scriptData
29
+ // .
30
+ // '<input type="hidden" name="shoppingflux_category_products" id="shoppingflux_in_category_products" value="" />');
31
+ return $html .
32
+ $scriptData
33
+ .
34
+ '<input type="hidden" name="shoppingflux_category_products" id="shoppingflux_in_category_products" value="" />';
35
+ }
36
+
37
+ protected function _addColumnFilterToCollection($column)
38
+ {
39
+ // Set custom filter for in category flag
40
+ if ($column->getId() == 'in_shoppingflux_category') {
41
+ $productIds = $this->_getSelectedProducts();
42
+ if (empty($productIds)) {
43
+ $productIds = 0;
44
+ }
45
+ if ($column->getFilter()->getValue()) {
46
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
47
+ }
48
+ elseif(!empty($productIds)) {
49
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
50
+ }
51
+ }
52
+ else if ($column->getId() == 'is_in_category') {
53
+ $productIds = $this->_getInCategoryProducts();
54
+ if (empty($productIds)) {
55
+ $productIds = 0;
56
+ }
57
+ if ($column->getFilter()->getValue()) {
58
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
59
+ }
60
+ elseif(!empty($productIds)) {
61
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
62
+ }
63
+ } else {
64
+ parent::_addColumnFilterToCollection($column);
65
+ }
66
+ return $this;
67
+ }
68
+
69
+ protected function _getSelectedProducts() {
70
+ $products = $this->getRequest()->getPost('sf_selected_products');
71
+ if (is_null($products)) {
72
+ $products = array();
73
+ $collection = Mage::getModel('catalog/product')->getCollection()
74
+ ->setStore($this->getRequest()->getParam('store'))
75
+ ->setStoreId($this->getRequest()->getParam('store'))
76
+ ->addAttributeToFilter('shoppingflux_default_category', $this->getCategory()->getId())
77
+ ->addStoreFilter($this->getRequest()->getParam('store'));
78
+ foreach($collection as $_product) {
79
+ $products[] = $_product->getId();
80
+ }
81
+ return $products;
82
+ }
83
+ return $products;
84
+ }
85
+
86
+ protected function _getInCategoryProducts()
87
+ {
88
+ $products = $this->getRequest()->getPost('selected_products');
89
+ if (is_null($products)) {
90
+ $products = $this->getCategory()->getProductsPosition();
91
+ return array_keys($products);
92
+ }
93
+ return $products;
94
+ }
95
+
96
+ protected function _prepareCollection() {
97
+ if ($this->getCategory()->getId()) {
98
+ $this->setDefaultFilter(array('in_shoppingflux_category' => 1));
99
+ }
100
+ $collection = Mage::getModel('catalog/product')->getCollection()
101
+ ->setStore($this->getRequest()->getParam('store'))
102
+ ->setStoreId($this->getRequest()->getParam('store'))
103
+ ->addAttributeToSelect('name')
104
+ ->addAttributeToSelect('sku')
105
+ ->addAttributeToSelect('price')
106
+ //->addAttributeToSelect('shoppingflux_default_category')
107
+ ->addExpressionAttributeToSelect('shoppingflux_default_category','IF({{shoppingflux_default_category}}, {{shoppingflux_default_category}}, -1)', 'shoppingflux_default_category')
108
+ ->addAttributeToSelect('shoppingflux_product')
109
+ ->addStoreFilter($this->getRequest()->getParam('store'));
110
+ $this->setCollection($collection);
111
+
112
+
113
+ return parent::_prepareCollection();
114
+ }
115
+
116
+ protected function _prepareColumns() {
117
+
118
+
119
+
120
+ $this->addColumn('in_shoppingflux_category', array(
121
+ 'header_css_class' => 'a-center',
122
+ 'type' => 'checkbox',
123
+ 'name' => 'in_shoppingflux_category',
124
+ 'values' => $this->_getSelectedProducts(),
125
+ 'align' => 'center',
126
+ 'index' => 'entity_id'
127
+ ));
128
+ $this->addColumn('is_in_category', array(
129
+ 'header' => Mage::helper('profileolabs_shoppingflux')->__('In category ?'),
130
+ 'type' => 'bool',
131
+ 'name' => 'is_in_category',
132
+ 'values' => $this->_getInCategoryProducts(),
133
+ 'align' => 'center',
134
+ 'index' => 'entity_id',
135
+ 'filter' => 'adminhtml/widget_grid_column_filter_checkbox'
136
+ ));
137
+
138
+ $this->addColumn('entity_id', array(
139
+ 'header' => Mage::helper('catalog')->__('ID'),
140
+ 'sortable' => true,
141
+ 'width' => '60',
142
+ 'index' => 'entity_id'
143
+ ));
144
+ $this->addColumn('name', array(
145
+ 'header' => Mage::helper('catalog')->__('Name'),
146
+ 'index' => 'name'
147
+ ));
148
+ $this->addColumn('sku', array(
149
+ 'header' => Mage::helper('catalog')->__('SKU'),
150
+ 'width' => '80',
151
+ 'index' => 'sku'
152
+ ));
153
+ $this->addColumn('price', array(
154
+ 'header' => Mage::helper('catalog')->__('Price'),
155
+ 'type' => 'currency',
156
+ 'width' => '1',
157
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
158
+ 'index' => 'price'
159
+ ));
160
+
161
+ $optionsCategories = Mage::helper('profileolabs_shoppingflux')->getCategoriesWithParents('name');
162
+ $optionsCategories = array_reverse($optionsCategories, true);
163
+ $optionsCategories[-1] = '__';
164
+ $optionsCategories = array_reverse($optionsCategories, true);
165
+ $this->addColumn('shoppingflux_default_category', array(
166
+ 'header' => Mage::helper('profileolabs_shoppingflux')->__('Current default category'),
167
+ 'width' => '80',
168
+ 'type' => 'options',
169
+ 'options' => $optionsCategories,
170
+ 'index' => 'shoppingflux_default_category'
171
+ ));
172
+
173
+ $optionsSf = array(0 => Mage::helper('profileolabs_shoppingflux')->__('No'), 1 => Mage::helper('profileolabs_shoppingflux')->__('Yes'));
174
+ $this->addColumn('shoppingflux_product', array(
175
+ 'header' => Mage::helper('profileolabs_shoppingflux')->__('Importé dans Shoppingflux'),
176
+ 'width' => '80',
177
+ 'index' => 'shoppingflux_product',
178
+ 'type' => 'options',
179
+ 'options' => $optionsSf
180
+ ));
181
+ return parent::_prepareColumns();
182
+ }
183
+
184
+ public function getGridUrl() {
185
+ return $this->getUrl('shoppingflux/export_adminhtml_category/grid', array('_current' => true));
186
+ }
187
+
188
+ public function getColumnRenderers() {
189
+ return array('bool'=>'profileolabs_shoppingflux/export_adminhtml_widget_grid_column_renderer_bool');
190
+ }
191
+
192
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Process.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ShoppingFlux
4
+ * @package Profileolabs_ShoppingFlux
5
+ * @author kassim belghait
6
+ * @deprecated deprecated since 0.1.1
7
+ */
8
+ class Profileolabs_Shoppingflux_Block_Export_Adminhtml_Process extends Mage_Adminhtml_Block_Abstract
9
+ {
10
+
11
+ /**
12
+ * Flag for flow model
13
+ * @var boolean
14
+ */
15
+ protected $_flowModelPrepared = false;
16
+ /**
17
+ * flow model instance
18
+ * @var Profileolabs_Shoppingflux_Model_Export_Flow
19
+ */
20
+ protected $_flowModel = null;
21
+
22
+ public function _getFlowModel()
23
+ {
24
+ return $this->_flowModel;
25
+ }
26
+
27
+ /**
28
+ * Return batch model and initialize it if need
29
+ * @return Profileolabs_Shoppingflux_Model_Export_Flow
30
+ */
31
+ public function getFlowModel()
32
+ {
33
+ return $this->_prepareFlowModel()
34
+ ->_getFlowModel();
35
+ }
36
+
37
+ /**
38
+ * Preparing flow model (initialization)
39
+ * @return Profileolabs_Shoppingflux_Block_Export_Adminhtml_Process
40
+ */
41
+ protected function _prepareFlowModel()
42
+ {
43
+ if ($this->_flowModelPrepared) {
44
+ return $this;
45
+ }
46
+ $this->setShowFinished(true);
47
+ /* @var $this->_flowModel Profileolabs_Shoppingflux_Model_Export_Flow */
48
+
49
+ $this->_flowModel = Mage::getSingleton('profileolabs_shoppingflux/export_flow')->reset();;
50
+ $storeId = $this->getRequest()->getParam('store',0);
51
+ $this->_flowModel->setStoreId($storeId);
52
+ $flowItemsCount = $this->_flowModel->getProductCollection()->getSize();
53
+
54
+
55
+
56
+ $this->_flowModel->setException(Mage::helper("dataflow")->__("%d produits trouvés.(en stock + hors stock)",$flowItemsCount));
57
+ $soldOutTxt = "";
58
+ if(!$this->_flowModel->getConfig()->isExportSoldout())
59
+ {
60
+ $soldOutTxt = Mage::helper('profileolabs_shoppingflux')->__('Seuls les produits en stock seront exportés');
61
+ $this->_flowModel->setException($soldOutTxt);
62
+ }
63
+
64
+ $numberOfRecords = $this->_flowModel->getCollectionByOffset(1)->count();
65
+ $this->setNumberOfRecords($numberOfRecords);
66
+ $this->setShowFinished(false);
67
+ $offsets = ceil((int)$flowItemsCount/ $this->_flowModel->getLimit());
68
+ if($offsets == 0)
69
+ $offsets =1;
70
+
71
+ $this->_flowModel->setException(Mage::helper("dataflow")->__("La génération se fera en %d lot(s) de %d produit(s)",$offsets,$this->_flowModel->getLimit()));
72
+
73
+ $this->setFlowItemsCount( $flowItemsCount);
74
+ $this->setFlowConfig(
75
+ array(
76
+ 'styles' => array(
77
+ 'error' => array(
78
+ 'icon' => Mage::getDesign()->getSkinUrl('images/error_msg_icon.gif'),
79
+ 'bg' => '#FDD'
80
+ ),
81
+ 'message' => array(
82
+ 'icon' => Mage::getDesign()->getSkinUrl('images/fam_bullet_success.gif'),
83
+ 'bg' => '#DDF'
84
+ ),
85
+ 'loader' => Mage::getDesign()->getSkinUrl('images/ajax-loader.gif')
86
+ ),
87
+ 'template' => '<li style="#{style}" id="#{id}">'
88
+ . '<img id="#{id}_img" src="#{image}" class="v-middle" style="margin-right:5px"/>'
89
+ . '<span id="#{id}_status" class="text">#{text}</span>'
90
+ . '</li>',
91
+ 'text' => $this->__('Etape <strong>%s/%s. %s/%s</strong> produit(s)','#{offset}', $offsets, '#{updated}', '#{savedRows}'),
92
+ 'successText' => $this->__('<strong>%s</strong> produits exportés.', '#{updated}')
93
+ )
94
+ );
95
+
96
+ $importData = array();
97
+
98
+ for($i=1;$i<=$offsets;$i++)
99
+ {
100
+ $nbProducts = $this->_flowModel->getLimit();
101
+ if($i==$offsets)
102
+ $nbProducts = $this->_flowModel->getCollectionByOffset($i)->count();
103
+
104
+ $importData[] = array("offset"=>$i,"nbProducts"=>$nbProducts,"store"=>$this->getRequest()->getParam('store'));
105
+ }
106
+
107
+ $this->setImportData($importData);
108
+
109
+ $this->_flowModelPrepared = true;
110
+ return $this;
111
+ }
112
+
113
+ public function getExceptions()
114
+ {
115
+ return $this->getFlowModel()->getExceptions();
116
+ }
117
+
118
+
119
+
120
+ /**
121
+ * Generating form key
122
+ * @return string
123
+ */
124
+ public function getFormKey()
125
+ {
126
+ return Mage::getSingleton('core/session')->getFormKey();
127
+ }
128
+
129
+ /**
130
+ * Return a flow model config JSON
131
+ * @return string
132
+ */
133
+ public function getFlowConfigJson()
134
+ {
135
+ return Zend_Json::encode(
136
+ $this->getflowConfig()
137
+ );
138
+ }
139
+
140
+ /**
141
+ * Encoding to JSON
142
+ * @param string $source
143
+ * @return string JSON
144
+ */
145
+ public function jsonEncode($source)
146
+ {
147
+ return Zend_Json::encode($source);
148
+ }
149
+
150
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Product.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shoppingflux select products block
4
+ *
5
+ * @category Profileolabs
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author kassim belghait kassim@profileo.com
8
+ */
9
+ class Profileolabs_Shoppingflux_Block_Export_Adminhtml_Product extends Mage_Adminhtml_Block_Widget_Container
10
+ {
11
+ /**
12
+ * Set template
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->setTemplate('profileolabs/shoppingflux/export/product.phtml');
18
+ }
19
+
20
+ /**
21
+ * Prepare button and grid
22
+ *
23
+ * @return Mage_Adminhtml_Block_Catalog_Product
24
+ */
25
+ protected function _prepareLayout()
26
+ {
27
+
28
+ $this->setChild('grid', $this->getLayout()->createBlock('profileolabs_shoppingflux/export_adminhtml_product_grid', 'product.grid'));
29
+ return parent::_prepareLayout();
30
+ }
31
+
32
+ /**
33
+ * Deprecated since 1.3.2
34
+ *
35
+ * @return string
36
+ */
37
+ public function getAddNewButtonHtml()
38
+ {
39
+ return $this->getChildHtml('add_new_button');
40
+ }
41
+
42
+ /**
43
+ * Render grid
44
+ *
45
+ * @return string
46
+ */
47
+ public function getGridHtml()
48
+ {
49
+ return $this->getChildHtml('grid');
50
+ }
51
+
52
+ /**
53
+ * Check whether it is single store mode
54
+ *
55
+ * @return bool
56
+ */
57
+ public function isSingleStoreMode()
58
+ {
59
+ if (!Mage::app()->isSingleStoreMode()) {
60
+ return false;
61
+ }
62
+ return true;
63
+ }
64
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Product/Grid.php ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppingflux grid products block
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author kassim belghait kassim@profileo.com
9
+ */
10
+ class Profileolabs_Shoppingflux_Block_Export_Adminhtml_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
11
+ {
12
+
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ $this->setId('productGrid');
17
+ $this->setDefaultSort('entity_id');
18
+ $this->setDefaultDir('desc');
19
+ $this->setSaveParametersInSession(true);
20
+ $this->setUseAjax(true);
21
+ $this->setVarNameFilter('product_filter');
22
+
23
+ }
24
+
25
+ protected function _getStore()
26
+ {
27
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
28
+ return Mage::app()->getStore($storeId);
29
+ }
30
+
31
+ protected function _prepareCollection()
32
+ {
33
+ $store = $this->_getStore();
34
+ $collection = Mage::getModel('catalog/product')->getCollection()
35
+ ->addAttributeToSelect('sku')
36
+ ->addAttributeToSelect('name')
37
+ ->addAttributeToSelect('shoppingflux_product')
38
+ ->addAttributeToSelect('attribute_set_id')
39
+ ->addAttributeToSelect('type_id')
40
+ ->joinField('qty',
41
+ 'cataloginventory/stock_item',
42
+ 'qty',
43
+ 'product_id=entity_id',
44
+ '{{table}}.stock_id=1',
45
+ 'left');
46
+
47
+ if ($store->getId()) {
48
+ //$collection->setStoreId($store->getId());
49
+ $collection->addStoreFilter($store);
50
+ $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
51
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
52
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
53
+ $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
54
+ }
55
+ else {
56
+ $collection->addAttributeToSelect('price');
57
+ $collection->addAttributeToSelect('status');
58
+ $collection->addAttributeToSelect('visibility');
59
+ }
60
+
61
+ $this->setCollection($collection);
62
+
63
+ parent::_prepareCollection();
64
+ $this->getCollection()->addWebsiteNamesToResult();
65
+ return $this;
66
+ }
67
+
68
+ protected function _addColumnFilterToCollection($column)
69
+ {
70
+ if ($this->getCollection()) {
71
+ if ($column->getId() == 'websites') {
72
+ $this->getCollection()->joinField('websites',
73
+ 'catalog/product_website',
74
+ 'website_id',
75
+ 'product_id=entity_id',
76
+ null,
77
+ 'left');
78
+ }
79
+ }
80
+ return parent::_addColumnFilterToCollection($column);
81
+ }
82
+
83
+ protected function _prepareColumns()
84
+ {
85
+ $this->addColumn('entity_id',
86
+ array(
87
+ 'header'=> Mage::helper('catalog')->__('ID'),
88
+ 'width' => '50px',
89
+ 'type' => 'number',
90
+ 'index' => 'entity_id',
91
+ ));
92
+ $this->addColumn('name',
93
+ array(
94
+ 'header'=> Mage::helper('catalog')->__('Name'),
95
+ 'index' => 'name',
96
+ ));
97
+
98
+ $store = $this->_getStore();
99
+ if ($store->getId()) {
100
+ $this->addColumn('custom_name',
101
+ array(
102
+ 'header'=> Mage::helper('catalog')->__('Name In %s', $store->getName()),
103
+ 'index' => 'custom_name',
104
+ ));
105
+ }
106
+
107
+ $this->addColumn('type',
108
+ array(
109
+ 'header'=> Mage::helper('catalog')->__('Type'),
110
+ 'width' => '60px',
111
+ 'index' => 'type_id',
112
+ 'type' => 'options',
113
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
114
+ ));
115
+
116
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
117
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
118
+ ->load()
119
+ ->toOptionHash();
120
+
121
+ $this->addColumn('set_name',
122
+ array(
123
+ 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
124
+ 'width' => '100px',
125
+ 'index' => 'attribute_set_id',
126
+ 'type' => 'options',
127
+ 'options' => $sets,
128
+ ));
129
+
130
+ $this->addColumn('sku',
131
+ array(
132
+ 'header'=> Mage::helper('catalog')->__('SKU'),
133
+ 'width' => '80px',
134
+ 'index' => 'sku',
135
+ ));
136
+
137
+ $store = $this->_getStore();
138
+ $this->addColumn('price',
139
+ array(
140
+ 'header'=> Mage::helper('catalog')->__('Price'),
141
+ 'type' => 'price',
142
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
143
+ 'index' => 'price',
144
+ ));
145
+
146
+ $this->addColumn('qty',
147
+ array(
148
+ 'header'=> Mage::helper('catalog')->__('Qty'),
149
+ 'width' => '100px',
150
+ 'type' => 'number',
151
+ 'index' => 'qty',
152
+ ));
153
+
154
+ $this->addColumn('visibility',
155
+ array(
156
+ 'header'=> Mage::helper('catalog')->__('Visibility'),
157
+ 'width' => '70px',
158
+ 'index' => 'visibility',
159
+ 'type' => 'options',
160
+ 'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
161
+ ));
162
+
163
+ $this->addColumn('status',
164
+ array(
165
+ 'header'=> Mage::helper('catalog')->__('Status'),
166
+ 'width' => '70px',
167
+ 'index' => 'status',
168
+ 'type' => 'options',
169
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
170
+ ));
171
+ $optionsSf = array(0=>"Non",1=>"Oui");
172
+ $this->addColumn('shoppingflux_product',
173
+ array(
174
+ 'header'=> Mage::helper('catalog')->__('Importé dans Shoppingflux'),
175
+ 'width' => '70px',
176
+ 'index' => 'shoppingflux_product',
177
+ 'type' => 'options',
178
+ 'options' => $optionsSf,
179
+ ));
180
+
181
+ if (!Mage::app()->isSingleStoreMode()) {
182
+ $this->addColumn('websites',
183
+ array(
184
+ 'header'=> Mage::helper('catalog')->__('Websites'),
185
+ 'width' => '100px',
186
+ 'sortable' => false,
187
+ 'index' => 'websites',
188
+ 'type' => 'options',
189
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
190
+ ));
191
+ }
192
+
193
+ return parent::_prepareColumns();
194
+ }
195
+
196
+ protected function _prepareMassaction()
197
+ {
198
+ $this->setMassactionIdField('entity_id');
199
+ $this->getMassactionBlock()->setFormFieldName('product');
200
+
201
+ $optionsSf = array(0=>"Non",1=>"Oui");
202
+ $this->getMassactionBlock()->addItem('publish', array(
203
+ 'label'=> Mage::helper('profileolabs_shoppingflux')->__('Changer la publication'),
204
+ 'url' => $this->getUrl('*/*/massPublish', array('_current'=>true)),
205
+ 'additional' => array(
206
+ 'visibility' => array(
207
+ 'name' => 'publish',
208
+ 'type' => 'select',
209
+ 'class' => 'required-entry',
210
+ 'label' => Mage::helper('profileolabs_shoppingflux')->__('Publication'),
211
+ 'values' => $optionsSf
212
+ )
213
+ )
214
+ ));
215
+
216
+ return $this;
217
+ }
218
+
219
+ public function getGridUrl()
220
+ {
221
+ return $this->getUrl('*/*/grid', array('_current'=>true));
222
+ }
223
+
224
+ public function getRowUrl($row)
225
+ {
226
+ return '';
227
+ }
228
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Widget/Grid/Column/Renderer/Bool.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Block for category page to assiocate products.
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author Vincent Enjalbert @ Web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Block_Export_Adminhtml_Widget_Grid_Column_Renderer_Bool
10
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
11
+ {
12
+ protected $_defaultWidth = 55;
13
+ /**
14
+ * Renders grid column
15
+ *
16
+ * @param Varien_Object $row
17
+ * @return string
18
+ */
19
+ public function render(Varien_Object $row)
20
+ {
21
+ $values = $this->getColumn()->getValues();
22
+ $value = $row->getData($this->getColumn()->getIndex());
23
+ if (is_array($values)) {
24
+ $checked = in_array($value, $values);
25
+ }
26
+ else {
27
+ $checked = ($value === $this->getColumn()->getValue());
28
+ }
29
+
30
+ return $checked?Mage::helper('profileolabs_shoppingflux')->__('Yes'):Mage::helper('profileolabs_shoppingflux')->__('No');
31
+ }
32
+
33
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Export/Flow.php ADDED
@@ -0,0 +1,982 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // V1 DEPRECATED
3
+ class Profileolabs_Shoppingflux_Block_Export_Flow extends Mage_Core_Block_Template {
4
+
5
+ protected $_attributes = null;
6
+ protected $_attributesConfigurable = array();
7
+ protected $_attributesOptions = array();
8
+ protected $_fileName = "flow2.xml";
9
+ protected $_storeCategories = array();
10
+
11
+ public function __construct() {
12
+ $this->forceStore();
13
+ }
14
+
15
+ protected function _getStoreId() {
16
+ //store id is store view id
17
+
18
+ return $this->_getStore()->getId();
19
+ ;
20
+ }
21
+
22
+ protected function _getStore() {
23
+
24
+ $storeId = (int) $this->getRequest()->getParam('store', Mage::app()->getStore()->getId());
25
+ return Mage::app()->getStore($storeId);
26
+ }
27
+
28
+ protected function forceStore() {
29
+ if (( $storeId = (int) $this->getRequest()->getParam('store', 0) ) != 0) {
30
+ Mage::app()->setCurrentStore(Mage::app()->getStore($storeId));
31
+ }
32
+ }
33
+
34
+ protected function _writeXml($xml, $start = false) {
35
+ $mode = "a+";
36
+ if ($start)
37
+ $mode = "w+";
38
+ $storeId = $this->_getStoreId();
39
+ $storeCode = Mage::app()->getStore($storeId)->getCode();
40
+ $dir = Mage::getBaseDir('media') . DS . "shoppingflux" . DS . $storeCode . DS;
41
+ $file = new Varien_Io_File;
42
+ $file->checkAndCreateFolder($dir);
43
+ $file->cd($dir);
44
+ $file->streamOpen($this->_fileName, $mode);
45
+ $file->streamLock();
46
+ $file->streamWrite($xml);
47
+ $file->streamUnlock();
48
+ $file->streamClose();
49
+
50
+ if ($file->fileExists($this->_fileName)) {
51
+ return $this->_fileName;
52
+ }
53
+
54
+ return false;
55
+ }
56
+
57
+ protected $_exludeProductIds = null;
58
+
59
+ protected function _getExcludeProductIds($store = null) {
60
+ Varien_Profiler::start("SF::Flow::_getExcludeProductIds");
61
+ if (is_null($this->_exludeProductIds)) {
62
+ $mageCacheKey = 'sf_exclude_pids';
63
+ $fromCache = Mage::app()->loadCache($mageCacheKey);
64
+ if ($fromCache) {
65
+ $this->_exludeProductIds = unserialize($fromCache);
66
+ } else {
67
+
68
+ $this->_exludeProductIds = array();
69
+ $collection = Mage::getModel('catalog/product')
70
+ ->getCollection()
71
+ ->addFieldToFilter('type_id', array('neq' => 'simple'));
72
+ if ($store) {
73
+ $collection->setStore($store)
74
+ ->addStoreFilter($store);
75
+ }
76
+
77
+ $product = Mage::getModel('catalog/product');
78
+ Mage::getSingleton('core/resource_iterator')
79
+ ->walk($collection->getSelect(), array(array($this, '_excludeProductIds')), array('product' => $product));
80
+ Mage::app()->saveCache(serialize($this->_exludeProductIds), $mageCacheKey, array('shoppingflux', Mage_Catalog_Model_Product::CACHE_TAG));
81
+ }
82
+ }
83
+
84
+ Varien_Profiler::stop("SF::Flow::_getExcludeProductIds");
85
+ return $this->_exludeProductIds;
86
+ }
87
+
88
+ public function _excludeProductIds($args) {
89
+ $product = $args['product'];
90
+ $product->reset()->setTypeInstance(null, true);
91
+ $product->setData($args['row']);
92
+
93
+ if ($product->getTypeId() == 'configurable') {
94
+ $childrenIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getChildrenIds($product->getEntityId());
95
+ if ($childrenIds && is_array($childrenIds) && !empty($childrenIds))
96
+ $this->_exludeProductIds = array_merge($this->_exludeProductIds, $childrenIds[0]);
97
+ }
98
+ if ($product->getTypeId() == 'grouped' || $product->getTypeId() == 'bundle' || $product->getTypeId() == 'virtual') {
99
+ $this->_exludeProductIds = array_merge($this->_exludeProductIds, array($product->getEntityId()));
100
+ }
101
+ //sometimes magento return empty id, so we filter the array
102
+ $this->_exludeProductIds = array_filter($this->_exludeProductIds);
103
+ }
104
+
105
+ protected function _toHtml() {
106
+ Varien_Profiler::start("SF::Flow::toHtml");
107
+ ini_set("memory_limit", $this->getConfig()->getMemoryLimit() . "M");
108
+ $storeId = $this->_getStoreId();
109
+
110
+ /*
111
+ oringinal price - getPrice() - inputed in admin
112
+ special price - getSpecialPrice()
113
+ getFinalPrice() - used in shopping cart calculations
114
+ */
115
+ $product = Mage::getModel('catalog/product');
116
+
117
+ $priceAttributeCode = $this->getConfig()->getConfigData('shoppingflux_export/specific_prices/price', $this->_getStoreId());
118
+ $specialPriceAttributeCode = $this->getConfig()->getConfigData('shoppingflux_export/specific_prices/special_price', $this->_getStoreId());
119
+
120
+
121
+ $otherAttributes = array(
122
+ "shoppingflux_product" => "shoppingflux_product",
123
+ "shoppingflux_default_category" => "shoppingflux_default_category",
124
+ "tax_class_id" => "tax_class_id",
125
+ "special_price" => "special_price",
126
+ "minimal_price" => "minimal_price",
127
+ "special_from_date" => "special_from_date",
128
+ "special_to_date" => "special_to_date",
129
+ "image" => "image",
130
+ $priceAttributeCode => $priceAttributeCode,
131
+ $specialPriceAttributeCode => $specialPriceAttributeCode
132
+ );
133
+ $attributesToSelect = array_merge($this->getAttributesFromConfig(true), $otherAttributes);
134
+
135
+
136
+ $stockItemWhere = null;
137
+ if (!$this->getConfig()->isExportSoldout()) {
138
+
139
+ $_configManageStock = (int) Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
140
+ $stockItemWhere = "({{table}}.is_in_stock = 1) "
141
+ . " OR IF({{table}}.use_config_manage_stock=1," . $_configManageStock . ",{{table}}.manage_stock)=0";
142
+ }
143
+
144
+
145
+ $products = $product->getCollection()
146
+ ->addStoreFilter($storeId)
147
+ // ->addAttributeToFilter('status',1)
148
+ ->addAttributeToSelect($this->getRequiredAttributes(), 'left')
149
+ ->joinTable('cataloginventory/stock_item', 'product_id=entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock'), $stockItemWhere, 'left');
150
+
151
+
152
+
153
+
154
+ //->addAttributeToSelect($attributesToSelect, 'left')
155
+ foreach ($attributesToSelect as $key => $attributeCode) {
156
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
157
+ if ($attributeCode == 'image' || $attributeCode == 'sku' || ($this->getFlatHelper()->isEnabled($storeId) && $attribute->getUsedInProductListing())) {
158
+ $products->addAttributeToSelect($attributeCode);
159
+ } else {
160
+ try {
161
+ $products->joinAttribute($attributeCode, 'catalog_product/' . $attributeCode, 'entity_id', null, 'left', $storeId);
162
+ } catch (Exception $e) {
163
+ //die($attributeCode);
164
+ }
165
+ }
166
+ }
167
+
168
+ /*
169
+ if ($this->getFlatHelper()->isEnabled($storeId)) {
170
+ /*->addAttributeToSelect($attributesToSelect, 'left') shouldnt be enough ?
171
+
172
+ $allAttributesToSelect = array_unique($attributesToSelect);
173
+ foreach ($allAttributesToSelect as $attributeToSelect) {
174
+ if ($attributeToSelect == "sku")
175
+ continue;
176
+
177
+ $products->joinAttribute($attributeToSelect, 'catalog_product/' . $attributeToSelect, 'entity_id', null, 'left', $storeId);
178
+ }
179
+ } */
180
+
181
+
182
+ //FILTER BY SHOPPING FLUX FLAG
183
+ $sfProductFilterAttribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'shoppingflux_product');
184
+ if ($this->getConfig()->isExportFilteredByAttribute()) {
185
+ if ($this->getFlatHelper()->isEnabled($storeId) && $sfProductFilterAttribute->getUsedInProductListing()) {
186
+ $products->addAttributeToFilter('shoppingflux_product', 1);
187
+ } else {
188
+ $prefixAttribute = 'at_';
189
+ $currentVersion = Mage::getVersion();
190
+ if (version_compare($currentVersion, '1.6.0') < 0)
191
+ $prefixAttribute = '_table_';
192
+
193
+ $fieldName = $prefixAttribute . "shoppingflux_product";
194
+ $products->getSelect()->where("if(`{$fieldName}`.`value`, `{$fieldName}`.`value`, `{$fieldName}_default`.`value`)=1");
195
+ //$products->addAttributeToFilter('shoppingflux_product',1);
196
+ }
197
+ }
198
+
199
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
200
+ $products->setVisibility($this->getConfig()->getVisibilitiesToExport($this->_getStoreId()));
201
+ //Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
202
+
203
+ $products->addIdFilter($this->_getExcludeProductIds(), true);
204
+
205
+ if ($this->getProductSku()) {
206
+ $products->addAttributeToFilter('sku', $this->getProductSku());
207
+ }
208
+
209
+
210
+ if ($this->getLimit()) {
211
+ //$products->setPageSize($this->getLimit());
212
+ $products->getSelect()->limit($this->getLimit());
213
+ }
214
+
215
+
216
+ // if($_SERVER['REMOTE_ADDR'] == "127.0.0.1" || $_SERVER['REMOTE_ADDR']=="90.2.197.14")
217
+ //die('>'.$products->getSize().' '.$products->getSelect().' ');
218
+
219
+
220
+ $this->iterateProducts($products);
221
+
222
+ //$output = $xmlObj->createXml();
223
+ // $this->_writeXml($output,true);
224
+ Varien_Profiler::stop("SF::Flow::toHtml");
225
+ //return $output;
226
+ }
227
+
228
+ public function iterateProducts($products, $withLoad = false) {
229
+
230
+ Varien_Profiler::start("SF::Flow::iterateProducts");
231
+ Varien_Profiler::start("SF::Flow::iterateProducts-0");
232
+ $xmlObj = Mage::getModel('profileolabs_shoppingflux/export_xmlflow');
233
+ $xmlObj->startXml();
234
+ Varien_Profiler::stop("SF::Flow::iterateProducts-0");
235
+ if (!$withLoad) {
236
+
237
+ $product = Mage::getModel('catalog/product');
238
+ /*
239
+ using resource iterator to load the data one by one
240
+ instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
241
+ */
242
+ Varien_Profiler::start("SF::Flow::iterateProducts-1");
243
+ Mage::getSingleton('core/resource_iterator')
244
+ ->walk($products->getSelect(), array(array($this, 'addNewItemXmlCallback')), array('xmlObj' => $xmlObj, 'product' => $product));
245
+ Varien_Profiler::stop("SF::Flow::iterateProducts-1");
246
+ } else {
247
+ $products->addMinimalPrice()
248
+ ->addFinalPrice()
249
+ ->addTaxPercents();
250
+ }
251
+
252
+ unset($products);
253
+ $xmlObj->endXml();
254
+ Varien_Profiler::stop("SF::Flow::iterateProducts");
255
+ return $xmlObj;
256
+ }
257
+
258
+ public function addNewItemXml($args) {
259
+ Varien_Profiler::start("SF::Flow::addNewItemXmlCallback");
260
+ Varien_Profiler::start("SF::Flow::addNewItemXmlCallback-1");
261
+ $product = $args['product'];
262
+ $product->reset()->setTypeInstance(null, true);
263
+ // $product = Mage::getModel('catalog/product');
264
+ $product->setData($args['row']);
265
+
266
+
267
+ //To get isinstock correct value
268
+ // Mage::getModel('cataloginventory/stock_item')->assignProduct($product);
269
+
270
+
271
+ /* @var $xmlObj Profileolabs_Shoppingflux_Model_Export_Xmlflow */
272
+ $xmlObj = $args['xmlObj'];
273
+ $data = array(
274
+ 'id' => $product->getId(),
275
+ 'sku' => $product->getSku(),
276
+ 'product-url' => $this->cleanUrl($product->getProductUrl(false)),
277
+ 'is-in-stock' => $product->getIsInStock(),
278
+ 'qty' => round($product->getQty()),
279
+ );
280
+
281
+ foreach ($this->getConfig()->getMappingAllAttributes($this->_getStoreId()) as $nameNode => $code) {
282
+ $data[$nameNode] = trim($xmlObj->extractData($nameNode, $code, $product));
283
+ }
284
+
285
+
286
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback-1");
287
+
288
+ Varien_Profiler::start("SF::Flow::addNewItemXmlCallback-2");
289
+ $data = $this->getPrices($data, $product);
290
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback-2");
291
+ Varien_Profiler::start("SF::Flow::addNewItemXmlCallback-3");
292
+ $data = $this->getImages($data, $product);
293
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback-3");
294
+ Varien_Profiler::start("SF::Flow::addNewItemXmlCallback-4");
295
+ $data = $this->getCategories($data, $product);
296
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback-4");
297
+ Varien_Profiler::start("SF::Flow::addNewItemXmlCallback-5");
298
+ $data = $this->getShippingInfo($data, $product);
299
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback-5");
300
+ Varien_Profiler::start("SF::Flow::addNewItemXmlCallback-6");
301
+ $data = $this->getConfigurableAttributes($data, $product);
302
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback-6");
303
+ Varien_Profiler::start("SF::Flow::addNewItemXmlCallback-7");
304
+ ini_set('display_errors', true);
305
+ error_reporting(-1);
306
+ foreach ($this->getConfig()->getAdditionalAttributes() as $attributeCode) {
307
+ if (!$attributeCode)
308
+ continue;
309
+ $data[$attributeCode] = trim($xmlObj->extractData($attributeCode, $attributeCode, $product));
310
+ /*$attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
311
+ if ($attribute->usesSource()) {
312
+ $value = $product->getAttributeText($attributeCode);
313
+ } else {
314
+ $value = $product->getData($attributeCode);
315
+ }
316
+ if (is_array($value)) {
317
+ $value = explode(',', $value);
318
+ }
319
+ if ($value) {
320
+ $data[$attributeCode] = trim($value);
321
+ }*/
322
+ }
323
+
324
+
325
+ //Exceptions data shipping_delay
326
+ if (!isset($data['shipping_delay']) && empty($data['shipping_delay']))
327
+ $data['shipping_delay'] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
328
+
329
+ if (!$this->getConfig()->isExportSoldout()) {
330
+
331
+ if (!$data["is-in-stock"]) {
332
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback-7");
333
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback");
334
+ return;
335
+ }
336
+ }
337
+
338
+
339
+ $dataObj = new Varien_Object(array('entry' => $data));
340
+ Mage::dispatchEvent('shoppingflux_before_add_entry', array('data_obj' => $dataObj));
341
+
342
+ $entry = $dataObj->getEntry();
343
+
344
+ $xmlObj->_addEntry($entry);
345
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback-7");
346
+ Varien_Profiler::stop("SF::Flow::addNewItemXmlCallback");
347
+ }
348
+
349
+ public function addNewItemXmlCallback($args) {
350
+ return $this->addNewItemXml($args);
351
+ /* if (! function_exists('pcntl_fork')) {
352
+ return $this->addNewItemXml($args);
353
+ }
354
+ switch ($pid = pcntl_fork()) {
355
+ case -1:
356
+ //fork failed, just do as usual
357
+ return $this->addNewItemXml($args);
358
+ break;
359
+
360
+ case 0:
361
+ // @child
362
+ return $this->addNewItemXml($args);
363
+ break;
364
+
365
+ default:
366
+ // @parent
367
+ pcntl_waitpid($pid, $status);
368
+ break;
369
+ }*/
370
+
371
+ }
372
+
373
+ protected function getShippingInfo($data, $product) {
374
+
375
+ $data["shipping-name"] = "";
376
+ $data["shipping-price"] = "";
377
+
378
+ $carrier = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_method');
379
+ if (empty($carrier)) {
380
+ $data["shipping-price"] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_price');
381
+ return $data;
382
+ }
383
+
384
+ $carrierTab = explode('_', $carrier);
385
+ list($carrierCode, $methodCode) = $carrierTab;
386
+ $data["shipping-name"] = ucfirst($methodCode);
387
+
388
+
389
+ $shippingPrice = 0;
390
+ if($this->getConfig()->getConfigData('shoppingflux_export/general/try_use_real_shipping_price')) {
391
+ $countryCode = $this->getConfig()->getConfigData('shoppingflux_export/general/shipping_price_based_on');
392
+ Varien_Profiler::start("SF::Flow::getShippingInfo-1");
393
+ $shippingPrice = $this->helper('profileolabs_shoppingflux')->getShippingPrice($product, $carrier, $countryCode);
394
+ Varien_Profiler::stop("SF::Flow::getShippingInfo-1");
395
+ }
396
+
397
+ if (!$shippingPrice) {
398
+ $shippingPrice = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_price');
399
+ }
400
+
401
+ $data["shipping-price"] = $shippingPrice;
402
+
403
+ return $data;
404
+ }
405
+
406
+ protected function getConfigurableAttributes($data, $product) {
407
+
408
+ Varien_Profiler::start("SF::Flow::getConfigurableAttributes");
409
+ $data["configurable_attributes"] = "";
410
+ $data["childs_product"] = "";
411
+ $images = array();
412
+
413
+ $labels = array();
414
+ if ($product->getTypeId() == "configurable") {
415
+
416
+
417
+ $attributes = $this->helper('profileolabs_shoppingflux')->getAttributesConfigurable($product);
418
+
419
+ $attributesToSelect = array();
420
+ $attributesToOptions = array();
421
+
422
+ foreach ($attributes as $attribute) {
423
+ $attributesToSelect[] = $attribute['attribute_code'];
424
+
425
+ $attributesToOptions[$attribute['attribute_code']] = array();
426
+ }
427
+
428
+
429
+ $attributesToSelect[] = "sku";
430
+ $attributesToSelect[] = "status";
431
+
432
+
433
+
434
+ $priceAttributeCode = $this->getConfig()->getConfigData('shoppingflux_export/specific_prices/price', $this->_getStoreId());
435
+ $specialPriceAttributeCode = $this->getConfig()->getConfigData('shoppingflux_export/specific_prices/special_price', $this->_getStoreId());
436
+
437
+
438
+ $otherAttributes = array(
439
+ "shoppingflux_product" => "shoppingflux_product",
440
+ "shoppingflux_default_category" => "shoppingflux_default_category",
441
+ "tax_class_id" => "tax_class_id",
442
+ "special_price" => "special_price",
443
+ "minimal_price" => "minimal_price",
444
+ "special_from_date" => "special_from_date",
445
+ "special_to_date" => "special_to_date",
446
+ "image" => "image",
447
+ $priceAttributeCode => $priceAttributeCode,
448
+ $specialPriceAttributeCode => $specialPriceAttributeCode
449
+ );
450
+
451
+ $attributesFromConfig = $this->getAttributesFromConfig(true, true);
452
+ $attributesFromConfig = array_slice($attributesFromConfig, 0, 42);// Too much attributes causes too much joins, which can overload mysql limits
453
+ $attributesToSelect = array_merge($otherAttributes, $attributesFromConfig);
454
+ //$attributesFromConfig = $this->getAttributesFromConfig(true, true);
455
+ //if (isset($attributesFromConfig['ean']))
456
+ // $attributesToSelect[] = $attributesFromConfig['ean'];
457
+ //$attributesToSelect = array_merge($attributesToSelect, $attributesFromConfig);
458
+
459
+ $usedProducts = $product->getTypeInstance(true)
460
+ ->getUsedProductCollection($product);
461
+ foreach($attributesToSelect as $attributeCode) {
462
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
463
+ if ($attributeCode == 'image' || $attributeCode == 'sku' || ($this->getFlatHelper()->isEnabled($this->_getStoreId()) && $attribute->getUsedInProductListing())) {
464
+ $usedProducts->addAttributeToSelect($attributeCode, 'left');
465
+ } else {
466
+ try {
467
+ $usedProducts->joinAttribute( $attributeCode, 'catalog_product/'.$attributeCode, 'entity_id', null, 'left' );
468
+ } catch (Exception $e) {
469
+
470
+ }
471
+ }
472
+ }
473
+
474
+ if ($this->getConfig()->isExportFilteredByAttribute()) {
475
+ $usedProducts->addAttributeToFilter('shoppingflux_product', 1);
476
+ }
477
+
478
+ $configurableAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
479
+
480
+ // var_dump($usedProducts->getSelect().'');die();
481
+
482
+
483
+ $usedProductsArray = array();
484
+ $salable = false;
485
+ foreach ($usedProducts as $usedProduct) {
486
+ $salable = $salable || $usedProduct->isSalable();
487
+
488
+
489
+ if (Mage::helper('profileolabs_shoppingflux')->isModuleInstalled('OrganicInternet_SimpleConfigurableProducts')
490
+ || Mage::helper('profileolabs_shoppingflux')->isModuleInstalled('DerModPro_BCP')) {
491
+
492
+ $tmpData = $this->getPrices(array(), $usedProduct);
493
+ $price = $tmpData['price-ttc'] > 0 ? $tmpData['price-ttc'] : $data['price-ttc'];
494
+ if ($data['price-ttc'] <= 0 || ($price > 0 && $price < $data['price-ttc'])) {
495
+ $data['price-ttc'] = $price;
496
+ }
497
+ $priceBeforeDiscount = $tmpData["price-before-discount"];
498
+ $discountAmount = $tmpData["discount-amount"];
499
+ $startDateDiscount = $tmpData["start-date-discount"];
500
+ $endDateDiscount = $tmpData["end-date-discount"];
501
+ } else {
502
+
503
+ $price = $data['price-ttc'];
504
+ $priceBeforeDiscount = $data["price-before-discount"];
505
+ $discountAmount = $data["discount-amount"];
506
+ $startDateDiscount = $data["start-date-discount"];
507
+ $endDateDiscount = $data["end-date-discount"];
508
+
509
+ foreach ($configurableAttributes as $configurableAttribute) {
510
+ $attributeCode = $configurableAttribute['attribute_code'];
511
+ foreach ($configurableAttribute['values'] as $confAttributeValue) {
512
+ if ($confAttributeValue['pricing_value'] && $usedProduct->getData($attributeCode) == $confAttributeValue['value_index']) {
513
+ if ($confAttributeValue['is_percent']) {
514
+ $price += $data['price-ttc'] * $confAttributeValue['pricing_value'] / 100;
515
+ $priceBeforeDiscount += $data['price-before-discount'] * $confAttributeValue['pricing_value'] / 100;
516
+ } else {
517
+ $price += $confAttributeValue['pricing_value'];
518
+ $priceBeforeDiscount += $confAttributeValue['pricing_value'];
519
+ }
520
+ }
521
+ }
522
+ }
523
+ }
524
+
525
+
526
+
527
+ $discountPercent = round((($priceBeforeDiscount - $price) * 100) / $priceBeforeDiscount);
528
+
529
+ $isInStock = 0;
530
+ $qty = 0;
531
+ if ($usedProduct->getStockItem()) {
532
+ $isInStock = $usedProduct->getStockItem()->getIsInStock();
533
+ $qty = $usedProduct->getStockItem()->getQty();
534
+ }
535
+
536
+ $usedProductsArray[$usedProduct->getId()]['child']["sku"] = $usedProduct->getSku();
537
+ $usedProductsArray[$usedProduct->getId()]['child']["id"] = $usedProduct->getId();
538
+ $usedProductsArray[$usedProduct->getId()]['child']["price-ttc"] = $price;
539
+ $usedProductsArray[$usedProduct->getId()]['child']["price-before-discount"] = $priceBeforeDiscount;
540
+ $usedProductsArray[$usedProduct->getId()]['child']["discount-amount"] = $discountAmount;
541
+ $usedProductsArray[$usedProduct->getId()]['child']["discount-percent"] = $discountPercent;
542
+ $usedProductsArray[$usedProduct->getId()]['child']["start-date-discount"] = $startDateDiscount;
543
+ $usedProductsArray[$usedProduct->getId()]['child']["end-date-discount"] = $endDateDiscount;
544
+ $usedProductsArray[$usedProduct->getId()]['child']['is-in-stock'] = $isInStock;
545
+ $usedProductsArray[$usedProduct->getId()]['child']['qty'] = round($qty);
546
+ if ($qty > 0 && $qty > $data['qty']) {
547
+ $data['qty'] = round($qty);
548
+ }
549
+ $usedProductsArray[$usedProduct->getId()]['child']["ean"] = isset($attributesFromConfig['ean']) ? $usedProduct->getData($attributesFromConfig['ean']) : '';
550
+
551
+ $images = $this->getImages($images, $usedProduct);
552
+ if (!$images['image-url-1']) {
553
+ $images = $this->getImages($images, $product);
554
+ }
555
+ foreach ($images as $key => $value) {
556
+ $usedProductsArray[$usedProduct->getId()]['child'][$key] = trim($value);
557
+ }
558
+
559
+
560
+
561
+ foreach ($this->getConfig()->getMappingAllAttributes($this->_getStoreId()) as $nameNode => $attributeCode) {
562
+ $attributeId = Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product', $attributeCode);
563
+ $found = false;
564
+ foreach ($attributes as $attribute) {
565
+ if ($attribute['attribute_id'] == $attributeId) {
566
+ $found = true;
567
+ }
568
+ }
569
+ if (!$found) {
570
+ if (!isset($this->_attributesConfigurable[$attributeId]))
571
+ $this->_attributesConfigurable[$attributeId] = $product->getResource()->getAttribute($attributeId);
572
+
573
+ $attributeModel = $this->_attributesConfigurable[$attributeId];
574
+
575
+ $value = '';
576
+ if ($usedProduct->getData($attributeCode)) {
577
+ $value = $attributeModel->getFrontend()->getValue($usedProduct);
578
+ }
579
+
580
+
581
+ $usedProductsArray[$usedProduct->getId()]['child'][$nameNode] = trim($value);
582
+ }
583
+ }
584
+
585
+
586
+ //$usedProductsArray[$usedProduct->getId()]['child']['price'] = $usedProduct->getPrice();
587
+
588
+ foreach ($attributes as $attribute) {
589
+ $attributeCode = $attribute['attribute_code'];
590
+ $attributeId = $attribute['attribute_id'];
591
+
592
+ if (!isset($this->_attributesConfigurable[$attributeId]))
593
+ $this->_attributesConfigurable[$attributeId] = $product->getResource()->getAttribute($attributeId);
594
+
595
+ $attributeModel = $this->_attributesConfigurable[$attributeId];
596
+
597
+ $value = '';
598
+ if ($usedProduct->getData($attributeCode)) {
599
+ $value = $attributeModel->getFrontend()->getValue($usedProduct);
600
+ }
601
+
602
+ if (!in_array($value, $attributesToOptions[$attributeCode]))
603
+ $attributesToOptions[$attributeCode][] = $value;
604
+
605
+ $usedProductsArray[$usedProduct->getId()]['child'][$attributeCode] = trim($value);
606
+ }
607
+
608
+
609
+ if (!isset($usedProductsArray[$usedProduct->getId()]['child']['shipping_delay']) || !$usedProductsArray[$usedProduct->getId()]['child']['shipping_delay'])
610
+ $usedProductsArray[$usedProduct->getId()]['child']['shipping_delay'] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
611
+ }
612
+
613
+
614
+
615
+
616
+ $data['is-in-stock'] = (int) $salable;
617
+
618
+ foreach ($attributesToOptions as $attributeCode => $value) {
619
+
620
+ $data["configurable_attributes"][$attributeCode] = implode(",", $value);
621
+ }
622
+
623
+ $data["childs_product"] = $usedProductsArray;
624
+
625
+ unset($usedProducts);
626
+ unset($usedProductsArray);
627
+ }
628
+
629
+ Varien_Profiler::stop("SF::Flow::getConfigurableAttributes");
630
+
631
+ return $data;
632
+ }
633
+
634
+ /**
635
+ * Get prices of product
636
+ * @param Mage_Catalog_Model_Product $product
637
+ * @return string $nodes
638
+ */
639
+ protected function getPrices($data, $product) {
640
+
641
+ Varien_Profiler::start("SF::Flow::getPrice");
642
+ $priceAttributeCode = $this->getConfig()->getConfigData('shoppingflux_export/specific_prices/price', $this->_getStoreId());
643
+ $specialPriceAttributeCode = $this->getConfig()->getConfigData('shoppingflux_export/specific_prices/special_price', $this->_getStoreId());
644
+ if (!$product->getData($priceAttributeCode)) {
645
+ $priceAttributeCode = 'price';
646
+ $specialPriceAttributeCode = 'special_price';
647
+ }
648
+
649
+ $discountAmount = 0;
650
+ $finalPrice = $product->getData($priceAttributeCode);
651
+ $priceBeforeDiscount = $product->getData($priceAttributeCode);
652
+ if ($product->getData($specialPriceAttributeCode) > 0 && $product->getData($specialPriceAttributeCode) < $finalPrice) {
653
+ $finalPrice = $product->getData($specialPriceAttributeCode);
654
+ $discountAmount = $product->getData($priceAttributeCode) - $product->getData($specialPriceAttributeCode);
655
+ }
656
+ $discountFromDate = $product->getSpecialFromDate();
657
+ $discountToDate = $product->getSpecialToDate();
658
+
659
+
660
+ $product->setCalculatedFinalPrice($finalPrice);
661
+ $product->setData('final_price', $finalPrice);
662
+
663
+ $currentVersion = Mage::getVersion();
664
+ if (version_compare($currentVersion, '1.5.0') < 0) {
665
+
666
+ } else {
667
+ $catalogPriceRulePrice = Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice());
668
+ if($catalogPriceRulePrice>0 && $catalogPriceRulePrice<$discountAmount) {
669
+ $discountAmount = $catalogPriceRulePrice;
670
+ $discountFromDate = '';
671
+ $discountToDate = '';
672
+ }
673
+ }
674
+
675
+ $data["price-ttc"] = $this->helper('tax')->getPrice($product, $finalPrice, true); //$finalPrice;
676
+ $data["price-before-discount"] = $this->helper('tax')->getPrice($product, $priceBeforeDiscount, true); //$priceBeforeDiscount;
677
+ $data["discount-amount"] = $product->getTypeId() != 'bundle' ? $discountAmount : 0;
678
+ $data["discount-percent"] = $this->getPercent($product);
679
+
680
+ $data["start-date-discount"] = "";
681
+ $data["end-date-discount"] = "";
682
+ if ($discountFromDate) {
683
+ $data["start-date-discount"] = $discountFromDate;
684
+ }
685
+ if ($discountToDate) {
686
+ $data["end-date-discount"] = $discountToDate;
687
+ }
688
+ Varien_Profiler::stop("SF::Flow::getPrice");
689
+ return $data;
690
+ }
691
+
692
+ /**
693
+ * Get categories of product
694
+ * @param Mage_Catalog_Model_Product $product
695
+ * @return string $nodes
696
+ */
697
+ protected function getCategories($data, $product) {
698
+ if ($product->getData('shoppingflux_default_category') && $product->getData('shoppingflux_default_category') > 0) {
699
+ return $this->getCategoriesViaShoppingfluxCategory($data, $product);
700
+ }
701
+ return $this->getCategoriesViaProductCategories($data, $product);
702
+ }
703
+
704
+ protected function getCategoriesViaShoppingfluxCategory($data, $product) {
705
+
706
+ $categoryId = $product->getData('shoppingflux_default_category');
707
+ $category = Mage::helper('profileolabs_shoppingflux')->getCategoriesWithParents();
708
+ if (!isset($category['name'][$categoryId])) {
709
+ return $this->getCategoriesViaProductCategories($data, $product);
710
+ }
711
+ Varien_Profiler::start("SF::Flow::getCategoriesViaShoppingfluxCategory");
712
+
713
+ $categoryNames = explode(' > ', $category['name'][$categoryId]);
714
+ $categoryUrls = explode(' > ', $category['url'][$categoryId]);
715
+
716
+
717
+ //we drop root category, which is useless here
718
+ array_shift($categoryNames);
719
+ array_shift($categoryUrls);
720
+
721
+ $data['category-breadcrumb'] = trim(implode(' > ', $categoryNames));
722
+
723
+ $data["category"] = trim($categoryNames[0]);
724
+ $data["category-url"] = $categoryUrls[0];
725
+
726
+
727
+ for ($i = 1; $i <= 5; $i++) {
728
+ if (isset($categoryNames[$i]) && isset($categoryUrls[$i])) {
729
+ $data["category-sub-" . ($i)] = trim($categoryNames[$i]);
730
+ $data["category-url-sub-" . ($i)] = $categoryUrls[$i];
731
+ } else {
732
+ $data["category-sub-" . ($i)] = '';
733
+ $data["category-url-sub-" . ($i)] = '';
734
+ }
735
+ }
736
+
737
+ Varien_Profiler::stop("SF::Flow::getCategoriesViaShoppingfluxCategory");
738
+ return $data;
739
+ }
740
+
741
+ protected function getCategoriesViaProductCategories($data, $product) {
742
+
743
+ Varien_Profiler::start("SF::Flow::getCategoriesViaProductCategories");
744
+ $sorted = false;
745
+ $asCollection = true;
746
+ $toLoad = false;
747
+ $parent = Mage::app()->getStore()->getRootCategoryId();
748
+
749
+ $cacheKey = sprintf('%d-%d-%d-%d', $parent, $sorted, $asCollection, $toLoad);
750
+ if (!isset($this->_storeCategories[$cacheKey])) {
751
+
752
+ /**
753
+ * Check if parent node of the store still exists
754
+ */
755
+ $category = Mage::getModel('catalog/category');
756
+ /* @var $category Mage_Catalog_Model_Category */
757
+ if (!$category->checkId($parent)) {
758
+ /* if ($asCollection) {
759
+ return new Varien_Data_Collection();
760
+ } */
761
+
762
+
763
+ Varien_Profiler::stop("SF::Flow::getCategoriesViaProductCategories");
764
+ return $data;
765
+ }
766
+
767
+ $recursionLevel = 0;
768
+ $storeCategories = $category->getCategories($parent, $recursionLevel, $sorted, $asCollection, $toLoad);
769
+
770
+ $storeCategoriesIds = array();
771
+ foreach ($storeCategories as $cat) {
772
+ $storeCategoriesIds[] = $cat['entity_id'];
773
+ }
774
+ $this->_storeCategories[$cacheKey] = $storeCategoriesIds;
775
+ }
776
+
777
+ Varien_Profiler::start("SF::Flow::getCategoriesViaProductCategories-1");
778
+ $storeCategoriesIds = $this->_storeCategories[$cacheKey];
779
+
780
+
781
+
782
+ $categoryCollection = $product->getCategoryCollection()
783
+ ->addAttributeToSelect(array('name'))
784
+ ->addFieldToFilter('level', array('lteq' => 5))
785
+ ->addUrlRewriteToResult()
786
+ ->groupByAttribute('level')
787
+ ->setOrder('level', 'ASC');
788
+
789
+ if (count($storeCategoriesIds) > 0)
790
+ $categoryCollection->addFieldToFilter("entity_id", array("in" => $storeCategoriesIds));
791
+
792
+ $nbCategories = $categoryCollection->count();
793
+
794
+ $cnt = 0;
795
+ $lastCategory = null;
796
+ foreach ($categoryCollection as $category) {
797
+ $name = $category->getName();
798
+ $level = $category->getLevel();
799
+ $url = $this->cleanUrl($category->getUrl());
800
+ if ($cnt == 0) {
801
+
802
+ $data["category"] = trim($name);
803
+ $data["category-url"] = $url;
804
+ } else {
805
+
806
+ $data["category-sub-" . ($cnt)] = trim($name);
807
+ $data["category-url-sub-" . ($cnt)] = $url;
808
+ }
809
+
810
+ $lastCategory = $category;
811
+
812
+ $cnt++;
813
+ }
814
+ $data['category-breadcrumb'] = "";
815
+ if (!is_null($lastCategory) && is_object($lastCategory)) {
816
+
817
+ $breadCrumb = array();
818
+
819
+ $pathInStore = $category->getPathInStore();
820
+ $pathIds = array_reverse(explode(',', $pathInStore));
821
+
822
+ $categories = $category->getParentCategories();
823
+
824
+ // add category path breadcrumb
825
+ foreach ($pathIds as $categoryId) {
826
+ if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
827
+ $breadCrumb[] = trim($categories[$categoryId]->getName());
828
+ }
829
+ }
830
+ unset($categories);
831
+ $data['category-breadcrumb'] = trim(implode(" > ", $breadCrumb));
832
+ }
833
+
834
+
835
+
836
+ unset($categoryCollection);
837
+
838
+
839
+ if ($nbCategories == 0) {
840
+ $data["category"] = "";
841
+ $data["category-url"] = "";
842
+
843
+ $cnt++;
844
+ }
845
+
846
+
847
+ for ($i = ($cnt); $i <= 5; $i++) {
848
+ $data["category-sub-" . ($i)] = "";
849
+ $data["category-url-sub-" . ($i)] = "";
850
+ }
851
+
852
+
853
+ Varien_Profiler::stop("SF::Flow::getCategoriesViaProductCategories-1");
854
+ Varien_Profiler::stop("SF::Flow::getCategoriesViaProductCategories");
855
+ return $data;
856
+ }
857
+
858
+ public function cleanUrl($url) {
859
+ $url = str_replace("index.php/", "", $url);
860
+
861
+ return $url;
862
+ }
863
+
864
+ public function getImages($data, $product) {
865
+
866
+ Varien_Profiler::start("SF::Flow::getImages");
867
+
868
+ $mediaUrl = Mage::getBaseUrl('media') . 'catalog/product';
869
+
870
+ $i = 1;
871
+
872
+ if ($product->getImage() != "" && $product->getImage() != 'no_selection') {
873
+ $data["image-url-" . $i++] = $mediaUrl . $product->getImage();
874
+ }
875
+
876
+
877
+
878
+ //LOAD media gallery for this product
879
+ $mediaGallery = $product->getResource()->getAttribute('media_gallery');
880
+ $mediaGallery->getBackend()->afterLoad($product);
881
+
882
+
883
+ foreach ($product->getMediaGallery('images') as $image) {
884
+ if ($mediaUrl . $product->getImage() == $product->getMediaConfig()->getMediaUrl($image['file']))
885
+ continue;
886
+
887
+ $data["image-url-" . $i++] = $product->getMediaConfig()->getMediaUrl($image['file']);
888
+ if (($i - 6) == 0)
889
+ break;
890
+ }
891
+
892
+
893
+ //Complet with empty nodes
894
+ for ($j = $i; $j < 6; $j++) {
895
+ $data["image-url-" . $i++] = "";
896
+ }
897
+ Varien_Profiler::stop("SF::Flow::getImages");
898
+ return $data;
899
+ }
900
+
901
+ /**
902
+ * Get singleton config for Export
903
+ * @return Profileolabs_Shoppingflux_Model_Export_Config
904
+ */
905
+ public function getConfig() {
906
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
907
+ }
908
+
909
+ protected function getPercent($product) {
910
+
911
+ /* if($product->getTypeId() == 'bundle')
912
+ return 0; */
913
+ $price = round($product->getPrice(), 2);
914
+ if ($price == "0") {
915
+ $price = round($product->getMinimalPrice(), 2);
916
+ }
917
+
918
+ if ($price == "0")
919
+ return 0;
920
+
921
+ $special = round($product->getFinalPrice(), 2);
922
+ $tmp = $price - $special;
923
+ $tmp = ($tmp * 100) / $price;
924
+ return round($tmp);
925
+ }
926
+
927
+ /**
928
+ *
929
+ */
930
+ protected function getAttributesFromConfig($checkIfExist = false, $withAdditional = true) {
931
+
932
+ Varien_Profiler::start("SF::Flow::getAttributesFromConfig");
933
+ if (is_null($this->_attributes)) {
934
+ $attributes = $this->getConfig()->getMappingAllAttributes();
935
+ if ($withAdditional) {
936
+ $additionalAttributes = $this->getConfig()->getAdditionalAttributes();
937
+ foreach ($additionalAttributes as $attributeCode) {
938
+ $attributes[$attributeCode] = trim($attributeCode);
939
+ }
940
+ }
941
+
942
+ if ($checkIfExist) {
943
+ $product = Mage::getModel('catalog/product');
944
+ foreach ($attributes as $key => $code) {
945
+
946
+ $attribute = $product->getResource()->getAttribute($code);
947
+ if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute && $attribute->getId() && $attribute->getFrontendInput() != 'weee') {
948
+ $this->_attributes[$key] = $code;
949
+ }
950
+ }
951
+ }
952
+ else
953
+ $this->_attributes = $attributes;
954
+ }
955
+
956
+ Varien_Profiler::stop("SF::Flow::getAttributesFromConfig");
957
+ return $this->_attributes;
958
+ }
959
+
960
+ protected function getRequiredAttributes() {
961
+
962
+ $requiredAttributes = array("sku" => "sku",
963
+ "price" => "price",
964
+ "image" => "image");
965
+
966
+ return $requiredAttributes;
967
+ }
968
+
969
+ protected function getAllAttributes() {
970
+ return array_merge($this->getAttributesFromConfig(true), $this->getRequiredAttributes());
971
+ }
972
+
973
+ /**
974
+ * Retrieve Catalog Product Flat Helper object
975
+ *
976
+ * @return Mage_Catalog_Helper_Product_Flat
977
+ */
978
+ public function getFlatHelper() {
979
+ return Mage::helper('catalog/product_flat');
980
+ }
981
+
982
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Export/Flux.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Profileolabs_Shoppingflux_Block_Export_Flux extends Mage_Core_Block_Template {
4
+
5
+ protected function _toHtml() {
6
+ $useAllStores = $this->getForceMultiStores() || $this->getConfig()->getUseAllStoreProducts();
7
+ if ($this->getProductSku() && $this->getRequest()->getParam('update') == 1) {
8
+ if($this->getConfig()->getUseAllStoreProducts()) {
9
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFlux($this->getProductSku(), Mage::app()->getStore()->getId());
10
+ } else {
11
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFluxForAllStores($this->getProductSku());
12
+ }
13
+ }
14
+
15
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateFlux($useAllStores?false:Mage::app()->getStore()->getId(), $this->getLimit() ? $this->getLimit() : 1000000);
16
+ $collection = Mage::getModel('profileolabs_shoppingflux/export_flux')->getCollection();
17
+ $collection->addFieldToFilter('should_export', 1);
18
+ if($useAllStores) {
19
+ $collection->getSelect()->group(array('sku'));
20
+ } else {
21
+ $collection->addFieldToFilter('store_id', Mage::app()->getStore()->getId());
22
+ }
23
+ $sizeTotal = $collection->count();
24
+ $collection->clear();
25
+
26
+ if (!$this->getConfig()->isExportSoldout()) {
27
+ $collection->addFieldToFilter('is_in_stock', 1);
28
+ }
29
+ if ($this->getConfig()->isExportFilteredByAttribute()) {
30
+ $collection->addFieldToFilter('is_in_flux', 1);
31
+ }
32
+ $visibilities = $this->getConfig()->getVisibilitiesToExport();
33
+ $collection->getSelect()->where("find_in_set(visibility, '" . implode(',', $visibilities) . "')");
34
+
35
+
36
+ $xmlObj = Mage::getModel('profileolabs_shoppingflux/export_xml');
37
+ echo $xmlObj->startXml(array('size-exportable' => $sizeTotal, 'size-xml' => $collection->count(), 'with-out-of-stock' => intval($this->getConfig()->isExportSoldout()), 'selected-only' => intval($this->getConfig()->isExportFilteredByAttribute()), 'visibilities' => implode(',', $visibilities)));
38
+
39
+
40
+ if ($this->getProductSku()) {
41
+ $collection->addFieldToFilter('sku', $this->getProductSku());
42
+ }
43
+ if ($this->getLimit()) {
44
+ $collection->getSelect()->limit($this->getLimit());
45
+ }
46
+
47
+
48
+ Mage::getSingleton('core/resource_iterator')
49
+ ->walk($collection->getSelect(), array(array($this, 'displayProductXml')), array());
50
+ echo $xmlObj->endXml();
51
+ return;
52
+ }
53
+
54
+ public function displayProductXml($args) {
55
+ if (Mage::app()->getRequest()->getActionName() == 'profile') {
56
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFlux($args['row']['sku'], Mage::app()->getStore()->getId());
57
+ }
58
+ echo $args['row']['xml'];
59
+ }
60
+
61
+ public function getConfig() {
62
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
63
+ }
64
+
65
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Export/Tracking.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Profileolabs_Shoppingflux Tracking Block
4
+ *
5
+ * @category Profileolabs
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author kassim belghait <kassim@profileo.com>
8
+ * @deprecated since version 0.5.6
9
+ */
10
+ class Profileolabs_Shoppingflux_Block_Export_Tracking extends Mage_Core_Block_Text
11
+ {
12
+
13
+ /**
14
+ * Retrieve Shopping flux Account Identifier
15
+ *
16
+ * @return string
17
+ */
18
+ public function getLogin()
19
+ {
20
+ if (!$this->hasData('login')) {
21
+ $this->setLogin(Mage::getStoreConfig('shoppingflux_export/general/login'));
22
+ }
23
+ return $this->getData('login');
24
+ }
25
+
26
+ /**
27
+ * Prepare and return block's html output
28
+ *
29
+ * @return string
30
+ */
31
+ protected function _toHtml()
32
+ {
33
+ if (!Mage::getStoreConfigFlag('shoppingflux_export/general/active')) {
34
+ return '';
35
+ }
36
+
37
+ if($this->getLogin() == "")
38
+ return '';
39
+
40
+ $quoteId = Mage::getSingleton('checkout/session')->getLastQuoteId();
41
+ if(!$quoteId)
42
+ return '';
43
+
44
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
45
+
46
+ $orders = Mage::getResourceModel('sales/order_collection')
47
+ ->addAttributeToFilter('quote_id', $quoteId)
48
+ ->load();
49
+
50
+ foreach($orders as $order)
51
+ {
52
+ $grandTotal = $order->getBaseGrandTotal();
53
+ $incrementId = $order->getIncrementId();
54
+
55
+ $this->addText('
56
+ <!-- BEGIN Shopping flux Tracking -->
57
+ <script type="text/javascript">
58
+ //<![CDATA[
59
+ document.write(\'<img src="http://www.shopping-flux.com/tracking/?cl='.$this->getLogin().'&mt='.$grandTotal.'&cmd='.$incrementId.'" />\');//]]>
60
+ </script>
61
+ <!-- END Shopping flux Tracking -->
62
+ ');
63
+
64
+ }
65
+
66
+ return parent::_toHtml();
67
+ }
68
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Cron.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Log grid container
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux_ManageOrders
7
+ * @author Vincent Enjalbert
8
+ */
9
+ class Profileolabs_Shoppingflux_Block_Manageorders_Adminhtml_Cron extends Mage_Adminhtml_Block_Widget_Grid_Container {
10
+
11
+ public function __construct() {
12
+ parent::__construct();
13
+
14
+ $this->_controller = 'manageorders_adminhtml_cron';
15
+ $this->_blockGroup = 'profileolabs_shoppingflux';
16
+ $this->_headerText = $this->__('Crons');
17
+
18
+ $this->_removeButton('add');
19
+ }
20
+
21
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Cron/Grid.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Adminhtml log shopping flux grid
4
+ *
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux_ManageOrders
7
+ * @author Vincent Enjalbert
8
+ */
9
+ class Profileolabs_Shoppingflux_Block_Manageorders_Adminhtml_Cron_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+
12
+
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ $this->setId('shoppingflux_cron_grid');
17
+ $this->setUseAjax(true);
18
+ $this->setDefaultSort('date');
19
+ $this->setDefaultDir('DESC');
20
+ $this->setSaveParametersInSession(true);
21
+ $this->setDefaultFilter(
22
+ array(
23
+ 'job_code' => 'shoppingflux'
24
+ )
25
+ );
26
+ }
27
+
28
+
29
+ protected function _prepareCollection()
30
+ {
31
+ $collection = Mage::getModel("cron/schedule")->getCollection();
32
+ $collection->getSelect()->order('schedule_id desc');
33
+
34
+ $this->setCollection($collection);
35
+ return parent::_prepareCollection();
36
+ }
37
+
38
+ protected function _prepareColumns()
39
+ {
40
+
41
+ $this->addColumn('schedule_id', array(
42
+ 'header'=> Mage::helper('cron')->__('Schedule Id'),
43
+ 'width' => '80px',
44
+ 'type' => 'text',
45
+ 'index' => 'schedule_id',
46
+ ));
47
+
48
+ $this->addColumn('job_code', array(
49
+ 'header'=> Mage::helper('cron')->__('Job Code'),
50
+ 'width' => '80px',
51
+ 'type' => 'text',
52
+ 'index' => 'job_code',
53
+ ));
54
+
55
+ $this->addColumn('status', array(
56
+ 'header'=> Mage::helper('cron')->__('Status'),
57
+ 'width' => '80px',
58
+ 'type' => 'text',
59
+ 'index' => 'status',
60
+ ));
61
+
62
+ $this->addColumn('messages', array(
63
+ 'header'=> Mage::helper('cron')->__('Messages'),
64
+ 'width' => '80px',
65
+ 'type' => 'text',
66
+ 'index' => 'messages',
67
+ ));
68
+
69
+ $this->addColumn('scheduled_at', array(
70
+ 'header'=> Mage::helper('cron')->__('Scheduled at'),
71
+ 'width' => '80px',
72
+ 'type' => 'datetime',
73
+ 'index' => 'scheduled_at',
74
+ ));
75
+
76
+
77
+ $this->addColumn('created_at', array(
78
+ 'header'=> Mage::helper('cron')->__('Created at'),
79
+ 'width' => '80px',
80
+ 'type' => 'datetime',
81
+ 'index' => 'created_at',
82
+ ));
83
+
84
+ $this->addColumn('executed_at', array(
85
+ 'header'=> Mage::helper('cron')->__('Executed at'),
86
+ 'width' => '80px',
87
+ 'type' => 'datetime',
88
+ 'index' => 'executed_at',
89
+ ));
90
+
91
+ $this->addColumn('finished_at', array(
92
+ 'header'=> Mage::helper('cron')->__('Finished at'),
93
+ 'width' => '80px',
94
+ 'type' => 'datetime',
95
+ 'index' => 'finished_at',
96
+ ));
97
+
98
+
99
+ return parent::_prepareColumns();
100
+ }
101
+
102
+ public function getGridUrl()
103
+ {
104
+ return $this->getUrl('*/*/grid', array('_current'=>true));
105
+ }
106
+
107
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Import.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Profileolabs_Shoppingflux_Block_Manageorders_Adminhtml_Import extends Mage_Adminhtml_Block_Template
3
+ {
4
+
5
+
6
+ public function getImportOrdersUrl()
7
+ {
8
+ return $this->getUrl('*/*/importOrders');
9
+ }
10
+
11
+
12
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Log.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping Flux Log grid container
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux_ManageOrders
6
+ * @author kassim belghait
7
+ */
8
+ class Profileolabs_Shoppingflux_Block_Manageorders_Adminhtml_Log extends Mage_Adminhtml_Block_Widget_Grid_Container
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+
14
+ $this->_controller = 'manageorders_adminhtml_log';
15
+ $this->_blockGroup = 'profileolabs_shoppingflux';
16
+ $this->_headerText = $this->__('Shopping flux log');
17
+
18
+ $this->_removeButton('add');
19
+ $this->_addButton("deleteAll",array(
20
+ 'label' => Mage::helper('profileolabs_shoppingflux')->__('Delete'),
21
+ 'onclick' => "setLocation('{$this->getUrl('*/*/delete')}')",
22
+ 'class' => 'delete'
23
+ ));
24
+ }
25
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Log/Grid.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Adminhtml log shopping flux grid
4
+ *
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux_ManageOrders
7
+ * @author kassim belghait
8
+ */
9
+ class Profileolabs_Shoppingflux_Block_Manageorders_Adminhtml_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+
12
+
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ $this->setId('shoppingflux_log_grid');
17
+ $this->setUseAjax(true);
18
+ $this->setDefaultSort('date');
19
+ $this->setDefaultDir('DESC');
20
+ $this->setSaveParametersInSession(true);
21
+ }
22
+
23
+
24
+ protected function _prepareCollection()
25
+ {
26
+ $collection = Mage::getModel("profileolabs_shoppingflux/manageorders_log")->getCollection();
27
+
28
+ $this->setCollection($collection);
29
+ return parent::_prepareCollection();
30
+ }
31
+
32
+ protected function _prepareColumns()
33
+ {
34
+
35
+ $this->addColumn('id', array(
36
+ 'header'=> Mage::helper('profileolabs_shoppingflux')->__('ID'),
37
+ 'width' => '80px',
38
+ 'type' => 'text',
39
+ 'index' => 'id',
40
+ ));
41
+
42
+
43
+ $this->addColumn('date', array(
44
+ 'header' => Mage::helper('profileolabs_shoppingflux')->__('Created at'),
45
+ 'index' => 'date',
46
+ 'type' => 'datetime',
47
+ 'width' => '100px',
48
+ ));
49
+
50
+ $this->addColumn('message', array(
51
+ 'header' => Mage::helper('profileolabs_shoppingflux')->__('Message'),
52
+ 'index' => 'message',
53
+ ));
54
+
55
+
56
+ return parent::_prepareColumns();
57
+ }
58
+
59
+ public function getGridUrl()
60
+ {
61
+ return $this->getUrl('*/*/grid', array('_current'=>true));
62
+ }
63
+
64
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Order.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping Flux Service
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux_ManageOrders
6
+ * @author kassim belghait
7
+ */
8
+ class Profileolabs_Shoppingflux_Block_Manageorders_Adminhtml_Order extends Mage_Adminhtml_Block_Widget_Grid_Container
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+
14
+ $this->_controller = 'manageorders_adminhtml_order';
15
+ $this->_blockGroup = 'profileolabs_shoppingflux';
16
+ $this->_headerText = $this->__('Shopping flux orders');
17
+
18
+ $this->_removeButton('add');
19
+ }
20
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Order/Grid.php ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Adminhtml sales orders shopping flux grid
4
+ *
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux_ManageOrders
7
+ * @author kassim belghait
8
+ */
9
+ class Profileolabs_Shoppingflux_Block_Manageorders_Adminhtml_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+
12
+ protected $_withGrid = true;
13
+
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->setId('sales_order_grid');
18
+ $this->setUseAjax(true);
19
+ $this->setDefaultSort('created_at');
20
+ $this->setDefaultDir('DESC');
21
+ $this->setSaveParametersInSession(true);
22
+ }
23
+
24
+ /**
25
+ * Retrieve collection class
26
+ *
27
+ * @return string
28
+ */
29
+ protected function _getCollectionClass()
30
+ {
31
+ $path = Mage::getBaseDir()."/app/code/core/Mage/Sales/Model/Mysql4/Order/Grid/Collection.php";
32
+ //die($path);
33
+ if(file_exists($path))
34
+ return 'sales/order_grid_collection';
35
+
36
+ $this->_withGrid = false;
37
+ return 'sales/order_collection';
38
+ }
39
+
40
+ protected function _prepareCollection()
41
+ {
42
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
43
+ $collection->addAttributeToFilter('from_shoppingflux',1);
44
+
45
+ if(!$this->_withGrid)
46
+ {
47
+ $collection->addAttributeToSelect('*')
48
+ ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
49
+ ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
50
+ ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
51
+ ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
52
+ ->addExpressionAttributeToSelect('billing_name',
53
+ 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
54
+ array('billing_firstname', 'billing_lastname'))
55
+ ->addExpressionAttributeToSelect('shipping_name',
56
+ 'CONCAT({{shipping_firstname}}, IFNULL(CONCAT(\' \', {{shipping_lastname}}), \'\'))',
57
+ array('shipping_firstname', 'shipping_lastname'));
58
+ }
59
+
60
+ $this->setCollection($collection);
61
+ return parent::_prepareCollection();
62
+ }
63
+
64
+ protected function _prepareColumns()
65
+ {
66
+
67
+ $this->addColumn('real_order_id', array(
68
+ 'header'=> Mage::helper('sales')->__('Order #'),
69
+ 'width' => '80px',
70
+ 'type' => 'text',
71
+ 'index' => 'increment_id',
72
+ ));
73
+
74
+ if (!Mage::app()->isSingleStoreMode()) {
75
+ $this->addColumn('store_id', array(
76
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
77
+ 'index' => 'store_id',
78
+ 'type' => 'store',
79
+ 'store_view'=> true,
80
+ 'display_deleted' => true,
81
+ ));
82
+ }
83
+
84
+ $this->addColumn('created_at', array(
85
+ 'header' => Mage::helper('sales')->__('Purchased On'),
86
+ 'index' => 'created_at',
87
+ 'type' => 'datetime',
88
+ 'width' => '100px',
89
+ ));
90
+
91
+ $this->addColumn('billing_name', array(
92
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
93
+ 'index' => 'billing_name',
94
+ ));
95
+
96
+ $this->addColumn('shipping_name', array(
97
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
98
+ 'index' => 'shipping_name',
99
+ ));
100
+
101
+ $this->addColumn('base_grand_total', array(
102
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
103
+ 'index' => 'base_grand_total',
104
+ 'type' => 'currency',
105
+ 'currency' => 'base_currency_code',
106
+ ));
107
+
108
+ $this->addColumn('grand_total', array(
109
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
110
+ 'index' => 'grand_total',
111
+ 'type' => 'currency',
112
+ 'currency' => 'order_currency_code',
113
+ ));
114
+
115
+ //Data shopping flux
116
+
117
+ $this->addColumn('order_id_shoppingflux', array(
118
+ 'header' => Mage::helper('profileolabs_shoppingflux')->__('Id shopping flux'),
119
+ 'index' => 'order_id_shoppingflux',
120
+ ));
121
+
122
+ $this->addColumn('marketplace_shoppingflux', array(
123
+ 'header' => Mage::helper('profileolabs_shoppingflux')->__('Marketplace'),
124
+ 'index' => 'marketplace_shoppingflux',
125
+ ));
126
+
127
+ $this->addColumn('fees_shoppingflux', array(
128
+ 'header'=> Mage::helper('profileolabs_shoppingflux')->__('Fees'),
129
+ 'type' => 'currency',
130
+ 'index' => 'fees_shoppingflux',
131
+ 'currency' => 'base_currency_code',
132
+ ));
133
+
134
+ //END data Shopping flux
135
+
136
+ $this->addColumn('status', array(
137
+ 'header' => Mage::helper('sales')->__('Status'),
138
+ 'index' => 'status',
139
+ 'type' => 'options',
140
+ 'width' => '70px',
141
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
142
+ ));
143
+
144
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
145
+ $this->addColumn('action',
146
+ array(
147
+ 'header' => Mage::helper('sales')->__('Action'),
148
+ 'width' => '50px',
149
+ 'type' => 'action',
150
+ 'getter' => 'getId',
151
+ 'actions' => array(
152
+ array(
153
+ 'caption' => Mage::helper('sales')->__('View'),
154
+ 'url' => array('base'=>'adminhtml/sales_order/view'),
155
+ 'field' => 'order_id'
156
+ )
157
+ ),
158
+ 'filter' => false,
159
+ 'sortable' => false,
160
+ 'index' => 'stores',
161
+ 'is_system' => true,
162
+ ));
163
+ }
164
+ //$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
165
+
166
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
167
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
168
+
169
+ return parent::_prepareColumns();
170
+ }
171
+
172
+ protected function _prepareMassaction()
173
+ {
174
+ $this->setMassactionIdField('entity_id');
175
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
176
+ $this->getMassactionBlock()->setUseSelectAll(false);
177
+
178
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
179
+ $this->getMassactionBlock()->addItem('cancel_order', array(
180
+ 'label'=> Mage::helper('sales')->__('Cancel'),
181
+ 'url' => $this->getUrl('adminhtml/sales_order/massCancel'),
182
+ ));
183
+ }
184
+
185
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
186
+ $this->getMassactionBlock()->addItem('hold_order', array(
187
+ 'label'=> Mage::helper('sales')->__('Hold'),
188
+ 'url' => $this->getUrl('adminhtml/sales_order/massHold'),
189
+ ));
190
+ }
191
+
192
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
193
+ $this->getMassactionBlock()->addItem('unhold_order', array(
194
+ 'label'=> Mage::helper('sales')->__('Unhold'),
195
+ 'url' => $this->getUrl('adminhtml/sales_order/massUnhold'),
196
+ ));
197
+ }
198
+
199
+ $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
200
+ 'label'=> Mage::helper('sales')->__('Print Invoices'),
201
+ 'url' => $this->getUrl('adminhtml/sales_order/pdfinvoices'),
202
+ ));
203
+
204
+ $this->getMassactionBlock()->addItem('pdfshipments_order', array(
205
+ 'label'=> Mage::helper('sales')->__('Print Packingslips'),
206
+ 'url' => $this->getUrl('adminhtml/sales_order/pdfshipments'),
207
+ ));
208
+
209
+ $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
210
+ 'label'=> Mage::helper('sales')->__('Print Credit Memos'),
211
+ 'url' => $this->getUrl('adminhtml/sales_order/pdfcreditmemos'),
212
+ ));
213
+
214
+ $this->getMassactionBlock()->addItem('pdfdocs_order', array(
215
+ 'label'=> Mage::helper('sales')->__('Print All'),
216
+ 'url' => $this->getUrl('adminhtml/sales_order/pdfdocs'),
217
+ ));
218
+
219
+ return $this;
220
+ }
221
+
222
+ public function getRowUrl($row)
223
+ {
224
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
225
+ return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
226
+ }
227
+ return false;
228
+ }
229
+
230
+ public function getGridUrl()
231
+ {
232
+ return $this->getUrl('*/*/grid', array('_current'=>true));
233
+ }
234
+
235
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/System/Config/Form/Fieldset/Shipping/Method.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Profileolabs_Shoppingflux_Block_Manageorders_Adminhtml_System_Config_Form_Fieldset_Shipping_Method extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
4
+
5
+ public function render(Varien_Data_Form_Element_Abstract $element) {
6
+ $html = $this->_getHeaderHtml($element);
7
+
8
+ $collection = Mage::getModel('profileolabs_shoppingflux/manageorders_shipping_method')->getCollection();
9
+
10
+ if($collection->count()<=0) {
11
+ $this->_addEmptyField($element);
12
+ }
13
+
14
+ $i = 1;
15
+ foreach($collection as $shippingMethod) {
16
+ $this->_addShippingMethodField($element, $shippingMethod->getFullShippingMethodCode(), 10*$i++);
17
+ }
18
+
19
+
20
+ foreach ($element->getSortedElements() as $field) {
21
+ $html .= $field->toHtml();
22
+ }
23
+
24
+ $html .= $this->_getFooterHtml($element);
25
+
26
+ return $html;
27
+ }
28
+
29
+ protected function _getHeaderHtml($element) {
30
+ $html = parent::_getHeaderHtml($element);
31
+ return $html;
32
+ }
33
+
34
+ protected function _getFieldRenderer() {
35
+ if (empty($this->_fieldRenderer)) {
36
+ $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
37
+ }
38
+ return $this->_fieldRenderer;
39
+ }
40
+
41
+ protected function _getDummyElement() {
42
+ if (empty($this->_dummyElement)) {
43
+ $this->_dummyElement = new Varien_Object(array('show_in_default' => 1, 'show_in_website' => 1, 'show_in_store' => 0));
44
+ }
45
+ return $this->_dummyElement;
46
+ }
47
+
48
+ protected function _getNiceName($index) {
49
+ return ucwords(str_replace('_', ' ', $index));
50
+ }
51
+
52
+
53
+ protected function _addShippingMethodField($fieldset, $shippingMethod, $sortOrder) {
54
+ $shippingMethod = preg_replace('%[^a-zA-Z0-9_]%', '', $shippingMethod);
55
+ $configData = $this->getConfigData();
56
+ $path = 'shoppingflux_mo/advanced_shipping_method/' . $shippingMethod;
57
+ if (isset($configData[$path])) {
58
+ $data = $configData[$path];
59
+ $inherit = false;
60
+ } else {
61
+ if($this->getForm()->getConfigRoot()) {
62
+ $data = (string) $this->getForm()->getConfigRoot()->descend($path);
63
+ $inherit = true;
64
+ }
65
+ }
66
+ $e = $this->_getDummyElement();
67
+ $fieldset->addField($shippingMethod, 'select', array(
68
+ 'name' => 'groups[advanced_shipping_method][fields][' . $shippingMethod . '][value]',
69
+ 'label' => Mage::helper('profileolabs_shoppingflux')->__('Shipping Method for %s', $this->_getNiceName($shippingMethod)),
70
+ 'value' => $data,
71
+ 'values' => Mage::getSingleton('adminhtml/system_config_source_shipping_allmethods')->toOptionArray(),
72
+ 'sort_order' => $sortOrder,
73
+ 'inherit' => $inherit,
74
+ 'can_use_default_value' => $this->getForm()->canUseDefaultValue($e),
75
+ 'can_use_website_value' => $this->getForm()->canUseWebsiteValue($e),
76
+ ))->setRenderer($this->_getFieldRenderer());
77
+
78
+ }
79
+
80
+
81
+ protected function _addEmptyField($fieldset) {
82
+ $configData = $this->getConfigData();
83
+ $path = 'shoppingflux_mo/advanced_shipping_method/zzzzzz';
84
+ $e = $this->_getDummyElement();
85
+ $fieldset->addField('zzzzzz', 'note', array(
86
+ 'name' => 'groups[advanced_shipping_method][fields][zzzzzz][value]',
87
+ 'label' => Mage::helper('profileolabs_shoppingflux')->__('There is no marketplace shipping method registered yet.'),
88
+ ))->setRenderer($this->_getFieldRenderer());
89
+
90
+ }
91
+
92
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Payment/Info/Purchaseorder.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ShoppingFlux
4
+ * @package Profileolabs_ShoppingFlux
5
+ * @author kassim belghait
6
+ */
7
+
8
+
9
+ class Profileolabs_Shoppingflux_Block_Manageorders_Payment_Info_Purchaseorder extends Mage_Payment_Block_Info
10
+ {
11
+ protected function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->setTemplate('profileolabs/shoppingflux/manageorders/payment/info/purchaseorder.phtml');
15
+ }
16
+
17
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Tracking/Buyline.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ShoppingFlux
4
+ * @package Profileolabs_Shoppingflux
5
+ * @author Vincent Enjalbert @ Web-cooking.net
6
+ */
7
+ class Profileolabs_Shoppingflux_Block_Tracking_Buyline extends Mage_Core_Block_Text {
8
+
9
+ protected function _toHtml() {
10
+
11
+ $this->addText('
12
+ <!-- BEGIN Shopping flux Tracking -->
13
+ <script type="text/javascript" src="http://tracking.shopping-flux.com/gg.js"></script>
14
+ <!-- END Shopping flux Tracking -->
15
+ ');
16
+ return parent::_toHtml();
17
+ }
18
+
19
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Tracking/Roi.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ShoppingFlux
4
+ * @package Profileolabs_Shoppingflux
5
+ * @author Vincent Enjalbert @ Web-cooking.net
6
+ */
7
+ class Profileolabs_Shoppingflux_Block_Tracking_Roi extends Mage_Core_Block_Text
8
+ {
9
+
10
+
11
+ protected function _toHtml()
12
+ {
13
+ $idTracking = Mage::getSingleton('profileolabs_shoppingflux/config')->getIdTracking();
14
+
15
+ if (!$idTracking) {
16
+ return '';
17
+ }
18
+
19
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
20
+ if ($orderId) {
21
+ $order = Mage::getModel('sales/order')->load($orderId);
22
+ if ($order->getId()) {
23
+ $grandTotal = $order->getBaseGrandTotal();
24
+ $incrementId = $order->getIncrementId();
25
+ $this->addText("
26
+ <!-- BEGIN Shopping flux Tracking -->
27
+ <script>
28
+ var sf = sf || [];
29
+ sf.push(['" . $idTracking . "'], ['" . $incrementId . "'], ['" . $grandTotal . "']);
30
+
31
+ (function() {
32
+ var sf_script = document.createElement('script');
33
+ sf_script.src = 'https://tag.shopping-flux.com/async.js';
34
+ sf_script.setAttribute('async', 'true');
35
+ document.documentElement.firstChild.appendChild(sf_script);
36
+ })();
37
+ </script>
38
+ <!-- END Shopping flux Tracking -->
39
+ ");
40
+ }
41
+ }
42
+ return parent::_toHtml();
43
+ }
44
+ }
app/code/community/Profileolabs/Shoppingflux/Helper/Data.php ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Helper
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author kassim belghait
8
+ */
9
+ class Profileolabs_Shoppingflux_Helper_Data extends Mage_Core_Helper_Abstract {
10
+
11
+
12
+ public function formatFeesDescription($fees, $marketplace) {
13
+ return $this->__('%s fees', $marketplace);
14
+ }
15
+
16
+ public function truncateAddress($street, $lineMaxLength=35, $res = array()) {
17
+ $street = trim($street);
18
+ if(!$street) return array();
19
+ if(preg_match('/^.{1,'.$lineMaxLength.'}(\s|$)/u', $street, $match)) {
20
+ $line = trim($match[0]);
21
+ } else {
22
+ $line = mb_substr($street, 0 , $lineMaxLength);
23
+ }
24
+ $street = preg_replace('%^'.$line.'%', '', $street);
25
+ return array_merge(array($line), $this->truncateAddress($street, $lineMaxLength), $res);
26
+ }
27
+
28
+ /**
29
+ * Returns the node and children as an array
30
+ * values ares trimed
31
+ *
32
+ * @param bool $isCanonical - whether to ignore attributes
33
+ * @return array|string
34
+ */
35
+ public function asArray(SimpleXMLElement $xml, $isCanonical = true) {
36
+ $result = array();
37
+ if (!$isCanonical) {
38
+ // add attributes
39
+ foreach ($xml->attributes() as $attributeName => $attribute) {
40
+ if ($attribute) {
41
+ $result['@'][$attributeName] = trim((string) $attribute);
42
+ }
43
+ }
44
+ }
45
+ // add children values
46
+ if ($xml->hasChildren()) {
47
+ foreach ($xml->children() as $childName => $child) {
48
+ if (!$child->hasChildren())
49
+ $result[$childName] = $this->asArray($child, $isCanonical);
50
+ else
51
+ $result[$childName][] = $this->asArray($child, $isCanonical);
52
+ }
53
+ } else {
54
+ if (empty($result)) {
55
+ // return as string, if nothing was found
56
+ $result = trim((string) $xml);
57
+ } else {
58
+ // value has zero key element
59
+ $result[0] = trim((string) $xml);
60
+ }
61
+ }
62
+ return $result;
63
+ }
64
+
65
+ public function log($message, $orderId = null) {
66
+ $modelLog = Mage::getModel('profileolabs_shoppingflux/manageorders_log');
67
+
68
+ $modelLog->log($message, $orderId);
69
+
70
+ return $this;
71
+ }
72
+
73
+ public function isUnderVersion14() {
74
+ $currentVersion = Mage::getVersion();
75
+ if (version_compare($currentVersion, '1.4.0') < 0)
76
+ return true;
77
+
78
+ return false;
79
+ }
80
+
81
+ public function getShippingPrice($product, $carrierValue, $countryCode = "FR") {
82
+ $carrierTab = explode('_', $carrierValue);
83
+ list($carrierCode, $methodCode) = $carrierTab;
84
+ $shipping = Mage::getModel('shipping/shipping');
85
+ $methodModel = $shipping->getCarrierByCode($carrierCode);
86
+ if ($methodModel) {
87
+ $result = $methodModel->collectRates($this->getRequest($product, $countryCode = "FR"));
88
+ if ($result->getError()) {
89
+ Mage::logException(new Exception($result->getError()));
90
+ } else {
91
+ foreach ($result->getAllRates() as $rate) {
92
+ return $rate->getPrice();
93
+ }
94
+ }
95
+ }
96
+
97
+ return false;
98
+ }
99
+
100
+ protected function getRequest($product, $countryCode = "FR") {
101
+ /** @var $request Mage_Shipping_Model_Rate_Request */
102
+ $request = Mage::getModel('shipping/rate_request');
103
+ $storeId = $request->getStoreId();
104
+ if (!$request->getOrig()) {
105
+ $request
106
+ ->setCountryId($countryCode)
107
+ ->setRegionId("")
108
+ ->setCity("")
109
+ ->setPostcode("")
110
+ ;
111
+ }
112
+
113
+ $item = Mage::getModel('sales/quote_item');
114
+ $item->setStoreId($storeId);
115
+ $item->setOptions($product->getCustomOptions())
116
+ ->setProduct($product);
117
+
118
+ $request->setAllItems(array($item));
119
+
120
+ $request->setDestCountryId($countryCode);
121
+ $request->setDestRegionId("");
122
+ $request->setDestRegionCode("");
123
+ $request->setDestPostcode("");
124
+ $request->setPackageValue($product->getPrice());
125
+
126
+ $request->setPackageValueWithDiscount($product->getFinalPrice());
127
+ $request->setPackageWeight($product->getWeight());
128
+ $request->setFreeMethodWeight(0);
129
+ $request->setPackageQty(1);
130
+
131
+ $request->setStoreId(Mage::app()->getStore()->getId());
132
+ $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
133
+ $request->setBaseCurrency(Mage::app()->getStore()->getBaseCurrency());
134
+ $request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency());
135
+
136
+ //$request->setLimitCarrier($limitCarrier);
137
+
138
+ return $request;
139
+ }
140
+
141
+ public function getFilesGenerated() {
142
+ $dirStores = array();
143
+ $links = array();
144
+ if (!is_dir(Mage::getBaseDir('media') . DS . 'shoppingflux')) {
145
+ mkdir(Mage::getBaseDir('media') . DS . 'shoppingflux');
146
+ }
147
+ if ($handle = opendir(Mage::getBaseDir('media') . DS . 'shoppingflux' . DS)) {
148
+
149
+ /* This is the correct way to loop over the directory. */
150
+ while (false !== ($file = readdir($handle))) {
151
+ if ($file == "." || $file == "..")
152
+ continue;
153
+ $dirStores[] = $file;
154
+ }
155
+
156
+ closedir($handle);
157
+ }
158
+
159
+ foreach ($dirStores as $store) {
160
+ $links[] = Mage::getBaseUrl('media') . "shoppingflux/" . $store . "/flow.xml";
161
+ }
162
+ return $links;
163
+ }
164
+
165
+ /**
166
+ * Clean None utf-8 characters
167
+ * @param string $value
168
+ * @return string $value
169
+ */
170
+ public function cleanNotUtf8($value) {
171
+ if (method_exists(Mage::helper('core/string'), "cleanString"))
172
+ $value = Mage::helper('core/string')->cleanString($value);
173
+
174
+
175
+ //reject overly long 2 byte sequences, as well as characters above U+10000 and replace with blank
176
+ $value = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' .
177
+ '|[\x00-\x7F][\x80-\xBF]+' .
178
+ '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' .
179
+ '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' .
180
+ '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', '', $value);
181
+
182
+ //reject overly long 3 byte sequences and UTF-16 surrogates and replace with blank
183
+ $value = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' .
184
+ '|\xED[\xA0-\xBF][\x80-\xBF]/S', '', $value);
185
+
186
+ /* $value = preg_replace("/([\x80-\xFF])/e",
187
+ "chr(0xC0|ord('\\1')>>6).chr(0x80|ord('\\1')&0x3F)",
188
+ $value); */
189
+
190
+
191
+ $value = str_replace(chr(31), "", $value);
192
+ $value = str_replace(chr(30), "", $value);
193
+ $value = str_replace(chr(29), "", $value);
194
+ $value = str_replace(chr(28), "", $value);
195
+
196
+
197
+ //$value = iconv("UTF-8","UTF-8//IGNORE",$value);
198
+
199
+
200
+ return $value;
201
+ }
202
+
203
+ function _convert($content) {
204
+ if (!mb_check_encoding($content, 'UTF-8') OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32'))) {
205
+
206
+ $content = mb_convert_encoding($content, 'UTF-8');
207
+
208
+ if (mb_check_encoding($content, 'UTF-8')) {
209
+ // log('Converted to UTF-8');
210
+ } else {
211
+ // log('Could not converted to UTF-8');
212
+ }
213
+ }
214
+ return $content;
215
+ }
216
+
217
+ public function getAttributesConfigurable($product) {
218
+
219
+ if (is_object($product))
220
+ $product = $product->getId();
221
+
222
+ $resource = Mage::getSingleton('core/resource');
223
+ $read = $resource->getConnection('catalog_read');
224
+
225
+ $superAttributeTable = $resource->getTableName('catalog_product_super_attribute');
226
+ $eavAttributeTable = $resource->getTableName('eav/attribute');
227
+
228
+ $select = $read->select('attribute_id')
229
+ ->from($superAttributeTable)
230
+ ->join(array("att" => $eavAttributeTable), $superAttributeTable . '.attribute_id=att.attribute_id', array("attribute_code" => "attribute_code"))
231
+ ->where("product_id = " . $product);
232
+
233
+ $result = $read->fetchAll($select);
234
+ return $result;
235
+ }
236
+
237
+ protected $_categoriesWithParents = null;
238
+ public function getCategoriesWithParents($key = false, $storeId=null) {
239
+
240
+
241
+ if(is_null($this->_categoriesWithParents)) {
242
+ $mageCacheKey = 'shoppingflux_category_list' . (Mage::app()->getStore()->isAdmin() ? '_admin'.intval($storeId) : '_' . intval($storeId)) ;
243
+ $cacheTags = array(Mage_Catalog_Model_Category::CACHE_TAG, 'shoppingflux');
244
+ $this->_categoriesWithParents = unserialize(Mage::app()->loadCache($mageCacheKey));
245
+ if (!$this->_categoriesWithParents) {
246
+
247
+ $rootCategoryId = Mage::app()->getStore($storeId)->getRootCategoryId();
248
+ $this->_categoriesWithParents = array('name' => array(), 'url' => array(), 'id' => array());
249
+
250
+
251
+ $categories = Mage::getModel('catalog/category')
252
+ ->getCollection()
253
+ ->addAttributeToSelect('name')
254
+ ->addAttributeToFilter('entity_id', array('neq' => 1))
255
+ ->addAttributeToSort('path', 'ASC')
256
+ ->addAttributeToSort('name', 'ASC');
257
+
258
+ if(!Mage::getSingleton('profileolabs_shoppingflux/config')->getUseAllStoreCategories()) {
259
+ $categories
260
+ ->addAttributeToFilter('entity_id', array('neq' => $rootCategoryId));
261
+ if($rootCategoryId!=0) {
262
+ $categories->addFieldToFilter('path', array('like' => "1/{$rootCategoryId}/%"));
263
+ }
264
+ }
265
+
266
+ foreach ($categories as $category) {
267
+ $parent = $category->getParentId();
268
+ while ($parent > 1) {
269
+ $parentCategory = Mage::getModel('catalog/category')->load($parent);
270
+ $category->setName($parentCategory->getName() . " > " . $category->getName());
271
+ if (!Mage::app()->getStore()->isAdmin()) {
272
+ //To avoid exception launched by third part module : ManaPro_FilterSeoLinks
273
+ $category->setUrl($parentCategory->getUrl() . " > " . $category->getUrl());
274
+ }
275
+ $category->setIds($parentCategory->getId() . " > " . $category->getIds() ? $category->getIds() : $category->getId());
276
+ $parent = $parentCategory->getParentId();
277
+ }
278
+ }
279
+
280
+ foreach ($categories as $_category) {
281
+ $this->_categoriesWithParents['name'][$_category->getId()] = $_category->getName();
282
+ if ($this->isModuleInstalled('ManaPro_FilterSeoLinks') && Mage::app()->getStore()->isAdmin()) {
283
+ $this->_categoriesWithParents['url'][$_category->getId()] = '';
284
+ } else {
285
+ $this->_categoriesWithParents['url'][$_category->getId()] = $_category->getUrl();
286
+ }
287
+ $this->_categoriesWithParents['id'][$_category->getId()] = $_category->getIds();
288
+ }
289
+ Mage::app()->saveCache(serialize($this->_categoriesWithParents), $mageCacheKey, $cacheTags);
290
+
291
+ unset($categories);
292
+ }
293
+ }
294
+
295
+ if ($key && isset($this->_categoriesWithParents[$key]))
296
+ return $this->_categoriesWithParents[$key];
297
+ return $this->_categoriesWithParents;
298
+ }
299
+
300
+ public function isModuleInstalled($module) {
301
+ $modules = Mage::getConfig()->getNode('modules')->children();
302
+ $modulesArray = (array) $modules;
303
+
304
+ return isset($modulesArray[$module]);
305
+ }
306
+
307
+ public function notifyError($message) {
308
+ //MAIL
309
+ $emailTemplate = Mage::getModel('core/email_template')
310
+ ->loadDefault('shoppingflux_alert');
311
+ $emailTemplateVariables = array();
312
+ $emailTemplateVariables['message'] = $message;
313
+ $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
314
+ $emailTemplate->setSenderName('Magento/ShoppingFlux');
315
+ $emailTemplate->setSenderEmail('no-reply@magento-shoppingflux.com');
316
+ $emailTemplate->send(Mage::getStoreConfig('shoppingflux/configuration/alert_email'), Mage::getStoreConfig('shoppingflux/configuration/alert_email'), $emailTemplateVariables);
317
+
318
+ // Notification
319
+ try {
320
+ $notification = Mage::getModel('adminnotification/inbox');
321
+ $notification->setseverity(Mage_AdminNotification_Model_Inbox::SEVERITY_CRITICAL);
322
+ $notification->setTitle(Mage::helper('profileolabs_shoppingflux')->__('Shoppingflux alert'));
323
+ $notification->setDateAdded(date('Y-m-d H:i:s'));
324
+ $notification->setDescription(Mage::helper('profileolabs_shoppingflux')->__('Shoppingflux alert : <br/> %s', $message));
325
+ $notification->save();
326
+ } catch (Exception $e) {
327
+ //var_dump($e->getMessage());die();
328
+ }
329
+ }
330
+
331
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Attribute/Source/Category.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Categories source for product attribute
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author Vincent Enjalbert @ Web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Attribute_Source_Category extends Mage_Eav_Model_Entity_Attribute_Source_Abstract {
10
+
11
+ protected $_options = null;
12
+
13
+
14
+
15
+ public function getAllOptions($withEmpty = false) {
16
+ if (is_null($this->_options)) {
17
+ $this->_options = array();
18
+ $categories = Mage::helper('profileolabs_shoppingflux')->getCategoriesWithParents('name', Mage::app()->getRequest()->getParam('store', null));
19
+ foreach($categories as $categoryId=>$categoryName)
20
+ $this->_options[] = array('label'=>$categoryName, 'value'=>$categoryId);
21
+ }
22
+ $options = $this->_options;
23
+ if ($withEmpty) {
24
+ array_unshift($options, array('value' => '', 'label' => ''));
25
+ }
26
+ return $options;
27
+ }
28
+
29
+ public function getOptionText($value) {
30
+ $options = $this->getAllOptions(false);
31
+
32
+ foreach ($options as $item) {
33
+ if ($item['value'] == $value) {
34
+ return $item['label'];
35
+ }
36
+ }
37
+ return false;
38
+ }
39
+
40
+ public function getFlatColums() {
41
+ $attributeCode = $this->getAttribute()->getAttributeCode();
42
+ $column = array(
43
+ 'unsigned' => false,
44
+ 'default' => null,
45
+ 'extra' => null
46
+ );
47
+
48
+ $currentVersion = Mage::getVersion();
49
+ if (version_compare($currentVersion, '1.6.0') < 0 || Mage::helper('core')->useDbCompatibleMode()) {
50
+ $column['type'] = 'int(10)';
51
+ $column['is_null'] = true;
52
+ } else {
53
+ $column['type'] = Varien_Db_Ddl_Table::TYPE_SMALLINT;
54
+ $column['length'] = 10;
55
+ $column['nullable'] = true;
56
+ $column['comment'] = $attributeCode . ' column';
57
+ }
58
+
59
+ return array($attributeCode => $column);
60
+ }
61
+
62
+ public function getFlatUpdateSelect($store) {
63
+ return Mage::getResourceModel('eav/entity_attribute')
64
+ ->getFlatUpdateSelect($this->getAttribute(), $store);
65
+ }
66
+
67
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Config.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author kassim belghait, vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Config extends Varien_Object {
10
+
11
+ public function getConfigData($key, $storeId = null) {
12
+ $dataKey = str_replace('/', '_', 'conf/' . $key . '/' . (is_null($storeId) ? '0' : $storeId));
13
+ if (!$this->hasData($dataKey)) {
14
+ $value = Mage::getStoreConfig($key, $storeId);
15
+ $this->setData($dataKey, $value);
16
+ }
17
+ return $this->getData($dataKey);
18
+ }
19
+
20
+ public function getConfigFlag($key, $storeId = null) {
21
+ $dataKey = str_replace('/', '_', 'flag/' . $key . '/' . (is_null($storeId) ? '0' : $storeId));
22
+ if (!$this->hasData($dataKey)) {
23
+ $value = Mage::getStoreConfigFlag($key, $storeId);
24
+ $this->setData($dataKey, $value);
25
+ }
26
+ return $this->getData($dataKey);
27
+ }
28
+
29
+ /**
30
+ * Return API KEY
31
+ * @return string
32
+ */
33
+ public function getApiKey($storeId = null) {
34
+ return $this->getConfigData('shoppingflux/configuration/api_key', $storeId);
35
+ }
36
+
37
+ public function getIdClient($storeId = null) {
38
+ return $this->getConfigData('shoppingflux/configuration/login', $storeId);
39
+ }
40
+
41
+ public function getIdTracking($storeId = null) {
42
+ return $this->getConfigData('shoppingflux/configuration/id_tracking', $storeId);
43
+ }
44
+
45
+ /*
46
+ * Define is in test mode
47
+ * @return boolean
48
+ */
49
+
50
+ public function isSandbox() {
51
+ return $this->getConfigFlag('shoppingflux/configuration/is_sandbox');
52
+ }
53
+
54
+ /**
55
+ * Get WS URI
56
+ * @return string uri of web service
57
+ */
58
+ public function getWsUri() {
59
+ if ($this->isSandbox())
60
+ return $this->getConfigData('shoppingflux/configuration/ws_uri_sandbox');
61
+ return $this->getConfigData('shoppingflux/configuration/ws_uri_prod');
62
+ }
63
+
64
+ public function isExportEnabled($storeId = null) {
65
+ return $this->getConfigFlag('shoppingflux_export/general/active', $storeId);
66
+ }
67
+
68
+ public function isExportFilteredByAttribute($storeId = null) {
69
+ return $this->getConfigFlag('shoppingflux_export/general/filter_by_attribute', $storeId);
70
+ }
71
+
72
+ /**
73
+ * Retrieve if export sold out products
74
+ *
75
+ * @return boolean
76
+ */
77
+ public function isExportSoldout($storeId = null) {
78
+ return $this->getConfigFlag('shoppingflux_export/general/export_soldout', $storeId);
79
+ }
80
+
81
+
82
+ public function getVisibilitiesToExport($storeId = null) {
83
+ return explode(',', $this->getConfigData('shoppingflux_export/general/export_visibility', $storeId));
84
+ }
85
+
86
+ /**
87
+ * Retrieve limit of product in query
88
+ *
89
+ * @return int
90
+ */
91
+ public function getExportProductLimit($storeId = null) {
92
+ return (int) $this->getConfigData('shoppingflux_export/general/limit_product', $storeId);
93
+ }
94
+
95
+ public function getUseAllStoreCategories($storeId = null) {
96
+ return $this->getConfigFlag('shoppingflux_export/general/all_store_categories', $storeId);
97
+ }
98
+
99
+ public function getUseAllStoreProducts($storeId = null) {
100
+ return $this->getConfigFlag('shoppingflux_export/general/all_store_products', $storeId);
101
+ }
102
+
103
+ public function getUseOnlySFCategory($storeId = null) {
104
+ return $this->getConfigFlag('shoppingflux_export/general/use_only_shoppingflux_category', $storeId);
105
+ }
106
+
107
+ public function getMaxCategoryLevel($storeId = null) {
108
+ return $this->getConfigData('shoppingflux_export/general/max_category_level', $storeId);
109
+ }
110
+
111
+ public function getEnableEvents($storeId = null) {
112
+ return $this->getConfigFlag('shoppingflux_export/general/enable_events', $storeId);
113
+ }
114
+
115
+ public function getManageConfigurables($storeId = null) {
116
+ return $this->getConfigFlag('shoppingflux_export/general/manage_configurable', $storeId);
117
+ }
118
+
119
+ public function getManageCatalogRules($storeId = null) {
120
+ return $this->getConfigFlag('shoppingflux_export/general/manage_catalog_rules', $storeId);
121
+ }
122
+
123
+ public function getManageMediaGallery($storeId = null) {
124
+ return $this->getConfigFlag('shoppingflux_export/general/manage_media_gallery', $storeId);
125
+ }
126
+
127
+
128
+
129
+ /**
130
+ * Return Attributes Knowed in array with key=>value
131
+ * key = node adn value = inner text
132
+ * @return array
133
+ */
134
+ public function getMappingAttributesKnow($storeId = null) {
135
+ return $this->getConfigData('shoppingflux_export/attributes_know', $storeId);
136
+ }
137
+
138
+ /**
139
+ * Return Attributes Unknowed in array with key=>value
140
+ * key = node adn value = inner text
141
+ * @param int $storeId
142
+ * @return array
143
+ */
144
+ public function getMappgingAttributesUnKnow($storeId = null) {
145
+ return $this->getConfigData('shoppingflux_export/attributes_unknow', $storeId);
146
+ }
147
+
148
+ /**
149
+ * Return Attributes Unknowed in array with key=>value
150
+ * key = node adn value = inner text
151
+ * @param int $storeId
152
+ * @return array
153
+ */
154
+ public function getAdditionalAttributes($storeId = null) {
155
+ $additionnal = explode(',',$this->getConfigData('shoppingflux_export/attributes_additionnal/list', $storeId));
156
+ $unknow = $this->getMappgingAttributesUnKnow($storeId);
157
+ $know = $this->getMappingAttributesKnow($storeId);
158
+ //We do not want attributes that are already in known or unknown lists
159
+ $additionnal = array_diff($additionnal, $know, $unknow);
160
+ return $additionnal;
161
+ }
162
+
163
+ /**
164
+ * Return ALL Attributes Knowed and Unknowed in array with key=>value
165
+ * key = node adn value = inner text
166
+ * @return array
167
+ * @param int $storeId
168
+ */
169
+ public function getMappingAllAttributes($storeId = null) {
170
+ return array_merge($this->getMappingAttributesKnow($storeId), $this->getMappgingAttributesUnKnow($storeId));
171
+ }
172
+
173
+ public function getMemoryLimit() {
174
+ $memoryLimit = intval($this->getConfigData('shoppingflux_export/general/memory_limit'));
175
+ if($memoryLimit>10) {
176
+ return $memoryLimit;
177
+ }
178
+ return 512;
179
+ }
180
+
181
+ public function isSyncEnabled($storeId = null) {
182
+ return $this->getConfigFlag('shoppingflux_export/general/enable_sync', $storeId);
183
+ }
184
+
185
+ public function useManageStock($storeId = null) {
186
+ return $this->getConfigFlag('shoppingflux_export/general/use_manage_stock', $storeId);
187
+ }
188
+
189
+ /** ORDERS * */
190
+ public function isOrdersEnabled($storeId = null) {
191
+ return $this->getConfigFlag('shoppingflux_mo/manageorders/enabled', $storeId);
192
+ }
193
+
194
+ /**
195
+ * Get Limit orders
196
+ * @return int
197
+ */
198
+ public function getLimitOrders($storeId = null) {
199
+ $limit = $this->getConfigData('shoppingflux_mo/manageorders/limit_orders', $storeId);
200
+ if ($limit < 1)
201
+ $limit = 10;
202
+ return $limit;
203
+ }
204
+
205
+ public function getAddressLengthLimit($storeId = null) {
206
+ $limit = $this->getConfigData('shoppingflux_mo/import_customer/limit_address_length');
207
+ if(!$limit || $limit < 20)
208
+ return false;
209
+ return $limit;
210
+ }
211
+
212
+ /**
213
+ * get customer Group
214
+ */
215
+ public function getCustomerGroupIdFor($marketplace = false, $storeId = null) {
216
+ if ($marketplace) {
217
+ $marketplace = strtolower($marketplace);
218
+ $customerGroupId = $this->getConfigData('shoppingflux_mo/import_customer/' . $marketplace . "_group", $storeId);
219
+ if ($customerGroupId)
220
+ return $customerGroupId;
221
+ }
222
+ $customerGroupId = $this->getConfigData("shoppingflux_mo/import_customer/default_group", $storeId);
223
+ if ($customerGroupId)
224
+ return $customerGroupId;
225
+ return false;
226
+ }
227
+
228
+
229
+
230
+ public function getShippingMethodFor($marketplace = false, $sfShippingMethod = false, $storeId = null) {
231
+ $defaultShippingMethod = Mage::getStoreConfig('shoppingflux_mo/shipping_method/default_method', $storeId);
232
+ if(!$marketplace) {
233
+ return $defaultShippingMethod;
234
+ }
235
+ $marketplace = strtolower($marketplace);
236
+ $marketplaceShippingMode = Mage::getStoreConfig('shoppingflux_mo/shipping_method/' . $marketplace . '_method', $storeId);
237
+ if(!$sfShippingMethod) {
238
+ return $marketplaceShippingMode?$marketplaceShippingMode:$defaultShippingMethod;
239
+ }
240
+ $sfShippingMethodCode = Mage::getModel('profileolabs_shoppingflux/manageorders_shipping_method')->getFullShippingMethodCodeFor($marketplace, $sfShippingMethod);
241
+ $sfShippingMethodCode = preg_replace('%[^a-zA-Z0-9_]%', '', $sfShippingMethodCode);
242
+ $shippingMethod = Mage::getStoreConfig('shoppingflux_mo/advanced_shipping_method/' . $sfShippingMethodCode, $storeId);
243
+ return $shippingMethod?$shippingMethod:($marketplaceShippingMode?$marketplaceShippingMode:$defaultShippingMethod);
244
+ }
245
+
246
+ /**
247
+ * Retrieve if we must to create invoice
248
+ *
249
+ * @return boolean
250
+ */
251
+ public function createInvoice($storeId = null) {
252
+ return $this->getConfigFlag('shoppingflux_mo/manageorders/create_invoice', $storeId);
253
+ }
254
+
255
+ /**
256
+ * Retrieve if we must to apply tax
257
+ *
258
+ * @return boolean
259
+ */
260
+ public function applyTax($storeId = null) {
261
+ return true;
262
+ //return $this->getConfigFlag('shoppingflux_mo/manageorders/apply_tax', $storeId);
263
+ }
264
+
265
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Convert/Parser/Product.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Profileolabs_Shoppingflux_Model_Export_Convert_Parser_Product
3
+ extends Mage_Catalog_Model_Convert_Parser_Product
4
+ {
5
+
6
+
7
+ /**
8
+ * Retrieve accessible external product attributes
9
+ *
10
+ * @return array
11
+ */
12
+ public function getExternalAttributes()
13
+ {
14
+ $productAttributes = array();
15
+ if(file_exists(Mage::getModuleDir(null,'Mage_Catalog') ."Model/Resource/Eav/Mysql4/Product/Attribute/Collection"))
16
+ $productAttributes = Mage::getResourceModel('catalog/product_attribute_collection')->load();
17
+ else
18
+ {
19
+
20
+ $entityTypeId = Mage::getSingleton('eav/config')->getEntityType('catalog_product')->getId();
21
+ $productAttributes = Mage::getResourceModel('eav/entity_attribute_collection')
22
+ ->setEntityTypeFilter($entityTypeId)
23
+ ->load();
24
+ }
25
+
26
+ $attributes = $this->_externalFields;
27
+
28
+ foreach ($productAttributes as $attr) {
29
+ $code = $attr->getAttributeCode();
30
+ if (in_array($code, $this->_internalFields) || $attr->getFrontendInput() == 'hidden') {
31
+ continue;
32
+ }
33
+ $attributes[$code] = $code;
34
+ }
35
+
36
+ foreach ($this->_inventoryFields as $field) {
37
+ $attributes[$field] = $field;
38
+ }
39
+
40
+ return $attributes;
41
+ }
42
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Flow.php ADDED
@@ -0,0 +1,800 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @deprecated deprecated since 0.1.1
6
+ *
7
+ */
8
+ class Profileolabs_Shoppingflux_Model_Export_Flow {
9
+
10
+ protected $_exceptions = array();
11
+ protected $_lastCount = 0;
12
+ protected $_totalCount = null;
13
+ protected $_totalOffset = null;
14
+ protected $_fileName = "flow.xml";
15
+ protected $_xmlFlow = "";
16
+ protected $_attributes = null;
17
+ protected $_storeId = 0;
18
+ protected $_errors = array();
19
+
20
+
21
+
22
+ /*
23
+ * Products collection
24
+ * @var Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
25
+ */
26
+ protected $_productCollection = null;
27
+
28
+ /**
29
+ * Get node XML for a product
30
+ * @param Mage_Catalog_Model_Product $product
31
+ * @return string $nodeXml
32
+ */
33
+ protected function _getProductNode($product) {
34
+
35
+ $_helper = Mage::helper('catalog/output');
36
+
37
+ $product->setStoreId($this->getStoreId());
38
+
39
+
40
+
41
+ $nodeXml = "<product>" . chr(10);
42
+
43
+ $nodeXml .= $this->getNode("id-product", $product->getId());
44
+
45
+ //$nodeXml .= $this->getNode("sku",$product->getSku());
46
+
47
+ foreach ($this->getAttributesForXml() as $nameNode => $valueNode) {
48
+
49
+ $data = $product->getData($valueNode);
50
+
51
+
52
+
53
+ $attribute = $product->getResource()->getAttribute($valueNode);
54
+ if ($attribute) {
55
+
56
+ $data = $product->getResource()->getAttribute($valueNode)->getFrontend()->getValue($product);
57
+ $data = $_helper->productAttribute($product, $data, $valueNode);
58
+ }
59
+
60
+
61
+
62
+ //Synthetize it
63
+ $method = "get" . ucfirst($valueNode);
64
+ if (method_exists($product, $method))
65
+ $data = $product->$method();
66
+
67
+ //TODO remove this
68
+ if ($data == "No" || $data == "Non")
69
+ $data = "";
70
+
71
+ //Exceptions data
72
+ if ($nameNode == 'shipping_delay' && empty($data))
73
+ $data = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
74
+
75
+ if ($nameNode == 'quantity')
76
+ $data = round($data);
77
+
78
+
79
+ $nodeXml .= $this->getNode($nameNode, $data);
80
+ }
81
+
82
+ //Add stock status
83
+ $nodeXml .= $this->getNode("is-in-stock", (int) $product->isSaleable());
84
+
85
+ //Add product url
86
+ $nodeXml .= $this->getNode("product-url", $this->cleanUrl($product->getProductUrl(false)));
87
+
88
+ //Add image's nodes
89
+ $nodeXml .= $this->getImages($product);
90
+
91
+ //Add categories
92
+ $nodeXml .= $this->getCategories($product);
93
+
94
+ //ADD Prices
95
+ $nodeXml .= $this->getPrices($product);
96
+
97
+ //ADD PARENT ID
98
+ $nodeXml .= $this->getParentId($product);
99
+
100
+ //ADD Shipping Name
101
+ $nodeXml .= $this->getShippingName();
102
+
103
+ //Add ShippingPrice
104
+ $nodeXml .= $this->getShippingPrice($product);
105
+
106
+ //Add Options
107
+ $nodeXml .= $this->getOptions($product);
108
+
109
+ $nodeXml .= $this->getNode("sku", $product->getSku());
110
+
111
+ $nodeXml .= "</product>" . chr(10);
112
+
113
+
114
+ return $nodeXml;
115
+ }
116
+
117
+ protected function getOptions($product) {
118
+ $nodes = "<options>" . chr(10);
119
+ $labels = array();
120
+ if ($product->getTypeId() == "configurable") {
121
+ $attributes = $product->getTypeInstance()->getConfigurableAttributes();
122
+ foreach ($attributes as $attribute) {
123
+ $options = $attribute->getProductAttribute()->getSource()->getAllOptions(false);
124
+ if (count($options)) {
125
+ $labels = array();
126
+ foreach ($options as $option)
127
+ $labels[] = $option['label'];
128
+
129
+ $nodes .= $this->getNode($attribute->getProductAttribute()->getAttributeCode(), implode(',', $labels));
130
+ }
131
+ }
132
+ }
133
+ /* elseif(count($product->getOptions()))
134
+ {
135
+ $options = $product->getOptions();
136
+ foreach($options as $option)
137
+ {
138
+ foreach($option->getValues() as $value)
139
+ {
140
+ $labels[] = $value->getTitle();
141
+ }
142
+
143
+ $nodes .= $this->getNode($option->getTitle(),implode(',',$labels));
144
+
145
+ }
146
+ } */
147
+
148
+
149
+ $nodes .= "</options>" . chr(10);
150
+ return $nodes;
151
+ }
152
+
153
+ protected function getShippingPrice($product) {
154
+ $carrier = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_method');
155
+ $shippingPrice = 0;
156
+ if (!empty($carrier)) {
157
+
158
+ $countryCode = $this->getConfig()->getConfigData('shoppingflux_export/general/shipping_price_based_on');
159
+ $shippingPrice = $this->getHelper()->getShippingPrice($product, $carrier, $countryCode);
160
+ }
161
+
162
+ if (!$shippingPrice) {
163
+ $shippingPrice = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_price');
164
+ }
165
+
166
+ $node = "";
167
+ $node = $this->getNode("shipping-price", $shippingPrice);
168
+
169
+ return $node;
170
+ }
171
+
172
+ protected function getShippingName() {
173
+ $node = "";
174
+ $carrier = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_method');
175
+ if (empty($carrier))
176
+ return $node;
177
+ $carrierTab = explode('_', $carrier);
178
+ list($carrierCode, $methodCode) = $carrierTab;
179
+
180
+ $node = $this->getNode("shipping-name", ucfirst($methodCode));
181
+
182
+ return $node;
183
+ }
184
+
185
+ protected function getParentId($product, $raw = false) {
186
+ $node = "";
187
+ $ids = array();
188
+ $ids = Mage::getResourceSingleton('catalog/product_type_configurable')
189
+ ->getParentIdsByChild($product->getId());
190
+
191
+ if (!count($ids))
192
+ $ids = Mage::getResourceSingleton('bundle/selection')
193
+ ->getParentIdsByChild($product->getId());
194
+
195
+ $idParent = count($ids) ? current($ids) : "";
196
+
197
+ if ($raw)
198
+ return $idParent;
199
+
200
+ $node = $this->getNode("parent-id", $idParent);
201
+
202
+ return $node;
203
+ }
204
+
205
+ private function _getMediaGallery($product) {
206
+ $media = $product->getData('media_gallery');
207
+ if (is_null($media)) {
208
+ if ($attribute = $product->getResource()->getAttribute('media_gallery')) {
209
+ $attribute->getBackend()->afterLoad($product);
210
+ $media = $product->getData('media_gallery');
211
+ }
212
+ }
213
+ return $media;
214
+ }
215
+
216
+ private function _imageIsValid($url) {
217
+ return (trim($url) != '' && !preg_match('%(no_selection|no_image\.jpg)$%i', $url));
218
+ }
219
+
220
+ /**
221
+ * Get images of product
222
+ * @param Mage_Catalog_Model_Product $product
223
+ * @return string $nodes
224
+ */
225
+ protected function getImages($product) {
226
+ $nodes = "";
227
+
228
+ $mediaUrl = Mage::getBaseUrl('media') . 'catalog/product';
229
+
230
+ $images = array();
231
+
232
+ $baseImage = Mage::helper('catalog/product')->getImageUrl($product);
233
+ if ($this->_imageIsValid($baseImage)) {
234
+ $images[] = $baseImage;
235
+ }
236
+ $smallimage = Mage::helper('catalog/product')->getSmallImageUrl($product);
237
+ if ($this->_imageIsValid($smallimage)) {
238
+ $images[] = $smallimage;
239
+ }
240
+
241
+ $additionalImages = $this->_getMediaGallery($product);
242
+ if ($additionalImages)
243
+ $additionalImages = $additionalImages['images'];
244
+ foreach ($additionalImages as $additionalImage) {
245
+ $image = Mage::getSingleton('catalog/product_media_config')->getMediaUrl($additionalImage['file']);
246
+ if ($this->_imageIsValid($image)) {
247
+ $images[] = $image;
248
+ }
249
+ }
250
+
251
+ $images = array_unique($images);
252
+ $images = array_values($images);
253
+
254
+ if (empty($images)) {
255
+ $parentId = $this->getParentId($product, true);
256
+ if (!empty($parentId)) {
257
+ $parent = Mage::getModel('catalog/product')->load($parentId);
258
+ return $this->getImages($parent);
259
+ }
260
+ }
261
+
262
+ foreach ($images as $i => $image) {
263
+ $nodes .= $this->getNode("image-url-" . ($i + 1), $image);
264
+ }
265
+
266
+
267
+ //Complet with empty nodes
268
+ for ($j = $i+1; $j < 6; $j++) {
269
+ $nodes .= $this->getNode("image-url-" . $j, '');
270
+ }
271
+
272
+ return $nodes;
273
+
274
+
275
+
276
+
277
+
278
+
279
+ /*
280
+ $i = 1;
281
+ $imagesFound = false;
282
+ if ($product->getImage() != "" && $product->getImage() != 'no_selection') {
283
+ $nodes .= $this->getNode("image-url-" . $i++, $mediaUrl . $product->getImage());
284
+ $imagesFound = true;
285
+ }
286
+
287
+ //LOAD media gallery for this product
288
+ $mediaGallery = $product->getResource()->getAttribute('media_gallery');
289
+ $mediaGallery->getBackend()->afterLoad($product);
290
+
291
+ if ($product->getMediaGalleryImages() instanceof Varien_Data_Collection) {
292
+ foreach ($product->getMediaGalleryImages() as $image) {
293
+ $imagesFound = true;
294
+ $nodes .= $this->getNode("image-url-" . $i++, $image->getUrl());
295
+ if ($i == 6)
296
+ break;
297
+ }
298
+ }
299
+
300
+
301
+
302
+
303
+ if (!$imagesFound) {//Images not found, we try to get them from parent if exists
304
+ $parentId = $this->getParentId($product, true);
305
+ if (!empty($parentId)) {
306
+ $parent = Mage::getModel('catalog/product')->load($parentId);
307
+ if ($parent->getId()) {
308
+ if ($parent->getImage() != "" && $parent->getImage() != 'no_selection') {
309
+ $nodes .= $this->getNode("image-url-" . $i++, $mediaUrl . $parent->getImage());
310
+ }
311
+
312
+ $mediaGallery = $parent->getResource()->getAttribute('media_gallery');
313
+ $mediaGallery->getBackend()->afterLoad($parent);
314
+ if ($parent->getMediaGalleryImages() instanceof Varien_Data_Collection)
315
+ foreach ($parent->getMediaGalleryImages() as $image) {
316
+ $nodes .= $this->getNode("image-url-" . $i++, $image->getUrl());
317
+ if ($i == 6)
318
+ break;
319
+ }
320
+ }
321
+ }
322
+ }
323
+
324
+ //Complet with empty nodes
325
+ for ($j = $i; $j < 6; $j++) {
326
+ $nodes .= $this->getNode("image-url-" . $i++, '');
327
+ }
328
+
329
+
330
+ return $nodes;*/
331
+ }
332
+
333
+ /**
334
+ * Get categories of product
335
+ * @param Mage_Catalog_Model_Product $product
336
+ * @return string $nodes
337
+ */
338
+ protected function getCategories($product) {
339
+ $nodes = "";
340
+ $categoryCollection = $product->getCategoryCollection()
341
+ ->addAttributeToSelect(array('name'))
342
+ ->addFieldToFilter('level', array('lteq' => 5))
343
+ ->addUrlRewriteToResult()
344
+ ->groupByAttribute('level')
345
+ ->setOrder('level', 'ASC')
346
+ ;
347
+
348
+ $nbCategories = $categoryCollection->count();
349
+ //echo "pId = ".$product->getId()." nb = {$nbCategories}<br />";
350
+ if ($nbCategories < 1) {
351
+ //Get categories from parent if exist
352
+ $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
353
+ ->getParentIdsByChild($product->getId());
354
+
355
+ foreach ($parentIds as $parentId) {
356
+ $categoryCollection = Mage::getResourceSingleton('catalog/product')
357
+ ->getCategoryCollection(new Varien_Object(array("id" => $parentId)))
358
+ ->addAttributeToSelect(array('name'))
359
+ ->addFieldToFilter('level', array('lteq' => 5))
360
+ ->addUrlRewriteToResult()
361
+ ->groupByAttribute('level')
362
+ ->setOrder('level', 'ASC');
363
+
364
+ if (($nbCategories = $categoryCollection->count()) > 0)
365
+ break;
366
+ }
367
+ }
368
+
369
+
370
+ $cnt = 0;
371
+
372
+ foreach ($categoryCollection as $category) {
373
+ //$category->setStoreId($this->getStoreId()); //When store is setted the rewrite url don't found
374
+ $category->getUrlInstance()->setStore($this->getStoreId());
375
+ $category->getUrlInstance()->setUseSession(false);
376
+
377
+ $name = $category->getName();
378
+ $level = $category->getLevel();
379
+ $url = $this->cleanUrl($category->getUrl());
380
+ if ($cnt == 0) {
381
+
382
+ $nodes .= $this->getNode("category", $name);
383
+ $nodes .= $this->getNode("category-url", $url);
384
+ } else {
385
+
386
+ $nodes .= $this->getNode("category-sub-" . ($cnt), $name);
387
+ $nodes .= $this->getNode("category-url-sub-" . ($cnt), $url);
388
+ }
389
+
390
+ $cnt++;
391
+ }
392
+ if ($nbCategories == 0) {
393
+ $nodes .= $this->getNode("category", "");
394
+ $nodes .= $this->getNode("category-url", "");
395
+
396
+ $cnt++;
397
+ }
398
+
399
+
400
+ for ($i = ($cnt); $i <= 5; $i++) {
401
+ $nodes .= $this->getNode("category-sub-" . $i, "");
402
+ $nodes .= $this->getNode("category-url-sub-" . $i, "");
403
+ }
404
+
405
+ return $nodes;
406
+ }
407
+
408
+ /**
409
+ * Get prices of product
410
+ * @param Mage_Catalog_Model_Product $product
411
+ * @return string $nodes
412
+ */
413
+ protected function getPrices($product) {
414
+ $nodes = "";
415
+
416
+ $finalPrice = $product->getFinalPrice() != 0 ? $product->getFinalPrice() : $product->getData('price');
417
+
418
+ $nodes .= $this->getNode("price-ttc", $finalPrice);
419
+ $nodes .= $this->getNode("price-before-discount", $product->getPrice());
420
+ $nodes .= $this->getNode("discount-amount", $product->getTypeId() != 'bundle' ? $product->getSpecialPrice() : 0);
421
+
422
+
423
+
424
+ $nodes .= $this->getNode("discount-percent", $this->getPercent($product));
425
+
426
+ if ($product->getSpecialFromDate() != "" && Zend_Date::isDate($product->getSpecialFromDate())) {
427
+ $startDate = new Zend_Date($product->getSpecialFromDate());
428
+ $nodes .= $this->getNode("start-date-discount", $startDate->toString(Zend_Date::ISO_8601));
429
+ }
430
+ if ($product->getSpecialToDate() != "" && Zend_Date::isDate($product->getSpecialToDate())) {
431
+
432
+ $endDate = new Zend_Date($product->getSpecialToDate());
433
+ $nodes .= $this->getNode("end-date-discount", $endDate->toString(Zend_Date::ISO_8601));
434
+ }
435
+
436
+ return $nodes;
437
+ }
438
+
439
+ protected function getPercent($product) {
440
+
441
+ /* if($product->getTypeId() == 'bundle')
442
+ return 0; */
443
+ $price = round($product->getPrice(), 2);
444
+ if ($price == "0") {
445
+ $price = round($product->getMinimalPrice(), 2);
446
+ }
447
+
448
+ if ($price == "0")
449
+ return 0;
450
+
451
+ $special = round($product->getFinalPrice(), 2);
452
+ $tmp = $price - $special;
453
+ $tmp = ($tmp * 100) / $price;
454
+ return round($tmp);
455
+ }
456
+
457
+ /*
458
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
459
+ */
460
+
461
+ public function getProductCollection() {
462
+ if (is_null($this->_productCollection)) {
463
+ $this->_productCollection = Mage::getResourceModel('catalog/product_collection');
464
+ $this->_productCollection->addStoreFilter($this->getStoreId())
465
+ ->addAttributeToSelect($this->getAllAttributes())
466
+ ->addAttributeToFilter('status', 1)
467
+ ->addAttributeToSort('entity_id', 'asc')
468
+ ->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left')
469
+ //->addAttributeToFilter('visibility',array('nin' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE));
470
+ ;
471
+
472
+ $this->_productCollection->joinTable(
473
+ 'core/url_rewrite', 'product_id=entity_id', array('request_path'), '{{table}}.category_id IS NULL AND {{table}}.is_system = 1 AND {{table}}.store_id = ' . $this->getStoreId() . '', 'left'
474
+ );
475
+
476
+
477
+
478
+ if ($this->getConfig()->isExportFilteredByAttribute()) {
479
+ $this->_productCollection->addAttributeToFilter('shoppingflux_product', array('eq' => 1));
480
+ }
481
+ $this->_totalCount = $this->_productCollection->getSize();
482
+
483
+ $this->_totalOffset = ceil((int) $this->_totalCount / $this->getLimit());
484
+ }
485
+
486
+ return $this->_productCollection;
487
+ }
488
+
489
+ public function getCollectionByOffset($offset = 1) {
490
+ $this->getProductCollection()->clear()->setPage($offset, $this->getLimit());
491
+ //$this->_productCollection->addOptionsToResult();
492
+ Mage::getModel('cataloginventory/stock_status')->addStockStatusToProducts($this->getProductCollection(), Mage::app()->getStore($this->getStoreId())->getWebsiteId());
493
+ $this->_lastCount = $this->getProductCollection()->count();
494
+
495
+ return $this->getProductCollection();
496
+ }
497
+
498
+ public function generateProductsNodes($offset = 1) {
499
+ $start = false;
500
+ if ($offset == 1) {
501
+
502
+ $this->_xmlFlow = '<?xml version="1.0" encoding="utf-8"?>' . chr(10);
503
+ $this->_xmlFlow .= "<products>" . chr(10);
504
+ $start = true;
505
+ }
506
+
507
+ foreach ($this->getCollectionByOffset($offset) as $product) {
508
+ try {
509
+
510
+ if (!$this->_validate($product)) {
511
+ $this->_lastCount--;
512
+ continue;
513
+ }
514
+
515
+ $this->_xmlFlow .= $this->_getProductNode($product);
516
+ } catch (Exception $e) {
517
+ $this->_errors[] = 'Product ID = ' . $product->getId() . "<br />" . $e->getMessage();
518
+ }
519
+ }
520
+
521
+ if ($offset == $this->_totalOffset) {
522
+ $this->closeFlow();
523
+ }
524
+
525
+ $this->_writeXml($start);
526
+
527
+ return $this;
528
+ //TODO maybe unset product collection
529
+ }
530
+
531
+ public function getErrors() {
532
+ return $this->_errors;
533
+ }
534
+
535
+ public function reset() {
536
+ unset($this->_productCollection);
537
+ $this->_productCollection = null;
538
+ $this->_xmlFlow = null;
539
+
540
+ return $this;
541
+ }
542
+
543
+ protected function getNode($name, $value, $withCDATA = 1) {
544
+ $value = $this->getHelper()->cleanNotUtf8($value);
545
+ $openCDATA = "";
546
+ $closeCDATA = "";
547
+ if ($withCDATA) {
548
+ $openCDATA = "<![CDATA[";
549
+ $closeCDATA = "]]>";
550
+ }
551
+ return "<{$name}>{$openCDATA}{$value}{$closeCDATA}</{$name}>" . chr(10);
552
+ }
553
+
554
+ public function closeFlow() {
555
+ $this->_xmlFlow .= "</products>";
556
+ //$this->_writeXml();
557
+ }
558
+
559
+ protected function _writeXml($start = false) {
560
+ $mode = "a+";
561
+ if ($start)
562
+ $mode = "w+";
563
+ $storeId = $this->getStoreId();
564
+ $storeCode = Mage::app()->getStore($storeId)->getCode();
565
+ $dir = Mage::getBaseDir('media') . DS . "shoppingflux" . DS . $storeCode . DS;
566
+ $file = new Varien_Io_File;
567
+ $file->checkAndCreateFolder($dir);
568
+ $file->cd($dir);
569
+ $file->streamOpen($this->_fileName, $mode);
570
+ $file->streamLock();
571
+ $file->streamWrite($this->_xmlFlow);
572
+ $file->streamUnlock();
573
+ $file->streamClose();
574
+
575
+ if ($file->fileExists($this->_fileName)) {
576
+ return $this->_fileName;
577
+ }
578
+
579
+ return false;
580
+ }
581
+
582
+ public function getXml() {
583
+ return $this->_xmlFlow;
584
+ }
585
+
586
+ public function getLastCount() {
587
+ return $this->_lastCount;
588
+ }
589
+
590
+ public function getLimit() {
591
+ return $this->getConfig()->getExportProductLimit();
592
+ }
593
+
594
+ public function setException($error, $level = null, $position = 0) {
595
+
596
+ $e = new Mage_Dataflow_Model_Convert_Exception($error);
597
+ $e->setLevel(!is_null($level) ? $level : Mage_Dataflow_Model_Convert_Exception::NOTICE);
598
+ // $e->setContainer($this);
599
+ $e->setPosition($position);
600
+
601
+ $this->_exceptions[] = $e;
602
+ return $this;
603
+ }
604
+
605
+ public function getExceptions() {
606
+ $exceptions = array();
607
+ foreach ($this->_exceptions as $e) {
608
+
609
+ switch ($e->getLevel()) {
610
+ case Varien_Convert_Exception::FATAL:
611
+ $img = 'error_msg_icon.gif';
612
+ $liStyle = 'background-color:#FBB; ';
613
+ break;
614
+ case Varien_Convert_Exception::ERROR:
615
+ $img = 'error_msg_icon.gif';
616
+ $liStyle = 'background-color:#FDD; ';
617
+ break;
618
+ case Varien_Convert_Exception::WARNING:
619
+ $img = 'fam_bullet_error.gif';
620
+ $liStyle = 'background-color:#FFD; ';
621
+ break;
622
+ case Varien_Convert_Exception::NOTICE:
623
+ $img = 'fam_bullet_success.gif';
624
+ $liStyle = 'background-color:#DDF; ';
625
+ break;
626
+ }
627
+
628
+ $exceptions[] = array(
629
+ "style" => $liStyle,
630
+ "src" => Mage::getDesign()->getSkinUrl('images/' . $img),
631
+ "message" => $e->getMessage(),
632
+ "position" => $e->getPosition()
633
+ );
634
+ }
635
+
636
+ return $exceptions;
637
+ }
638
+
639
+ /**
640
+ * Get singleton config for Export
641
+ * @return Profileolabs_Shoppingflux_Model_Export_Config
642
+ */
643
+ public function getConfig() {
644
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
645
+ }
646
+
647
+ /**
648
+ *
649
+ */
650
+ protected function getAttributesForXml() {
651
+ if (is_null($this->_attributes)) {
652
+ $this->_attributes = $this->getConfig()->getMappingAllAttributes();
653
+ }
654
+
655
+ return $this->_attributes;
656
+ }
657
+
658
+ protected function getAllAttributes() {
659
+ $requiredAttributes = array(
660
+ "sku" => "sku",
661
+ "price" => "price",
662
+ "special_price" => "special_price",
663
+ "minimal_price" => "minimal_price",
664
+ "special_from_date" => "special_from_date",
665
+ "special_to_date" => "special_to_date",
666
+ "image" => "image");
667
+
668
+ return array_merge($this->getAttributesForXml(), $requiredAttributes);
669
+ }
670
+
671
+ public function generateDirectly() {
672
+
673
+ if (!$this->getConfig()->isExportEnabled())
674
+ return $this;
675
+
676
+ try {
677
+ $stores = Mage::getModel('core/store')->getCollection();
678
+ $product = Mage::getModel('catalog/product');
679
+ foreach ($stores as $store) {
680
+ if ($store->getId() == 0)
681
+ continue;
682
+
683
+ $this->setStoreId($store->getId());
684
+
685
+ $flowItemsCount = $this->getProductCollection()->getSize();
686
+ $offsets = ceil((int) $flowItemsCount / $this->getLimit());
687
+ if ($offsets == 0)
688
+ $offsets = 1;
689
+
690
+ $this->_xmlFlow = '<?xml version="1.0" encoding="utf-8"?>' . chr(10);
691
+ $this->_xmlFlow .= "<products>" . chr(10);
692
+
693
+ for ($i = 1; $i <= $offsets; $i++) {
694
+
695
+ //Mage::log('offset = '.$i,null,"test_flow.log");
696
+ $collection = $this->getCollectionByOffset($i);
697
+ foreach ($collection as $product) {
698
+ //Mage::log('pId = '.$product,null,"test_flow.log");
699
+ try {
700
+
701
+ if (!$this->_validate($product)) {
702
+ $this->_lastCount--;
703
+ continue;
704
+ }
705
+
706
+ $this->_xmlFlow .= $this->_getProductNode($product);
707
+ } catch (Exception $e) {
708
+ $this->_errors[] = 'Product ID = ' . $product->getId() . "<br />" . $e->getMessage();
709
+ }
710
+ }
711
+
712
+ /*
713
+ using resource iterator to load the data one by one
714
+ instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
715
+ */
716
+ /* Mage::getSingleton('core/resource_iterator')
717
+ ->walk($collection->getSelect(), array(array($this, 'addItemXmlCallback')), array('xml'=> $this->_xmlFlow, 'product'=>$product));
718
+ */
719
+
720
+ unset($collection);
721
+ }
722
+
723
+ $this->closeFlow();
724
+ $this->_writeXml(true);
725
+ $this->reset();
726
+ }
727
+ } catch (Exception $e) {
728
+ Mage::logException($e);
729
+ Mage::throwException($e);
730
+ }
731
+ return $this;
732
+ }
733
+
734
+ public function addItemXmlCallback($args) {
735
+ $product = $args['product'];
736
+ $product->setData($args['row']);
737
+ $xmlFlow = $args['xml'];
738
+
739
+ try {
740
+
741
+ if (!$this->_validate($product)) {
742
+
743
+ //Mage::log("noValid = ".$product,null,'test_callback.log'); $this->_lastCount--;
744
+ continue;
745
+ }
746
+
747
+
748
+ //Mage::log('ID P = ' . $product->getId(), null, 'test_callback.log');
749
+ $xmlFlow .= $this->_getProductNode($product);
750
+ //Mage::log($xmlFlow, null, 'test_callback.log');
751
+ } catch (Exception $e) {
752
+ $this->_errors[] = 'Product ID = ' . $product->getId() . "<br />" . $e->getMessage();
753
+ }
754
+ }
755
+
756
+ /**
757
+ * Return Shoppingflu Helper
758
+ * @return Profileolabs_Shoppingflux_Helper_Data
759
+ */
760
+ protected function getHelper() {
761
+ return Mage::helper('profileolabs_shoppingflux');
762
+ }
763
+
764
+ public function setStoreId($storeId) {
765
+ $this->_storeId = $storeId;
766
+ return $this;
767
+ }
768
+
769
+ public function getStoreId() {
770
+ return $this->_storeId;
771
+ return $this;
772
+ }
773
+
774
+ public function getTotalCount() {
775
+ if (is_null($this->_totalCount))
776
+ $this->getProductCollection();
777
+
778
+ return $this->_totalCount;
779
+ }
780
+
781
+ protected function _validate($product) {
782
+ /* if($product->getType() != "bundle" && $product->getPrice() == 0 && $product->getMinimalPrice() == 0)
783
+ return false; */
784
+
785
+ if (!$this->getConfig()->isExportSoldout() && !$product->isSaleable()) {
786
+ //$this->setException("Le produit {$product->getSku()} est hors stock. Il n'a pas été importé.",Varien_Convert_Exception::NOTICE);
787
+ $this->_errors[] = Mage::helper('profileolabs_shoppingflux')->__("Le produit %s est hors stock. Il n'a pas été importé.", $product->getSku());
788
+ return false;
789
+ }
790
+
791
+ return true;
792
+ }
793
+
794
+ public function cleanUrl($url) {
795
+ $url = str_replace("index.php/", "", $url);
796
+
797
+ return $url;
798
+ }
799
+
800
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Flux.php ADDED
@@ -0,0 +1,898 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Export_Flux extends Mage_Core_Model_Abstract {
10
+
11
+ protected $_attributesFromConfig = null;
12
+ protected $_attributesConfigurable = array();
13
+ protected $_storeCategories = array();
14
+
15
+ protected function _construct() {
16
+ $this->_init('profileolabs_shoppingflux/export_flux');
17
+ }
18
+
19
+ public function getEntry($productSku, $storeId) {
20
+ $collection = $this->getCollection();
21
+ $collection->addFieldToFilter('sku', $productSku);
22
+ $collection->addFieldToFilter('store_id', $storeId);
23
+ if ($collection->count() > 0) {
24
+ return $collection->getFirstItem();
25
+ }
26
+ $model = Mage::getModel('profileolabs_shoppingflux/export_flux')
27
+ ->setStoreId($storeId)
28
+ ->setSku($productSku)
29
+ ->setUpdateNeeded(0);
30
+ return $model;
31
+ }
32
+
33
+ protected function _getProductBySku($productSku, $storeId) {
34
+ $pId = Mage::getModel('catalog/product')->getIdBySku($productSku);
35
+ if(!$pId) {
36
+ return false;
37
+ }
38
+ return $this->_getProduct($pId, $storeId);
39
+ }
40
+
41
+ protected function _getProduct($product, $storeId) {
42
+ if (is_numeric($product)) {
43
+ $productId = $product;
44
+ } else if (is_object($product)) {
45
+ $productId = $product->getId();
46
+ } else {
47
+ return false;
48
+ }
49
+
50
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
51
+ $select = $read->select()
52
+ ->distinct()
53
+ ->from(Mage::getConfig()->getTablePrefix() . 'catalog_product_website', array('website_id'))
54
+ ->where('product_id = ?', $productId);
55
+ $result = $read->fetchAll($select);
56
+ $websiteIds = array();
57
+ foreach($result as $row) {
58
+ $websiteIds[] = $row['website_id'];
59
+ }
60
+
61
+ if(!in_array(Mage::app()->getStore($storeId)->getWebsiteId(), $websiteIds)) {
62
+ return false;
63
+ }
64
+
65
+ $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId);
66
+ if(!$product->getId()) {
67
+ return false;
68
+ }
69
+
70
+ return $product;
71
+ }
72
+
73
+ public function getConfig() {
74
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
75
+ }
76
+
77
+ public function addMissingProduct($args) {
78
+ $storeId = $args['store_id'];
79
+ $this->updateProductInFlux($args['row']['sku'], $storeId);
80
+
81
+ }
82
+
83
+ public function checkForMissingProducts($store_id = false, $maxImport = 200) {
84
+ ini_set('display_errors', 1);
85
+ error_reporting(-1);
86
+ foreach (Mage::app()->getStores() as $store) {
87
+ $storeId = $store->getId();
88
+ if(!$this->getConfig()->isExportEnabled($storeId)) {
89
+ continue;
90
+ }
91
+ if (!$store_id || $storeId == $store_id) {
92
+ $productCollection = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId)->setStoreId($storeId);
93
+ $productCollection->addAttributeToSelect('sku', 'left');
94
+ $currentVersion = Mage::getVersion();
95
+ $tableName = Mage::getSingleton('core/resource')->getTableName('profileolabs_shoppingflux/export_flux');
96
+ $productCollection->joinTable($tableName, "sku=sku", array('skusf' => 'sku'), "{{table}}.store_id = '" . $storeId . "'", 'left');
97
+ //not compatible with mage 1.3
98
+ //$productCollection->joinTable(array('sf'=>'profileolabs_shoppingflux/export_flux'), "sku=sku", array('skusf'=>'sku'), "{{table}}.store_id = '".$storeId."'", 'left');
99
+ $productCollection->setPage(1, $maxImport);
100
+ $productCollection->getSelect()->where($tableName . '.sku
101
+ IS NULL');
102
+ $productCollection->load();
103
+ Mage::getSingleton('core/resource_iterator')
104
+ ->walk($productCollection->getSelect(), array(array($this, 'addMissingProduct')), array('store_id' => $storeId));
105
+ }
106
+ }
107
+ }
108
+
109
+ public function updateFlux($store_id = false, $maxImportLimit = 500, $shouldExportOnly = false) {
110
+ foreach (Mage::app()->getStores() as $store) {
111
+ $storeId = $store->getId();
112
+ if (!$store_id || $store_id == $storeId) {
113
+ $collection = Mage::getModel('profileolabs_shoppingflux/export_flux')->getCollection();
114
+ $collection->addFieldToFilter('update_needed', 1);
115
+ $collection->addFieldToFilter('store_id', $storeId);
116
+ if ($shouldExportOnly) {
117
+ $collection->addFieldToFilter('should_export', 1);
118
+ }
119
+ foreach ($collection as $item) {
120
+ $this->updateProductInFlux($item->getSku(), $storeId);
121
+ }
122
+ $this->checkForMissingProducts($storeId, $maxImportLimit);
123
+ }
124
+ }
125
+ }
126
+
127
+ public function productNeedUpdate($product) {
128
+ foreach (Mage::app()->getStores() as $store) {
129
+ $storeId = $store->getId();
130
+ $product = $this->_getProduct($product, $storeId);
131
+ if ($product && $product->getId()) {
132
+ $fluxEntry = Mage::getModel('profileolabs_shoppingflux/export_flux')->getEntry($product->getSku(), $storeId);
133
+ if ($fluxEntry->getUpdateNeeded() != 1) {
134
+ $fluxEntry->setUpdateNeeded(1);
135
+ $fluxEntry->save();
136
+ }
137
+ // update also parents
138
+ $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
139
+ foreach ($parentIds as $parentId) {
140
+ $this->productNeedUpdate($parentId);
141
+ }
142
+ }
143
+ }
144
+ return;
145
+ }
146
+
147
+ protected function _shouldUpdate($product, $storeId) {
148
+ if(!$this->getConfig()->isExportEnabled($storeId)) {
149
+ return false;
150
+ }
151
+
152
+ if ($product->getStatus() == 2)
153
+ return false;
154
+
155
+ if ($product->getTypeId() == 'grouped' || $product->getTypeId() == 'bundle' || $product->getTypeId() == 'virtual') {
156
+ return false;
157
+ }
158
+
159
+ if(!$product->isSalable()) {
160
+ return false;
161
+ }
162
+
163
+ if ($product->getTypeId() == 'simple') {
164
+ $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
165
+ if (!empty($parentIds))
166
+ return false;
167
+ }
168
+
169
+
170
+
171
+ $store = Mage::app()->getStore($storeId);
172
+ if(!in_array($store->getWebsiteId(), $product->getWebsiteIds())) {
173
+ return false;
174
+ }
175
+
176
+ return true;
177
+ }
178
+
179
+ protected $_attributes = array();
180
+
181
+ protected function _getAttribute($attributeCode) {
182
+ if (!isset($this->_attributes[$attributeCode])) {
183
+ $this->_attributes[$attributeCode] = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
184
+ }
185
+ return $this->_attributes[$attributeCode];
186
+ }
187
+
188
+ protected function _getAttributeDataForProduct($nameNode, $attributeCode, $product) {
189
+ $_helper = Mage::helper('catalog/output');
190
+
191
+ $data = $product->getData($attributeCode);
192
+
193
+ $attribute = $this->_getAttribute($attributeCode);
194
+ if ($attribute) {
195
+ if ($attribute->getFrontendInput() == 'date') {
196
+ return $data;
197
+ }
198
+
199
+ //$data = $attribute->getFrontend()->getValue($product);
200
+ //$data = $_helper->productAttribute($product, $data, $attributeCode);
201
+ if ($attribute->usesSource()) {
202
+ $data = $attribute->getSource()->getOptionText($data);
203
+ if(is_array($data)) {
204
+ $data = implode(', ', $data);
205
+ }
206
+ //$data = $product->getAttributeText($attributeCode);
207
+ }
208
+
209
+
210
+ if ($nameNode == 'ecotaxe' && $attribute->getFrontendInput() == 'weee') {
211
+ $weeeAttributes = Mage::getSingleton('weee/tax')->getProductWeeeAttributes($product);
212
+
213
+ foreach ($weeeAttributes as $wa) {
214
+ if ($wa->getCode() == $attributeCode) {
215
+ $data = round($wa->getAmount(), 2);
216
+ break;
217
+ }
218
+ }
219
+ }
220
+ }
221
+
222
+ //TODO remove this
223
+ if ($data == "No" || $data == "Non")
224
+ $data = "";
225
+
226
+ //Exceptions data
227
+ if ($nameNode == 'shipping_delay' && empty($data))
228
+ $data = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
229
+
230
+ if ($nameNode == 'quantity')
231
+ $data = round($data);
232
+
233
+ return trim($data);
234
+ }
235
+
236
+ protected $_memoryLimit = null;
237
+ protected function _checkMemory() {
238
+ $request = Mage::app()->getRequest();
239
+ if($request->getControllerName() == 'export_flux' && $request->getActionName() == 'index') {
240
+ if(is_null($this->_memoryLimit)) {
241
+ $memoryLimit = ini_get('memory_limit');
242
+ if(preg_match('%M$%', $memoryLimit)) {
243
+ $memoryLimit = intval($memoryLimit)*1024*1024;
244
+ } else if(preg_match('%G$%', $memoryLimit)) {
245
+ $memoryLimit = intval($memoryLimit)*1024*1024*1024;
246
+ } else {
247
+ $memoryLimit = false;
248
+ }
249
+ $this->_memoryLimit = $memoryLimit;
250
+ }
251
+ if($this->_memoryLimit > 0) {
252
+ $currentMemoryUsage = memory_get_usage(true);
253
+ if($this->_memoryLimit-10*1024*1024 <= $currentMemoryUsage) {
254
+ header('Content-type: text/html; charset=UTF-8');
255
+ header('Refresh: 0;');
256
+ die('<html><head><meta http-equiv="refresh" content="0"/></head><body></body></html>');
257
+ }
258
+ }
259
+ }
260
+ }
261
+
262
+ public function updateProductInFluxForAllStores($productSku) {
263
+ foreach (Mage::app()->getStores() as $store) {
264
+ $this->updateProductInFlux($productSku, $store->getId());
265
+ }
266
+ }
267
+
268
+ public function updateProductInFlux($productSku, $storeId) {
269
+
270
+ $this->_checkMemory();
271
+
272
+ $product = $this->_getProductBySku($productSku, $storeId);
273
+
274
+ if (!$product || !$product->getSku()) {
275
+ $fluxEntry = Mage::getModel('profileolabs_shoppingflux/export_flux')->getEntry($productSku, $storeId);
276
+ $fluxEntry->setShouldExport(0);
277
+ $fluxEntry->setUpdateNeeded(0);
278
+ $fluxEntry->setUpdatedAt(date('Y-m-d H:i:s'));
279
+ $fluxEntry->save();
280
+ return;
281
+ }
282
+
283
+
284
+ if (!$this->_shouldUpdate($product, $storeId)) {
285
+ $fluxEntry = Mage::getModel('profileolabs_shoppingflux/export_flux')->getEntry($product->getSku(), $storeId);
286
+ $fluxEntry->setShouldExport(0);
287
+ $fluxEntry->setUpdateNeeded(0);
288
+ $fluxEntry->setUpdatedAt(date('Y-m-d H:i:s'));
289
+ $fluxEntry->save();
290
+ return;
291
+ }
292
+ //Varien_Profiler::start("SF::Flux::updateProductInFlux");
293
+
294
+ $xmlObj = Mage::getModel('profileolabs_shoppingflux/export_xml');
295
+ $xml = '';
296
+
297
+ if ($this->getConfig()->useManageStock()) {
298
+ $_configManageStock = (int) Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK, $storeId);
299
+ $_manageStock = ($product->getStockItem()->getUseConfigManageStock() ? $_configManageStock : $product->getStockItem()->getManageStock());
300
+ } else {
301
+ $_manageStock = true;
302
+ }
303
+ $data = array(
304
+ 'id' => $product->getId(),
305
+ 'sku' => $product->getSku(),
306
+ 'product-url' => $this->cleanUrl($product->getProductUrl(false)),
307
+ 'is-in-stock' => $_manageStock ? $product->getStockItem()->getIsInStock() : 1,
308
+ 'qty' => $_manageStock ? round($product->getStockItem()->getQty()) : 100,
309
+ 'tax-rate' => $product->getTaxPercent()
310
+ );
311
+
312
+ foreach ($this->getConfig()->getMappingAllAttributes($storeId) as $nameNode => $code) {
313
+ $data[$nameNode] = $this->_getAttributeDataForProduct($nameNode, $code, $product); //trim($xmlObj->extractData($nameNode, $code, $product));
314
+ }
315
+
316
+ //Varien_Profiler::start("SF::Flux::getPrices");
317
+ $data = $this->getPrices($data, $product, $storeId);
318
+ //Varien_Profiler::stop("SF::Flux::getPrices");
319
+ //Varien_Profiler::start("SF::Flux::getImages");
320
+ $data = $this->getImages($data, $product, $storeId);
321
+ //Varien_Profiler::stop("SF::Flux::getImages");
322
+ //Varien_Profiler::start("SF::Flux::getCategories");
323
+ $data = $this->getCategories($data, $product, $storeId);
324
+ //Varien_Profiler::stop("SF::Flux::getCategories");
325
+ //Varien_Profiler::start("SF::Flux::getShippingInfo");
326
+ $data = $this->getShippingInfo($data, $product, $storeId);
327
+ //Varien_Profiler::stop("SF::Flux::getShippingInfo");
328
+ if($this->getConfig()->getManageConfigurables()) {
329
+ //Varien_Profiler::start("SF::Flux::getConfigurableAttributes");
330
+ $data = $this->getConfigurableAttributes($data, $product, $storeId);
331
+ //Varien_Profiler::stop("SF::Flux::getConfigurableAttributes");
332
+ }
333
+ //Varien_Profiler::start("SF::Flux::getAdditionalAttributes");
334
+ foreach ($this->getConfig()->getAdditionalAttributes() as $attributeCode) {
335
+ if ($attributeCode) {
336
+ $data[$attributeCode] = $this->_getAttributeDataForProduct($attributeCode, $attributeCode, $product);
337
+ }
338
+ }
339
+
340
+ //Varien_Profiler::stop("SF::Flux::getAdditionalAttributes");
341
+ //Varien_Profiler::start("SF::Flux::addEntry1");
342
+ if (!isset($data['shipping_delay']) && empty($data['shipping_delay']))
343
+ $data['shipping_delay'] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
344
+
345
+
346
+ if($this->getConfig()->getEnableEvents()) {
347
+ $dataObj = new Varien_Object(array('entry' => $data, 'store_id' => $storeId, 'product' => $product));
348
+ Mage::dispatchEvent('shoppingflux_before_update_entry', array('data_obj' => $dataObj));
349
+
350
+ $entry = $dataObj->getEntry();
351
+ } else {
352
+ $entry = $data;
353
+ }
354
+
355
+
356
+ //Varien_Profiler::stop("SF::Flux::addEntry1");
357
+ //Varien_Profiler::start("SF::Flux::addEntry2");
358
+ $xml .= $xmlObj->_addEntry($entry);
359
+ //Varien_Profiler::stop("SF::Flux::addEntry2");
360
+ //Varien_Profiler::start("SF::Flux::saveProductFlux");
361
+ $fluxEntry = Mage::getModel('profileolabs_shoppingflux/export_flux')->getEntry($product->getSku(), $storeId);
362
+ $fluxEntry->setUpdatedAt(date('Y-m-d H:i:s'));
363
+ $fluxEntry->setXml($xml);
364
+ $fluxEntry->setUpdateNeeded(0);
365
+ $fluxEntry->setStockValue($product->getStockItem()->getQty());
366
+ $fluxEntry->setIsInStock($data['is-in-stock']);
367
+ $fluxEntry->setIsInFlux(intval($product->getData('shoppingflux_product')));
368
+ $fluxEntry->setType($product->getTypeId());
369
+ $fluxEntry->setVisibility($product->getVisibility());
370
+ $fluxEntry->setShouldExport(1);
371
+ $fluxEntry->save();
372
+ // Faster
373
+ /*
374
+ $tableName = Mage::getSingleton('core/resource')->getTableName('profileolabs_shoppingflux/export_flux');
375
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
376
+ $request = "INSERT INTO " . $tableName . " (sku, store_id, updated_at, xml, update_needed, is_in_stock, is_in_flux, type, visibility, should_export) VALUES ";
377
+ $request .= "(" . $write->quote($product->getSku()) . ", " . $write->quote($storeId) . ", " . $write->quote(date('Y-m-d H:i:s')) . ", " . $write->quote($xml) . ", '0', " . $write->quote($data['is-in-stock']) . ", " . $write->quote($product->getData('shoppingflux_product')) . ", '" . $product->getTypeId() . "', '" . $product->getVisibility() . "', '1')";
378
+ $request .= " on duplicate key update updated_at = VALUES(updated_at), xml = VALUES(xml), update_needed = VALUES(update_needed), is_in_stock = VALUES(is_in_stock), is_in_flux = VALUES(is_in_flux), type = VALUES(type), visibility = VALUES(visibility), should_export = VALUES(should_export) ";
379
+ $write->query($request);
380
+ */
381
+ //Varien_Profiler::stop("SF::Flux::saveProductFlux");
382
+ //Varien_Profiler::stop("SF::Flux::updateProductInFlux");
383
+ }
384
+
385
+ /**
386
+ * Get prices of product
387
+ * @param Mage_Catalog_Model_Product $product
388
+ * @return string $nodes
389
+ */
390
+ protected function getPrices($data, $product, $storeId) {
391
+
392
+ $priceAttributeCode = $this->getConfig()->getConfigData('shoppingflux_export/specific_prices/price', $storeId);
393
+ $specialPriceAttributeCode = $this->getConfig()->getConfigData('shoppingflux_export/specific_prices/special_price', $storeId);
394
+ if (!$product->getData($priceAttributeCode)) {
395
+ $priceAttributeCode = 'price';
396
+ $specialPriceAttributeCode = 'special_price';
397
+ }
398
+
399
+ $discountAmount = 0;
400
+ $finalPrice = $product->getData($priceAttributeCode);
401
+ $priceBeforeDiscount = $product->getData($priceAttributeCode);
402
+ if ($product->getData($specialPriceAttributeCode) > 0 && $product->getData($specialPriceAttributeCode) < $finalPrice) {
403
+ $finalPrice = $product->getData($specialPriceAttributeCode);
404
+ $discountAmount = $priceBeforeDiscount - $finalPrice;
405
+ }
406
+ $discountFromDate = $product->getSpecialFromDate();
407
+ $discountToDate = $product->getSpecialToDate();
408
+
409
+
410
+ $product->setCalculatedFinalPrice($finalPrice);
411
+ $product->setData('final_price', $finalPrice);
412
+ $currentVersion = Mage::getVersion();
413
+ if (version_compare($currentVersion, '1.5.0') < 0) {
414
+
415
+ } else {
416
+ if($this->getConfig()->getManageCatalogRules()) {
417
+ $catalogPriceRulePrice = Mage::getModel('catalogrule/rule')->calcProductPriceRule($product, $product->getPrice());
418
+ if ($catalogPriceRulePrice > 0 && $catalogPriceRulePrice < $finalPrice) {
419
+ $finalPrice = $catalogPriceRulePrice;
420
+ $discountAmount = $priceBeforeDiscount - $catalogPriceRulePrice;
421
+ $discountFromDate = '';
422
+ $discountToDate = '';
423
+ }
424
+ }
425
+ }
426
+
427
+ $data["price-ttc"] = Mage::helper('tax')->getPrice($product, $finalPrice, true); //$finalPrice;
428
+ $data["price-before-discount"] = Mage::helper('tax')->getPrice($product, $priceBeforeDiscount, true); //$priceBeforeDiscount;
429
+ $data["discount-amount"] = $product->getTypeId() != 'bundle' ? $discountAmount : 0;
430
+ $data["discount-percent"] = $this->getPercent($product);
431
+
432
+ $data["start-date-discount"] = "";
433
+ $data["end-date-discount"] = "";
434
+ if ($discountFromDate) {
435
+ $data["start-date-discount"] = $discountFromDate;
436
+ }
437
+ if ($discountToDate) {
438
+ $data["end-date-discount"] = $discountToDate;
439
+ }
440
+ return $data;
441
+ }
442
+
443
+ /**
444
+ * Get categories of product
445
+ * @param Mage_Catalog_Model_Product $product
446
+ * @return string $nodes
447
+ */
448
+ protected function getCategories($data, $product, $storeId) {
449
+ if ($product->getData('shoppingflux_default_category') && $product->getData('shoppingflux_default_category') > 0) {
450
+ return $this->getCategoriesViaShoppingfluxCategory($data, $product);
451
+ }
452
+ return $this->getCategoriesViaProductCategories($data, $product);
453
+ }
454
+
455
+ protected function getCategoriesViaShoppingfluxCategory($data, $product) {
456
+
457
+ //Varien_Profiler::start("SF::Flux::getCategoriesViaShoppingfluxCategory-1");
458
+ $categoryId = $product->getData('shoppingflux_default_category');
459
+ $category = Mage::helper('profileolabs_shoppingflux')->getCategoriesWithParents(false, $product->getStoreId());
460
+ //Varien_Profiler::stop("SF::Flux::getCategoriesViaShoppingfluxCategory-1");
461
+ if (!isset($category['name'][$categoryId])) {
462
+ return $this->getCategoriesViaProductCategories($data, $product);
463
+ }
464
+
465
+ //Varien_Profiler::start("SF::Flux::getCategoriesViaShoppingfluxCategory");
466
+
467
+ $categoryNames = explode(' > ', $category['name'][$categoryId]);
468
+ $categoryUrls = explode(' > ', $category['url'][$categoryId]);
469
+
470
+
471
+ //we drop root category, which is useless here
472
+ array_shift($categoryNames);
473
+ array_shift($categoryUrls);
474
+
475
+ $data['category-breadcrumb'] = trim(implode(' > ', $categoryNames));
476
+
477
+ $data["category-main"] = trim($categoryNames[0]);
478
+ $data["category-url-main"] = $categoryUrls[0];
479
+
480
+
481
+ for ($i = 1; $i <= 5; $i++) {
482
+ if (isset($categoryNames[$i]) && isset($categoryUrls[$i])) {
483
+ $data["category-sub-" . ($i)] = trim($categoryNames[$i]);
484
+ $data["category-url-sub-" . ($i)] = $categoryUrls[$i];
485
+ } else {
486
+ $data["category-sub-" . ($i)] = '';
487
+ $data["category-url-sub-" . ($i)] = '';
488
+ }
489
+ }
490
+
491
+ //Varien_Profiler::stop("SF::Flux::getCategoriesViaShoppingfluxCategory");
492
+ return $data;
493
+ }
494
+
495
+ protected function getCategoriesViaProductCategories($data, $product) {
496
+
497
+ //Varien_Profiler::start("SF::Flux::getCategoriesViaProductCategories");
498
+ $cnt = 0;
499
+
500
+ if (!$this->getConfig()->getUseOnlySFCategory()) {
501
+ $rootCategoryId = Mage::app()->getStore($product->getStoreId())->getRootCategoryId();
502
+
503
+ //$categoryWithParents = Mage::helper('profileolabs_shoppingflux')->getCategoriesWithParents(false, $product->getStoreId());
504
+
505
+ $maxLevelCategory = $this->getConfig()->getMaxCategoryLevel()>0?$this->getConfig()->getMaxCategoryLevel():5;
506
+ $productCategoryCollection = $product->getCategoryCollection()
507
+ ->addAttributeToSelect(array('name'))
508
+ ->addFieldToFilter('level', array('lteq' => $maxLevelCategory+1))
509
+ ->addUrlRewriteToResult()
510
+ ->groupByAttribute('level')
511
+ ->setOrder('level', 'ASC');
512
+ if (!Mage::getSingleton('profileolabs_shoppingflux/config')->getUseAllStoreCategories()) {
513
+ $productCategoryCollection->addFieldToFilter('path', array('like' => "1/{$rootCategoryId}/%"));
514
+ }
515
+
516
+
517
+ $lastCategory = null;
518
+ foreach ($productCategoryCollection as $category) {
519
+ $name = $category->getName();
520
+ $level = $category->getLevel();
521
+ $url = $this->cleanUrl($category->getUrl());
522
+ if ($cnt == 0) {
523
+
524
+ $data["category-main"] = trim($name);
525
+ $data["category-url-main"] = $url;
526
+ } else {
527
+
528
+ $data["category-sub-" . ($cnt)] = trim($name);
529
+ $data["category-url-sub-" . ($cnt)] = $url;
530
+ }
531
+
532
+ $lastCategory = $category;
533
+
534
+ $cnt++;
535
+ }
536
+
537
+ $data['category-breadcrumb'] = "";
538
+ if (!is_null($lastCategory) && is_object($lastCategory)) {
539
+
540
+ $breadCrumb = array();
541
+
542
+ $pathInStore = $category->getPathInStore();
543
+ $pathIds = array_reverse(explode(',', $pathInStore));
544
+
545
+ $categories = $category->getParentCategories();
546
+
547
+ // add category path breadcrumb
548
+ foreach ($pathIds as $categoryId) {
549
+ if ($categoryId != $rootCategoryId && isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
550
+ $breadCrumb[] = trim($categories[$categoryId]->getName());
551
+ }
552
+ }
553
+ unset($categories);
554
+ $data['category-breadcrumb'] = trim(implode(" > ", $breadCrumb));
555
+ }
556
+
557
+
558
+
559
+ unset($productCategoryCollection);
560
+
561
+ }
562
+
563
+ if (!isset($data["category-main"])) {
564
+ $data["category-main"] = "";
565
+ $data["category-url-main"] = "";
566
+ $cnt++;
567
+ }
568
+
569
+
570
+ for ($i = ($cnt); $i <= 5; $i++) {
571
+ $data["category-sub-" . ($i)] = "";
572
+ $data["category-url-sub-" . ($i)] = "";
573
+ }
574
+
575
+
576
+ //Varien_Profiler::stop("SF::Flux::getCategoriesViaProductCategories");
577
+ return $data;
578
+ }
579
+
580
+ public function cleanUrl($url) {
581
+ $url = str_replace("index.php/", "", $url);
582
+ $url = preg_replace('%(.*)\?.*$%i', '$1', $url);
583
+ return $url;
584
+ }
585
+
586
+ public function getImages($data, $product, $storeId) {
587
+
588
+
589
+
590
+ $mediaUrl = Mage::getBaseUrl('media') . 'catalog/product';
591
+
592
+ $i = 1;
593
+
594
+ if ($product->getImage() != "" && $product->getImage() != 'no_selection') {
595
+ $data["image-url-" . $i] = $mediaUrl . $product->getImage();
596
+ $data["image-label-" . $i] = $product->getImageLabel();
597
+ $i++;
598
+ }
599
+
600
+
601
+ if($this->getConfig()->getManageMediaGallery()) {
602
+ //LOAD media gallery for this product
603
+ $mediaGallery = $product->getResource()->getAttribute('media_gallery');
604
+ $mediaGallery->getBackend()->afterLoad($product);
605
+
606
+
607
+ foreach ($product->getMediaGallery('images') as $image) {
608
+ if ($mediaUrl . $product->getImage() == $product->getMediaConfig()->getMediaUrl($image['file']))
609
+ continue;
610
+
611
+ $data["image-url-" . $i] = $product->getMediaConfig()->getMediaUrl($image['file']);
612
+ $data["image-label-" . $i] = $image['label'];
613
+ $i++;
614
+ if (($i - 6) == 0)
615
+ break;
616
+ }
617
+ }
618
+
619
+
620
+ //Complet with empty nodes
621
+ for ($j = $i; $j < 6; $j++) {
622
+ $data["image-url-" . $i] = "";
623
+ $data["image-label-" . $i] = "";
624
+ $i++;
625
+ }
626
+ return $data;
627
+ }
628
+
629
+ protected function getPercent($product) {
630
+
631
+ /* if($product->getTypeId() == 'bundle')
632
+ return 0; */
633
+ $price = round($product->getPrice(), 2);
634
+ if ($price == "0") {
635
+ $price = round($product->getMinimalPrice(), 2);
636
+ }
637
+
638
+ if ($price == "0")
639
+ return 0;
640
+
641
+ $special = round($product->getFinalPrice(), 2);
642
+ $tmp = $price - $special;
643
+ $tmp = ($tmp * 100) / $price;
644
+ return round($tmp);
645
+ }
646
+
647
+ /**
648
+ *
649
+ */
650
+ protected function getAttributesFromConfig($checkIfExist = false, $withAdditional = true) {
651
+
652
+ if (is_null($this->_attributesFromConfig)) {
653
+ $attributes = $this->getConfig()->getMappingAllAttributes();
654
+ if ($withAdditional) {
655
+ $additionalAttributes = $this->getConfig()->getAdditionalAttributes();
656
+ foreach ($additionalAttributes as $attributeCode) {
657
+ $attributes[$attributeCode] = trim($attributeCode);
658
+ }
659
+ }
660
+
661
+ if ($checkIfExist) {
662
+ $product = Mage::getModel('catalog/product');
663
+ foreach ($attributes as $key => $code) {
664
+ $attribute = $this->_getAttribute($code);
665
+ if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute && $attribute->getId() && $attribute->getFrontendInput() != 'weee') {
666
+ $this->_attributesFromConfig[$key] = $code;
667
+ }
668
+ }
669
+ } else
670
+ $this->_attributesFromConfig = $attributes;
671
+ }
672
+
673
+ return $this->_attributesFromConfig;
674
+ }
675
+
676
+ protected function getRequiredAttributes() {
677
+
678
+ $requiredAttributes = array("sku" => "sku",
679
+ "price" => "price",
680
+ "image" => "image");
681
+
682
+ return $requiredAttributes;
683
+ }
684
+
685
+ protected function getAllAttributes() {
686
+ return array_merge($this->getAttributesFromConfig(true), $this->getRequiredAttributes());
687
+ }
688
+
689
+ /**
690
+ * Retrieve Catalog Product Flat Helper object
691
+ *
692
+ * @return Mage_Catalog_Helper_Product_Flat
693
+ */
694
+ public function getFlatHelper() {
695
+ return Mage::helper('catalog/product_flat');
696
+ }
697
+
698
+ protected function getShippingInfo($data, $product, $storeId) {
699
+
700
+ $data["shipping-name"] = "";
701
+ $data["shipping-price"] = "";
702
+
703
+ $carrier = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_method');
704
+ if (empty($carrier)) {
705
+ $data["shipping-price"] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_price');
706
+ return $data;
707
+ }
708
+
709
+ $carrierTab = explode('_', $carrier);
710
+ list($carrierCode, $methodCode) = $carrierTab;
711
+ $data["shipping-name"] = ucfirst($methodCode);
712
+
713
+
714
+ $shippingPrice = 0;
715
+ if ($this->getConfig()->getConfigData('shoppingflux_export/general/try_use_real_shipping_price')) {
716
+ $countryCode = $this->getConfig()->getConfigData('shoppingflux_export/general/shipping_price_based_on');
717
+ $shippingPrice = Mage::helper('profileolabs_shoppingflux')->getShippingPrice($product, $carrier, $countryCode);
718
+ }
719
+
720
+ if (!$shippingPrice) {
721
+ $shippingPrice = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_price');
722
+ }
723
+
724
+ $data["shipping-price"] = $shippingPrice;
725
+
726
+ return $data;
727
+ }
728
+
729
+ protected function getConfigurableAttributes($data, $product, $storeId) {
730
+
731
+ $xmlObj = Mage::getModel('profileolabs_shoppingflux/export_xml');
732
+ $data["configurable_attributes"] = "";
733
+ $data["childs_product"] = "";
734
+ $images = array();
735
+
736
+ $labels = array();
737
+ if ($product->getTypeId() == "configurable") {
738
+
739
+ $attributes = Mage::helper('profileolabs_shoppingflux')->getAttributesConfigurable($product);
740
+
741
+ $attributesToOptions = array();
742
+
743
+ foreach ($attributes as $attribute) {
744
+ $attributesToOptions[$attribute['attribute_code']] = array();
745
+ }
746
+
747
+ $usedProducts = $product->getTypeInstance(true)
748
+ ->getUsedProductCollection($product);
749
+
750
+
751
+ $configurableAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
752
+
753
+
754
+ $usedProductsArray = array();
755
+ $salable = false;
756
+ foreach (Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($usedProducts->getSelect()) as $usedProduct) { //Prevent Old magento bug
757
+ $usedProduct = $this->_getProduct($usedProduct['entity_id'], $storeId);
758
+
759
+ if(!$usedProduct) {
760
+ continue;
761
+ }
762
+
763
+ $salable = $salable || $usedProduct->isSalable();
764
+
765
+
766
+ if (Mage::helper('profileolabs_shoppingflux')->isModuleInstalled('OrganicInternet_SimpleConfigurableProducts') || Mage::helper('profileolabs_shoppingflux')->isModuleInstalled('DerModPro_BCP')) {
767
+
768
+ $tmpData = $this->getPrices(array(), $usedProduct, $storeId);
769
+ $price = $tmpData['price-ttc'] > 0 ? $tmpData['price-ttc'] : $data['price-ttc'];
770
+ if ($data['price-ttc'] <= 0 || ($price > 0 && $price < $data['price-ttc'])) {
771
+ $data['price-ttc'] = $price;
772
+ }
773
+ $priceBeforeDiscount = $tmpData["price-before-discount"];
774
+ $discountAmount = $tmpData["discount-amount"];
775
+ $startDateDiscount = $tmpData["start-date-discount"];
776
+ $endDateDiscount = $tmpData["end-date-discount"];
777
+ } else {
778
+
779
+ $price = $data['price-ttc'];
780
+ $priceBeforeDiscount = $data["price-before-discount"];
781
+ $discountAmount = $data["discount-amount"];
782
+ $startDateDiscount = $data["start-date-discount"];
783
+ $endDateDiscount = $data["end-date-discount"];
784
+
785
+ foreach ($configurableAttributes as $configurableAttribute) {
786
+ $attributeCode = $configurableAttribute['attribute_code'];
787
+ foreach ($configurableAttribute['values'] as $confAttributeValue) {
788
+ if ($confAttributeValue['pricing_value'] && $usedProduct->getData($attributeCode) == $confAttributeValue['value_index']) {
789
+ if ($confAttributeValue['is_percent']) {
790
+ $price += $data['price-ttc'] * $confAttributeValue['pricing_value'] / 100;
791
+ $priceBeforeDiscount += $data['price-before-discount'] * $confAttributeValue['pricing_value'] / 100;
792
+ } else {
793
+ $price += $confAttributeValue['pricing_value'];
794
+ $priceBeforeDiscount += $confAttributeValue['pricing_value'];
795
+ }
796
+ }
797
+ }
798
+ }
799
+ }
800
+
801
+ $attributesFromConfig = $this->getAttributesFromConfig(true, true);
802
+
803
+ $discountPercent = 0;
804
+ if($priceBeforeDiscount) {
805
+ $discountPercent = round((($priceBeforeDiscount - $price) * 100) / $priceBeforeDiscount);
806
+ }
807
+
808
+ $isInStock = 0;
809
+ $qty = 0;
810
+ if ($usedProduct->getStockItem()) {
811
+ if ($this->getConfig()->useManageStock()) {
812
+ $_configManageStock = (int) Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK, $storeId);
813
+ $_manageStock = $usedProduct->getStockItem()->getUseConfigManageStock() ? $_configManageStock : $usedProduct->getStockItem()->getManageStock();
814
+ } else {
815
+ $_manageStock = true;
816
+ }
817
+
818
+ $isInStock = $_manageStock ? $usedProduct->getStockItem()->getIsInStock() : 1;
819
+
820
+ $qty = $_manageStock ? $usedProduct->getStockItem()->getQty() : 100;
821
+ }
822
+
823
+ $usedProductsArray[$usedProduct->getId()]['child']["sku"] = $usedProduct->getSku();
824
+ $usedProductsArray[$usedProduct->getId()]['child']["id"] = $usedProduct->getId();
825
+ $usedProductsArray[$usedProduct->getId()]['child']["price-ttc"] = $price;
826
+ $usedProductsArray[$usedProduct->getId()]['child']["price-before-discount"] = $priceBeforeDiscount;
827
+ $usedProductsArray[$usedProduct->getId()]['child']["discount-amount"] = $discountAmount;
828
+ $usedProductsArray[$usedProduct->getId()]['child']["discount-percent"] = $discountPercent;
829
+ $usedProductsArray[$usedProduct->getId()]['child']["start-date-discount"] = $startDateDiscount;
830
+ $usedProductsArray[$usedProduct->getId()]['child']["end-date-discount"] = $endDateDiscount;
831
+ $usedProductsArray[$usedProduct->getId()]['child']['is-in-stock'] = $isInStock;
832
+ $usedProductsArray[$usedProduct->getId()]['child']['qty'] = round($qty);
833
+ $usedProductsArray[$usedProduct->getId()]['child']['tax-rate'] = $usedProduct->getTaxPercent();
834
+ if (!$data['tax-rate'] && $usedProductsArray[$usedProduct->getId()]['child']['tax-rate']) {
835
+ $data['tax-rate'] = $usedProductsArray[$usedProduct->getId()]['child']['tax-rate'];
836
+ }
837
+ if ($qty > 0 && $qty > $data['qty']) {
838
+ $data['qty'] = round($qty);
839
+ }
840
+ $usedProductsArray[$usedProduct->getId()]['child']["ean"] = isset($attributesFromConfig['ean']) ? $usedProduct->getData($attributesFromConfig['ean']) : '';
841
+
842
+ $images = $this->getImages($images, $usedProduct, $storeId);
843
+ if (!$images['image-url-1']) {
844
+ $images = $this->getImages($images, $product, $storeId);
845
+ }
846
+ foreach ($images as $key => $value) {
847
+ $usedProductsArray[$usedProduct->getId()]['child'][$key] = trim($value);
848
+ }
849
+
850
+ foreach ($attributesFromConfig as $nameNode => $attributeCode) {
851
+ $usedProductsArray[$usedProduct->getId()]['child'][$nameNode] = $this->_getAttributeDataForProduct($nameNode, $attributeCode, $usedProduct); //$xmlObj->extractData($nameNode, $attributeCode, $usedProduct);
852
+ }
853
+
854
+
855
+ $attributes = Mage::helper('profileolabs_shoppingflux')->getAttributesConfigurable($product);
856
+ foreach ($attributes as $attribute) {
857
+ $attributeCode = $attribute['attribute_code'];
858
+ $attributeId = $attribute['attribute_id'];
859
+
860
+ if (!isset($this->_attributesConfigurable[$attributeId]))
861
+ $this->_attributesConfigurable[$attributeId] = $product->getResource()->getAttribute($attributeId);
862
+
863
+ $attributeModel = $this->_attributesConfigurable[$attributeId];
864
+
865
+ $value = '';
866
+ if ($usedProduct->getData($attributeCode)) {
867
+ $value = $attributeModel->getFrontend()->getValue($usedProduct);
868
+ }
869
+
870
+ if (!isset($attributesToOptions[$attributeCode]) || !in_array($value, $attributesToOptions[$attributeCode]))
871
+ $attributesToOptions[$attributeCode][] = $value;
872
+
873
+ $usedProductsArray[$usedProduct->getId()]['child'][$attributeCode] = trim($value);
874
+ }
875
+
876
+
877
+ if (!isset($usedProductsArray[$usedProduct->getId()]['child']['shipping_delay']) || !$usedProductsArray[$usedProduct->getId()]['child']['shipping_delay'])
878
+ $usedProductsArray[$usedProduct->getId()]['child']['shipping_delay'] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
879
+ }
880
+
881
+
882
+
883
+
884
+ $data['is-in-stock'] = (int) $salable;
885
+
886
+ foreach ($attributesToOptions as $attributeCode => $value) {
887
+
888
+ $data["configurable_attributes"][$attributeCode] = implode(",", $value);
889
+ }
890
+ $data["childs_product"] = $usedProductsArray;
891
+
892
+ unset($usedProducts);
893
+ unset($usedProductsArray);
894
+ }
895
+ return $data;
896
+ }
897
+
898
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Observer.php ADDED
@@ -0,0 +1,414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author kassim belghait, vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Export_Observer {
10
+
11
+ public function getConfig() {
12
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
13
+ }
14
+
15
+
16
+ public static function checkStock() {
17
+ $productCollection = Mage::getModel('catalog/product')->getCollection();
18
+ $fluxCollection = Mage::getModel('profileolabs_shoppingflux/export_flux')->getCollection();
19
+ $productCollection->getSelect()->join(
20
+ array('sf_stock' => $productCollection->getTable('cataloginventory/stock_item')), 'e.entity_id = sf_stock.product_id', array('qty')
21
+ );
22
+ $productCollection->getSelect()->joinRight(
23
+ array('flux' => $fluxCollection->getMainTable()), 'e.sku = flux.sku and flux.should_export = 1', array('stock_value', 'sku')
24
+ );
25
+ $productCollection->getSelect()->where('CAST(sf_stock.qty AS SIGNED) != flux.stock_value');
26
+ $productCollection->getSelect()->group('e.entity_id');
27
+ foreach($productCollection as $product) {
28
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFluxForAllStores($product->getSku());
29
+ }
30
+ die($productCollection->count().'a');
31
+ }
32
+
33
+ public function updateFlux() {
34
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->getCollection();
35
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateFlux();
36
+ }
37
+
38
+
39
+ protected function generateFluxInFileForStore($storeId) {
40
+ $filePath = Mage::getBaseDir('media') . DS . 'shoppingflux_'.$storeId.'.xml';
41
+ $handle = fopen($filePath, 'a');
42
+ ftruncate($handle, 0);
43
+
44
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateFlux($storeId, 1000000);
45
+ $collection = Mage::getModel('profileolabs_shoppingflux/export_flux')->getCollection();
46
+ $collection->addFieldToFilter('should_export', 1);
47
+ $collection->addFieldToFilter('store_id', $storeId);
48
+ $sizeTotal = $collection->count();
49
+ $collection->clear();
50
+
51
+ if (!$this->getConfig()->isExportSoldout($storeId)) {
52
+ $collection->addFieldToFilter('is_in_stock', 1);
53
+ }
54
+ if ($this->getConfig()->isExportFilteredByAttribute($storeId)) {
55
+ $collection->addFieldToFilter('is_in_flux', 1);
56
+ }
57
+ $visibilities = $this->getConfig()->getVisibilitiesToExport($storeId);
58
+ $collection->getSelect()->where("find_in_set(visibility, '" . implode(',', $visibilities) . "')");
59
+
60
+
61
+
62
+ $xmlObj = Mage::getModel('profileolabs_shoppingflux/export_xml');
63
+ $startXml = $xmlObj->startXml(array('size-exportable' => $sizeTotal, 'size-xml' => $collection->count(), 'with-out-of-stock' => intval($this->getConfig()->isExportSoldout()), 'selected-only' => intval($this->getConfig()->isExportFilteredByAttribute()), 'visibilities' => implode(',', $visibilities)));
64
+ fwrite($handle, $startXml);
65
+ Mage::getSingleton('core/resource_iterator')
66
+ ->walk($collection->getSelect(), array(array($this, 'saveProductXml')), array('handle'=>$handle));
67
+ $endXml = $xmlObj->endXml();
68
+ fwrite($handle, $endXml);
69
+ fclose($handle);
70
+ }
71
+
72
+ public function saveProductXml($args) {
73
+ fwrite($args['handle'], $args['row']['xml']);
74
+ }
75
+
76
+ public function generateFluxInFile() {
77
+ //foreach(Mage::app()->getStores() as $store) {
78
+ // $this->generateFluxInFileForStore($store->getId());
79
+ //}
80
+ $this->generateFluxInFileForStore(Mage::app()->getDefaultStoreView()->getId());
81
+ }
82
+
83
+ /**
84
+ * @deprecated deprecated since 0.1.1
85
+ * @param Varien_Object $observer
86
+ */
87
+ public function generateFlow($observer) {
88
+ try {
89
+
90
+ $url = str_replace("index.php/", "", Mage::getBaseUrl() . 'Script_Profileolabs/generate_flow.php');
91
+ $curl = curl_init($url);
92
+ curl_setopt($curl, CURLOPT_POST, false);
93
+ curl_setopt($curl, CURLOPT_HEADER, false);
94
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
95
+ curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1800);
96
+ $curl_response = curl_exec($curl);
97
+ curl_close($curl);
98
+ } catch (Exception $e) {
99
+ Mage::throwException($e);
100
+ }
101
+
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Add shoppingflux product tab in category edit page
107
+ * @param $observer
108
+ */
109
+ public function addShoppingfluxProductsTab($observer) {
110
+ $tabs = $observer->getTabs();
111
+ $tabs->addTab('shoppingflux_products', array(
112
+ 'label' => Mage::helper('catalog')->__('Shoppingflux Category Products'),
113
+ 'content' => $tabs->getLayout()->createBlock(
114
+ 'profileolabs_shoppingflux/export_adminhtml_catalog_category_tab_default', 'shoppingflux.product.grid'
115
+ )->toHtml(),
116
+ ));
117
+ }
118
+
119
+ public function catalogProductAttributeUpdateBefore($observer) {
120
+ $productIds = $observer->getEvent()->getProductIds();
121
+ foreach ($productIds as $productId) {
122
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($productId);
123
+ }
124
+ }
125
+
126
+ public function catalogProductSaveCommitAfter($observer) {
127
+ $product = $observer->getEvent()->getProduct();
128
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($product->getId());
129
+ }
130
+
131
+ /**
132
+ * update default category for selected products
133
+ */
134
+ public function saveShoppingfluxCategoryProducts($observer) {
135
+ $category = $observer->getEvent()->getCategory();
136
+ $request = $observer->getEvent()->getRequest();
137
+ $postedProducts = $request->getParam('shoppingflux_category_products');
138
+ $products = array();
139
+ $storeId = intval($request->getParam('store', 0));
140
+ parse_str($postedProducts, $products);
141
+ if (isset($products['on']))
142
+ unset($products['on']);
143
+ $products = array_keys($products);
144
+ if (!empty($products)) {
145
+ $currentVersion = Mage::getVersion();
146
+ /* if (version_compare($currentVersion, '1.4.0') < 0) { */
147
+ $product = Mage::getModel('catalog/product');
148
+ foreach ($products as $productId) {
149
+
150
+ $product->setData(array());
151
+ $product->setStoreId($storeId)
152
+ ->load($productId)
153
+ ->setIsMassupdate(true)
154
+ ->setExcludeUrlRewrite(true);
155
+
156
+ if (!$product->getId()) {
157
+ continue;
158
+ }
159
+
160
+ $product->addData(array('shoppingflux_default_category' => $category->getId()));
161
+ $dataChanged = $product->dataHasChangedFor('shoppingflux_default_category');
162
+
163
+ if ($dataChanged) {
164
+ $product->save();
165
+ }
166
+ }
167
+ // This method may be faster alone, but put all updated products to "Need Update" even if no changes
168
+ /* } else {
169
+ Mage::getSingleton('catalog/product_action')
170
+ ->updateAttributes($products, array('shoppingflux_default_category' => $category->getId()), $storeId);
171
+
172
+ //var_dump($products);die();
173
+ } */
174
+ }
175
+ }
176
+
177
+ public function manageUpdates() {
178
+ $apiKeyManaged = array();
179
+ foreach (Mage::app()->getStores() as $store) {
180
+ $apiKey = $this->getConfig()->getApiKey($store->getId());
181
+ if (!$apiKey || in_array($apiKey, $apiKeyManaged))
182
+ continue;
183
+ $apiKeyManaged[] = $apiKey;
184
+
185
+
186
+ $updates = Mage::getModel('profileolabs_shoppingflux/export_updates')->getCollection();
187
+ $updates->addFieldToFilter('store_id', $store->getId());
188
+
189
+ $wsUri = $this->getConfig()->getWsUri();
190
+ $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
191
+ try {
192
+ $service->updateProducts($updates);
193
+ $updates->walk('delete');
194
+ } catch (Exception $e) {
195
+
196
+ }
197
+ }
198
+ }
199
+
200
+ protected function _scheduleProductUpdate(array $data) {
201
+ /* * REALTIME* */
202
+ $object = new Varien_Object();
203
+ $object->setData($data);
204
+ $collection = new Varien_Data_Collection();
205
+ $collection->addItem($object);
206
+ $apiKey = $this->getConfig()->getApiKey($data['store_id']);
207
+ $wsUri = $this->getConfig()->getWsUri();
208
+ $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
209
+ $service->updateProducts($collection);
210
+ /* * SCHEDULED* */
211
+ /*
212
+ $data['updated_at'] = date('Y-m-d H:i:s');
213
+ $updates = Mage::getModel('profileolabs_shoppingflux/export_updates');
214
+ $updates->loadWithData($data);
215
+ foreach ($data as $k => $v)
216
+ $updates->setData($k, $v);
217
+ $updates->save();
218
+ * *
219
+ */
220
+ }
221
+
222
+ /**
223
+ * @param mixed $product product id, or Mage_Catalog_Model_Product
224
+ */
225
+ protected function _scheduleProductUpdates($product, array $forceData = array()) {
226
+ if ($product) {
227
+ if (is_numeric($product))
228
+ $product = Mage::getModel('catalog/product')->load($product);
229
+ $productStoresIds = $product->getStoreIds();
230
+ $apiKeyManaged = array();
231
+ foreach ($productStoresIds as $storeId) {
232
+ $apiKey = $this->getConfig()->getApiKey($storeId);
233
+ if (!$apiKey || in_array($apiKey, $apiKeyManaged))
234
+ continue;
235
+ $apiKeyManaged[] = $apiKey;
236
+ $storeProduct = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product->getId());
237
+
238
+ $stock = $storeProduct->getStockItem()->getQty();
239
+ if ($this->getConfig()->isExportFilteredByAttribute($storeId) && $storeProduct->getData('shoppingflux_product') != 1) {
240
+ $stock = 0;
241
+ }
242
+ if ($storeProduct->getStatus() != 1) {
243
+ $stock = 0;
244
+ }
245
+ $data = array(
246
+ 'store_id' => $storeId,
247
+ 'product_sku' => $storeProduct->getSku(),
248
+ 'stock_value' => $stock,
249
+ 'price_value' => $storeProduct->getFinalPrice(),
250
+ 'old_price_value' => $storeProduct->getPrice()
251
+ );
252
+ foreach ($forceData as $key => $val) {
253
+ $data[$key] = $val;
254
+ }
255
+ $this->_scheduleProductUpdate($data);
256
+ }
257
+ }
258
+ }
259
+
260
+ /**
261
+ * cataloginventory_stock_item_save_after (adminhtml,frontend)
262
+ * @param type $observer
263
+ */
264
+ public function realtimeUpdateStock($observer) {
265
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getItem()->getProductId());
266
+ if (!$this->getConfig()->isSyncEnabled())
267
+ return;
268
+
269
+ $oldStock = (int) $observer->getItem()->getOrigData('qty');
270
+ $newStock = (int) $observer->getItem()->getData('qty');
271
+ if ($oldStock != $newStock) {
272
+
273
+ //Mage::log('realtimeUpdateStock');
274
+ $productId = $observer->getItem()->getProductId();
275
+ $this->_scheduleProductUpdates($productId);
276
+ }
277
+ }
278
+
279
+ /**
280
+ * catalog_product_save_after (adminhtml)
281
+ * @param type $observer
282
+ */
283
+ public function realtimeUpdatePrice($observer) {
284
+ if ($observer->getProduct()->getSku() != $observer->getProduct()->getOrigData('sku')) {
285
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFluxForAllStores($observer->getProduct()->getOrigData('sku'));
286
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFluxForAllStores($observer->getProduct()->getSku());
287
+ }
288
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getProduct());
289
+
290
+
291
+ if (!$this->getConfig()->isSyncEnabled())
292
+ return;
293
+
294
+ $product = $observer->getProduct();
295
+ $storeId = $product->getStoreId();
296
+ $attributesToCheck = array('price', 'tax_class_id', 'special_price', 'special_to_date', 'special_from_date');
297
+ /*
298
+ $ecotaxeAttributeCode = Mage::getStoreConfigFlag('shoppingflux_export/attributes_unknow/ecotaxe', $storeId);
299
+ if ($ecotaxeAttributeCode) {
300
+ $attributesToCheck[] = $ecotaxeAttributeCode;
301
+ }
302
+ */
303
+ $somePriceChanged = false;
304
+ foreach ($attributesToCheck as $attributeCode) {
305
+ if ($product->getData($attributeCode) != $product->getOrigData($attributeCode)) {
306
+ $somePriceChanged = true;
307
+ }
308
+ }
309
+
310
+ if ($somePriceChanged) {
311
+ //Mage::log('realtimeUpdatePrice');
312
+ if ($storeId == 0) { // update for all stores
313
+ $this->_scheduleProductUpdates($product);
314
+ } else { // change happened in one store, update only this one
315
+ $stock = $product->getStockItem()->getQty();
316
+ $this->_scheduleProductUpdate(array(
317
+ 'store_id' => $storeId,
318
+ 'product_sku' => $product->getSku(),
319
+ 'stock_value' => $stock,
320
+ 'price_value' => $product->getFinalPrice(),
321
+ 'old_price_value' => $product->getPrice()
322
+ ));
323
+ }
324
+ }
325
+ }
326
+
327
+ /**
328
+ * catalog_product_save_after (adminhtml)
329
+ * @param type $observer
330
+ */
331
+ public function realtimeUpdateDeletedProduct($observer) {
332
+ if (!$this->getConfig()->isSyncEnabled())
333
+ return;
334
+
335
+ $product = $observer->getProduct();
336
+ $apiKeyManaged = array();
337
+ foreach (Mage::app()->getStores() as $store) {
338
+ $apiKey = $this->getConfig()->getApiKey($store->getId());
339
+ if (!$apiKey || in_array($apiKey, $apiKeyManaged))
340
+ continue;
341
+ $apiKeyManaged[] = $apiKey;
342
+ //Mage::log('realtimeUpdateDeletedProduct');
343
+
344
+ $this->_scheduleProductUpdate(array(
345
+ 'store_id' => $store->getId(),
346
+ 'product_sku' => $product->getSku(),
347
+ 'stock_value' => 0,
348
+ 'price_value' => $product->getPrice(),
349
+ 'old_price_value' => $product->getPrice()
350
+ ));
351
+ }
352
+ }
353
+
354
+ /**
355
+ * catalog_product_status_update (adminhtml)
356
+ * @param type $observer
357
+ */
358
+ public function realtimeUpdateDisabledProduct($observer) {
359
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getProductId());
360
+ if (!$this->getConfig()->isSyncEnabled())
361
+ return;
362
+
363
+ //Mage::log('realtimeUpdateDisabledProduct');
364
+ $this->_scheduleProductUpdates($observer->getProductId());
365
+ }
366
+
367
+ /**
368
+ * catalog_product_save_after (adminhtml)
369
+ * @param type $observer
370
+ */
371
+ public function realtimeUpdateDisabledProductSave($observer) {
372
+ if (!$this->getConfig()->isSyncEnabled())
373
+ return;
374
+
375
+ $product = $observer->getProduct();
376
+ if ($product->getStatus() != $product->getOrigData('status')) {
377
+ //Mage::log('realtimeUpdateDisabledProductSave');
378
+ $this->_scheduleProductUpdates($product);
379
+ }
380
+ }
381
+
382
+ /**
383
+ * catalog_product_save_after (adminhtml)
384
+ * @param type $observer
385
+ */
386
+ public function realtimeUpdateInSf($observer) {
387
+ if (!$this->getConfig()->isSyncEnabled())
388
+ return;
389
+
390
+ $product = $observer->getProduct();
391
+ if ($product->getData('shoppingflux_product') != 1 && $product->getOrigData('shoppingflux_product') == 1) {
392
+ //Mage::log('realtimeUpdateInSf');
393
+ $this->_scheduleProductUpdates($product, array('stock_value' => 0));
394
+ }
395
+ }
396
+
397
+ /**
398
+ * shoppingflux_mass_publish_save_item (adminhtml)
399
+ * @param type $observer
400
+ */
401
+ public function realtimeUpdateInSfMass($observer) {
402
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getProductId());
403
+ if (!$this->getConfig()->isSyncEnabled())
404
+ return;
405
+
406
+ $productId = $observer->getProductId();
407
+ $publish = $observer->getShoppingfluxProduct();
408
+ if ($publish != 1) {
409
+ //Mage::log('realtimeUpdateInSfMass');
410
+ $this->_scheduleProductUpdates($productId, array('stock_value' => 0));
411
+ }
412
+ }
413
+
414
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Rewrite/Catalog/Config.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Catalog
24
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+ if (file_exists(BP . '/app/code/local/Amasty/Improved/Model/Rewrite/Config.php')) {
28
+
29
+ class Profileolabs_Shoppingflux_Model_Export_Rewrite_Catalog_Config_Compatibility extends Amasty_ImprovedSorting_Model_Rewrite_Config {
30
+
31
+ }
32
+
33
+ } else {
34
+
35
+ class Profileolabs_Shoppingflux_Model_Export_Rewrite_Catalog_Config_Compatibility extends Mage_Catalog_Model_Config {
36
+
37
+ }
38
+
39
+ }
40
+
41
+ class Profileolabs_Shoppingflux_Model_Export_Rewrite_Catalog_Config extends Profileolabs_Shoppingflux_Model_Export_Rewrite_Catalog_Config_Compatibility {
42
+
43
+ /**
44
+ * Get attribute by code for entity type
45
+ *
46
+ * @param mixed $entityType
47
+ * @param mixed $code
48
+ * @return Mage_Eav_Model_Entity_Attribute_Abstract
49
+ */
50
+ public function getAttribute($entityType, $code) {
51
+ $attribute = parent::getAttribute($entityType, $code);
52
+ if (is_object($attribute) && $attribute->getAttributeCode() == "") {
53
+ $attribute->setAttributeCode($code);
54
+ }
55
+ return $attribute;
56
+ }
57
+
58
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Rewrite/CatalogInventory/Stock/Item.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author vincent enjalbert @ web-cooking.net
8
+ */
9
+
10
+
11
+ if(file_exists(BP.'/app/code/community/MDN/AdvancedStock/Model/CatalogInventory/Stock/Item.php') || file_exists(BP.'/app/code/local/MDN/AdvancedStock/Model/CatalogInventory/Stock/Item.php')) {
12
+ class Profileolabs_Shoppingflux_Model_Export_Rewrite_CatalogInventory_Stock_Item_Compatibility extends MDN_AdvancedStock_Model_CatalogInventory_Stock_Item {}
13
+ } else {
14
+ class Profileolabs_Shoppingflux_Model_Export_Rewrite_CatalogInventory_Stock_Item_Compatibility extends Mage_CatalogInventory_Model_Stock_Item {}
15
+ }
16
+
17
+ class Profileolabs_Shoppingflux_Model_Export_Rewrite_CatalogInventory_Stock_Item
18
+ extends Profileolabs_Shoppingflux_Model_Export_Rewrite_CatalogInventory_Stock_Item_Compatibility {
19
+
20
+ /**
21
+ * cataloginventory_stock_item_save_before simply ceases to exist on Magento 1.4.0.0 and up
22
+ */
23
+ protected function _beforeSave() {
24
+ if(version_compare(Mage::getVersion(),'1.4.0.0') >= 0) {
25
+ parent::_beforeSave();
26
+ Mage::dispatchEvent('cataloginventory_stock_item_save_before', array('item' => $this));
27
+ return $this;
28
+ } else {
29
+ return parent::_beforeSave();
30
+ }
31
+ }
32
+
33
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Attributes.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping Flux
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author kassim belghait - Vincent Enjalbert
7
+ */
8
+ class Profileolabs_Shoppingflux_Model_Export_Source_Attributes
9
+ {
10
+
11
+ protected $_exceptions = array(
12
+ 'store',
13
+ 'websites',
14
+ 'attribute_set',
15
+ 'type',
16
+ 'news_from_date',
17
+ 'news_to_date',
18
+ 'gallery',
19
+ 'url_key',
20
+ 'url_path',
21
+ 'minimal_price',
22
+ 'custom_design',
23
+ 'custom_design_from',
24
+ 'custom_design_to',
25
+ 'category_ids',
26
+ 'options_container',
27
+ 'required_options',
28
+ 'has_options',
29
+ 'tax_class_id',
30
+ 'custom_layout_update',
31
+ 'page_layout',
32
+ 'recurring_profile',
33
+ 'is_recurring',
34
+ );
35
+
36
+ public function toOptionArray()
37
+ {
38
+ $attributes = array();
39
+ $attributesArray= Mage::getSingleton('profileolabs_shoppingflux/export_convert_parser_product')->getExternalAttributes();
40
+ foreach($attributesArray as $k=>$v) {
41
+ if(!in_array($k, $this->_exceptions)) {
42
+ $attributes[] = array('value'=>$k, 'label'=>$v);
43
+ }
44
+ }
45
+ array_unshift($attributes, array("value"=>"none","label"=>""));
46
+ return $attributes;
47
+ }
48
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Attributesprice.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping Flux
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author kassim belghait
7
+ */
8
+ class Profileolabs_Shoppingflux_Model_Export_Source_Attributesprice
9
+ {
10
+
11
+
12
+ public function toOptionArray()
13
+ {
14
+ $model = Mage::getResourceModel('catalog/product');
15
+ $typeId = $model->getTypeId();
16
+
17
+ $attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection')
18
+ ->setEntityTypeFilter($typeId)
19
+ ->load();
20
+ $attributes = array();
21
+ $attributes[] = array('value' => '', 'label' => '');
22
+ foreach ($attributesCollection as $attribute) {
23
+ if($attribute->getFrontendInput() == 'price') {
24
+ $code = $attribute->getAttributeCode();
25
+ $attributes[] = array('value' => $code, 'label' => $code);
26
+ }
27
+ }
28
+
29
+ return $attributes;
30
+ }
31
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Category/Level.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Profileolabs_Shoppingflux_Model_Export_Source_Category_Level
4
+ {
5
+
6
+
7
+ public function toOptionArray()
8
+ {
9
+ return array(
10
+ array('label'=>5, 'value'=>5),
11
+ array('label'=>4, 'value'=>4),
12
+ array('label'=>3, 'value'=>3),
13
+ array('label'=>2, 'value'=>2),
14
+ array('label'=>1, 'value'=>1),
15
+ );
16
+
17
+ }
18
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Visibility.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping Flux
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author kassim belghait
7
+ */
8
+ class Profileolabs_Shoppingflux_Model_Export_Source_Visibility
9
+ {
10
+
11
+
12
+ public function toOptionArray()
13
+ {
14
+ $options = Mage_Catalog_Model_Product_Visibility::getOptionArray();
15
+ $result = array();
16
+ foreach ($options as $optionValue=>$optionLabel) {
17
+ $result[] = array('label'=>$optionLabel, 'value'=>$optionValue);
18
+ }
19
+ return $result;
20
+ }
21
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Updates.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Export_Updates extends Mage_Core_Model_Abstract {
10
+
11
+ protected function _construct() {
12
+ $this->_init('profileolabs_shoppingflux/export_updates');
13
+ }
14
+
15
+ public function loadWithData($data) {
16
+ if (!isset($data['product_sku']) || !isset($data['store_id']))
17
+ return;
18
+ $productSku = $data['product_sku'];
19
+ $storeId = $data['store_id'];
20
+
21
+ $collection = $this->getCollection();
22
+ $select = $collection->getSelect();
23
+ $select->where('product_sku = ?', $productSku);
24
+ $select->where('store_id = ?', $storeId);
25
+ $collection->load();
26
+ if ($collection->getSize() <= 0)
27
+ return;
28
+ $this->load($collection->getFirstItem()->getId());
29
+ return;
30
+ }
31
+
32
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Xml.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Profileolabs_Shoppingflux_Model_Export_Xml {
4
+
5
+
6
+ public function __construct() {
7
+
8
+ }
9
+
10
+ public function _addEntries($entries) {
11
+ foreach($entries as $entry) {
12
+ $this->_addEntry($entry);
13
+ }
14
+ }
15
+
16
+ public function _addEntry($entry) {
17
+ return "<product>" . chr(10) .
18
+ $this->arrayToNode($entry) .
19
+ "</product>" . chr(10);
20
+ }
21
+
22
+
23
+ public function getVersion() {
24
+ return Mage::getConfig()->getModuleConfig("Profileolabs_Shoppingflux")->version;
25
+ }
26
+
27
+ public function startXml($params=array()) {
28
+ $xml = '<?xml version="1.0" encoding="utf-8"?>' . chr(10) .
29
+ '<products version="' . $this->getVersion() . '"';
30
+ foreach($params as $attrName=>$attrValue) {
31
+ $xml .= ' ' . $attrName . '="' . $attrValue . '"';
32
+ }
33
+ $xml .= '>' . chr(10);
34
+ return $xml;
35
+ }
36
+
37
+ public function endXml() {
38
+ return "</products>" . chr(10);
39
+ }
40
+
41
+ protected $_attributes = array();
42
+ protected function _getAttribute($attributeCode) {
43
+ if(!isset($this->_attributes[$attributeCode])) {
44
+ $this->_attributes[$attributeCode] = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
45
+ }
46
+ return $this->_attributes[$attributeCode];
47
+ }
48
+
49
+ /*obsolete*/
50
+ public function extractData($nameNode, $attributeCode, $product) {
51
+
52
+ $_helper = Mage::helper('catalog/output');
53
+
54
+ $data = $product->getData($attributeCode);
55
+
56
+ $attribute = $this->_getAttribute($attributeCode);
57
+ if ($attribute) {
58
+ if($attribute->getFrontendInput() == 'date') {
59
+ return $data;
60
+ }
61
+
62
+ $data = $attribute->getFrontend()->getValue($product);
63
+ $data = $_helper->productAttribute($product, $data, $attributeCode);
64
+
65
+ if ($nameNode == 'ecotaxe' && $attribute->getFrontendInput() == 'weee') {
66
+ $weeeAttributes = Mage::getSingleton('weee/tax')->getProductWeeeAttributes($product);
67
+
68
+ foreach ($weeeAttributes as $wa) {
69
+ if ($wa->getCode() == $attributeCode) {
70
+ $data = round($wa->getAmount(), 2);
71
+ break;
72
+ }
73
+ }
74
+ }
75
+ }
76
+
77
+
78
+
79
+
80
+ //$_helper = Mage::helper('catalog/output');
81
+ //if($nameNode == 'description' || $nameNode == 'short_description')
82
+ //$data = $_helper->productAttribute($product, $data, $attributeCode);
83
+ //Synthetize it
84
+ /* $method = "get".ucfirst($attributeCode);
85
+ if(method_exists($product,$method))
86
+ $data = $product->$method(); */
87
+
88
+ //TODO remove this
89
+ if ($data == "No" || $data == "Non")
90
+ $data = "";
91
+
92
+ //Exceptions data
93
+ if ($nameNode == 'shipping_delay' && empty($data))
94
+ $data = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
95
+
96
+ if ($nameNode == 'quantity')
97
+ $data = round($data);
98
+
99
+ return $data;
100
+ }
101
+
102
+ /**
103
+ * Get singleton config for Export
104
+ * @return Profileolabs_Shoppingflux_Model_Export_Config
105
+ */
106
+ public function getConfig() {
107
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
108
+ }
109
+
110
+ protected function arrayToNode($entry) {
111
+ $node = "";
112
+
113
+ foreach ($entry as $key => $value) {
114
+
115
+ if (is_array($value)) {
116
+ if (is_string($key))
117
+ $node.= $this->getNode($key, $this->arrayToNode($value), 0);
118
+ elseif (is_string(($subKey = current($value))))
119
+ $node.= $this->getNode($subKey, $this->arrayToNode($value), 0);
120
+ else
121
+ $node.= $this->arrayToNode($value);
122
+ }
123
+ else
124
+ $node .= $this->getNode($key, $value);
125
+ }
126
+
127
+
128
+ return $node;
129
+ }
130
+
131
+ protected function getNode($name, $value, $withCDATA = 1) {
132
+ $value = $this->getHelper()->cleanNotUtf8($value);
133
+ $openCDATA = "";
134
+ $closeCDATA = "";
135
+ if ($withCDATA) {
136
+ $openCDATA = "<![CDATA[";
137
+ $closeCDATA = "]]>";
138
+ }
139
+ return "<{$name}>{$openCDATA}{$value}{$closeCDATA}</{$name}>" . chr(10);
140
+ }
141
+
142
+ /**
143
+ * Return Shoppingflu Helper
144
+ * @return Profileolabs_Shoppingflux_Helper_Data
145
+ */
146
+ protected function getHelper() {
147
+ return Mage::helper('profileolabs_shoppingflux');
148
+ }
149
+
150
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Xmlflow.deprecated.php ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Profileolabs_Shoppingflux_Model_Export_Xmlflow
3
+ {
4
+ protected $_xmlArray = array();
5
+
6
+ protected $_backendCacheAttributes = array();
7
+
8
+ protected $_memoryManager = null;
9
+
10
+ public function __construct()
11
+ {
12
+ $backendAttributes = array(
13
+ 'cache_dir' => Mage::getBaseDir('cache'),
14
+ 'hashed_directory_level' => 1,
15
+ 'hashed_directory_umask' => 0777,
16
+ 'file_name_prefix' => 'mage',
17
+ );
18
+ }
19
+
20
+ public function getMemoryManager()
21
+ {
22
+ if(is_null($this->_memoryManager))
23
+ {
24
+ $this->_memoryManager = Zend_Memory::factory('File',$this->_backendCacheAttributes);
25
+ }
26
+
27
+ return $this->_memoryManager;
28
+ }
29
+
30
+ public function _addEntries($entries)
31
+ {
32
+ $this->_xmlArray = $entries;
33
+ return $this;
34
+ }
35
+
36
+ public function _addEntry($entry)
37
+ {
38
+ $this->_xmlArray[] = $entry;
39
+ return $this;
40
+ }
41
+
42
+ public function getXmlArray()
43
+ {
44
+ return $this->_xmlArray;
45
+ }
46
+
47
+
48
+ public function getVersion()
49
+ {
50
+ return Mage::getConfig()->getModuleConfig("Profileolabs_Shoppingflux")->version;
51
+ }
52
+
53
+ public function createXml()
54
+ {
55
+ try {
56
+ if($this->useZendMemory())
57
+ {
58
+ $xmlFlow = "";
59
+ $mem = $this->getMemoryManager()->create($xmlFlow);
60
+
61
+ $mem->value = '<?xml version="1.0" encoding="utf-8"?>'.chr(10);
62
+ $mem->value .= '<products count="'.count($this->_xmlArray).'" version="'.$this->getVersion().'">'.chr(10);
63
+
64
+
65
+ foreach ($this->_xmlArray as $key=>$entry)
66
+ {
67
+
68
+ $mem->value .= "<product>".chr(10);
69
+
70
+ $mem->value .= $this->arrayToNode($entry);
71
+
72
+ $mem->value .= "</product>".chr(10);
73
+ //unset($this->_xmlArray[$key]);
74
+ }
75
+
76
+ $mem->value .= "</products>".chr(10);
77
+
78
+ return $mem->value;
79
+ }
80
+ else
81
+ {
82
+
83
+ $xmlFlow = '<?xml version="1.0" encoding="utf-8"?>'.chr(10);
84
+ $xmlFlow .= '<products count="'.count($this->_xmlArray).'" version="'.$this->getVersion().'">'.chr(10);
85
+
86
+ $i= 0;
87
+ foreach ($this->_xmlArray as $key=>$entry)
88
+ {
89
+ //Mage::log("i = ".$i++,null,"test_sf.log");
90
+ $xmlFlow .= "<product>".chr(10);
91
+
92
+ $xmlFlow .= $this->arrayToNode($entry);
93
+
94
+ $xmlFlow .= "</product>".chr(10);
95
+ //unset($this->_xmlArray[$key]);
96
+ }
97
+
98
+ $xmlFlow .= "</products>".chr(10);
99
+
100
+ return $xmlFlow;
101
+ }
102
+
103
+ } catch (Exception $e) {
104
+ return $this->getHelper()->__('Error in processing xml. %s',$e->getMessage());
105
+ }
106
+ }
107
+
108
+
109
+
110
+
111
+
112
+ public function extractData($nameNode,$attributeCode,$product)
113
+ {
114
+
115
+ $_helper = Mage::helper('catalog/output');
116
+
117
+ $data = $product->getData($attributeCode);
118
+
119
+ $attribute = $product->getResource()->getAttribute($attributeCode);
120
+ if($attribute)
121
+ {
122
+ $data = $attribute->getFrontend()->getValue($product);
123
+ $data = $_helper->productAttribute($product, $data, $attributeCode);
124
+
125
+ if($nameNode == 'ecotaxe' && $attribute->getFrontendInput() == 'weee')
126
+ {
127
+ $weeeAttributes = Mage::getSingleton('weee/tax')->getProductWeeeAttributes($product);
128
+
129
+ foreach ($weeeAttributes as $wa)
130
+ {
131
+ if($wa->getCode() == $attributeCode)
132
+ {
133
+ $data = round($wa->getAmount(),2);
134
+ break;
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+
141
+
142
+
143
+ //$_helper = Mage::helper('catalog/output');
144
+ //if($nameNode == 'description' || $nameNode == 'short_description')
145
+ //$data = $_helper->productAttribute($product, $data, $attributeCode);
146
+
147
+ //Synthetize it
148
+ /*$method = "get".ucfirst($attributeCode);
149
+ if(method_exists($product,$method))
150
+ $data = $product->$method();*/
151
+
152
+ //TODO remove this
153
+ if($data== "No" || $data == "Non")
154
+ $data = "";
155
+
156
+ //Exceptions data
157
+ if($nameNode == 'shipping_delay' && empty($data))
158
+ $data = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
159
+
160
+ if($nameNode == 'quantity')
161
+ $data = round($data);
162
+
163
+ return $data;
164
+ }
165
+
166
+ /**
167
+ * Get singleton config for Export
168
+ * @return Profileolabs_Shoppingflux_Model_Export_Config
169
+ */
170
+ public function getConfig()
171
+ {
172
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
173
+ }
174
+
175
+ protected function arrayToNode($entry)
176
+ {
177
+ $node = "";
178
+
179
+ if($this->useZendMemory())
180
+ {
181
+ $mem = $this->getMemoryManager()->create($node);
182
+ foreach ($entry as $key=>$value) {
183
+
184
+ if(is_array($value))
185
+ {
186
+ if(is_string($key))
187
+ $mem->value.= $this->getNode($key, $this->arrayToNode($value),0);
188
+ elseif(is_string(($subKey =current($value))))
189
+ $mem->value.= $this->getNode($subKey, $this->arrayToNode($value),0);
190
+ else
191
+ $mem->value.= $this->arrayToNode($value);
192
+ }
193
+ else
194
+ $mem->value .= $this->getNode($key, $value);
195
+ }
196
+
197
+
198
+ return $mem->value;
199
+ }
200
+ else
201
+ {
202
+
203
+ foreach ($entry as $key=>$value) {
204
+
205
+ if(is_array($value))
206
+ {
207
+ if(is_string($key))
208
+ $node.= $this->getNode($key, $this->arrayToNode($value),0);
209
+ elseif(is_string(($subKey =current($value))))
210
+ $node.= $this->getNode($subKey, $this->arrayToNode($value),0);
211
+ else
212
+ $node.= $this->arrayToNode($value);
213
+ }
214
+ else
215
+ $node .= $this->getNode($key, $value);
216
+ }
217
+
218
+
219
+ return $node;
220
+ }
221
+ }
222
+
223
+ protected function useZendMemory()
224
+ {
225
+ return false;
226
+ }
227
+
228
+ protected function getNode($name,$value,$withCDATA = 1)
229
+ {
230
+ $value = $this->getHelper()->cleanNotUtf8($value);
231
+ $openCDATA = "";
232
+ $closeCDATA = "";
233
+ if($withCDATA)
234
+ {
235
+ $openCDATA = "<![CDATA[";
236
+ $closeCDATA = "]]>";
237
+ }
238
+ return "<{$name}>{$openCDATA}{$value}{$closeCDATA}</{$name}>".chr(10);
239
+ }
240
+
241
+ /**
242
+ * Return Shoppingflu Helper
243
+ * @return Profileolabs_Shoppingflux_Helper_Data
244
+ */
245
+ protected function getHelper()
246
+ {
247
+ return Mage::helper('profileolabs_shoppingflux');
248
+ }
249
+
250
+
251
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Xmlflow.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // V1 DEPRECATED
3
+ class Profileolabs_Shoppingflux_Model_Export_Xmlflow {
4
+
5
+
6
+ public function __construct() {
7
+
8
+ }
9
+
10
+ public function _addEntries($entries) {
11
+ foreach($entries as $entry) {
12
+ $this->_addEntry($entry);
13
+ }
14
+ }
15
+
16
+ public function _addEntry($entry) {
17
+ echo "<product>" . chr(10);
18
+ echo $this->arrayToNode($entry);
19
+ echo "</product>" . chr(10);
20
+ }
21
+
22
+
23
+ public function getVersion() {
24
+ return Mage::getConfig()->getModuleConfig("Profileolabs_Shoppingflux")->version;
25
+ }
26
+
27
+ public function startXml($size) {
28
+ echo '<?xml version="1.0" encoding="utf-8"?>' . chr(10);
29
+ echo '<products version="' . $this->getVersion() . '">' . chr(10);
30
+ }
31
+
32
+ public function endXml() {
33
+ echo "</products>" . chr(10);
34
+ }
35
+
36
+ protected $_attributes = array();
37
+ protected function _getAttribute($attributeCode) {
38
+ if(!isset($this->_attributes[$attributeCode])) {
39
+ $this->_attributes[$attributeCode] = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
40
+ }
41
+ return $this->_attributes[$attributeCode];
42
+ }
43
+
44
+ public function extractData($nameNode, $attributeCode, $product) {
45
+
46
+ $_helper = Mage::helper('catalog/output');
47
+
48
+ $data = $product->getData($attributeCode);
49
+
50
+ $attribute = $this->_getAttribute($attributeCode);
51
+ if ($attribute) {
52
+ $data = $attribute->getFrontend()->getValue($product);
53
+ $data = $_helper->productAttribute($product, $data, $attributeCode);
54
+
55
+ if ($nameNode == 'ecotaxe' && $attribute->getFrontendInput() == 'weee') {
56
+ $weeeAttributes = Mage::getSingleton('weee/tax')->getProductWeeeAttributes($product);
57
+
58
+ foreach ($weeeAttributes as $wa) {
59
+ if ($wa->getCode() == $attributeCode) {
60
+ $data = round($wa->getAmount(), 2);
61
+ break;
62
+ }
63
+ }
64
+ }
65
+ }
66
+
67
+
68
+
69
+
70
+ //$_helper = Mage::helper('catalog/output');
71
+ //if($nameNode == 'description' || $nameNode == 'short_description')
72
+ //$data = $_helper->productAttribute($product, $data, $attributeCode);
73
+ //Synthetize it
74
+ /* $method = "get".ucfirst($attributeCode);
75
+ if(method_exists($product,$method))
76
+ $data = $product->$method(); */
77
+
78
+ //TODO remove this
79
+ if ($data == "No" || $data == "Non")
80
+ $data = "";
81
+
82
+ //Exceptions data
83
+ if ($nameNode == 'shipping_delay' && empty($data))
84
+ $data = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
85
+
86
+ if ($nameNode == 'quantity')
87
+ $data = round($data);
88
+
89
+ return $data;
90
+ }
91
+
92
+ /**
93
+ * Get singleton config for Export
94
+ * @return Profileolabs_Shoppingflux_Model_Export_Config
95
+ */
96
+ public function getConfig() {
97
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
98
+ }
99
+
100
+ protected function arrayToNode($entry) {
101
+ $node = "";
102
+
103
+ foreach ($entry as $key => $value) {
104
+
105
+ if (is_array($value)) {
106
+ if (is_string($key))
107
+ $node.= $this->getNode($key, $this->arrayToNode($value), 0);
108
+ elseif (is_string(($subKey = current($value))))
109
+ $node.= $this->getNode($subKey, $this->arrayToNode($value), 0);
110
+ else
111
+ $node.= $this->arrayToNode($value);
112
+ }
113
+ else
114
+ $node .= $this->getNode($key, $value);
115
+ }
116
+
117
+
118
+ return $node;
119
+ }
120
+
121
+ protected function getNode($name, $value, $withCDATA = 1) {
122
+ $value = $this->getHelper()->cleanNotUtf8($value);
123
+ $openCDATA = "";
124
+ $closeCDATA = "";
125
+ if ($withCDATA) {
126
+ $openCDATA = "<![CDATA[";
127
+ $closeCDATA = "]]>";
128
+ }
129
+ return "<{$name}>{$openCDATA}{$value}{$closeCDATA}</{$name}>" . chr(10);
130
+ }
131
+
132
+ /**
133
+ * Return Shoppingflu Helper
134
+ * @return Profileolabs_Shoppingflux_Helper_Data
135
+ */
136
+ protected function getHelper() {
137
+ return Mage::helper('profileolabs_shoppingflux');
138
+ }
139
+
140
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Convert/Customer.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux_Model_Manageorders
6
+ * @author kassim belghait, vincent enjalbert @ web-cooking.net
7
+ *
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Manageorders_Convert_Customer extends Varien_Object {
10
+
11
+ /**
12
+ * Convert xml node to customer model
13
+ *
14
+ * @param array $data
15
+ * @return Mage_Customer_Model_Customer
16
+ */
17
+ public function toCustomer(array $data, $storeId, $customer = null) {
18
+ /* @var $customer Mage_Customer_Model_Customer */
19
+ $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
20
+ if (!($customer instanceof Mage_Customer_Model_Customer)) {
21
+ $customer = Mage::getModel('customer/customer')->setWebsiteId($websiteId)
22
+ ->loadByEmail($data['Email']);
23
+ $customer->setImportMode(true);
24
+
25
+ if (!$customer->getId()) {
26
+ $customer->setWebsiteId($websiteId);
27
+ $customer->setConfirmation(null);
28
+ $customer->setForceConfirmed(true);
29
+ $customer->setPasswordHash($customer->hashPassword($customer->generatePassword(8)));
30
+ $customer->setFromShoppingflux(1);
31
+ }
32
+ }
33
+
34
+ Mage::helper('core')->copyFieldset('shoppingflux_convert_customer', 'to_customer', $data, $customer);
35
+ if ($customer->getFirstname() == "")
36
+ $customer->setFirstname('__');
37
+
38
+
39
+
40
+ return $customer;
41
+ }
42
+
43
+ /**
44
+ * Convert xml node to customer address model
45
+ *
46
+ * @param array $data
47
+ * @return Mage_Customer_Model_Address
48
+ */
49
+ public function addresstoCustomer(array $data, $storeId, $customer = null, $type = 'billing') {
50
+ /* @var $customer Mage_Customer_Model_Customer */
51
+ if (!($customer instanceof Mage_Customer_Model_Customer)) {
52
+
53
+ $customer = $this->toCustomer($data, $storeId);
54
+ }
55
+
56
+ /* @var $address Mage_Customer_Model_Address */
57
+ $address = Mage::getModel('customer/address');
58
+ $address->setId(null);
59
+ $address->setIsDefaultBilling(true);
60
+ $address->setIsDefaultShipping(false);
61
+ if ($type == "shipping") {
62
+ $address->setIsDefaultBilling(false);
63
+ $address->setIsDefaultShipping(true);
64
+ }
65
+
66
+ Mage::helper('core')->copyFieldset('shoppingflux_convert_customer', 'to_customer_address', $data, $address);
67
+
68
+ if ($address->getFirstname() == "")
69
+ $address->setFirstname(' __ ');
70
+
71
+ if (strpos(strtolower($address->getCountryId()), 'france') !== false)
72
+ $address->setCountryId('FR');
73
+
74
+ if ($address->getTelephone() == "" && $data['PhoneMobile'])
75
+ $address->setTelephone($data['PhoneMobile']);
76
+
77
+ $codeRegion = substr(str_pad($address->getPostcode(), 5, "0", STR_PAD_LEFT), 0, 2);
78
+
79
+ //$regionId = Mage::getModel('directory/region')->loadByCode($codeRegion,$address->getCountry())->getId();
80
+ $regionId = Mage::getModel('directory/region')->getCollection()
81
+ ->addRegionCodeFilter($codeRegion)
82
+ ->addCountryFilter($address->getCountry())
83
+ ->getFirstItem()
84
+ ->getId();
85
+
86
+ if ($regionId)
87
+ $address->setRegionId($regionId);
88
+ else
89
+ $address->setRegionId(182); //Ain pour le pays FR
90
+
91
+
92
+ if(Mage::getSingleton('profileolabs_shoppingflux/config')->getAddressLengthLimit($storeId)) {
93
+ $limit = Mage::getSingleton('profileolabs_shoppingflux/config')->getAddressLengthLimit($storeId);
94
+ $streets = $address->getStreet();
95
+ $nStreets = array();
96
+ foreach($streets as $street) {
97
+ if(strlen($street) > $limit) {
98
+ $nStreets = array_merge($nStreets, Mage::helper('profileolabs_shoppingflux')->truncateAddress($street, $limit));
99
+ } else {
100
+ $nStreets[] = $street;
101
+ }
102
+ }
103
+ $address->setStreet($nStreets);
104
+ }
105
+ return $address;
106
+ }
107
+
108
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Export/Shipments.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ShoppingFlux
4
+ * @package Profileolabs_Shoppingflux
5
+ * @author Vincent Enjalbert @ Web-cooking.net
6
+ */
7
+ class Profileolabs_Shoppingflux_Model_Manageorders_Export_Shipments extends Mage_Core_Model_Abstract
8
+ {
9
+ protected function _construct()
10
+ {
11
+ $this->_init('profileolabs_shoppingflux/manageorders_export_shipments');
12
+ }
13
+
14
+ public function scheduleShipmentExport($shipmentId) {
15
+ $this->setUpdateId(null)->setShipmentId($shipmentId)->setUpdatedAt(date('Y-m-d H:i:s'))->save();
16
+ return $this;
17
+ }
18
+
19
+
20
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Log.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Error Log
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author kassim belghait
7
+ *
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Manageorders_Log extends Mage_Core_Model_Abstract
10
+ {
11
+ protected function _construct()
12
+ {
13
+ $this->_init('profileolabs_shoppingflux/manageorders_log');
14
+ }
15
+
16
+ /**
17
+ * Save message event
18
+ * @param $message string
19
+ * @param $orderId int
20
+ */
21
+ public function log($message,$orderId = null)
22
+ {
23
+ $orderMessage ="";
24
+ if(!is_null($orderId))
25
+ {
26
+ $orderMessage = Mage::helper('profileolabs_shoppingflux')->__('OrderID')." Shopping Flux #".$orderId." ";
27
+ }
28
+
29
+ $message = $orderMessage.$message;
30
+
31
+ $this->setMessage($message);
32
+
33
+ return $this->save();
34
+ }
35
+
36
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Observer.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Profileolabs_Shoppingflux_Model_Manageorders_Observer {
4
+
5
+ public function setCustomerTaxClassId($observer) {
6
+ if (!$this->getConfig()->applyTax() && Mage::getSingleton('checkout/session')->getIsShoppingFlux()) {
7
+ $customerGroup = $observer->getEvent()->getObject();
8
+ $customerGroup->setData('tax_class_id', 999);
9
+ }
10
+ }
11
+
12
+ public function manageOrders($observer) {
13
+ try {
14
+ set_time_limit(0);
15
+ Mage::getModel('profileolabs_shoppingflux/manageorders_order')->manageOrders();
16
+ } catch (Exception $e) {
17
+ Mage::throwException($e);
18
+ }
19
+
20
+ return $this;
21
+ }
22
+
23
+ public function getShipmentTrackingNumber($shipment) {
24
+ $result = false;
25
+ $tracks = $shipment->getAllTracks();
26
+ $trackUrl = '';
27
+ if (is_array($tracks) && !empty($tracks)) {
28
+ $firstTrack = array_shift($tracks);
29
+ if (preg_match('%^owebia%i', $firstTrack->getCarrierCode())) {
30
+ $carrierInstance = Mage::getSingleton('shipping/config')->getCarrierInstance($firstTrack->getCarrierCode());
31
+ if ($carrierInstance) {
32
+ // Gestion du cas Owebia Shipping
33
+ $trackingInfo = $carrierInstance->getTrackingInfo($firstTrack->getData('number'));
34
+ $status = $trackingInfo->getStatus();
35
+ if (preg_match('%href="(.*)"%i', $status, $regs)) {
36
+ $trackUrl = $regs[1];
37
+ }
38
+ }
39
+ }
40
+ if (trim($firstTrack->getData('number'))) {
41
+ $result = array('trackUrl' => $trackUrl, 'trackId' => $firstTrack->getData('number'), 'trackTitle' => $firstTrack->getData('title'));
42
+ }
43
+ }
44
+ $dataObj = new Varien_Object(array('result' => $result, 'shipment'=>$shipment));
45
+ Mage::dispatchEvent('shoppingflux_get_shipment_tracking', array('data_obj' => $dataObj));
46
+ $result = $dataObj->getEntry();
47
+
48
+ return $result;
49
+ }
50
+
51
+ public function sendStatusCanceled($observer) {
52
+ $order = $observer->getEvent()->getOrder();
53
+ if (!$order->getFromShoppingflux())
54
+ return $this;
55
+
56
+
57
+ $storeId = $order->getStoreId();
58
+
59
+ $apiKey = $this->getConfig()->getApiKey($storeId);
60
+ $wsUri = $this->getConfig()->getWsUri();
61
+
62
+
63
+ $orderIdShoppingflux = $order->getOrderIdShoppingflux();
64
+ $marketPlace = $order->getMarketplaceShoppingflux();
65
+
66
+ $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
67
+
68
+ try {
69
+ $service->updateCanceledOrder(
70
+ $orderIdShoppingflux, $marketPlace, Profileolabs_Shoppingflux_Model_Service::ORDER_STATUS_CANCELED
71
+ );
72
+ } catch(Exception $e) {
73
+
74
+ }
75
+
76
+ Mage::helper('profileolabs_shoppingflux')->log('Order ' . $orderIdShoppingflux . ' has been canceled. Information sent to ShoppingFlux.');
77
+
78
+
79
+ }
80
+
81
+
82
+ public function scheduleShipmentUpdate($observer) {
83
+ $shipment = $observer->getShipment();
84
+ Mage::getModel('profileolabs_shoppingflux/manageorders_export_shipments')->scheduleShipmentExport($shipment->getId());
85
+ }
86
+
87
+ public function sendScheduledShipments() {
88
+ $collection = Mage::getModel('profileolabs_shoppingflux/manageorders_export_shipments')->getCollection();
89
+ $collection->addFieldToFilter('updated_at', array('lt'=>new Zend_Db_Expr("DATE_SUB('".date('Y-m-d H:i:s')."', INTERVAL 60 MINUTE)")));
90
+ foreach($collection as $item) {
91
+ try {
92
+ $this->sendStatusShipped($item->getShipmentId());
93
+ $item->delete();
94
+ } catch(Exception $e) {
95
+ $shipment = Mage::getModel('sales/order_shipment')->load($item->getShipmentId());
96
+ $message = 'Erreur de mise à jour de l\'expédition #'.$shipment->getIncrementId().' (commande #'.$shipment->getOrder()->getIncrementId().') : <br/>' . $e->getMessage();
97
+ $message .= "<br/><br/> Merci de vérifier les infos de votre commandes ou de contacter le support Shopping Flux ou celui de la place de marché";
98
+ $this->getHelper()->notifyError($message);
99
+ if($item->getId()) {
100
+ try {
101
+ $item->delete();
102
+ } catch(Exception $e) {}
103
+ }
104
+ }
105
+ }
106
+ return $this;
107
+ }
108
+
109
+ public function sendStatusShipped($shipmentId) {
110
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
111
+ if(!$shipment->getId())
112
+ return $this;
113
+ $order = $shipment->getOrder();
114
+ $storeId = $order->getStoreId();
115
+
116
+ $apiKey = $this->getConfig()->getApiKey($storeId);
117
+ $wsUri = $this->getConfig()->getWsUri();
118
+
119
+ //Mage::log("order = ".print_r($order->debug(),true),null,'debug_update_status_sf.log');
120
+
121
+ if (!$order->getFromShoppingflux())
122
+ return $this;
123
+
124
+ if($order->getShoppingfluxShipmentFlag()) {
125
+ return $this;
126
+ }
127
+
128
+ $trakingInfos = $this->getShipmentTrackingNumber($shipment);
129
+
130
+
131
+
132
+ $orderIdShoppingflux = $order->getOrderIdShoppingflux();
133
+ $marketPlace = $order->getMarketplaceShoppingflux();
134
+
135
+
136
+ //Mage::log("OrderIdSF = ".$orderIdShoppingflux." MP: ".$marketPlace,null,'debug_update_status_sf.log');
137
+
138
+ /* @var $service Profileolabs_Shoppingflux_Model_Service */
139
+ $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
140
+ $result = $service->updateShippedOrder(
141
+ $orderIdShoppingflux, $marketPlace, Profileolabs_Shoppingflux_Model_Service::ORDER_STATUS_SHIPPED, $trakingInfos ? $trakingInfos['trackId'] : '', $trakingInfos ? $trakingInfos['trackTitle'] : '', $trakingInfos ? $trakingInfos['trackUrl'] : ''
142
+ );
143
+
144
+
145
+ if ($result) {
146
+ if ($result->Response->Orders->Order->StatusUpdated == 'False') {
147
+ Mage::throwException('Error in update status shipped to shopping flux');
148
+ } else {
149
+ $status = $result->Response->Orders->Order->StatusUpdated;
150
+ //Mage::log("status = ".$status,null,'debug_update_status_sf.log');
151
+
152
+ $order->setShoppingfluxShipmentFlag(1);
153
+ $order->save();
154
+ $this->getHelper()->log($this->getHelper()->__("Order %s updated to shopping flux.Status returned %s", $orderIdShoppingflux, $status));
155
+ }
156
+ } else {
157
+ $this->getHelper()->log($this->getHelper()->__("Error in update status shipped to shopping flux"));
158
+ Mage::throwException($this->getHelper()->__("Error in update status shipped to shopping flux"));
159
+ }
160
+
161
+ return $this;
162
+ }
163
+
164
+ /**
165
+ * Retrieve config
166
+ * @return Profileolabs_Shoppingflux_Model_Manageorders_Config
167
+ */
168
+ public function getConfig() {
169
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
170
+ }
171
+
172
+ /**
173
+ * Get Helper
174
+ * @return Profileolabs_Shoppingflux_Model_Manageorders_Helper_Data
175
+ */
176
+ public function getHelper() {
177
+ return Mage::helper('profileolabs_shoppingflux');
178
+ }
179
+
180
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Order.php ADDED
@@ -0,0 +1,817 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Orders getted here
5
+ *
6
+ * @category ShoppingFlux
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author kassim belghait, vincent enjalbert @ web-cooking
9
+ *
10
+ */
11
+ class Profileolabs_Shoppingflux_Model_Manageorders_Order extends Varien_Object {
12
+
13
+ /**
14
+ * @var Mage_Sales_Model_Quote
15
+ */
16
+ protected $_quote = null;
17
+
18
+ /**
19
+ * @var Mage_Customer_Model_Customer
20
+ */
21
+ protected $_customer = null;
22
+
23
+ /**
24
+ * Config Data of Module Manageorders
25
+ * @var Profileolabs_Shoppingflux_Model_Manageorders_Config
26
+ */
27
+ protected $_config = null;
28
+ protected $_paymentMethod = 'shoppingflux_purchaseorder';
29
+ protected $_shippingMethod = 'shoppingflux_shoppingflux';
30
+ protected $_nb_orders_imported = 0;
31
+ protected $_nb_orders_read = 0;
32
+ protected $_ordersIdsImported = array();
33
+ protected $_orderIdsAlreadyImported = null;
34
+ protected $_result;
35
+ protected $_resultSendOrder = "";
36
+ protected $_isUnderVersion14 = null;
37
+
38
+ /**
39
+ * Product model
40
+ *
41
+ * @var Mage_Catalog_Model_Product
42
+ */
43
+ protected $_productModel;
44
+
45
+ public function getResultSendOrder() {
46
+ return $this->_resultSendOrder;
47
+ }
48
+
49
+ public function isUnderVersion14() {
50
+ if (is_null($this->_isUnderVersion14)) {
51
+ $this->_isUnderVersion14 = $this->getHelper()->isUnderVersion14();
52
+ }
53
+ return $this->_isUnderVersion14;
54
+ }
55
+
56
+ /**
57
+ * Retrieve product model cache
58
+ *
59
+ * @return Mage_Catalog_Model_Product
60
+ */
61
+ public function getProductModel() {
62
+ if (is_null($this->_productModel)) {
63
+ $productModel = Mage::getModel('profileolabs_shoppingflux/manageorders_product');
64
+ $this->_productModel = Mage::objects()->save($productModel);
65
+ }
66
+ return Mage::objects()->load($this->_productModel);
67
+ }
68
+
69
+ public function getOrderIdsAlreadyImported() {
70
+ if (is_null($this->_orderIdsAlreadyImported)) {
71
+ $orders = Mage::getModel('sales/order')->getCollection()
72
+ ->addAttributeToFilter('from_shoppingflux', 1)
73
+ ->addAttributeToSelect('order_id_shoppingflux');
74
+
75
+ $this->_orderIdsAlreadyImported = array();
76
+ foreach ($orders as $order) {
77
+ $this->_orderIdsAlreadyImported[] = $order->getOrderIdShoppingflux();
78
+ }
79
+ }
80
+
81
+ return $this->_orderIdsAlreadyImported;
82
+ }
83
+
84
+ public function getOrderFlagFile($idShoppingflux) {
85
+ if(!file_exists(BP . DS . 'var/shoppingflux')) {
86
+ @mkdir(BP . DS . 'var/shoppingflux');
87
+ }
88
+ return BP . DS . 'var/shoppingflux/' . $idShoppingflux . '.flag';
89
+ }
90
+
91
+ public function clearOrderFlagFile($idShoppingflux) {
92
+ @unlink($this->getOrderFlagFile($idShoppingflux));
93
+ }
94
+
95
+ public function clearOldOrderFlagFiles() {
96
+ $files = glob(BP . DS . 'var/shoppingflux/*.flag');
97
+ if($files) {
98
+ foreach ($files as $filename) {
99
+ if (filemtime($filename) < time() - 2 * 60 * 60) {
100
+ @unlink($filename);
101
+ }
102
+ }
103
+ }
104
+ }
105
+
106
+ public function isAlreadyImported($idShoppingflux) {
107
+ $alreadyImported = $this->getOrderIdsAlreadyImported();
108
+ if (in_array($idShoppingflux, $alreadyImported))
109
+ return true;
110
+ $flagPath = $this->getOrderFlagFile($idShoppingflux);
111
+ if (file_exists($flagPath)) { //double check
112
+ return true;
113
+ }
114
+
115
+ touch($flagPath);
116
+
117
+ return false;
118
+ }
119
+
120
+ public function getSession() {
121
+ return Mage::getSingleton('checkout/session');
122
+ }
123
+
124
+ protected function _getQuote($storeId = null) {
125
+ return $this->getSession()->getQuote();
126
+ }
127
+
128
+ /**
129
+ * Retrieve config
130
+ * @return Profileolabs_Shoppingflux_Model_Manageorders_Config
131
+ */
132
+ public function getConfig() {
133
+ if (is_null($this->_config)) {
134
+ $this->_config = Mage::getSingleton('profileolabs_shoppingflux/config');
135
+ }
136
+
137
+ return $this->_config;
138
+ }
139
+
140
+ /**
141
+ * Get orders and create it
142
+ */
143
+ public function manageOrders() {
144
+ $stores = Mage::app()->getStores();
145
+
146
+ if (Mage::app()->getStore()->getCode() != 'admin')
147
+ Mage::app()->setCurrentStore('admin');
148
+
149
+ $apiKeyManaged = array();
150
+
151
+ //old module version compliance. The goal is to use default store, as in previous versions, if api key is set in global scope.
152
+ $defaultStoreId = Mage::app()->getDefaultStoreView()->getId();
153
+ if (key($stores) != $defaultStoreId) {
154
+ $tmpStores = array($defaultStoreId => $stores[$defaultStoreId]);
155
+ foreach ($stores as $store) {
156
+ if ($store->getId() != $defaultStoreId) {
157
+ $tmpStores[$store->getId()] = $store;
158
+ }
159
+ }
160
+ $stores = $tmpStores;
161
+ }
162
+ //old module version compliance end
163
+
164
+
165
+ foreach ($stores as $_store) {
166
+ $storeId = $_store->getId();
167
+ if ($this->getConfig()->isOrdersEnabled($storeId)) {
168
+ $apiKey = $this->getConfig()->getApiKey($storeId);
169
+
170
+ if (!$apiKey || in_array($apiKey, $apiKeyManaged))
171
+ continue;
172
+ $apiKeyManaged[] = $apiKey;
173
+
174
+ $wsUri = $this->getConfig()->getWsUri();
175
+
176
+ //$isUnderVersion14 = $this->getHelper()->isUnderVersion14();
177
+
178
+ /* @var $service Profileolabs_Shoppingflux_Model_Service */
179
+ $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
180
+ ini_set("memory_limit", $this->getConfig()->getMemoryLimit() . "M");
181
+ try {
182
+
183
+ /* @var $this->_result Varien_Simplexml_Element */
184
+ $this->_result = $service->getOrders();
185
+
186
+ $this->_nb_orders_imported = 0;
187
+ } catch (Exception $e) {
188
+ Mage::logException($e);
189
+ $message = Mage::helper('profileolabs_shoppingflux')->__('Orders import error. '.$e->getMessage()); //." ".Mage::helper('profileolabs_shoppingflux')->__('Error').": ".$e->getMessage();
190
+ $this->getHelper()->log($message);
191
+ //Mage::throwException($message);
192
+
193
+ Mage::throwException($e);
194
+ }
195
+
196
+ //We parse result
197
+ //$nodes = current($this->_result->children());
198
+ $nodes = $this->_result->children();
199
+ if($nodes && count($nodes) > 0) {
200
+ foreach ($nodes as $childName => $child) {
201
+
202
+ $orderSf = $this->getHelper()->asArray($child);
203
+
204
+
205
+ if ($this->isAlreadyImported($orderSf['IdOrder']))
206
+ continue;
207
+
208
+ $this->_nb_orders_read++;
209
+
210
+ $this->createAllForOrder($orderSf, $storeId);
211
+
212
+ if ($this->_nb_orders_imported == $this->getConfig()->getLimitOrders($storeId))
213
+ break;
214
+ }
215
+ }
216
+
217
+ try {
218
+ if ($this->_nb_orders_imported > 0 || count($this->_ordersIdsImported)) {
219
+
220
+ $result = $service->sendValidOrders($this->_ordersIdsImported);
221
+ foreach($this->_ordersIdsImported as $importedOrder) {
222
+ $shippingMethod = $importedOrder['ShippingMethod'];
223
+ $marketplace = $importedOrder['Marketplace'];
224
+ try {
225
+ Mage::getModel('profileolabs_shoppingflux/manageorders_shipping_method')->saveShippingMethod($marketplace, $shippingMethod);
226
+ } catch(Exception $e) {
227
+
228
+ }
229
+ }
230
+
231
+
232
+ if ($result) {
233
+ if ($result->error) {
234
+ Mage::throwException($result->error);
235
+ }
236
+
237
+ $this->_resultSendOrder = $result->status;
238
+ } else {
239
+ $this->getHelper()->log("Error in order ids validated");
240
+ Mage::throwException("Error in order ids validated");
241
+ }
242
+ }
243
+ } catch (Exception $e) {
244
+ $this->getHelper()->log($e->getMessage());
245
+ Mage::throwException($e);
246
+ }
247
+ }
248
+ }
249
+ $this->clearOldOrderFlagFiles();
250
+ return $this;
251
+ }
252
+
253
+ /**
254
+ * Inititalize the quote with minimum requirement
255
+ * @param array $orderSf
256
+ */
257
+ protected function _initQuote(array $orderSf, $storeId) {
258
+
259
+ if (is_null($storeId)) {//just in case..
260
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
261
+ }
262
+
263
+ $this->_getQuote()->setStoreId($storeId);
264
+
265
+ //Super mode is setted to bypass check item qty ;)
266
+ $this->_getQuote()->setIsSuperMode(true);
267
+
268
+ //Set boolean shopping flux and shipping prices in session for shopping method
269
+ $this->getSession()->setIsShoppingFlux(true);
270
+ //$this->getSession()->setShippingPrice((float)$orderSf['TotalShipping']);
271
+
272
+ $this->_getQuote()->setCustomer($this->_customer);
273
+ }
274
+
275
+ /**
276
+ * Create or Update customer with converter
277
+ * @param array $data Data From ShoppingFlux
278
+ */
279
+ protected function _createCustomer(array $data, $storeId) {
280
+ try {
281
+
282
+ /* @var $convert_customer Profileolabs_Shoppingflux_Model_Manageorders_Convert_Customer */
283
+ $convert_customer = Mage::getModel('profileolabs_shoppingflux/manageorders_convert_customer');
284
+
285
+ $this->_customer = $convert_customer->toCustomer(current($data['BillingAddress']), $storeId);
286
+ $billingAddress = $convert_customer->addresstoCustomer(current($data['BillingAddress']), $storeId, $this->_customer);
287
+
288
+ $this->_customer->addAddress($billingAddress);
289
+
290
+ $shippingAddress = $convert_customer->addresstoCustomer(current($data['ShippingAddress']), $storeId, $this->_customer, 'shipping');
291
+ $this->_customer->addAddress($shippingAddress);
292
+ $customerGroupId = $this->getConfig()->getCustomerGroupIdFor($data['Marketplace'], $storeId);
293
+ if ($customerGroupId) {
294
+ $this->_customer->setGroupId($customerGroupId);
295
+ }
296
+ $this->_customer->save();
297
+ } catch (Exception $e) {
298
+ Mage::throwException($e);
299
+ }
300
+ }
301
+
302
+ public function createAllForOrder($orderSf, $storeId) {
303
+ try {
304
+ $orderIdShoppingFlux = (string) $orderSf['IdOrder'];
305
+
306
+ $dataObj = new Varien_Object(array('entry' => $orderSf, 'store_id'=>$storeId));
307
+ Mage::dispatchEvent('shoppingflux_before_import_order', array('order_sf' => $dataObj));
308
+ $orderSf = $dataObj->getEntry();
309
+
310
+ //Set array with shopping flux ids
311
+ $this->_ordersIdsImported[$orderIdShoppingFlux] = array(
312
+ 'Marketplace' => $orderSf['Marketplace'],
313
+ 'MageOrderId' => '',
314
+ 'ShippingMethod' => $orderSf['ShippingMethod'],
315
+ 'ErrorOrder' => false
316
+ );
317
+
318
+ //$this->_quote = null;
319
+ $this->_customer = null;
320
+
321
+
322
+ //Create or Update customer with addresses
323
+ $this->_createCustomer($orderSf, $storeId);
324
+
325
+ $this->_initQuote($orderSf, $storeId);
326
+
327
+ //Add products to quote with data from ShoppingFlux
328
+ $this->_addProductsToQuote($orderSf);
329
+
330
+ $order = null;
331
+ if (!$this->isUnderVersion14())
332
+ $order = $this->_saveOrder($orderSf, $storeId);
333
+ else
334
+ $order = $this->_saveOrder13($orderSf, $storeId);
335
+
336
+ $this->getHelper()->log('Order ' . $orderSf['IdOrder'] . ' has been created (' . $order->getIncrementId() . ')');
337
+ $this->_nb_orders_imported++;
338
+
339
+ if (!is_null($order) && $order->getId())
340
+ $this->_changeDateCreatedAt($order, $orderSf['OrderDate']);
341
+
342
+ //Erase session for the next order
343
+ $this->getSession()->clear();
344
+ } catch (Exception $e) {
345
+ $this->getHelper()->log($e->getMessage(), $orderSf['IdOrder']);
346
+ $this->_ordersIdsImported[$orderIdShoppingFlux]['ErrorOrder'] = $e->getMessage();
347
+ $this->clearOrderFlagFile($orderSf['IdOrder']);
348
+ //Erase session for the next order
349
+ $this->getSession()->clear();
350
+ }
351
+ }
352
+
353
+ protected function _changeDateCreatedAt($order, $date) {
354
+ try {
355
+
356
+ $order->setCreatedAt($date);
357
+ //$order->setUpdatedAt($date);
358
+ $order->save();
359
+ } catch (Exception $e) {
360
+ Mage::logException($e);
361
+ Mage::throwException($message);
362
+ }
363
+ }
364
+
365
+ /**
366
+ * Add products to quote with data from ShoppinfFlux
367
+ * @param array $orderSf
368
+ */
369
+ protected function _addProductsToQuote(array $orderSf) {
370
+ $totalAmount = $orderSf['TotalAmount'];
371
+ $productsSf = current($orderSf['Products']);
372
+ $productsToIterate = current($productsSf);
373
+
374
+
375
+
376
+
377
+ if (!$this->_customer->getDefaultBilling() || !$this->_customer->getDefaultShipping())
378
+ $this->_customer->load($this->_customer->getId());
379
+
380
+ $customerAddressBillingId = $this->_customer->getDefaultBilling();
381
+ $customerAddressShippingId = $this->_customer->getDefaultShipping();
382
+
383
+ //Set billing Address
384
+ $addressBilling = $this->_getQuote()->getBillingAddress();
385
+ //Make sure addresses will be saved without validation errors
386
+ $addressBilling->setShouldIgnoreValidation(true);
387
+ $customerAddressBilling = Mage::getModel('customer/address')->load($customerAddressBillingId);
388
+ $addressBilling->importCustomerAddress($customerAddressBilling)->setSaveInAddressBook(0);
389
+
390
+ //Set shipping Address
391
+ $addressShipping = $this->_getQuote()->getShippingAddress();
392
+ //Make sure addresses will be saved without validation errors
393
+ $addressShipping->setShouldIgnoreValidation(true);
394
+ $customerAddressShipping = Mage::getModel('customer/address')->load($customerAddressShippingId);
395
+ $addressShipping->importCustomerAddress($customerAddressShipping)->setSaveInAddressBook(0);
396
+ $addressShipping->setSameAsBilling(0);
397
+
398
+
399
+ //Convert shipping price by tax rate
400
+ $shippingPrice = (float) $orderSf['TotalShipping'];
401
+ $this->getSession()->setShippingPrice($shippingPrice);
402
+ if (!Mage::helper('tax')->shippingPriceIncludesTax() && Mage::helper('tax')->getShippingTaxClass(null)) {
403
+ $percent = null;
404
+ $pseudoProduct = new Varien_Object();
405
+ $pseudoProduct->setTaxClassId(Mage::helper('tax')->getShippingTaxClass(null));
406
+
407
+ $taxClassId = $pseudoProduct->getTaxClassId();
408
+ if (is_null($percent)) {
409
+ if ($taxClassId) {
410
+ $request = Mage::getSingleton('tax/calculation')->getRateRequest($addressShipping, $addressBilling, null, null);
411
+ $request->setProductClassId($taxClassId);
412
+ $request->setCustomerClassId($this->_getQuote()->getCustomerTaxClassId());
413
+ $percent = Mage::getSingleton('tax/calculation')->getRate($request);
414
+
415
+ if ($percent !== false || !is_null($percent)) {
416
+
417
+ $shippingPrice = $shippingPrice - ($shippingPrice / (100 + $percent) * $percent);
418
+ $this->getSession()->setShippingPrice($shippingPrice);
419
+ }
420
+ }
421
+ }
422
+
423
+ //Mage::log("including tax = ".$includingTax." shipping price = ".$shippingPrice,null,'test_shipping_price.log');
424
+ }
425
+
426
+ //Set shipping Mehtod and collect shipping rates
427
+ $addressShipping->setShippingMethod($this->_shippingMethod)->setCollectShippingRates(true);
428
+
429
+
430
+
431
+
432
+ foreach ($productsToIterate as $key => $productSf) {
433
+
434
+ $sku = $productSf['SKU'];
435
+
436
+ if (($productId = $this->getProductModel()->getResource()->getIdBySku($sku)) != false) {
437
+ $product = Mage::getModel('profileolabs_shoppingflux/manageorders_product')->load($productId); // $this->getProductModel()->reset()->load($productId);
438
+
439
+ $request = new Varien_Object(array('qty' => $productSf['Quantity']));
440
+ /*if ($product->getTypeId() == 'simple' && $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) {
441
+
442
+ $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
443
+ ->getParentIdsByChild($product->getId());
444
+
445
+ if (count($parentIds)) {
446
+ $parentId = current($parentIds);
447
+ $confProduct = Mage::getModel('profileolabs_shoppingflux/manageorders_product')->load($parentId);
448
+ if ($confProduct->getId() && $confProduct->isSalable()) {
449
+
450
+ $attributesConf = $this->getHelper()->getAttributesConfigurable($parentId);
451
+ $superAttributes = array();
452
+
453
+ foreach ($attributesConf as $attribute) {
454
+
455
+ $attributeCode = $attribute['attribute_code'];
456
+ $attributeId = $attribute['attribute_id'];
457
+
458
+ $superAttributes[$attributeId] = $product->getData($attributeCode);
459
+ }
460
+
461
+ $product = $confProduct;
462
+ $request->setData('super_attribute', $superAttributes);
463
+ }
464
+ }
465
+ }*/
466
+
467
+
468
+ $item = $this->_getQuote()->addProduct($product, $request);
469
+
470
+ if (!is_object($item)) {
471
+ $this->getSession()->clear();
472
+ Mage::throwException("le produit sku = " . $sku . " n'a pas pu être ajouté! Id = " . $product->getId() . " Item = " . (string) $item);
473
+ }
474
+
475
+
476
+ //Save the quote with the new product
477
+ $this->_getQuote()->save();
478
+
479
+
480
+ $unitPrice = $productSf['Price'];
481
+ if($unitPrice <= 0) {
482
+ $this->getHelper()->log('Order '.$orderSf['IdOrder'].' has a product with 0 price : '.$productSf['SKU']);
483
+ }
484
+ if ($this->getConfig()->applyTax() && !Mage::helper('tax')->priceIncludesTax()) {
485
+ $taxClassId = $product->getTaxClassId();
486
+ if($taxClassId > 0) {
487
+ $request = Mage::getSingleton('tax/calculation')->getRateRequest($addressShipping, $addressBilling, null, null);
488
+ $request->setProductClassId($taxClassId);
489
+ $request->setCustomerClassId($this->_getQuote()->getCustomerTaxClassId());
490
+ $percent = Mage::getSingleton('tax/calculation')->getRate($request);
491
+ $unitPrice = $unitPrice / (1 + $percent / 100);
492
+ if($unitPrice <= 0) {
493
+ $this->getHelper()->log('Order '.$orderSf['IdOrder'].' has a product with 0 price after applying tax : '.$productSf['SKU']);
494
+ }
495
+ }
496
+ }
497
+
498
+
499
+
500
+
501
+ //Modify Item price
502
+ $item->setCustomPrice($unitPrice);
503
+ $item->setOriginalCustomPrice($unitPrice);
504
+ $item->save();
505
+
506
+ if (is_object($parentItem = $item->getParentItem())) {
507
+ $parentItem->setCustomPrice($unitPrice);
508
+ $parentItem->setOriginalCustomPrice($unitPrice);
509
+ $parentItem->save();
510
+ }
511
+
512
+ //Mage::log(print_r($item->debug(),true),null,'debug_items.log');
513
+ } else {
514
+
515
+ $this->getSession()->clear();
516
+ Mage::throwException("le produit sku = " . $sku . " n'existe plus en base!");
517
+ }
518
+ }
519
+
520
+
521
+ $this->_getQuote()->collectTotals();
522
+ $this->_getQuote()->save();
523
+
524
+ //Set payment method
525
+ /* @var $payment Mage_Sales_Quote_Payment */
526
+ $this->_getQuote()->getShippingAddress()->setPaymentMethod($this->_paymentMethod);
527
+ $payment = $this->_getQuote()->getPayment();
528
+ $dataPayment = array('method' => $this->_paymentMethod, 'marketplace' => $orderSf['Marketplace']);
529
+ $payment->importData($dataPayment);
530
+ //$addressShipping->setShippingMethod($this->_shippingMethod)->setCollectShippingRates(true);
531
+
532
+ $this->_getQuote()->collectTotals();
533
+ $this->_getQuote()->save();
534
+ }
535
+
536
+
537
+ /**
538
+ * Save the new order with the quote
539
+ * @param array $orderSf
540
+ */
541
+ protected function _saveOrder(array $orderSf, $storeId) {
542
+ $orderIdShoppingFlux = (string) $orderSf['IdOrder'];
543
+ $additionalData = array("from_shoppingflux" => 1,
544
+ "marketplace_shoppingflux" => $orderSf['Marketplace'],
545
+ "fees_shoppingflux" => (float) (isset($orderSf['TotalFees']) ? $orderSf['TotalFees'] : 0),
546
+ "order_id_shoppingflux" => $orderIdShoppingFlux,
547
+ "grand_total" => $orderSf['TotalAmount'],
548
+ "base_grand_total" => $orderSf['TotalAmount'],
549
+ "order_currency_code" => isset($orderSf['Currency'])?$orderSf['Currency']:'EUR',
550
+ "base_currency_code" => isset($orderSf['Currency'])?$orderSf['Currency']:'EUR',
551
+ "store_currency_code" => isset($orderSf['Currency'])?$orderSf['Currency']:'EUR',
552
+
553
+ );
554
+
555
+ $shippingMethod = $this->getConfig()->getShippingMethodFor($orderSf['Marketplace'], $orderSf['ShippingMethod'], $storeId);
556
+ if($shippingMethod) {
557
+ $additionalData['shipping_method'] = $shippingMethod;
558
+ $additionalData['shipping_description'] = "Frais de port de la place de marché (" . $shippingMethod . ")";
559
+ }
560
+ /* @var $service Mage_Sales_Model_Service_Quote */
561
+ $service = Mage::getModel('sales/service_quote', $this->_getQuote());
562
+ $service->setOrderData($additionalData);
563
+ $order = false;
564
+
565
+ ini_set('display_errors', 1);
566
+ error_reporting(-1);
567
+
568
+ try {
569
+ if (method_exists($service, "submitAll")) {
570
+
571
+ $service->submitAll();
572
+ $order = $service->getOrder();
573
+ } else {
574
+
575
+ $order = $service->submit();
576
+ }
577
+ } catch(Exception $e) {
578
+ throw $e;
579
+ }
580
+
581
+ if ($order) {
582
+
583
+ $newStatus = $this->getConfig()->getConfigData('shoppingflux_mo/manageorders/new_order_status', $order->getStoreId());
584
+ if ($newStatus) {
585
+ $order->setStatus($newStatus);
586
+ $order->save();
587
+ }
588
+
589
+
590
+
591
+ $this->_saveInvoice($order);
592
+
593
+
594
+ $processingStatus = $this->getConfig()->getConfigData('shoppingflux_mo/manageorders/processing_order_status', $order->getStoreId());
595
+ if ($processingStatus) {
596
+ $order->setStatus($processingStatus);
597
+ $order->save();
598
+ }
599
+
600
+ foreach($order->getAllItems() as $orderItem) {
601
+ if($orderItem->getWeeeTaxAppliedRowAmount()) {
602
+ /*Mage::log('------order : ' . $order->getIncrementId(). '--------START', null, 'sf.debug.weee.log');
603
+ Mage::log('------order : ' . $order->getIncrementId(). '---BEFORE', null, 'sf.debug.weee.log');
604
+ Mage::log('row_total_incl_tax : ' . $orderItem->getData('row_total_incl_tax'), null, 'sf.debug.weee.log');
605
+ Mage::log('base_row_total_incl_tax : ' . $orderItem->getData('base_row_total_incl_tax'), null, 'sf.debug.weee.log');
606
+ Mage::log('row_total : ' . $orderItem->getData('row_total'), null, 'sf.debug.weee.log');
607
+ Mage::log('base_row_total : ' . $orderItem->getData('base_row_total'), null, 'sf.debug.weee.log');
608
+ Mage::log('price : ' . $orderItem->getData('price'), null, 'sf.debug.weee.log');
609
+ Mage::log('base_price : ' . $orderItem->getData('base_price'), null, 'sf.debug.weee.log');
610
+ Mage::log('weee_tax_applied_row_amount : ' . $orderItem->getData('weee_tax_applied_row_amount'), null, 'sf.debug.weee.log');
611
+ Mage::log('base_weee_tax_applied_row_amnt : ' . $orderItem->getData('base_weee_tax_applied_row_amnt'), null, 'sf.debug.weee.log');
612
+ Mage::log('weee_tax_applied_amount : ' . $orderItem->getData('weee_tax_applied_amount'), null, 'sf.debug.weee.log');
613
+ Mage::log('base_weee_tax_applied_amount : ' . $orderItem->getData('base_weee_tax_applied_amount'), null, 'sf.debug.weee.log');*/
614
+ if($orderItem->getData('row_total_incl_tax')) {
615
+ $orderItem->setData('row_total_incl_tax', $orderItem->getData('row_total_incl_tax') - $orderItem->getWeeeTaxAppliedRowAmount());
616
+ }
617
+ if($orderItem->getData('base_row_total_incl_tax')) {
618
+ $orderItem->setData('base_row_total_incl_tax', $orderItem->getData('base_row_total_incl_tax') - $orderItem->getBaseWeeeTaxAppliedRowAmnt());
619
+ }
620
+ $orderItem->setData('row_total', $orderItem->getData('row_total') - $orderItem->getWeeeTaxAppliedRowAmount());
621
+ $orderItem->setData('base_row_total', $orderItem->getData('base_row_total') - $orderItem->getBaseWeeeTaxAppliedRowAmnt());
622
+ $orderItem->setData('price', $orderItem->getData('price') - $orderItem->getWeeeTaxAppliedAmount());
623
+ $orderItem->setData('base_price', $orderItem->getData('base_price') - $orderItem->getBaseWeeeTaxAppliedAmount());
624
+ $orderItem->save();
625
+
626
+ /*Mage::log('------order : ' . $order->getIncrementId(). '---AFTER', null, 'sf.debug.weee.log');
627
+ Mage::log('row_total_incl_tax : ' . $orderItem->getData('row_total_incl_tax'), null, 'sf.debug.weee.log');
628
+ Mage::log('base_row_total_incl_tax : ' . $orderItem->getData('base_row_total_incl_tax'), null, 'sf.debug.weee.log');
629
+ Mage::log('row_total : ' . $orderItem->getData('row_total'), null, 'sf.debug.weee.log');
630
+ Mage::log('base_row_total : ' . $orderItem->getData('base_row_total'), null, 'sf.debug.weee.log');
631
+ Mage::log('price : ' . $orderItem->getData('price'), null, 'sf.debug.weee.log');
632
+ Mage::log('base_price : ' . $orderItem->getData('base_price'), null, 'sf.debug.weee.log');
633
+ Mage::log('------order : ' . $order->getIncrementId(). '--------STOP', null, 'sf.debug.weee.log');*/
634
+
635
+ }
636
+ }
637
+
638
+
639
+ $this->_orderIdsAlreadyImported[] = $orderIdShoppingFlux;
640
+ $this->_ordersIdsImported[$orderIdShoppingFlux]['MageOrderId'] = $order->getIncrementId();
641
+
642
+ if(Mage::helper('sales')->canSendNewOrderEmail()) {
643
+ $order->sendNewOrderEmail();
644
+ }
645
+
646
+ return $order;
647
+ }
648
+
649
+ return null;
650
+ }
651
+
652
+ protected function _saveOrder13(array $orderSf, $storeId) {
653
+ $orderIdShoppingFlux = (string) $orderSf['IdOrder'];
654
+ $additionalData = array("from_shoppingflux" => 1,
655
+ "marketplace_shoppingflux" => $orderSf['Marketplace'],
656
+ "fees_shoppingflux" => (float) (isset($orderSf['Fees']) ? $orderSf['Fees'] : 0.0),
657
+ "order_id_shoppingflux" => $orderIdShoppingFlux);
658
+
659
+
660
+ $billing = $this->_getQuote()->getBillingAddress();
661
+ $shipping = $this->_getQuote()->getShippingAddress();
662
+
663
+ $this->_getQuote()->reserveOrderId();
664
+ $convertQuote = Mage::getModel('sales/convert_quote');
665
+ /* @var $convertQuote Mage_Sales_Model_Convert_Quote */
666
+
667
+ $order = $convertQuote->addressToOrder($shipping);
668
+
669
+ $order->addData($additionalData);
670
+
671
+ /* @var $order Mage_Sales_Model_Order */
672
+ $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
673
+ $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
674
+
675
+ $order->setPayment($convertQuote->paymentToOrderPayment($this->_getQuote()->getPayment()));
676
+
677
+ foreach ($this->_getQuote()->getAllItems() as $item) {
678
+ $orderItem = $convertQuote->itemToOrderItem($item);
679
+ if ($item->getParentItem()) {
680
+ $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
681
+ }
682
+ $order->addItem($orderItem);
683
+ }
684
+
685
+ /**
686
+ * We can use configuration data for declare new order status
687
+ */
688
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order' => $order, 'quote' => $this->getQuote()));
689
+ //Mage::throwException(print_r($order->getData(),true));
690
+ //die("<pre> DIE = ".print_r($order->getData()));
691
+ $order->place();
692
+
693
+ $order->setCustomerId($this->_getQuote()->getCustomer()->getId());
694
+
695
+ $order->setEmailSent(false);
696
+ $order->save();
697
+
698
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order' => $order, 'quote' => $this->getQuote()));
699
+
700
+ $this->_getQuote()->setIsActive(false);
701
+ $this->_getQuote()->save();
702
+
703
+ ///////////////////////////////////////////////////////////////////////////
704
+
705
+ if ($order) {
706
+
707
+ $this->_saveInvoice($order);
708
+
709
+ //Set array with shopping flux ids
710
+ $this->_ordersIdsImported[$orderIdShoppingFlux] = array('Marketplace' => $orderSf['Marketplace'], 'MageOrderId' => $order->getIncrementId());
711
+
712
+ return $order;
713
+ }
714
+
715
+ return null;
716
+ }
717
+
718
+ /**
719
+ * Create and Save invoice for the new order
720
+ * @param Mage_Sales_Model_Order $order
721
+ */
722
+ protected function _saveInvoice($order) {
723
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order' => $order, 'quote' => $this->_getQuote()));
724
+
725
+ if (!$this->getConfig()->createInvoice()) {
726
+ return $this;
727
+ }
728
+
729
+ //Prepare invoice and save it
730
+ $path = Mage::getBaseDir() . "/app/code/core/Mage/Sales/Model/Service/Order.php";
731
+ $invoice = false;
732
+ if (file_exists($path)) {
733
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
734
+ } else {
735
+ $invoice = $this->_initInvoice($order);
736
+ }
737
+
738
+ if ($invoice) {
739
+ $invoice->setBaseGrandTotal($order->getBaseGrandTotal());
740
+ $invoice->setGrandTotal($order->getGrandTotal());
741
+ $invoice->register();
742
+ $invoice->getOrder()->setCustomerNoteNotify(false);
743
+ $invoice->getOrder()->setIsInProcess(true);
744
+
745
+
746
+ $transactionSave = Mage::getModel('core/resource_transaction')
747
+ ->addObject($invoice)
748
+ ->addObject($invoice->getOrder());
749
+ $transactionSave->save();
750
+ }
751
+ }
752
+
753
+ /**
754
+ * Initialize invoice
755
+ * @param Mage_Sales_Model_Order $order
756
+ * @return Mage_Sales_Model_Order_Invoice $invoice
757
+ */
758
+ protected function _initInvoice($order) {
759
+
760
+ $convertor = Mage::getModel('sales/convert_order');
761
+ $invoice = $convertor->toInvoice($order);
762
+ $update = false;
763
+ $savedQtys = array();
764
+ $itemsToInvoice = 0;
765
+ /* @var $orderItem Mage_Sales_Model_Order_Item */
766
+ foreach ($order->getAllItems() as $orderItem) {
767
+
768
+ if (!$orderItem->isDummy() && !$orderItem->getQtyToInvoice() && $orderItem->getLockedDoInvoice()) {
769
+ continue;
770
+ }
771
+
772
+ if ($order->getForcedDoShipmentWithInvoice() && $orderItem->getLockedDoShip()) {
773
+ continue;
774
+ }
775
+
776
+ if (!$update && $orderItem->isDummy() && !empty($savedQtys) && !$this->_needToAddDummy($orderItem, $savedQtys)) {
777
+ continue;
778
+ }
779
+ $item = $convertor->itemToInvoiceItem($orderItem);
780
+
781
+ if (isset($savedQtys[$orderItem->getId()])) {
782
+ $qty = $savedQtys[$orderItem->getId()];
783
+ } else {
784
+ if ($orderItem->isDummy()) {
785
+ $qty = 1;
786
+ } else {
787
+ $qty = $orderItem->getQtyToInvoice();
788
+ }
789
+ }
790
+ $itemsToInvoice += floatval($qty);
791
+ $item->setQty($qty);
792
+ $invoice->addItem($item);
793
+
794
+ if ($itemsToInvoice <= 0) {
795
+ Mage::throwException($this->__('Invoice without products could not be created.'));
796
+ }
797
+ }
798
+
799
+
800
+ $invoice->collectTotals();
801
+
802
+ return $invoice;
803
+ }
804
+
805
+ /**
806
+ * Get Helper
807
+ * @return Profileolabs_Shoppingflux_Model_Manageorders_Helper_Data
808
+ */
809
+ public function getHelper() {
810
+ return Mage::helper('profileolabs_shoppingflux');
811
+ }
812
+
813
+ public function getNbOrdersImported() {
814
+ return $this->_nb_orders_imported;
815
+ }
816
+
817
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/OrderOLD.php ADDED
@@ -0,0 +1,683 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Orders getted here
5
+ *
6
+ * @category ShoppingFlux
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author kassim belghait, vincent enjalbert @ web-cooking
9
+ *
10
+ */
11
+ class Profileolabs_Shoppingflux_Model_Manageorders_Order extends Varien_Object {
12
+
13
+ /**
14
+ * @var Mage_Sales_Model_Quote
15
+ */
16
+ protected $_quote = null;
17
+
18
+ /**
19
+ * @var Mage_Customer_Model_Customer
20
+ */
21
+ protected $_customer = null;
22
+
23
+ /**
24
+ * Config Data of Module Manageorders
25
+ * @var Profileolabs_Shoppingflux_Model_Manageorders_Config
26
+ */
27
+ protected $_config = null;
28
+ protected $_paymentMethod = 'shoppingflux_purchaseorder';
29
+ protected $_shippingMethod = 'shoppingflux_shoppingflux';
30
+ protected $_nb_orders_imported = 0;
31
+ protected $_nb_orders_read = 0;
32
+ protected $_ordersIdsImported = array();
33
+ protected $_orderIdsAlreadyImported = null;
34
+ protected $_result;
35
+ protected $_resultSendOrder = "";
36
+ protected $_isUnderVersion14 = null;
37
+
38
+ /**
39
+ * Product model
40
+ *
41
+ * @var Mage_Catalog_Model_Product
42
+ */
43
+ protected $_productModel;
44
+
45
+ public function getResultSendOrder() {
46
+ return $this->_resultSendOrder;
47
+ }
48
+
49
+ public function isUnderVersion14() {
50
+ if (is_null($this->_isUnderVersion14)) {
51
+ $this->_isUnderVersion14 = $this->getHelper()->isUnderVersion14();
52
+ }
53
+ return $this->_isUnderVersion14;
54
+ }
55
+
56
+ /**
57
+ * Retrieve product model cache
58
+ *
59
+ * @return Mage_Catalog_Model_Product
60
+ */
61
+ public function getProductModel() {
62
+ if (is_null($this->_productModel)) {
63
+ $productModel = Mage::getModel('profileolabs_shoppingflux/manageorders_product');
64
+ $this->_productModel = Mage::objects()->save($productModel);
65
+ }
66
+ return Mage::objects()->load($this->_productModel);
67
+ }
68
+
69
+ public function getOrderIdsAlreadyImported() {
70
+ if (is_null($this->_orderIdsAlreadyImported)) {
71
+ $orders = Mage::getModel('sales/order')->getCollection()
72
+ ->addAttributeToFilter('from_shoppingflux', 1)
73
+ ->addAttributeToSelect('order_id_shoppingflux');
74
+
75
+ $this->_orderIdsAlreadyImported = array();
76
+ foreach ($orders as $order) {
77
+ $this->_orderIdsAlreadyImported[] = $order->getOrderIdShoppingflux();
78
+ }
79
+ }
80
+
81
+ return $this->_orderIdsAlreadyImported;
82
+ }
83
+
84
+ public function isAlreadyImported($idShoppingflux) {
85
+ $alreadyImported = $this->getOrderIdsAlreadyImported();
86
+ if (in_array($idShoppingflux, $alreadyImported))
87
+ return true;
88
+
89
+ return false;
90
+ }
91
+
92
+ public function getSession() {
93
+ return Mage::getSingleton('checkout/session');
94
+ }
95
+
96
+ protected function _getQuote($storeId=null) {
97
+ return $this->getSession()->getQuote();
98
+ }
99
+
100
+ /**
101
+ * Retrieve config
102
+ * @return Profileolabs_Shoppingflux_Model_Manageorders_Config
103
+ */
104
+ public function getConfig() {
105
+ if (is_null($this->_config)) {
106
+ $this->_config = Mage::getSingleton('profileolabs_shoppingflux/config');
107
+ }
108
+
109
+ return $this->_config;
110
+ }
111
+
112
+ /**
113
+ * Get orders and create it
114
+ */
115
+ public function manageOrders() {
116
+ $stores = Mage::app()->getStores();
117
+
118
+ if (Mage::app()->getStore()->getCode() != 'admin')
119
+ Mage::app()->setCurrentStore('admin');
120
+
121
+ $apiKeyManaged = array();
122
+
123
+ //old module version compliance. The goal is to use default store, as in previous versions, if api key is set in global scope.
124
+ $defaultStoreId = Mage::app()->getDefaultStoreView()->getId();
125
+ if(key($stores) != $defaultStoreId) {
126
+ $tmpStores = array($defaultStoreId=>$stores[$defaultStoreId]);
127
+ foreach($stores as $store) {
128
+ if($store->getId() != $defaultStoreId) {
129
+ $tmpStores[$store->getId()] = $store;
130
+ }
131
+ }
132
+ $stores = $tmpStores;
133
+ }
134
+ //old module version compliance end
135
+
136
+
137
+ foreach ($stores as $_store) {
138
+ $storeId = $_store->getId();
139
+ if ($this->getConfig()->isOrdersEnabled($storeId)) {
140
+ $apiKey = $this->getConfig()->getApiKey($storeId);
141
+
142
+ if(!$apiKey || in_array($apiKey, $apiKeyManaged))
143
+ continue;
144
+ $apiKeyManaged[] = $apiKey;
145
+
146
+ $wsUri = $this->getConfig()->getWsUri();
147
+
148
+ //$isUnderVersion14 = $this->getHelper()->isUnderVersion14();
149
+
150
+ /* @var $service Profileolabs_Shoppingflux_Model_Service */
151
+ $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
152
+ ini_set("memory_limit", "512M");
153
+ try {
154
+
155
+ /* @var $this->_result Varien_Simplexml_Element */
156
+ $this->_result = $service->getOrders();
157
+
158
+ $this->_nb_orders_imported = 0;
159
+ } catch (Exception $e) {
160
+ Mage::logException($e);
161
+ $message = Mage::helper('profileolabs_shoppingflux')->__('Orders can not getted.'); //." ".Mage::helper('profileolabs_shoppingflux')->__('Error').": ".$e->getMessage();
162
+ $this->getHelper()->log($message);
163
+ //Mage::throwException($message);
164
+
165
+ Mage::throwException($e);
166
+ }
167
+
168
+ //We parse result
169
+ //$nodes = current($this->_result->children());
170
+ $nodes = $this->_result->children();
171
+ foreach ($nodes as $childName => $child) {
172
+
173
+ $orderSf = $this->getHelper()->asArray($child);
174
+
175
+
176
+ if ($this->isAlreadyImported($orderSf['IdOrder']))
177
+ continue;
178
+
179
+
180
+ $this->_nb_orders_read++;
181
+
182
+ $this->createAllForOrder($orderSf, $storeId);
183
+
184
+ if ($this->_nb_orders_imported == $this->getConfig()->getLimitOrders($storeId))
185
+ break;
186
+ }
187
+
188
+ try {
189
+ if ($this->_nb_orders_imported > 0) {
190
+
191
+ $result = $service->sendValidOrders($this->_ordersIdsImported);
192
+
193
+
194
+ if ($result) {
195
+ if ($result->error) {
196
+ Mage::throwException($result->error);
197
+ }
198
+
199
+ $this->_resultSendOrder = $result->status;
200
+ } else {
201
+ $this->getHelper()->log("Error in order ids validated");
202
+ Mage::throwException("Error in order ids validated");
203
+ }
204
+ }
205
+ } catch (Exception $e) {
206
+ $this->getHelper()->log($e->getMessage());
207
+ Mage::throwException($e);
208
+ }
209
+ }
210
+ }
211
+ return $this;
212
+ }
213
+
214
+ /**
215
+ * Inititalize the quote with minimum requirement
216
+ * @param array $orderSf
217
+ */
218
+ protected function _initQuote(array $orderSf, $storeId) {
219
+
220
+ if(is_null($storeId)) {//just in case..
221
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
222
+ }
223
+
224
+ $this->_getQuote()->setStoreId($storeId);
225
+
226
+ //Super mode is setted to bypass check item qty ;)
227
+ $this->_getQuote()->setIsSuperMode(true);
228
+
229
+ //Set boolean shopping flux and shipping prices in session for shopping method
230
+ $this->getSession()->setIsShoppingFlux(true);
231
+ //$this->getSession()->setShippingPrice((float)$orderSf['TotalShipping']);
232
+
233
+ $this->_getQuote()->setCustomer($this->_customer);
234
+ }
235
+
236
+ /**
237
+ * Create or Update customer with converter
238
+ * @param array $data Data From ShoppingFlux
239
+ */
240
+ protected function _createCustomer(array $data, $storeId) {
241
+ try {
242
+
243
+ /* @var $convert_customer Profileolabs_Shoppingflux_Model_Manageorders_Convert_Customer */
244
+ $convert_customer = Mage::getModel('profileolabs_shoppingflux/manageorders_convert_customer');
245
+
246
+ $this->_customer = $convert_customer->toCustomer(current($data['BillingAddress']), $storeId);
247
+ $billingAddress = $convert_customer->addresstoCustomer(current($data['BillingAddress']), $storeId, $this->_customer);
248
+
249
+ $this->_customer->addAddress($billingAddress);
250
+
251
+ $shippingAddress = $convert_customer->addresstoCustomer(current($data['ShippingAddress']), $storeId, $this->_customer, 'shipping');
252
+ $this->_customer->addAddress($shippingAddress);
253
+ $customerGroupId = $this->getConfig()->getCustomerGroupIdFor($data['Marketplace'], $storeId);
254
+ if ($customerGroupId) {
255
+ $this->_customer->setGroupId($customerGroupId);
256
+ }
257
+ $this->_customer->save();
258
+ } catch (Exception $e) {
259
+ Mage::throwException($e);
260
+ }
261
+ }
262
+
263
+ public function createAllForOrder($orderSf, $storeId) {
264
+ try {
265
+
266
+ //$this->_quote = null;
267
+ $this->_customer = null;
268
+
269
+
270
+ //Create or Update customer with addresses
271
+ $this->_createCustomer($orderSf, $storeId);
272
+
273
+ $this->_initQuote($orderSf, $storeId);
274
+
275
+ //Add products to quote with data from ShoppingFlux
276
+ $this->_addProductsToQuote($orderSf);
277
+
278
+ $order = null;
279
+ if (!$this->isUnderVersion14())
280
+ $order = $this->_saveOrder($orderSf);
281
+ else
282
+ $order = $this->_saveOrder13($orderSf);
283
+
284
+
285
+ $this->_nb_orders_imported++;
286
+
287
+ if (!is_null($order) && $order->getId())
288
+ $this->_changeDateCreatedAt($order, $orderSf['OrderDate']);
289
+
290
+ //Erase session for the next order
291
+ $this->getSession()->clear();
292
+ } catch (Exception $e) {
293
+ $this->getHelper()->log($e->getMessage(), $orderSf['IdOrder']);
294
+ //Erase session for the next order
295
+ $this->getSession()->clear();
296
+ }
297
+ }
298
+
299
+ protected function _changeDateCreatedAt($order, $date) {
300
+ try {
301
+
302
+ $order->setCreatedAt($date);
303
+ //$order->setUpdatedAt($date);
304
+ $order->save();
305
+ } catch (Exception $e) {
306
+ Mage::logException($e);
307
+ Mage::throwException($message);
308
+ }
309
+ }
310
+
311
+ /**
312
+ * Add products to quote with data from ShoppinfFlux
313
+ * @param array $orderSf
314
+ */
315
+ protected function _addProductsToQuote(array $orderSf) {
316
+ $totalAmount = $orderSf['TotalAmount'];
317
+ $productsSf = current($orderSf['Products']);
318
+ $productsToIterate = current($productsSf);
319
+
320
+
321
+
322
+
323
+ if (!$this->_customer->getDefaultBilling() || !$this->_customer->getDefaultShipping())
324
+ $this->_customer->load($this->_customer->getId());
325
+
326
+ $customerAddressBillingId = $this->_customer->getDefaultBilling();
327
+ $customerAddressShippingId = $this->_customer->getDefaultShipping();
328
+
329
+ //Set billing Address
330
+ $addressBilling = $this->_getQuote()->getBillingAddress();
331
+ //Make sure addresses will be saved without validation errors
332
+ $addressBilling->setShouldIgnoreValidation(true);
333
+ $customerAddressBilling = Mage::getModel('customer/address')->load($customerAddressBillingId);
334
+ $addressBilling->importCustomerAddress($customerAddressBilling)->setSaveInAddressBook(0);
335
+
336
+ //Set shipping Address
337
+ $addressShipping = $this->_getQuote()->getShippingAddress();
338
+ //Make sure addresses will be saved without validation errors
339
+ $addressShipping->setShouldIgnoreValidation(true);
340
+ $customerAddressShipping = Mage::getModel('customer/address')->load($customerAddressShippingId);
341
+ $addressShipping->importCustomerAddress($customerAddressShipping)->setSaveInAddressBook(0);
342
+ $addressShipping->setSameAsBilling(0);
343
+
344
+
345
+ //Convert shipping price by tax rate
346
+ $shippingPrice = (float) $orderSf['TotalShipping'];
347
+ $this->getSession()->setShippingPrice($shippingPrice);
348
+ if (!Mage::helper('tax')->shippingPriceIncludesTax() && Mage::helper('tax')->getShippingTaxClass(null)) {
349
+ $percent = null;
350
+ $pseudoProduct = new Varien_Object();
351
+ $pseudoProduct->setTaxClassId(Mage::helper('tax')->getShippingTaxClass(null));
352
+
353
+ $taxClassId = $pseudoProduct->getTaxClassId();
354
+ if (is_null($percent)) {
355
+ if ($taxClassId) {
356
+ $request = Mage::getSingleton('tax/calculation')->getRateRequest($addressShipping, $addressBilling, null, null);
357
+ $request->setProductClassId($taxClassId);
358
+ $request->setCustomerClassId($this->_getQuote()->getCustomerTaxClassId());
359
+ $percent = Mage::getSingleton('tax/calculation')->getRate($request);
360
+
361
+ if ($percent !== false || !is_null($percent)) {
362
+
363
+ $shippingPrice = $shippingPrice - ($shippingPrice / (100 + $percent) * $percent);
364
+ $this->getSession()->setShippingPrice($shippingPrice);
365
+ }
366
+ }
367
+ }
368
+
369
+ //Mage::log("including tax = ".$includingTax." shipping price = ".$shippingPrice,null,'test_shipping_price.log');
370
+ }
371
+
372
+ //Set shipping Mehtod and collect shipping rates
373
+ $addressShipping->setShippingMethod($this->_shippingMethod)->setCollectShippingRates(true);
374
+
375
+
376
+
377
+
378
+ foreach ($productsToIterate as $key => $productSf) {
379
+
380
+ $sku = $productSf['SKU'];
381
+
382
+ if (($productId = $this->getProductModel()->getResource()->getIdBySku($sku)) != false) {
383
+ $product = Mage::getModel('profileolabs_shoppingflux/manageorders_product')->load($productId); // $this->getProductModel()->reset()->load($productId);
384
+
385
+ $request = new Varien_Object(array('qty' => $productSf['Quantity']));
386
+ if ($product->getTypeId() == 'simple' && $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) {
387
+
388
+ $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
389
+ ->getParentIdsByChild($product->getId());
390
+
391
+ if (count($parentIds)) {
392
+ $parentId = current($parentIds);
393
+
394
+ $attributesConf = $this->getHelper()->getAttributesConfigurable($parentId);
395
+ $superAttributes = array();
396
+
397
+ foreach ($attributesConf as $attribute) {
398
+
399
+ $attributeCode = $attribute['attribute_code'];
400
+ $attributeId = $attribute['attribute_id'];
401
+
402
+ $superAttributes[$attributeId] = $product->getData($attributeCode);
403
+ }
404
+
405
+ $product = Mage::getModel('profileolabs_shoppingflux/manageorders_product')->load($parentId);
406
+
407
+ $request->setData('super_attribute', $superAttributes);
408
+ }
409
+ }
410
+
411
+
412
+ $item = $this->_getQuote()->addProduct($product, $request);
413
+
414
+ if (!is_object($item)) {
415
+ $this->getSession()->clear();
416
+ Mage::throwException("le produit sku = " . $sku . " n'a pas pu être ajouté! Id = " . $product->getId() . " Item = " . (string) $item);
417
+ }
418
+
419
+
420
+ //Save the quote with the new product
421
+ $this->_getQuote()->save();
422
+
423
+
424
+ $unitPrice = $productSf['Price'];
425
+ if($this->getConfig()->applyTax() && !Mage::helper('tax')->priceIncludesTax()) {
426
+ $taxClassId = $product->getTaxClassId();
427
+ $request = Mage::getSingleton('tax/calculation')->getRateRequest($addressShipping, $addressBilling, null, null);
428
+ $request->setProductClassId($taxClassId);
429
+ $request->setCustomerClassId($this->_getQuote()->getCustomerTaxClassId());
430
+ $percent = Mage::getSingleton('tax/calculation')->getRate($request);
431
+ $unitPrice = $unitPrice / (1+$percent/100);
432
+ }
433
+
434
+
435
+ //Modify Item price
436
+ $item->setCustomPrice($unitPrice);
437
+ $item->setOriginalCustomPrice($unitPrice);
438
+ $item->save();
439
+
440
+ if (is_object($parentItem = $item->getParentItem())) {
441
+ $parentItem->setCustomPrice($unitPrice);
442
+ $parentItem->setOriginalCustomPrice($unitPrice);
443
+ $parentItem->save();
444
+ }
445
+
446
+ //Mage::log(print_r($item->debug(),true),null,'debug_items.log');
447
+ } else {
448
+
449
+ $this->getSession()->clear();
450
+ Mage::throwException("le produit sku = " . $sku . " n'existe plus en base!");
451
+ }
452
+ }
453
+
454
+
455
+ $this->_getQuote()->collectTotals();
456
+ $this->_getQuote()->save();
457
+
458
+ //Set payment method
459
+ /* @var $payment Mage_Sales_Quote_Payment */
460
+ $this->_getQuote()->getShippingAddress()->setPaymentMethod($this->_paymentMethod);
461
+ $payment = $this->_getQuote()->getPayment();
462
+ $dataPayment = array('method' => $this->_paymentMethod, 'marketplace' => $orderSf['Marketplace']);
463
+ $payment->importData($dataPayment);
464
+ //$addressShipping->setShippingMethod($this->_shippingMethod)->setCollectShippingRates(true);
465
+
466
+ $this->_getQuote()->collectTotals();
467
+ $this->_getQuote()->save();
468
+ }
469
+
470
+ /**
471
+ * Save the new order with the quote
472
+ * @param array $orderSf
473
+ */
474
+ protected function _saveOrder(array $orderSf) {
475
+ $orderIdShoppingFlux = (string) $orderSf['IdOrder'];
476
+ $additionalData = array("from_shoppingflux" => 1,
477
+ "marketplace_shoppingflux" => $orderSf['Marketplace'],
478
+ "fees_shoppingflux" => (float) (isset($orderSf['Fees'])?$orderSf['Fees']:0),
479
+ "order_id_shoppingflux" => $orderIdShoppingFlux);
480
+
481
+ /* @var $service Mage_Sales_Model_Service_Quote */
482
+ $service = Mage::getModel('sales/service_quote', $this->_getQuote());
483
+ $service->setOrderData($additionalData);
484
+ $order = false;
485
+ if (method_exists($service, "submitAll")) {
486
+
487
+ $service->submitAll();
488
+ $order = $service->getOrder();
489
+ } else {
490
+ $order = $service->submit();
491
+ }
492
+
493
+ if ($order) {
494
+ $newStatus = $this->getConfig()->getConfigData('shoppingflux_mo/manageorders/new_order_status', $order->getStoreId());
495
+ if($newStatus) {
496
+ $order->setStatus($newStatus);
497
+ $order->save();
498
+ }
499
+
500
+
501
+
502
+ $this->_saveInvoice($order);
503
+
504
+
505
+ $processingStatus = $this->getConfig()->getConfigData('shoppingflux_mo/manageorders/processing_order_status', $order->getStoreId());
506
+ if($processingStatus) {
507
+ $order->setStatus($processingStatus);
508
+ $order->save();
509
+ }
510
+
511
+ //Set array with shopping flux ids
512
+ $this->_ordersIdsImported[$orderIdShoppingFlux] = $orderSf['Marketplace'];
513
+
514
+ return $order;
515
+ }
516
+
517
+ return null;
518
+ }
519
+
520
+ protected function _saveOrder13(array $orderSf) {
521
+ $orderIdShoppingFlux = (string) $orderSf['IdOrder'];
522
+ $additionalData = array("from_shoppingflux" => 1,
523
+ "marketplace_shoppingflux" => $orderSf['Marketplace'],
524
+ "fees_shoppingflux" => (float) (isset($orderSf['Fees'])?$orderSf['Fees']:0.0),
525
+ "order_id_shoppingflux" => $orderIdShoppingFlux);
526
+
527
+
528
+ $billing = $this->_getQuote()->getBillingAddress();
529
+ $shipping = $this->_getQuote()->getShippingAddress();
530
+
531
+ $this->_getQuote()->reserveOrderId();
532
+ $convertQuote = Mage::getModel('sales/convert_quote');
533
+ /* @var $convertQuote Mage_Sales_Model_Convert_Quote */
534
+
535
+ $order = $convertQuote->addressToOrder($shipping);
536
+
537
+ $order->addData($additionalData);
538
+
539
+ /* @var $order Mage_Sales_Model_Order */
540
+ $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
541
+ $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
542
+
543
+ $order->setPayment($convertQuote->paymentToOrderPayment($this->_getQuote()->getPayment()));
544
+
545
+ foreach ($this->_getQuote()->getAllItems() as $item) {
546
+ $orderItem = $convertQuote->itemToOrderItem($item);
547
+ if ($item->getParentItem()) {
548
+ $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
549
+ }
550
+ $order->addItem($orderItem);
551
+ }
552
+
553
+ /**
554
+ * We can use configuration data for declare new order status
555
+ */
556
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order' => $order, 'quote' => $this->getQuote()));
557
+ //Mage::throwException(print_r($order->getData(),true));
558
+ //die("<pre> DIE = ".print_r($order->getData()));
559
+ $order->place();
560
+
561
+ $order->setCustomerId($this->_getQuote()->getCustomer()->getId());
562
+
563
+ $order->setEmailSent(false);
564
+ $order->save();
565
+
566
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order' => $order, 'quote' => $this->getQuote()));
567
+
568
+ $this->_getQuote()->setIsActive(false);
569
+ $this->_getQuote()->save();
570
+
571
+ ///////////////////////////////////////////////////////////////////////////
572
+
573
+ if ($order) {
574
+
575
+ $this->_saveInvoice($order);
576
+
577
+ //Set array with shopping flux ids
578
+ $this->_ordersIdsImported[$orderIdShoppingFlux] = $orderSf['Marketplace'];
579
+
580
+ return $order;
581
+ }
582
+
583
+ return null;
584
+ }
585
+
586
+ /**
587
+ * Create and Save invoice for the new order
588
+ * @param Mage_Sales_Model_Order $order
589
+ */
590
+ protected function _saveInvoice($order) {
591
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order' => $order, 'quote' => $this->_getQuote()));
592
+
593
+ if (!$this->getConfig()->createInvoice()) {
594
+ return $this;
595
+ }
596
+
597
+ //Prepare invoice and save it
598
+ $path = Mage::getBaseDir() . "/app/code/core/Mage/Sales/Model/Service/Order.php";
599
+ $invoice = false;
600
+ if (file_exists($path))
601
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
602
+ else
603
+ $invoice = $this->_initInvoice($order);
604
+
605
+ if ($invoice) {
606
+ $invoice->register();
607
+ $invoice->getOrder()->setCustomerNoteNotify(false);
608
+ $invoice->getOrder()->setIsInProcess(true);
609
+
610
+
611
+
612
+ $transactionSave = Mage::getModel('core/resource_transaction')
613
+ ->addObject($invoice)
614
+ ->addObject($invoice->getOrder());
615
+ $transactionSave->save();
616
+ }
617
+ }
618
+
619
+ /**
620
+ * Initialize invoice
621
+ * @param Mage_Sales_Model_Order $order
622
+ * @return Mage_Sales_Model_Order_Invoice $invoice
623
+ */
624
+ protected function _initInvoice($order) {
625
+
626
+ $convertor = Mage::getModel('sales/convert_order');
627
+ $invoice = $convertor->toInvoice($order);
628
+ $update = false;
629
+ $savedQtys = array();
630
+ $itemsToInvoice = 0;
631
+ /* @var $orderItem Mage_Sales_Model_Order_Item */
632
+ foreach ($order->getAllItems() as $orderItem) {
633
+
634
+ if (!$orderItem->isDummy() && !$orderItem->getQtyToInvoice() && $orderItem->getLockedDoInvoice()) {
635
+ continue;
636
+ }
637
+
638
+ if ($order->getForcedDoShipmentWithInvoice() && $orderItem->getLockedDoShip()) {
639
+ continue;
640
+ }
641
+
642
+ if (!$update && $orderItem->isDummy() && !empty($savedQtys) && !$this->_needToAddDummy($orderItem, $savedQtys)) {
643
+ continue;
644
+ }
645
+ $item = $convertor->itemToInvoiceItem($orderItem);
646
+
647
+ if (isset($savedQtys[$orderItem->getId()])) {
648
+ $qty = $savedQtys[$orderItem->getId()];
649
+ } else {
650
+ if ($orderItem->isDummy()) {
651
+ $qty = 1;
652
+ } else {
653
+ $qty = $orderItem->getQtyToInvoice();
654
+ }
655
+ }
656
+ $itemsToInvoice += floatval($qty);
657
+ $item->setQty($qty);
658
+ $invoice->addItem($item);
659
+
660
+ if ($itemsToInvoice <= 0) {
661
+ Mage::throwException($this->__('Invoice without products could not be created.'));
662
+ }
663
+ }
664
+
665
+
666
+ $invoice->collectTotals();
667
+
668
+ return $invoice;
669
+ }
670
+
671
+ /**
672
+ * Get Helper
673
+ * @return Profileolabs_Shoppingflux_Model_Manageorders_Helper_Data
674
+ */
675
+ public function getHelper() {
676
+ return Mage::helper('profileolabs_shoppingflux');
677
+ }
678
+
679
+ public function getNbOrdersImported() {
680
+ return $this->_nb_orders_imported;
681
+ }
682
+
683
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Payment/Method/Purchaseorder.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ShoppingFlux
4
+ * @package Profileolabs_Shoppingflux
5
+ * @author kassim belghait
6
+ */
7
+
8
+
9
+
10
+ class Profileolabs_Shoppingflux_Model_Manageorders_Payment_Method_Purchaseorder extends Mage_Payment_Model_Method_Abstract
11
+ {
12
+ protected $_code = 'shoppingflux_purchaseorder';
13
+ //protected $_formBlockType = 'payment/form_purchaseorder';
14
+ protected $_infoBlockType = 'profileolabs_shoppingflux/manageorders_payment_info_purchaseorder';
15
+
16
+ /**
17
+ * Assign data to info model instance
18
+ *
19
+ * @param mixed $data
20
+ * @return Profileolabs_Shoppingflux_Model_Manageorders_Payment_Method_Purchaseorder
21
+ */
22
+ public function assignData($data)
23
+ {
24
+ if (!($data instanceof Varien_Object)) {
25
+ $data = new Varien_Object($data);
26
+ }
27
+
28
+ $this->getInfoInstance()->setAdditionalData($data->getMarketplace());
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Check whether payment method can be used
34
+ * TODO: payment method instance is not supposed to know about quote
35
+ * @param Mage_Sales_Model_Quote
36
+ * @return bool
37
+ */
38
+ public function isAvailable($quote = null)
39
+ {
40
+ if(Mage::getSingleton('checkout/session')->getIsShoppingFlux())
41
+ return true;
42
+
43
+ return parent::isAvailable($quote);
44
+ }
45
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Product.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Manageorders_Product extends Mage_Catalog_Model_Product {
10
+
11
+ public function getOptions() {
12
+ return array();
13
+ }
14
+
15
+ public function getHasOptions() {
16
+ return false;
17
+ }
18
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Shipping/Carrier/Shoppingflux.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * ShoppingFLux shipping model
5
+ *
6
+ * @category ShoppingFlux
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author kassim belghait
9
+ */
10
+ class Profileolabs_Shoppingflux_Model_Manageorders_Shipping_Carrier_Shoppingflux
11
+ extends Mage_Shipping_Model_Carrier_Abstract
12
+ implements Mage_Shipping_Model_Carrier_Interface
13
+ {
14
+
15
+ protected $_code = 'shoppingflux';
16
+ protected $_isFixed = true;
17
+
18
+ /**
19
+ * FreeShipping Rates Collector
20
+ *
21
+ * @param Mage_Shipping_Model_Rate_Request $request
22
+ * @return Mage_Shipping_Model_Rate_Result
23
+ */
24
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
25
+ {
26
+ if (!$this->isActive()) {
27
+ return false;
28
+ }
29
+
30
+ $result = Mage::getModel('shipping/rate_result');
31
+
32
+ $method = Mage::getModel('shipping/rate_result_method');
33
+
34
+ $method->setCarrier('shoppingflux');
35
+ $method->setCarrierTitle($this->getConfigData('title'));
36
+
37
+ $method->setMethod('shoppingflux');
38
+ $method->setMethodTitle($this->getConfigData('name'));
39
+
40
+ $method->setPrice($this->getSession()->getShippingPrice());
41
+ $method->setCost($this->getSession()->getShippingPrice());
42
+
43
+ $result->append($method);
44
+
45
+
46
+ return $result;
47
+ }
48
+
49
+ /**
50
+ * Processing additional validation to check is carrier applicable.
51
+ *
52
+ * @param Mage_Shipping_Model_Rate_Request $request
53
+ * @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean
54
+ */
55
+ public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request)
56
+ {
57
+ if(Mage::getVersion() == '1.4.1.0')
58
+ return $this->isActive();
59
+
60
+ return parent::proccessAdditionalValidation($request);
61
+ }
62
+
63
+ public function getSession()
64
+ {
65
+ return Mage::getSingleton('checkout/session');
66
+ }
67
+
68
+ public function isActive()
69
+ {
70
+ if($this->getSession()->getIsShoppingFlux())
71
+ return true;
72
+
73
+ return false;
74
+ }
75
+
76
+ public function getAllowedMethods()
77
+ {
78
+ return array('shoppingflux'=>$this->getConfigData('name'));
79
+ }
80
+
81
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Shipping/Method.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ShoppingFlux
4
+ * @package Profileolabs_Shoppingflux
5
+ * @author Vincent Enjalbert @ Web-cooking.net
6
+ */
7
+ class Profileolabs_Shoppingflux_Model_Manageorders_Shipping_Method extends Mage_Core_Model_Abstract
8
+ {
9
+ protected function _construct()
10
+ {
11
+ $this->_init('profileolabs_shoppingflux/manageorders_shipping_method');
12
+ }
13
+
14
+
15
+
16
+ public function getFullShippingMethodCodeFor($marketplace, $shippingMethod) {
17
+ $code = $marketplace . '_' . $shippingMethod;
18
+ $code = strtolower($code);
19
+ $code = preg_replace('%\s+%i', '_', $code);
20
+ return $code;
21
+ }
22
+
23
+ public function getFullShippingMethodCode() {
24
+ return $this->getFullShippingMethodCodeFor($this->getMarketplace(), $this->getShippingMethod());
25
+ }
26
+
27
+ public function loadByMethod($marketplace, $shippingMethod) {
28
+ $collection = $this->getCollection();
29
+ $collection->addFieldToFilter('marketplace', $marketplace);
30
+ $collection->addFieldToFilter('shipping_method', $shippingMethod);
31
+ if($collection->count() <= 0) {
32
+ $this->setId(null);
33
+ $this->setMarketplace($marketplace);
34
+ $this->setShippingMethod($shippingMethod);
35
+ return $this;
36
+ }
37
+ return $collection->getFirstItem();
38
+ }
39
+
40
+ public function saveShippingMethod($marketplace, $shippingMethod) {
41
+ $model = $this->loadByMethod($marketplace, $shippingMethod);
42
+ $model->setLastSeenAt(date('Y-m-d H:i:s'));
43
+ $model->save();
44
+ }
45
+
46
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Flux.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Mysql4_Export_Flux extends Mage_Core_Model_Mysql4_Abstract {
10
+
11
+ protected function _construct() {
12
+ $this->_init('profileolabs_shoppingflux/export_flux', 'id');
13
+ }
14
+
15
+
16
+
17
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Flux/Collection.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Mysql4_Export_Flux_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+ protected function _construct()
12
+ {
13
+ $this->_init('profileolabs_shoppingflux/export_flux');
14
+ }
15
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Updates.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Mysql4_Export_Updates extends Mage_Core_Model_Mysql4_Abstract {
10
+
11
+ protected function _construct() {
12
+ $this->_init('profileolabs_shoppingflux/export_updates', 'update_id');
13
+ }
14
+
15
+
16
+
17
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Updates/Collection.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Mysql4_Export_Updates_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+ protected function _construct()
12
+ {
13
+ $this->_init('profileolabs_shoppingflux/export_updates');
14
+ }
15
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Export/Shipments.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category ShoppingFlux
4
+ * @package Profileolabs_Shoppingflux
5
+ * @author Vincent Enjalbert @ Web-cooking.net
6
+ */
7
+ class Profileolabs_Shoppingflux_Model_Mysql4_Manageorders_Export_Shipments extends Mage_Core_Model_Mysql4_Abstract
8
+ {
9
+ protected function _construct()
10
+ {
11
+ $this->_init('profileolabs_shoppingflux/manageorders_export_shipments','update_id');
12
+ }
13
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Export/Shipments/Collection.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author Vincent Enjalbert @ Web-cooking.net
7
+ */
8
+ class Profileolabs_Shoppingflux_Model_Mysql4_Manageorders_Export_Shipments_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
9
+
10
+ protected function _construct() {
11
+ $this->_init('profileolabs_shoppingflux/manageorders_export_shipments');
12
+ }
13
+
14
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Log.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Error Log
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author kassim belghait
7
+ *
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Mysql4_Manageorders_Log extends Mage_Core_Model_Mysql4_Abstract
10
+ {
11
+ protected function _construct()
12
+ {
13
+ $this->_init('profileolabs_shoppingflux/manageorders_log','id');
14
+ }
15
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Log/Collection.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Error Log
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author kassim belghait
7
+ *
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Mysql4_Manageorders_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+ protected function _construct()
12
+ {
13
+ $this->_init('profileolabs_shoppingflux/manageorders_log');
14
+ }
15
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Shipping/Method.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Error Log
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author kassim belghait
7
+ *
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Mysql4_Manageorders_Shipping_Method extends Mage_Core_Model_Mysql4_Abstract
10
+ {
11
+ protected function _construct()
12
+ {
13
+ $this->_init('profileolabs_shoppingflux/manageorders_shipping_method','id');
14
+ }
15
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Shipping/Method/Collection.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Error Log
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author kassim belghait
7
+ *
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Mysql4_Manageorders_Shipping_Method_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+ protected function _construct()
12
+ {
13
+ $this->_init('profileolabs_shoppingflux/manageorders_shipping_method');
14
+ }
15
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Service.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux Service
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author kassim belghait, vincent enjalbert @ web-cooking.net
8
+ */
9
+ class Profileolabs_Shoppingflux_Model_Service extends Varien_Object {
10
+ /**
11
+ * Order status
12
+ */
13
+
14
+ const ORDER_STATUS_SHIPPED = 'Shipped';
15
+ const ORDER_STATUS_CANCELED = 'Canceled';
16
+
17
+ /**
18
+ * Method's names
19
+ */
20
+ const METHOD_GET_ORDERS = "GetOrders";
21
+ const METHOD_VALIDATE_ORDERS = "ValidOrders";
22
+ const METHOD_UPDATE_ORDERS = "UpdateOrders";
23
+ const METHOD_UPDATE_PRODUCT = "UpdateProduct";
24
+ const METHOD_LOGIN = "getLogin";
25
+
26
+ /**
27
+ *
28
+ * @var Zend_Http_Client
29
+ */
30
+ protected $_client = null;
31
+
32
+ /**
33
+ *
34
+ * @var SimpleXMLElement
35
+ */
36
+ protected $_xml = null;
37
+ protected $_apiKey = null;
38
+ protected $_wsUri = null;
39
+
40
+ public function __construct($apiKey, $wsUri) {
41
+ $this->_apiKey = $apiKey;
42
+ $this->_wsUri = $wsUri;
43
+ }
44
+
45
+ protected function _getApiKey() {
46
+ return $this->_apiKey;
47
+ }
48
+
49
+ /**
50
+ * Get client HTTP
51
+ * @return Zend_Http_Client
52
+ */
53
+ public function getClient() {
54
+ if (is_null($this->_client)) {
55
+ //adapter options
56
+ $config = array('curloptions' => array(/* CURLOPT_FOLLOWLOCATION => true, */
57
+ //CURLOPT_POST=>true,
58
+ CURLOPT_SSL_VERIFYHOST => 0,
59
+ CURLOPT_SSL_VERIFYPEER => 0,
60
+ CURLOPT_HEADER => false,
61
+ CURLOPT_RETURNTRANSFER => true,
62
+ CURLOPT_CONNECTTIMEOUT => 20,
63
+ CURLOPT_TIMEOUT => 100),
64
+ );
65
+ try {
66
+
67
+ //innitialize http lcient and adapter curl
68
+ //$adapter = new Zend_Http_Client_Adapter_Curl();
69
+ $adapter = new Profileolabs_Shoppingflux_Model_Service_Http_Client_Adapter_Curl();
70
+ $this->_client = new Zend_Http_Client($this->_wsUri);
71
+ $this->_client->setAdapter($adapter);
72
+ $adapter->setConfig($config);
73
+ } catch (Exception $e) {
74
+ Mage::throwException($e);
75
+ }
76
+ }
77
+
78
+ return $this->_client;
79
+ }
80
+
81
+ /**
82
+ * Connect to Shopping Flux and Call method
83
+ *
84
+ * @param string $apiKey
85
+ * @param string $method
86
+ */
87
+ protected function _connect($apiKey, $method, $request='') {
88
+ if (empty($apiKey)) {
89
+ Mage::throwException("API Key (Token) is empty");
90
+ }
91
+ $mode = Mage::getSingleton('profileolabs_shoppingflux/config')->isSandbox() ? 'Sandbox' : 'Production';
92
+ $data = array("CALL" => $method, "TOKEN" => $apiKey, "MODE" => $mode, "REQUEST" => $request);
93
+ /* @var $response Zend_Http_Response */
94
+ //set Post Params
95
+ foreach ($data as $key => $val)
96
+ $this->getClient()->setParameterPost($key, $val);
97
+ //send the request
98
+ $response = $this->getClient()->request(Zend_Http_Client::POST);
99
+ //die($response->getBody());
100
+ //load response at xml (SimpleXMLElement)
101
+
102
+
103
+ $responseText = $response->getBody();
104
+ /*
105
+ $responseText = '<?xml version="1.0" encoding="utf-8"?>
106
+ <Result>
107
+ <Request>
108
+ <Date>2014-02-27T11:08:42+01:00</Date><Call>GetOrders</Call><Token>beea17ee07d2a87e444827c18a77e01d</Token><Mode>Sandbox</Mode><Version>2</Version>
109
+ </Request>
110
+ <Response>
111
+ <Orders>
112
+ <Order>
113
+ <IdOrder>402-8eeed340e085-1568300</IdOrder>
114
+ <Marketplace>Amazon</Marketplace>
115
+ <Currency>EUR</Currency>
116
+ <TotalAmount>299.00</TotalAmount>
117
+ <TotalProducts>299</TotalProducts>
118
+ <TotalShipping>0.00</TotalShipping>
119
+ <TotalFees>0</TotalFees>
120
+ <NumberOfProducts>1</NumberOfProducts>
121
+ <OrderDate>2014-02-27T12:08:40+01:00</OrderDate>
122
+ <Other></Other>
123
+ <ShippingMethod>Std FR Dom</ShippingMethod>
124
+ <BillingAddress><LastName>moon chan kim</LastName><FirstName></FirstName><Phone>0698750828</Phone><PhoneMobile></PhoneMobile><Street><![CDATA[121 rue du faubourg du temple etg 2, porte droit]]></Street><Street1><![CDATA[121 rue du faubourg du temple]]></Street1><Street2><![CDATA[etg 2, porte droit]]></Street2><Company><![CDATA[]]></Company><PostalCode>75010</PostalCode><Town><![CDATA[paris]]></Town><Country>FR</Country><Email>vbdels5s4sfpc98p7@marketplace.amazon.fr</Email></BillingAddress>
125
+ <ShippingAddress><LastName>moon chan kim</LastName><FirstName></FirstName><Phone>0698750828</Phone><PhoneMobile></PhoneMobile><Street><![CDATA[121 rue du faubourg du temple etg 2, porte droit]]></Street><Street1><![CDATA[121 rue du faubourg du temple]]></Street1><Street2><![CDATA[etg 2, porte droit]]></Street2><Company><![CDATA[]]></Company><PostalCode>75010</PostalCode><Town><![CDATA[paris]]></Town><Country>FR</Country><Email>vbldes5s4sfpc98p7@marketplace.amazon.fr</Email></ShippingAddress>
126
+ <Products>
127
+ <Product>
128
+ <SKU>Ordinateur</SKU>
129
+ <Quantity>1</Quantity>
130
+ <Price>299.000000</Price>
131
+ <Ecotax>0</Ecotax>
132
+ </Product>
133
+ </Products>
134
+ </Order>
135
+ </Orders>
136
+ </Response>
137
+ </Result>';
138
+ */
139
+
140
+ $this->_xml = simplexml_load_string($responseText, 'Varien_Simplexml_Element', LIBXML_NOCDATA);
141
+
142
+
143
+
144
+ //Mage::log($this->_xml,null,"flux_order.log");
145
+ //Mage::throwException(Mage::helper('profileolabs_shoppingflux')->__('TEST KASSIM'));
146
+
147
+
148
+ if (!($this->_xml instanceof Varien_Simplexml_Element))
149
+ Mage::throwException(Mage::helper('profileolabs_shoppingflux')->__("Result is not Varien_Simplexml_Element"));
150
+ elseif ($this->_xml->error)
151
+ Mage::throwException(Mage::helper('profileolabs_shoppingflux')->__('API key (Token) not valid'));
152
+
153
+ /* } catch (Exception $e) {
154
+ Mage::throwException($e);
155
+ } */
156
+
157
+ return $this->_xml;
158
+ }
159
+
160
+ /**
161
+ * Retrieve orders
162
+ *
163
+ */
164
+ public function getOrders() {
165
+ $data = $this->_connect($this->_getApiKey(), self::METHOD_GET_ORDERS);
166
+ return $data->Response->Orders;
167
+ }
168
+
169
+ /**
170
+ * Send orders ids imported
171
+ * @param array $orderIds
172
+ */
173
+ public function sendValidOrders(array $orderIds) {
174
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
175
+ $xml .= '<ValidOrders>';
176
+ foreach($orderIds as $orderId => $orderInfo) {
177
+ if(isset($orderInfo['ErrorOrder']) && $orderInfo['ErrorOrder'] !== false && !$orderInfo['ErrorOrder']) {
178
+ $orderInfo['ErrorOrder'] = 'Une erreur s\'est produite';
179
+ }
180
+ $xml .= '<Order>';
181
+ $xml .= '<IdOrder>' . $orderId . '</IdOrder>';
182
+ $xml .= '<Marketplace>' . $orderInfo['Marketplace'] . '</Marketplace>';
183
+ $xml .= '<MerchantIdOrder>' . $orderInfo['MageOrderId'] . '</MerchantIdOrder>';
184
+ if(isset($orderInfo['ErrorOrder']) && $orderInfo['ErrorOrder']) {
185
+ $xml .= '<ErrorOrder>' . $orderInfo['ErrorOrder'] . '</ErrorOrder>';
186
+ }
187
+ $xml .= '</Order>';
188
+ }
189
+ $xml .= '</ValidOrders>';
190
+
191
+
192
+ $dataObj = new Varien_Object(array('xml' => $xml));
193
+ Mage::dispatchEvent('shoppingflux_send_valid_orders', array('data_obj' => $dataObj));
194
+ $xml = $dataObj->getXml();
195
+ return $this->_connect($this->_getApiKey(), self::METHOD_VALIDATE_ORDERS, $xml);
196
+ }
197
+
198
+ /**
199
+ * Update orders id shipped
200
+ * @param string $orderId
201
+ */
202
+ public function updateShippedOrder($orderId, $marketplace, $status, $trackNum = '', $trackCarrier = '', $trackUrl = '') {
203
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
204
+ $xml .= '<UpdateOrders>';
205
+ $xml .= '<Order>';
206
+ $xml .= '<IdOrder>' . $orderId . '</IdOrder>';
207
+ $xml .= '<Marketplace>' . $marketplace . '</Marketplace>';
208
+ $xml .= '<Status>' . $status . '</Status>';
209
+ if ($trackNum) {
210
+ $xml .= '<TrackingNumber><![CDATA[' . $trackNum . ']]></TrackingNumber>';
211
+ }
212
+ if ($trackUrl) {
213
+ $xml .= '<TrackingUrl><![CDATA[' . $trackUrl . ']]></TrackingUrl>';
214
+ }
215
+ if ($trackCarrier) {
216
+ $xml .= '<CarrierName><![CDATA[' . $trackCarrier . ']]></CarrierName>';
217
+ }
218
+ $xml .= '</Order>';
219
+ $xml .= '</UpdateOrders>';
220
+ $dataObj = new Varien_Object(array('xml' => $xml));
221
+ Mage::dispatchEvent('shoppingflux_update_shipped_orders', array('data_obj' => $dataObj));
222
+ $xml = $dataObj->getXml();
223
+ return $this->_connect(
224
+ $this->_getApiKey(), self::METHOD_UPDATE_ORDERS, $xml
225
+ );
226
+ }
227
+
228
+ public function updateCanceledOrder($orderId, $marketplace, $status) {
229
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
230
+ $xml .= '<UpdateOrders>';
231
+ $xml .= '<Order>';
232
+ $xml .= '<IdOrder>' . $orderId . '</IdOrder>';
233
+ $xml .= '<Marketplace>' . $marketplace . '</Marketplace>';
234
+ $xml .= '<Status>' . $status . '</Status>';
235
+ $xml .= '</Order>';
236
+ $xml .= '</UpdateOrders>';
237
+ $dataObj = new Varien_Object(array('xml' => $xml));
238
+ Mage::dispatchEvent('shoppingflux_update_canceled_orders', array('data_obj' => $dataObj));
239
+ $xml = $dataObj->getXml();
240
+ return $this->_connect(
241
+ $this->_getApiKey(), self::METHOD_UPDATE_ORDERS, $xml
242
+ );
243
+ }
244
+
245
+
246
+ public function updateProducts($updates) {
247
+ if($updates->getSize() <=0) return;
248
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
249
+ $xml .= '<UpdateProduct>';
250
+ foreach($updates as $update) {
251
+ $xml .= '<Product>';
252
+ $xml .= '<SKU>' . $update->getProductSku() . '</SKU>';
253
+ $xml .= '<Quantity>' . $update->getStockValue() . '</Quantity>';
254
+ $xml .= '<Price>' . $update->getPriceValue() . '</Price>';
255
+ $xml .= '<OldPrice>' . $update->getOldPriceValue() . '</OldPrice>';
256
+ $xml .= '</Product>';
257
+ }
258
+ $xml .= '</UpdateProduct>';
259
+ $this->_connect(
260
+ $this->_getApiKey(), self::METHOD_UPDATE_PRODUCT, $xml
261
+ );
262
+ }
263
+
264
+ /**
265
+ * Retrieve login
266
+ * @param string|null $apiKey
267
+ */
268
+ public function getLogin($apiKey = null) {
269
+ if (is_null($apiKey))
270
+ $apiKey = $this->_getApiKey();
271
+
272
+ return $this->_connect($apiKey, self::METHOD_LOGIN);
273
+ }
274
+
275
+ /**
276
+ * Check if ApiKey is valid
277
+ * @param string $apiKey
278
+ */
279
+ public function checkApiKey($apiKey) {
280
+ if ($this->getLogin($apiKey)->error)
281
+ return false;
282
+
283
+ return true;
284
+ }
285
+
286
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Service/Http/Client/Adapter/Curl.php ADDED
@@ -0,0 +1,507 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Zend Framework
5
+ *
6
+ * LICENSE
7
+ *
8
+ * This source file is subject to the new BSD license that is bundled
9
+ * with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://framework.zend.com/license/new-bsd
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@zend.com so we can send you a copy immediately.
15
+ *
16
+ * @category Zend
17
+ * @package Zend_Http
18
+ * @subpackage Client_Adapter
19
+ * @version $Id: Curl.php 22216 2010-05-20 21:12:05Z dragonbe $
20
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
21
+ * @license http://framework.zend.com/license/new-bsd New BSD License
22
+ */
23
+
24
+ /**
25
+ * @see Zend_Uri_Http
26
+ */
27
+ #require_once 'Zend/Uri/Http.php';
28
+
29
+ /**
30
+ * @see Zend_Http_Client_Adapter_Interface
31
+ */
32
+ #require_once 'Zend/Http/Client/Adapter/Interface.php';
33
+ /**
34
+ * @see Zend_Http_Client_Adapter_Stream
35
+ */
36
+ #require_once 'Zend/Http/Client/Adapter/Stream.php';
37
+
38
+ /**
39
+ * An adapter class for Zend_Http_Client based on the curl extension.
40
+ * Curl requires libcurl. See for full requirements the PHP manual: http://php.net/curl
41
+ *
42
+ * @category Zend
43
+ * @package Zend_Http
44
+ * @subpackage Client_Adapter
45
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
46
+ * @license http://framework.zend.com/license/new-bsd New BSD License
47
+ */
48
+ class Profileolabs_Shoppingflux_Model_Service_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interface, Profileolabs_Shoppingflux_Model_Service_Http_Client_Adapter_Stream
49
+ {
50
+ /**
51
+ * Parameters array
52
+ *
53
+ * @var array
54
+ */
55
+ protected $_config = array();
56
+
57
+ /**
58
+ * What host/port are we connected to?
59
+ *
60
+ * @var array
61
+ */
62
+ protected $_connected_to = array(null, null);
63
+
64
+ /**
65
+ * The curl session handle
66
+ *
67
+ * @var resource|null
68
+ */
69
+ protected $_curl = null;
70
+
71
+ /**
72
+ * List of cURL options that should never be overwritten
73
+ *
74
+ * @var array
75
+ */
76
+ protected $_invalidOverwritableCurlOptions;
77
+
78
+ /**
79
+ * Response gotten from server
80
+ *
81
+ * @var string
82
+ */
83
+ protected $_response = null;
84
+
85
+ /**
86
+ * Stream for storing output
87
+ *
88
+ * @var resource
89
+ */
90
+ protected $out_stream;
91
+
92
+ /**
93
+ * Adapter constructor
94
+ *
95
+ * Config is set using setConfig()
96
+ *
97
+ * @return void
98
+ * @throws Zend_Http_Client_Adapter_Exception
99
+ */
100
+ public function __construct()
101
+ {
102
+ if (!extension_loaded('curl')) {
103
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
104
+ throw new Zend_Http_Client_Adapter_Exception('cURL extension has to be loaded to use this Zend_Http_Client adapter.');
105
+ }
106
+ $this->_invalidOverwritableCurlOptions = array(
107
+ CURLOPT_HTTPGET,
108
+ CURLOPT_POST,
109
+ CURLOPT_PUT,
110
+ CURLOPT_CUSTOMREQUEST,
111
+ CURLOPT_HEADER,
112
+ CURLOPT_RETURNTRANSFER,
113
+ CURLOPT_HTTPHEADER,
114
+ CURLOPT_POSTFIELDS,
115
+ CURLOPT_INFILE,
116
+ CURLOPT_INFILESIZE,
117
+ CURLOPT_PORT,
118
+ CURLOPT_MAXREDIRS,
119
+ CURLOPT_CONNECTTIMEOUT,
120
+ CURL_HTTP_VERSION_1_1,
121
+ CURL_HTTP_VERSION_1_0,
122
+ );
123
+ }
124
+
125
+ /**
126
+ * Set the configuration array for the adapter
127
+ *
128
+ * @throws Zend_Http_Client_Adapter_Exception
129
+ * @param Zend_Config | array $config
130
+ * @return Zend_Http_Client_Adapter_Curl
131
+ */
132
+ public function setConfig($config = array())
133
+ {
134
+ if ($config instanceof Zend_Config) {
135
+ $config = $config->toArray();
136
+
137
+ } elseif (! is_array($config)) {
138
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
139
+ throw new Zend_Http_Client_Adapter_Exception(
140
+ 'Array or Zend_Config object expected, got ' . gettype($config)
141
+ );
142
+ }
143
+
144
+ if(isset($config['proxy_user']) && isset($config['proxy_pass'])) {
145
+ $this->setCurlOption(CURLOPT_PROXYUSERPWD, $config['proxy_user'].":".$config['proxy_pass']);
146
+ unset($config['proxy_user'], $config['proxy_pass']);
147
+ }
148
+
149
+ foreach ($config as $k => $v) {
150
+ $option = strtolower($k);
151
+ switch($option) {
152
+ case 'proxy_host':
153
+ $this->setCurlOption(CURLOPT_PROXY, $v);
154
+ break;
155
+ case 'proxy_port':
156
+ $this->setCurlOption(CURLOPT_PROXYPORT, $v);
157
+ break;
158
+ default:
159
+ $this->_config[$option] = $v;
160
+ break;
161
+ }
162
+ }
163
+
164
+ return $this;
165
+ }
166
+
167
+ /**
168
+ * Retrieve the array of all configuration options
169
+ *
170
+ * @return array
171
+ */
172
+ public function getConfig()
173
+ {
174
+ return $this->_config;
175
+ }
176
+
177
+ /**
178
+ * Direct setter for cURL adapter related options.
179
+ *
180
+ * @param string|int $option
181
+ * @param mixed $value
182
+ * @return Zend_Http_Adapter_Curl
183
+ */
184
+ public function setCurlOption($option, $value)
185
+ {
186
+ if (!isset($this->_config['curloptions'])) {
187
+ $this->_config['curloptions'] = array();
188
+ }
189
+ $this->_config['curloptions'][$option] = $value;
190
+ return $this;
191
+ }
192
+
193
+ /**
194
+ * Initialize curl
195
+ *
196
+ * @param string $host
197
+ * @param int $port
198
+ * @param boolean $secure
199
+ * @return void
200
+ * @throws Zend_Http_Client_Adapter_Exception if unable to connect
201
+ */
202
+ public function connect($host, $port = 80, $secure = false)
203
+ {
204
+ // If we're already connected, disconnect first
205
+ if ($this->_curl) {
206
+ $this->close();
207
+ }
208
+
209
+ // If we are connected to a different server or port, disconnect first
210
+ if ($this->_curl
211
+ && is_array($this->_connected_to)
212
+ && ($this->_connected_to[0] != $host
213
+ || $this->_connected_to[1] != $port)
214
+ ) {
215
+ $this->close();
216
+ }
217
+
218
+ // Do the actual connection
219
+ $this->_curl = curl_init();
220
+ if ($port != 80) {
221
+ curl_setopt($this->_curl, CURLOPT_PORT, intval($port));
222
+ }
223
+
224
+ // Set timeout
225
+ curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, $this->_config['timeout']);
226
+
227
+ // Set Max redirects
228
+ curl_setopt($this->_curl, CURLOPT_MAXREDIRS, $this->_config['maxredirects']);
229
+
230
+ if (!$this->_curl) {
231
+ $this->close();
232
+
233
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
234
+ throw new Zend_Http_Client_Adapter_Exception('Unable to Connect to ' . $host . ':' . $port);
235
+ }
236
+
237
+ if ($secure !== false) {
238
+ // Behave the same like Zend_Http_Adapter_Socket on SSL options.
239
+ if (isset($this->_config['sslcert'])) {
240
+ curl_setopt($this->_curl, CURLOPT_SSLCERT, $this->_config['sslcert']);
241
+ }
242
+ if (isset($this->_config['sslpassphrase'])) {
243
+ curl_setopt($this->_curl, CURLOPT_SSLCERTPASSWD, $this->_config['sslpassphrase']);
244
+ }
245
+ }
246
+
247
+ // Update connected_to
248
+ $this->_connected_to = array($host, $port);
249
+ }
250
+
251
+ /**
252
+ * Send request to the remote server
253
+ *
254
+ * @param string $method
255
+ * @param Zend_Uri_Http $uri
256
+ * @param float $http_ver
257
+ * @param array $headers
258
+ * @param string $body
259
+ * @return string $request
260
+ * @throws Zend_Http_Client_Adapter_Exception If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option
261
+ */
262
+ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $body = '')
263
+ {
264
+ // Make sure we're properly connected
265
+ if (!$this->_curl) {
266
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
267
+ throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected");
268
+ }
269
+
270
+ if ($this->_connected_to[0] != $uri->getHost() || $this->_connected_to[1] != $uri->getPort()) {
271
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
272
+ throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong host");
273
+ }
274
+
275
+ // set URL
276
+ curl_setopt($this->_curl, CURLOPT_URL, $uri->__toString());
277
+
278
+ // ensure correct curl call
279
+ $curlValue = true;
280
+ switch ($method) {
281
+ case Zend_Http_Client::GET:
282
+ $curlMethod = CURLOPT_HTTPGET;
283
+ break;
284
+
285
+ case Zend_Http_Client::POST:
286
+ $curlMethod = CURLOPT_POST;
287
+ break;
288
+
289
+ case Zend_Http_Client::PUT:
290
+ // There are two different types of PUT request, either a Raw Data string has been set
291
+ // or CURLOPT_INFILE and CURLOPT_INFILESIZE are used.
292
+ if(is_resource($body)) {
293
+ $this->_config['curloptions'][CURLOPT_INFILE] = $body;
294
+ }
295
+ if (isset($this->_config['curloptions'][CURLOPT_INFILE])) {
296
+ // Now we will probably already have Content-Length set, so that we have to delete it
297
+ // from $headers at this point:
298
+ foreach ($headers AS $k => $header) {
299
+ if (preg_match('/Content-Length:\s*(\d+)/i', $header, $m)) {
300
+ if(is_resource($body)) {
301
+ $this->_config['curloptions'][CURLOPT_INFILESIZE] = (int)$m[1];
302
+ }
303
+ unset($headers[$k]);
304
+ }
305
+ }
306
+
307
+ if (!isset($this->_config['curloptions'][CURLOPT_INFILESIZE])) {
308
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
309
+ throw new Zend_Http_Client_Adapter_Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE.");
310
+ }
311
+
312
+ if(is_resource($body)) {
313
+ $body = '';
314
+ }
315
+
316
+ $curlMethod = CURLOPT_PUT;
317
+ } else {
318
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
319
+ $curlValue = "PUT";
320
+ }
321
+ break;
322
+
323
+ case Zend_Http_Client::DELETE:
324
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
325
+ $curlValue = "DELETE";
326
+ break;
327
+
328
+ case Zend_Http_Client::OPTIONS:
329
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
330
+ $curlValue = "OPTIONS";
331
+ break;
332
+
333
+ case Zend_Http_Client::TRACE:
334
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
335
+ $curlValue = "TRACE";
336
+ break;
337
+
338
+ case Zend_Http_Client::HEAD:
339
+ $curlMethod = CURLOPT_CUSTOMREQUEST;
340
+ $curlValue = "HEAD";
341
+ break;
342
+
343
+ default:
344
+ // For now, through an exception for unsupported request methods
345
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
346
+ throw new Zend_Http_Client_Adapter_Exception("Method currently not supported");
347
+ }
348
+
349
+ if(is_resource($body) && $curlMethod != CURLOPT_PUT) {
350
+ #require_once 'Zend/Http/Client/Adapter/Exception.php';
351
+ throw new Zend_Http_Client_Adapter_Exception("Streaming requests are allowed only with PUT");
352
+ }
353
+
354
+ // get http version to use
355
+ $curlHttp = ($httpVersion == 1.1) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0;
356
+
357
+ // mark as HTTP request and set HTTP method
358
+ curl_setopt($this->_curl, $curlHttp, true);
359
+ curl_setopt($this->_curl, $curlMethod, $curlValue);
360
+
361
+ if($this->out_stream) {
362
+ // headers will be read into the response
363
+ curl_setopt($this->_curl, CURLOPT_HEADER, false);
364
+ curl_setopt($this->_curl, CURLOPT_HEADERFUNCTION, array($this, "readHeader"));
365
+ // and data will be written into the file
366
+ curl_setopt($this->_curl, CURLOPT_FILE, $this->out_stream);
367
+ } else {
368
+ // ensure headers are also returned
369
+ curl_setopt($this->_curl, CURLOPT_HEADER, true);
370
+
371
+ // ensure actual response is returned
372
+ curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true);
373
+ }
374
+
375
+ // set additional headers
376
+ $headers['Accept'] = '';
377
+ curl_setopt($this->_curl, CURLOPT_HTTPHEADER, $headers);
378
+
379
+ /**
380
+ * Make sure POSTFIELDS is set after $curlMethod is set:
381
+ * @link http://de2.php.net/manual/en/function.curl-setopt.php#81161
382
+ */
383
+ if ($method == Zend_Http_Client::POST) {
384
+ curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
385
+ } elseif ($curlMethod == CURLOPT_PUT) {
386
+ // this covers a PUT by file-handle:
387
+ // Make the setting of this options explicit (rather than setting it through the loop following a bit lower)
388
+ // to group common functionality together.
389
+ curl_setopt($this->_curl, CURLOPT_INFILE, $this->_config['curloptions'][CURLOPT_INFILE]);
390
+ curl_setopt($this->_curl, CURLOPT_INFILESIZE, $this->_config['curloptions'][CURLOPT_INFILESIZE]);
391
+ unset($this->_config['curloptions'][CURLOPT_INFILE]);
392
+ unset($this->_config['curloptions'][CURLOPT_INFILESIZE]);
393
+ } elseif ($method == Zend_Http_Client::PUT) {
394
+ // This is a PUT by a setRawData string, not by file-handle
395
+ curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
396
+ }
397
+
398
+ // set additional curl options
399
+ if (isset($this->_config['curloptions'])) {
400
+ foreach ((array)$this->_config['curloptions'] as $k => $v) {
401
+ if (!in_array($k, $this->_invalidOverwritableCurlOptions)) {
402
+ if (curl_setopt($this->_curl, $k, $v) == false) {
403
+ #require_once 'Zend/Http/Client/Exception.php';
404
+ throw new Zend_Http_Client_Exception(sprintf("Unknown or erroreous cURL option '%s' set", $k));
405
+ }
406
+ }
407
+ }
408
+ }
409
+
410
+ // send the request
411
+ $response = curl_exec($this->_curl);
412
+
413
+ // if we used streaming, headers are already there
414
+ if(!is_resource($this->out_stream)) {
415
+ $this->_response = $response;
416
+ }
417
+
418
+ $request = curl_getinfo($this->_curl, CURLINFO_HEADER_OUT);
419
+ $request .= $body;
420
+
421
+ if (empty($this->_response)) {
422
+ #require_once 'Zend/Http/Client/Exception.php';
423
+ throw new Zend_Http_Client_Exception("Error in cURL request: " . curl_error($this->_curl));
424
+ }
425
+
426
+ // cURL automatically decodes chunked-messages, this means we have to disallow the Zend_Http_Response to do it again
427
+ if (stripos($this->_response, "Transfer-Encoding: chunked\r\n")) {
428
+ $this->_response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $this->_response);
429
+ }
430
+
431
+ // Eliminate multiple HTTP responses.
432
+ do {
433
+ $parts = preg_split('|(?:\r?\n){2}|m', $this->_response, 2);
434
+ $again = false;
435
+
436
+ if (isset($parts[1]) && preg_match("|^HTTP/1\.[01](.*?)\r\n|mi", $parts[1])) {
437
+ $this->_response = $parts[1];
438
+ $again = true;
439
+ }
440
+ } while ($again);
441
+
442
+ // cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string:
443
+ if (stripos($this->_response, "HTTP/1.0 200 Connection established\r\n\r\n") !== false) {
444
+ $this->_response = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $this->_response);
445
+ }
446
+
447
+ return $request;
448
+ }
449
+
450
+ /**
451
+ * Return read response from server
452
+ *
453
+ * @return string
454
+ */
455
+ public function read()
456
+ {
457
+ return $this->_response;
458
+ }
459
+
460
+ /**
461
+ * Close the connection to the server
462
+ *
463
+ */
464
+ public function close()
465
+ {
466
+ if(is_resource($this->_curl)) {
467
+ curl_close($this->_curl);
468
+ }
469
+ $this->_curl = null;
470
+ $this->_connected_to = array(null, null);
471
+ }
472
+
473
+ /**
474
+ * Get cUrl Handle
475
+ *
476
+ * @return resource
477
+ */
478
+ public function getHandle()
479
+ {
480
+ return $this->_curl;
481
+ }
482
+
483
+ /**
484
+ * Set output stream for the response
485
+ *
486
+ * @param resource $stream
487
+ * @return Zend_Http_Client_Adapter_Socket
488
+ */
489
+ public function setOutputStream($stream)
490
+ {
491
+ $this->out_stream = $stream;
492
+ return $this;
493
+ }
494
+
495
+ /**
496
+ * Header reader function for CURL
497
+ *
498
+ * @param resource $curl
499
+ * @param string $header
500
+ * @return int
501
+ */
502
+ public function readHeader($curl, $header)
503
+ {
504
+ $this->_response .= $header;
505
+ return strlen($header);
506
+ }
507
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Service/Http/Client/Adapter/Stream.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Zend Framework
5
+ *
6
+ * LICENSE
7
+ *
8
+ * This source file is subject to the new BSD license that is bundled
9
+ * with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://framework.zend.com/license/new-bsd
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@zend.com so we can send you a copy immediately.
15
+ *
16
+ * @category Zend
17
+ * @package Zend_Http
18
+ * @subpackage Client_Adapter
19
+ * @version $Id: Stream.php 20785 2010-01-31 09:43:03Z mikaelkael $
20
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
21
+ * @license http://framework.zend.com/license/new-bsd New BSD License
22
+ */
23
+
24
+ /**
25
+ * An interface description for Zend_Http_Client_Adapter_Stream classes.
26
+ *
27
+ * This interface decribes Zend_Http_Client_Adapter which supports streaming.
28
+ *
29
+ * @category Zend
30
+ * @package Zend_Http
31
+ * @subpackage Client_Adapter
32
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
33
+ * @license http://framework.zend.com/license/new-bsd New BSD License
34
+ */
35
+ interface Profileolabs_Shoppingflux_Model_Service_Http_Client_Adapter_Stream
36
+ {
37
+ /**
38
+ * Set output stream
39
+ *
40
+ * This function sets output stream where the result will be stored.
41
+ *
42
+ * @param resource $stream Stream to write the output to
43
+ *
44
+ */
45
+ function setOutputStream($stream);
46
+ }
app/code/community/Profileolabs/Shoppingflux/Model/System/Config/Backend/Apikey.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @deprecated
5
+ * Shopping Flux Backend Model for Config Api key
6
+ * @category ShoppingFlux
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author kassim belghait
9
+ */
10
+ class Profileolabs_Shoppingflux_Model_System_Config_Backend_Apikey extends Mage_Core_Model_Config_Data {
11
+
12
+ public function getConfig() {
13
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
14
+ }
15
+
16
+ protected function _beforeSave() {
17
+ parent::_beforeSave();
18
+
19
+ /*
20
+ if ($this->isValueChanged()) {
21
+ $storeId = 0;
22
+ switch($this->getScope()) {
23
+ case 'stores':
24
+ $storeId = $this->getScopeId();
25
+ break;
26
+ }
27
+ $apiKey = $this->getConfig()->getApiKey($storeId);
28
+ $wsUri = $this->getConfig()->getWsUri();
29
+
30
+ $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
31
+
32
+ if ((boolean) $this->getFieldsetDataValue('enabled') && !$service->checkApiKey($this->getValue()))
33
+ Mage::throwException(Mage::helper('profileolabs_shoppingflux')->__('API key (Token) not valid'));
34
+ }
35
+
36
+ */
37
+ }
38
+
39
+ }
app/code/community/Profileolabs/Shoppingflux/Model/System/Config/Backend/Refresh.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @deprecated
5
+ * Shopping Flux Backend Model for Config Api key
6
+ * @category ShoppingFlux
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author kassim belghait
9
+ */
10
+ class Profileolabs_Shoppingflux_Model_System_Config_Backend_Refresh extends Mage_Core_Model_Config_Data {
11
+
12
+ public function getConfig() {
13
+ return Mage::getSingleton('profileolabs_shoppingflux/config');
14
+ }
15
+
16
+ protected function _afterSave() {
17
+ try {
18
+ if ($this->isValueChanged()) {
19
+
20
+ $storeIds = array();
21
+
22
+ $storeId = Mage::app()->getStore($this->getStoreCode())->getId();
23
+
24
+ try {
25
+ $websiteId = Mage::app()->getWebsite($this->getWebsiteCode())->getId();
26
+ } catch (Mage_Core_Exception $e) {
27
+ $websiteId = 0;
28
+ }
29
+
30
+ if ($storeId != 0) {
31
+ $storeIds[] = $storeId;
32
+ } else if ($websiteId != 0) {
33
+ $stores = Mage::app()->getWebsite($this->getWebsiteCode())->getStores();
34
+ foreach ($stores as $strId => $str) {
35
+ $storeIds[] = $strId;
36
+ }
37
+ } else {
38
+ $stores = Mage::app()->getStores();
39
+ foreach ($stores as $strId => $str) {
40
+ $storeIds[] = $strId;
41
+ }
42
+ }
43
+
44
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
45
+ foreach ($storeIds as $storeId) {
46
+ $write->beginTransaction();
47
+ try {
48
+ $query = "update " . Mage::getSingleton('core/resource')->getTableName('profileolabs_shoppingflux/export_flux') . " set update_needed = 1 where store_id = '" . $storeId . "'";
49
+ $write->query($query);
50
+ $write->commit();
51
+ } catch (Exception $e) {
52
+ $write->rollback();
53
+ }
54
+ }
55
+ }
56
+ } catch (Exception $e) {
57
+
58
+ }
59
+ }
60
+
61
+ }
app/code/community/Profileolabs/Shoppingflux/controllers/Adminhtml/GeneralController.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping Flux
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux
6
+ * @author vincent enjalbert - web cooking
7
+ */
8
+ class Profileolabs_Shoppingflux_Adminhtml_GeneralController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+ public function userdefinedAction() {
11
+ $installer = Mage::getResourceModel('catalog/setup','profileolabs_shoppingflux_setup');
12
+ $installer->updateAttribute('catalog_product', 'shoppingflux_default_category', 'is_user_defined', 1);
13
+ $installer->updateAttribute('catalog_product', 'shoppingflux_product', 'is_user_defined', 1);
14
+ }
15
+
16
+
17
+ public function nuserdefinedAction() {
18
+ $installer = Mage::getResourceModel('catalog/setup','profileolabs_shoppingflux_setup');
19
+ $installer->updateAttribute('catalog_product', 'shoppingflux_default_category', 'is_user_defined', 0);
20
+ $installer->updateAttribute('catalog_product', 'shoppingflux_product', 'is_user_defined', 0);
21
+ }
22
+
23
+
24
+ }
app/code/community/Profileolabs/Shoppingflux/controllers/Export/Adminhtml/CategoryController.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author vincent enjalbert
8
+ */
9
+ include_once "Mage/Adminhtml/controllers/Catalog/CategoryController.php";
10
+
11
+ class Profileolabs_Shoppingflux_Export_Adminhtml_CategoryController extends Mage_Adminhtml_Catalog_CategoryController {
12
+
13
+ /**
14
+ * Grid Action
15
+ * Display list of products related to current category
16
+ *
17
+ * @return void
18
+ */
19
+ public function gridAction() {
20
+ if (!$category = $this->_initCategory(true)) {
21
+ return;
22
+ }
23
+ $this->getResponse()->setBody(
24
+ $this->getLayout()->createBlock('profileolabs_shoppingflux/export_adminhtml_catalog_category_tab_default', 'shoppingflux.product.grid')
25
+ ->toHtml()
26
+ );
27
+ }
28
+
29
+ }
app/code/community/Profileolabs/Shoppingflux/controllers/Export/Adminhtml/ExportController.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author kassim belghait
8
+ * @deprecated deprecated since 0.1.1
9
+ */
10
+ class Profileolabs_Shoppingflux_Export_Adminhtml_ExportController extends Mage_Adminhtml_Controller_action {
11
+
12
+ protected $_flowModel = null;
13
+
14
+ /**
15
+ * Get Singleton Flow
16
+ * @return Profileolabs_Shoppingflux_Model_Export_Flow
17
+ */
18
+ protected function _getFlow() {
19
+ $storeId = $this->getRequest()->getParam('store', 0);
20
+ return Mage::getSingleton('profileolabs_shoppingflux/export_flow')->setStoreId($storeId);
21
+ }
22
+
23
+ public function indexAction() {
24
+ $this->_redirect('*/*/edit');
25
+ }
26
+
27
+ public function editAction() {
28
+ $this->loadLayout();
29
+ $this->renderLayout();
30
+ }
31
+
32
+ public function updateAction() {
33
+
34
+ $this->loadLayout();
35
+ $this->renderLayout();
36
+
37
+ return $this;
38
+ }
39
+
40
+ /**
41
+ * Product grid for AJAX request
42
+ */
43
+ public function gridAction() {
44
+ $this->loadLayout();
45
+ $this->getResponse()->setBody(
46
+ $this->getLayout()->createBlock('profileolabs_shoppingflux/export_adminhtml_product_grid')->toHtml()
47
+ );
48
+ }
49
+
50
+ public function massPublishAction() {
51
+ $productIds = (array) $this->getRequest()->getParam('product');
52
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
53
+ $publish = (int) $this->getRequest()->getParam('publish');
54
+ // die('P: '.$publish);
55
+ //$entityTypeId = Mage::getSingleton('eav/config')->getEntityType('catalog_product')->getEntiyTypeId();
56
+ $resource = Mage::getResourceModel('catalog/product');
57
+ $entityTypeId = $resource->getEntityType()->getId();
58
+
59
+ try {
60
+ foreach ($productIds as $productId) {
61
+ $product = new Varien_Object(array('entity_id' => $productId,
62
+ 'id' => $productId,
63
+ 'entity_type_id' => $entityTypeId,
64
+ 'store_id' => $storeId,
65
+ 'shoppingflux_product' => $publish));
66
+ Mage::dispatchEvent('shoppingflux_mass_publish_save_item', array('product_id' => $productId, 'shoppingflux_product'=>$publish));
67
+ $resource->saveAttribute($product, 'shoppingflux_product');
68
+ }
69
+ $this->_getSession()->addSuccess(
70
+ $this->__('Total of %d record(s) were successfully updated', count($productIds))
71
+ );
72
+ } catch (Mage_Core_Model_Exception $e) {
73
+ $this->_getSession()->addError($e->getMessage());
74
+ } catch (Exception $e) {
75
+ $this->_getSession()->addException($e, $e->getMessage() . $this->__('There was an error while updating product(s) publication'));
76
+ }
77
+
78
+ $this->_redirect('*/*/update', array('store' => $storeId));
79
+ }
80
+
81
+ public function runAction() {
82
+ $this->loadLayout();
83
+ $this->renderLayout();
84
+
85
+ return $this;
86
+ }
87
+
88
+ public function flowRunAction() {
89
+ if ($this->getRequest()->isPost()) {
90
+
91
+ $offset = $this->getRequest()->getPost('offset', 1);
92
+ $errors = array();
93
+ $saved = 0;
94
+ try {
95
+
96
+ $this->_getFlow()->generateProductsNodes($offset);
97
+ $saved = $this->_getFlow()->getLastCount();
98
+ ;
99
+ $errors = $this->_getFlow()->getErrors();
100
+ } catch (Exception $e) {
101
+ $errors[] = $e->getMessage();
102
+ }
103
+
104
+ $result = array(
105
+ 'savedRows' => $saved,
106
+ 'errors' => $errors,
107
+ 'offset' => $offset,
108
+ );
109
+ $this->getResponse()->setBody(Zend_Json::encode($result));
110
+ }
111
+ }
112
+
113
+ protected function _getSession() {
114
+ return Mage::getSingleton('adminhtml/session');
115
+ }
116
+
117
+ public function flowFinishAction() {
118
+ $result = array();
119
+ $storeCode = Mage::app()->getStore($this->getRequest()->getParam('store'))->getCode();
120
+ $result['filename'] = Mage::getBaseUrl('media') . "shoppingflux/" . $storeCode . "/flow.xml";
121
+ $this->getResponse()->setBody(Zend_Json::encode($result));
122
+ }
123
+
124
+ }
app/code/community/Profileolabs/Shoppingflux/controllers/Export/FluxController.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Profileolabs_Shoppingflux_Export_FluxController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function phpinfoAction() {
6
+ //phpinfo();die();
7
+ }
8
+
9
+ public function testAction() {
10
+ ini_set('display_errors', 1);
11
+ Mage::app()->cleanCache();
12
+ die('TESTS_END');
13
+ }
14
+
15
+ public function refreshAllAction() {
16
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
17
+ $storeId = Mage::app()->getStore()->getId();
18
+ $write->beginTransaction();
19
+ try {
20
+ $query = "update " . Mage::getSingleton('core/resource')->getTableName('profileolabs_shoppingflux/export_flux') . " set update_needed = 1 where store_id = '" . $storeId . "' and should_export = 1";
21
+ $write->query($query);
22
+ $write->commit();
23
+ } catch (Exception $e) {
24
+ $write->rollback();
25
+ }
26
+ die('Le flux shopping flux sera mis a jour pour ce flux');
27
+ }
28
+
29
+ public function refreshEverythingAction() {
30
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
31
+ $storeId = Mage::app()->getStore()->getId();
32
+ $write->beginTransaction();
33
+ try {
34
+ $query = "update " . Mage::getSingleton('core/resource')->getTableName('profileolabs_shoppingflux/export_flux') . " set update_needed = 1, should_export = 1";
35
+ $write->query($query);
36
+ $write->commit();
37
+ } catch (Exception $e) {
38
+ $write->rollback();
39
+ }
40
+ die('Le flux shopping flux sera mis a jour pour ce flux');
41
+ }
42
+
43
+ public function indexAction() {
44
+ error_reporting(-1);
45
+ ini_set('display_errors', 1);
46
+ set_time_limit(0);
47
+ ini_set("memory_limit", Mage::getSingleton('profileolabs_shoppingflux/config')->getMemoryLimit() . "M");
48
+
49
+
50
+
51
+
52
+ $limit = $this->getRequest()->getParam('limit');
53
+ $productSku = $this->getRequest()->getParam('product_sku');
54
+ $forceMultiStores = $this->getRequest()->getParam('force_multi_stores', false);
55
+
56
+ if(!headers_sent()) {
57
+ header('Content-type: text/xml; charset=UTF-8');
58
+ }
59
+
60
+ $block = $this->getLayout()->createBlock('profileolabs_shoppingflux/export_flux', 'sf.export.flux');
61
+ if ($limit) {
62
+ $block->setLimit($limit);
63
+ }
64
+ if ($productSku) {
65
+ $block->setProductSku($productSku);
66
+ }
67
+ if($forceMultiStores) {
68
+ $block->setForceMultiStores(true);
69
+ }
70
+
71
+ $block->toHtml();
72
+
73
+ exit();
74
+ }
75
+
76
+ // V1 DEPRECATED
77
+ public function v1Action() {
78
+ $limit = $this->getRequest()->getParam('limit');
79
+ $productSku = $this->getRequest()->getParam('product_sku');
80
+
81
+ /**
82
+ * Error reporting
83
+ */
84
+ error_reporting(E_ALL | E_STRICT);
85
+ ini_set('display_errors', 1);
86
+ set_time_limit(0);
87
+ /* $this->getResponse()
88
+ ->setHttpResponseCode(200)
89
+ ->setHeader('Pragma', 'public', true)
90
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
91
+ ->setHeader('Content-type', 'text/xml; charset=UTF-8'); */
92
+ header('Content-type: text/xml; charset=UTF-8');
93
+
94
+
95
+ try {
96
+ $block = $this->getLayout()->createBlock('profileolabs_shoppingflux/export_flow', 'sf.export.flow');
97
+ if ($limit) {
98
+ $block->setLimit($limit);
99
+ }
100
+ if ($productSku) {
101
+ $block->setProductSku($productSku);
102
+ }
103
+ $block->toHtml();
104
+
105
+ /* $this->loadLayout(false);
106
+ if($limit) {
107
+ $block = $this->getLayout()->getBlock('sf.export.flow');
108
+ $block->setLimit($limit);
109
+ }
110
+ $this->renderLayout(); */
111
+
112
+ //$block = $this->getLayout()->createBlock('profileolabs_shoppingflux/export_flow','sf.export.flow');
113
+ //$output = $block->toHtml();
114
+ //$this->getResponse()->setBody($output);
115
+ } catch (Exception $e) {
116
+
117
+ Mage::throwException($e);
118
+ }
119
+
120
+
121
+
122
+ return $this;
123
+ }
124
+
125
+ public function profileAction() {
126
+ error_reporting(E_ALL | E_STRICT);
127
+ ini_set('display_errors', 1);
128
+ set_time_limit(0);
129
+
130
+ $limit = $this->getRequest()->getParam('limit');
131
+ $productSku = $this->getRequest()->getParam('product_sku');
132
+
133
+ header('Content-type: text/html; charset=UTF-8');
134
+
135
+ $block = $this->getLayout()->createBlock('profileolabs_shoppingflux/export_flux', 'sf.export.flux');
136
+ if ($limit) {
137
+ $block->setLimit($limit);
138
+ }
139
+ if ($productSku) {
140
+ $block->setProductSku($productSku);
141
+ }
142
+ $block->toHtml();
143
+ $block = $this->getLayout()->createBlock('core/profiler', 'profiler');
144
+ $output = $block->toHtml();
145
+
146
+ $this->getResponse()->setBody($output);
147
+ return $this;
148
+ }
149
+
150
+ }
app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/CronController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping Flux
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux_ManageOrders
6
+ * @author Vincent Enjalbert
7
+ */
8
+ class Profileolabs_Shoppingflux_Manageorders_Adminhtml_CronController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+ protected function _initAction() {
11
+ $this->loadLayout()
12
+ ->_setActiveMenu('shoppingflux/manageorders/crons')
13
+ ->_addBreadcrumb(Mage::helper('profileolabs_shoppingflux')->__('Crons'), Mage::helper('profileolabs_shoppingflux')->__('Crons'));
14
+
15
+ return $this;
16
+ }
17
+
18
+
19
+ public function indexAction()
20
+ {
21
+ $this->_initAction()
22
+ ->renderLayout();
23
+
24
+ return $this;
25
+ }
26
+
27
+
28
+
29
+ public function gridAction()
30
+ {
31
+ $this->getResponse()->setBody(
32
+ $this->getLayout()->createBlock('profileolabs_shoppingflux/manageorders_adminhtml_cron_grid')->toHtml()
33
+ );
34
+
35
+ return $this;
36
+ }
37
+
38
+ }
app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/ImportController.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shopping Flux
5
+ * @category ShoppingFlux
6
+ * @package Profileolabs_Shoppingflux_ManageOrders
7
+ * @author kassim belghait
8
+ */
9
+ class Profileolabs_Shoppingflux_Manageorders_Adminhtml_ImportController extends Mage_Adminhtml_Controller_Action {
10
+
11
+ protected function _initAction() {
12
+ $this->loadLayout()
13
+ ->_setActiveMenu('shoppingflux/manageorders/import')
14
+ ->_addBreadcrumb(Mage::helper('profileolabs_shoppingflux')->__('Shopping flux import orders'), Mage::helper('profileolabs_shoppingflux')->__('Shopping flux import orders'));
15
+
16
+ return $this;
17
+ }
18
+
19
+ public function indexAction() {
20
+ $this->_initAction()
21
+ ->renderLayout();
22
+
23
+ return $this;
24
+ }
25
+
26
+ public function importOrdersAction() {
27
+ try {
28
+
29
+ if (!Mage::getSingleton('profileolabs_shoppingflux/config')->isOrdersEnabled())
30
+ Mage::throwException(Mage::helper('profileolabs_shoppingflux')->__("Le module n'est pas activé. Activez le dans la configuration du module."));
31
+
32
+
33
+ error_reporting(E_ALL | E_STRICT);
34
+ ini_set("display_errors", 1);
35
+
36
+ /* @var $model Profileolabs_Shoppingflux_ManageOrders_Model_Order */
37
+
38
+
39
+ $model = Mage::getModel('profileolabs_shoppingflux/manageorders_order')->manageOrders();
40
+
41
+ $this->_getSession()->addSuccess(Mage::helper('profileolabs_shoppingflux')->__("%d orders are imported", $model->getNbOrdersImported()));
42
+
43
+ if ($model->getResultSendOrder() != "") {
44
+ $this->_getSession()->addSuccess(Mage::helper('profileolabs_shoppingflux')->__("Status of order ids sended: %s", $model->getResultSendOrder()));
45
+ }
46
+ } catch (Exception $e) {
47
+ $this->_getSession()->addError($e->getMessage());
48
+ }
49
+
50
+ $this->_redirect("*/*/index");
51
+ }
52
+
53
+
54
+
55
+ }
app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/LogController.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping Flux
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux_ManageOrders
6
+ * @author kassim belghait
7
+ */
8
+ class Profileolabs_Shoppingflux_Manageorders_Adminhtml_LogController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+ protected function _initAction() {
11
+ $this->loadLayout()
12
+ ->_setActiveMenu('shoppingflux/manageorders/log')
13
+ ->_addBreadcrumb(Mage::helper('profileolabs_shoppingflux')->__('Shopping flux orders'), Mage::helper('profileolabs_shoppingflux')->__('Shopping flux orders'));
14
+
15
+ return $this;
16
+ }
17
+
18
+
19
+ public function indexAction()
20
+ {
21
+ $this->_initAction()
22
+ ->renderLayout();
23
+
24
+ return $this;
25
+ }
26
+
27
+ public function deleteAction()
28
+ {
29
+ $collection = Mage::getModel('profileolabs_shoppingflux/manageorders_log')->getCollection();
30
+ foreach($collection as $log)
31
+ $log->delete();
32
+
33
+ $this->_getSession()->addSuccess(Mage::helper('profileolabs_shoppingflux')->__("Log is empty."));
34
+
35
+ $this->_redirect('*/*/index');
36
+
37
+ }
38
+
39
+ public function gridAction()
40
+ {
41
+ $this->getResponse()->setBody(
42
+ $this->getLayout()->createBlock('profileolabs_shoppingflux/manageorders_adminhtml_log_grid')->toHtml()
43
+ );
44
+
45
+ return $this;
46
+ }
47
+
48
+ }
app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/OrderController.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopping Flux
4
+ * @category ShoppingFlux
5
+ * @package Profileolabs_Shoppingflux_ManageOrders
6
+ * @author kassim belghait
7
+ */
8
+ class Profileolabs_Shoppingflux_Manageorders_Adminhtml_OrderController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+ protected function _initAction() {
11
+ $this->loadLayout()
12
+ ->_setActiveMenu('shoppingflux/manageorders/order')
13
+ ->_addBreadcrumb(Mage::helper('profileolabs_shoppingflux')->__('Shopping flux orders'), Mage::helper('profileolabs_shoppingflux')->__('Shopping flux orders'));
14
+
15
+ return $this;
16
+ }
17
+
18
+
19
+ public function indexAction()
20
+ {
21
+ $this->_initAction()
22
+ ->renderLayout();
23
+
24
+ return $this;
25
+ }
26
+
27
+ public function gridAction()
28
+ {
29
+ $this->getResponse()->setBody(
30
+ $this->getLayout()->createBlock('profileolabs_shoppingflux/manageorders_adminhtml_order_grid')->toHtml()
31
+ );
32
+
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Export order grid to CSV format
38
+ */
39
+ public function exportCsvAction()
40
+ {
41
+ $fileName = 'orders_shoppingflux.csv';
42
+ $grid = $this->getLayout()->createBlock('profileolabs_shoppingflux/manageorders_adminhtml_order_grid');
43
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
44
+ }
45
+
46
+ /**
47
+ * Export order grid to Excel XML format
48
+ */
49
+ public function exportExcelAction()
50
+ {
51
+ $fileName = 'orders_shoppingflux.xml';
52
+ $grid = $this->getLayout()->createBlock('profileolabs_shoppingflux/manageorders_adminhtml_order_grid');
53
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
54
+ }
55
+
56
+
57
+ }
app/code/community/Profileolabs/Shoppingflux/doc/doc_module_1.4.pdf ADDED
Binary file
app/code/community/Profileolabs/Shoppingflux/etc/config.xml ADDED
@@ -0,0 +1,551 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Profileolabs_Shoppingflux>
5
+ <version>0.6.7</version>
6
+ </Profileolabs_Shoppingflux>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <shoppingflux>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Profileolabs_Shoppingflux</module>
14
+ <frontName>shoppingflux</frontName>
15
+ </args>
16
+ </shoppingflux>
17
+ </routers>
18
+ </admin>
19
+ <global>
20
+ <fieldsets>
21
+ <shoppingflux_convert_customer>
22
+ <LastName>
23
+ <to_customer>lastname</to_customer>
24
+ <to_customer_address>lastname</to_customer_address>
25
+ </LastName>
26
+ <FirstName>
27
+ <to_customer>firstname</to_customer>
28
+ <to_customer_address>firstname</to_customer_address>
29
+ </FirstName>
30
+ <Email>
31
+ <to_customer>email</to_customer>
32
+ <to_customer_address>email</to_customer_address>
33
+ </Email>
34
+ <Phone>
35
+ <to_customer_address>telephone</to_customer_address>
36
+ </Phone>
37
+ <Street>
38
+ <to_customer_address>street_full</to_customer_address>
39
+ </Street>
40
+ <PostalCode>
41
+ <to_customer_address>postcode</to_customer_address>
42
+ </PostalCode>
43
+ <Town>
44
+ <to_customer_address>city</to_customer_address>
45
+ </Town>
46
+ <Country>
47
+ <to_customer_address>country_id</to_customer_address>
48
+ </Country>
49
+ </shoppingflux_convert_customer>
50
+ </fieldsets>
51
+ <blocks>
52
+ <profileolabs_shoppingflux>
53
+ <class>Profileolabs_Shoppingflux_Block</class>
54
+ </profileolabs_shoppingflux>
55
+ </blocks>
56
+ <helpers>
57
+ <profileolabs_shoppingflux>
58
+ <class>Profileolabs_Shoppingflux_Helper</class>
59
+ </profileolabs_shoppingflux>
60
+ </helpers>
61
+ <models>
62
+ <profileolabs_shoppingflux>
63
+ <class>Profileolabs_Shoppingflux_Model</class>
64
+ <resourceModel>profileolabs_shoppingflux_mysql4</resourceModel>
65
+ </profileolabs_shoppingflux>
66
+ <profileolabs_shoppingflux_mysql4>
67
+ <class>Profileolabs_Shoppingflux_Model_Mysql4</class>
68
+ <entities>
69
+ <export_flux>
70
+ <table>shoppingflux_export_flux</table>
71
+ </export_flux>
72
+ <manageorders_log>
73
+ <table>shoppingflux_log</table>
74
+ </manageorders_log>
75
+ <export_updates>
76
+ <table>shoppingflux_export_updates</table>
77
+ </export_updates>
78
+ <manageorders_shipping_method>
79
+ <table>shoppingflux_shipping_methods</table>
80
+ </manageorders_shipping_method>
81
+ <manageorders_export_shipments>
82
+ <table>shoppingflux_manageorders_export_shipments</table>
83
+ </manageorders_export_shipments>
84
+ </entities>
85
+ </profileolabs_shoppingflux_mysql4>
86
+ <catalog>
87
+ <rewrite>
88
+ <config>Profileolabs_Shoppingflux_Model_Export_Rewrite_Catalog_Config</config>
89
+ </rewrite>
90
+ </catalog>
91
+ <cataloginventory>
92
+ <rewrite>
93
+ <stock_item>Profileolabs_Shoppingflux_Model_Export_Rewrite_CatalogInventory_Stock_Item</stock_item>
94
+ </rewrite>
95
+ </cataloginventory>
96
+ </models>
97
+ <resources>
98
+ <profileolabs_shoppingflux_setup>
99
+ <setup>
100
+ <module>Profileolabs_Shoppingflux</module>
101
+ </setup>
102
+ <connection>
103
+ <use>core_setup</use>
104
+ </connection>
105
+ </profileolabs_shoppingflux_setup>
106
+ <profileolabs_shoppingflux_write>
107
+ <connection>
108
+ <use>core_write</use>
109
+ </connection>
110
+ </profileolabs_shoppingflux_write>
111
+ <profileolabs_shoppingflux_read>
112
+ <connection>
113
+ <use>core_read</use>
114
+ </connection>
115
+ </profileolabs_shoppingflux_read>
116
+ </resources>
117
+ <events>
118
+ <cataloginventory_stock_item_save_after>
119
+ <observers>
120
+ <sf_update_stock>
121
+ <type>singleton</type>
122
+ <class>Profileolabs_Shoppingflux_Model_Export_Observer</class>
123
+ <method>realtimeUpdateStock</method>
124
+ </sf_update_stock>
125
+ </observers>
126
+ </cataloginventory_stock_item_save_after>
127
+ <customer_group_load_after>
128
+ <observers>
129
+ <shoppingflux_quote_observer>
130
+ <class>Profileolabs_Shoppingflux_Model_Manageorders_Observer</class>
131
+ <method>setCustomerTaxClassId</method>
132
+ </shoppingflux_quote_observer>
133
+ </observers>
134
+ </customer_group_load_after>
135
+ <sales_order_shipment_save_after>
136
+ <observers>
137
+ <shoppingflux_shipment_save_after>
138
+ <class>Profileolabs_Shoppingflux_Model_Manageorders_Observer</class>
139
+ <method>scheduleShipmentUpdate</method>
140
+ </shoppingflux_shipment_save_after>
141
+ </observers>
142
+ </sales_order_shipment_save_after>
143
+ <order_cancel_after>
144
+ <observers>
145
+ <shoppingflux_order_cancel_after>
146
+ <class>Profileolabs_Shoppingflux_Model_Manageorders_Observer</class>
147
+ <method>sendStatusCanceled</method>
148
+ </shoppingflux_order_cancel_after>
149
+ </observers>
150
+ </order_cancel_after>
151
+ <catalog_product_attribute_update_before>
152
+ <observers>
153
+ <shoppingflux_catalog_product_attribute_update_before>
154
+ <class>Profileolabs_Shoppingflux_Model_Export_Observer</class>
155
+ <method>catalogProductAttributeUpdateBefore</method>
156
+ </shoppingflux_catalog_product_attribute_update_before>
157
+ </observers>
158
+ </catalog_product_attribute_update_before>
159
+ <catalog_product_save_commit_after>
160
+ <observers>
161
+ <shoppingflux_catalog_product_save_commit_after>
162
+ <class>Profileolabs_Shoppingflux_Model_Export_Observer</class>
163
+ <method>catalogProductSaveCommitAfter</method>
164
+ </shoppingflux_catalog_product_save_commit_after>
165
+ </observers>
166
+ </catalog_product_save_commit_after>
167
+ </events>
168
+ <template>
169
+ <email>
170
+ <shoppingflux_alert translate="label" module="profileolabs_shoppingflux">
171
+ <label>Shoppingflux Alert</label>
172
+ <file>shoppingflux/alert.html</file>
173
+ <type>html</type>
174
+ </shoppingflux_alert>
175
+ </email>
176
+ </template>
177
+ </global>
178
+ <frontend>
179
+ <routers>
180
+ <shoppingflux>
181
+ <use>standard</use>
182
+ <args>
183
+ <module>Profileolabs_Shoppingflux</module>
184
+ <frontName>shoppingflux</frontName>
185
+ </args>
186
+ </shoppingflux>
187
+ </routers>
188
+ <layout>
189
+ <updates>
190
+ <shoppingflux>
191
+ <file>profileolabs_shoppingflux.xml</file>
192
+ </shoppingflux>
193
+ </updates>
194
+ </layout>
195
+ <product>
196
+ <collection>
197
+ <attributes>
198
+ <shoppingflux_product />
199
+ <shoppingflux_default_category />
200
+ </attributes>
201
+ </collection>
202
+ </product>
203
+ </frontend>
204
+ <adminhtml>
205
+ <layout>
206
+ <updates>
207
+ <shoppingflux>
208
+ <file>profileolabs_shoppingflux.xml</file>
209
+ </shoppingflux>
210
+ </updates>
211
+ </layout>
212
+ <translate>
213
+ <modules>
214
+ <Profileolabs_Shoppingflux>
215
+ <files>
216
+ <default>Profileolabs_Shoppingflux.csv</default>
217
+ </files>
218
+ </Profileolabs_Shoppingflux>
219
+ </modules>
220
+ </translate>
221
+ <menu>
222
+ <shoppingflux>
223
+ <title>Shopping Flux</title>
224
+ <sort_order>20</sort_order>
225
+ <depends>
226
+ <module>Profileolabs_Shoppingflux</module>
227
+ </depends>
228
+ <children>
229
+ <manageorders translate="title" module="profileolabs_shoppingflux">
230
+ <title>Commandes</title>
231
+ <sort_order>200</sort_order>
232
+ <children>
233
+ <order translate="title" module="profileolabs_shoppingflux">
234
+ <title>Shopping flux orders</title>
235
+ <action>shoppingflux/manageorders_adminhtml_order</action>
236
+ <sort_order>10</sort_order>
237
+ </order>
238
+ <import translate="title" module="profileolabs_shoppingflux">
239
+ <title>Shopping flux import orders</title>
240
+ <action>shoppingflux/manageorders_adminhtml_import</action>
241
+ <sort_order>20</sort_order>
242
+ </import>
243
+ <log translate="title" module="profileolabs_shoppingflux">
244
+ <title>Shopping flux log</title>
245
+ <action>shoppingflux/manageorders_adminhtml_log</action>
246
+ <sort_order>30</sort_order>
247
+ </log>
248
+ </children>
249
+ </manageorders>
250
+ <export translate="title" module="profileolabs_shoppingflux">
251
+ <title>Export</title>
252
+ <sort_order>200</sort_order>
253
+ <children>
254
+ <!-- @deprecated since version 0.1.1 -->
255
+ <!-- <run_export translate="title" module="profileolabs_shoppingflux">
256
+ <title>Lancer l'export</title>
257
+ <action>shoppingflux/export_adminhtml_export/edit</action>
258
+ <sort_order>10</sort_order>
259
+ </run_export> -->
260
+ <set_product translate="title" module="profileolabs_shoppingflux">
261
+ <title>Sélection de produit</title>
262
+ <action>shoppingflux/export_adminhtml_export/update</action>
263
+ <sort_order>20</sort_order>
264
+ </set_product>
265
+ </children>
266
+ </export>
267
+ <crons translate="title" module="profileolabs_shoppingflux">
268
+ <title>Suivi des crons</title>
269
+ <sort_order>900</sort_order>
270
+ <action>shoppingflux/manageorders_adminhtml_cron</action>
271
+ </crons>
272
+ </children>
273
+ </shoppingflux>
274
+ </menu>
275
+ <acl>
276
+ <resources>
277
+ <admin>
278
+ <children>
279
+ <system>
280
+ <children>
281
+ <config>
282
+ <children>
283
+ <shoppingflux translate="title" module="profileolabs_shoppingflux">
284
+ <title>Shoppingflux general</title>
285
+ </shoppingflux>
286
+ <shoppingflux_mo translate="title" module="profileolabs_shoppingflux">
287
+ <title>Shoppingflux manage orders</title>
288
+ </shoppingflux_mo>
289
+ <shoppingflux_export translate="title" module="profileolabs_shoppingflux">
290
+ <title>Shoppingflux Export des produits</title>
291
+ </shoppingflux_export>
292
+ </children>
293
+ </config>
294
+ </children>
295
+ </system>
296
+ <shoppingflux>
297
+ <title>Shopping Flux</title>
298
+ <children>
299
+ <manageorders translate="title" module="profileolabs_shoppingflux">
300
+ <title>Commandes</title>
301
+ <children>
302
+ <order translate="title" module="profileolabs_shoppingflux">
303
+ <title>Shopping flux orders</title>
304
+ </order>
305
+ <import translate="title" module="profileolabs_shoppingflux">
306
+ <title>Shopping flux import orders</title>
307
+ </import>
308
+ <log translate="title" module="profileolabs_shoppingflux">
309
+ <title>Shopping flux log</title>
310
+ </log>
311
+ </children>
312
+ </manageorders>
313
+ <export>
314
+ <title>Export</title>
315
+ <children>
316
+ <!-- @deprecated since version 0.1.1 -->
317
+ <!-- <run_export translate="title" module="profileolabs_shoppingflux">
318
+ <title>Lancer l'export</title>
319
+ </run_export> -->
320
+ <set_product translate="title" module="profileolabs_shoppingflux">
321
+ <title>Sélection de produit</title>
322
+ </set_product>
323
+ </children>
324
+ </export>
325
+ <crons translate="title" module="profileolabs_shoppingflux">
326
+ <title>Suivi des crons</title>
327
+ </crons>
328
+ </children>
329
+ </shoppingflux>
330
+ </children>
331
+ </admin>
332
+ </resources>
333
+ </acl>
334
+ <events>
335
+ <catalog_product_delete_after_done>
336
+ <observers>
337
+ <sf_delete_event>
338
+ <type>singleton</type>
339
+ <class>Profileolabs_Shoppingflux_Model_Export_Observer</class>
340
+ <method>realtimeUpdateDeletedProduct</method>
341
+ </sf_delete_event>
342
+ </observers>
343
+ </catalog_product_delete_after_done>
344
+ <shoppingflux_mass_publish_save_item>
345
+ <observers>
346
+ <sf_mass_insf_update>
347
+ <type>singleton</type>
348
+ <class>Profileolabs_Shoppingflux_Model_Export_Observer</class>
349
+ <method>realtimeUpdateInSfMass</method>
350
+ </sf_mass_insf_update>
351
+ </observers>
352
+ </shoppingflux_mass_publish_save_item>
353
+ <catalog_product_save_after>
354
+ <observers>
355
+ <sf_price_update>
356
+ <type>singleton</type>
357
+ <class>Profileolabs_Shoppingflux_Model_Export_Observer</class>
358
+ <method>realtimeUpdatePrice</method>
359
+ </sf_price_update>
360
+ <sf_insf_update>
361
+ <type>singleton</type>
362
+ <class>Profileolabs_Shoppingflux_Model_Export_Observer</class>
363
+ <method>realtimeUpdateInSf</method>
364
+ </sf_insf_update>
365
+ <sf_disabled_update_save>
366
+ <type>singleton</type>
367
+ <class>Profileolabs_Shoppingflux_Model_Export_Observer</class>
368
+ <method>realtimeUpdateDisabledProductSave</method>
369
+ </sf_disabled_update_save>
370
+ </observers>
371
+ </catalog_product_save_after>
372
+ <catalog_product_status_update>
373
+ <observers>
374
+ <sf_disabled_update>
375
+ <type>singleton</type>
376
+ <class>Profileolabs_Shoppingflux_Model_Export_Observer</class>
377
+ <method>realtimeUpdateDisabledProduct</method>
378
+ </sf_disabled_update>
379
+ </observers>
380
+ </catalog_product_status_update>
381
+ <adminhtml_catalog_category_tabs>
382
+ <observers>
383
+ <sf_adminhtml_catalog_category_tabs>
384
+ <type>singleton</type>
385
+ <class>profileolabs_shoppingflux/export_observer</class>
386
+ <method>addShoppingfluxProductsTab</method>
387
+ </sf_adminhtml_catalog_category_tabs>
388
+ </observers>
389
+ </adminhtml_catalog_category_tabs>
390
+ <catalog_category_prepare_save>
391
+ <observers>
392
+ <sf_catalog_category_prepare_save>
393
+ <type>singleton</type>
394
+ <class>profileolabs_shoppingflux/export_observer</class>
395
+ <method>saveShoppingfluxCategoryProducts</method>
396
+ </sf_catalog_category_prepare_save>
397
+ </observers>
398
+ </catalog_category_prepare_save>
399
+ </events>
400
+ </adminhtml>
401
+ <crontab>
402
+ <jobs>
403
+ <import_orders_shoppingflux>
404
+ <schedule>
405
+ <cron_expr>*/30 * * * *</cron_expr>
406
+ </schedule>
407
+ <run>
408
+ <model>profileolabs_shoppingflux/manageorders_observer::manageOrders</model>
409
+ </run>
410
+ </import_orders_shoppingflux>
411
+ <export_updates_shoppingflux>
412
+ <schedule>
413
+ <cron_expr>*/10 * * * *</cron_expr>
414
+ </schedule>
415
+ <run>
416
+ <model>profileolabs_shoppingflux/export_observer::updateFlux</model>
417
+ </run>
418
+ </export_updates_shoppingflux>
419
+ <export_update_stock_shoppingflux>
420
+ <schedule>
421
+ <cron_expr>*/30 * * * *</cron_expr>
422
+ </schedule>
423
+ <run>
424
+ <model>profileolabs_shoppingflux/export_observer::checkStock</model>
425
+ </run>
426
+ </export_update_stock_shoppingflux>
427
+ <export_flux_in_file>
428
+ <schedule>
429
+ <cron_expr>0 5 * * *</cron_expr>
430
+ </schedule>
431
+ <run>
432
+ <model>profileolabs_shoppingflux/export_observer::generateFluxInFile</model>
433
+ </run>
434
+ </export_flux_in_file>
435
+ <export_shipments_shoppingflux>
436
+ <schedule>
437
+ <cron_expr>*/10 * * * *</cron_expr>
438
+ </schedule>
439
+ <run>
440
+ <model>profileolabs_shoppingflux/manageorders_observer::sendScheduledShipments</model>
441
+ </run>
442
+ </export_shipments_shoppingflux>
443
+ <!--<export_updates_shoppingflux>
444
+ <schedule>
445
+ <cron_expr>*/5 * * * *</cron_expr>
446
+ </schedule>
447
+ <run>
448
+ <model>profileolabs_shoppingflux/export_observer::manageUpdates</model>
449
+ </run>
450
+ </export_updates_shoppingflux>-->
451
+ <!-- <generate_flow_shoppingflux>
452
+ <schedule><cron_expr>30 03 * * *</cron_expr></schedule>
453
+ <run><model>profileolabs_shoppingflux/export_observer::generateFlow</model></run>
454
+ </generate_flow_shoppingflux> -->
455
+ </jobs>
456
+ </crontab>
457
+ <default>
458
+ <shoppingflux>
459
+ <configuration>
460
+ <is_sandbox>0</is_sandbox>
461
+ <ws_uri_test>http://test.shopping-flux.com/ws/</ws_uri_test>
462
+ <ws_uri_prod>http://ws.shopping-flux.com</ws_uri_prod>
463
+ <!--<ws_uri_prod>https://clients.shopping-flux.com/webservice/</ws_uri_prod>-->
464
+ <!--<ws_uri_prod>https://clients.shopping-flux.com/webservice/magento/</ws_uri_prod>-->
465
+ <api_key></api_key>
466
+ </configuration>
467
+ </shoppingflux>
468
+ <shoppingflux_mo>
469
+ <manageorders>
470
+ <enabled>0</enabled>
471
+ <limit_orders>30</limit_orders>
472
+ <new_order_status>pending</new_order_status>
473
+ <create_invoice>1</create_invoice>
474
+ <processing_order_status>processing</processing_order_status>
475
+ <apply_tax>0</apply_tax>
476
+ </manageorders>
477
+ </shoppingflux_mo>
478
+ <payment>
479
+ <shoppingflux_purchaseorder>
480
+ <active>0</active>
481
+ <model>profileolabs_shoppingflux/manageorders_payment_method_purchaseorder</model>
482
+ <order_status>new</order_status>
483
+ <title>Shopping Flux Purchase Order</title>
484
+ <allowspecific>0</allowspecific>
485
+ </shoppingflux_purchaseorder>
486
+ </payment>
487
+ <carriers>
488
+ <shoppingflux>
489
+ <active>1</active>
490
+ <sallowspecific>0</sallowspecific>
491
+ <model>profileolabs_shoppingflux/manageorders_shipping_carrier_shoppingflux</model>
492
+ <name>Frais de port de la place de marché</name>
493
+ <title></title>
494
+ </shoppingflux>
495
+ </carriers>
496
+ <shoppingflux_export>
497
+ <general>
498
+ <active>1</active>
499
+ <filter_by_attribute>0</filter_by_attribute>
500
+ <limit_product>100</limit_product>
501
+ <default_shipping_delay>2</default_shipping_delay>
502
+ <default_shipping_price></default_shipping_price>
503
+ <default_shipping_method>flatrate_flatrate</default_shipping_method>
504
+ <shipping_price_based_on>FR</shipping_price_based_on>
505
+ <export_soldout>1</export_soldout>
506
+ <export_visibility>2,3,4</export_visibility>
507
+ <memory_limit>512</memory_limit>
508
+ <use_manage_stock>1</use_manage_stock>
509
+ <all_store_categories>0</all_store_categories>
510
+ <all_store_products>0</all_store_products>
511
+ <use_only_shoppingflux_category>0</use_only_shoppingflux_category>
512
+ <max_category_level>5</max_category_level>
513
+ <enable_events>0</enable_events>
514
+ <manage_configurable>1</manage_configurable>
515
+ <manage_catalog_rules>1</manage_catalog_rules>
516
+ <manage_media_gallery>1</manage_media_gallery>
517
+ </general>
518
+ <attributes_unknow>
519
+ <ean>ean</ean>
520
+ <isbn>isbn</isbn>
521
+ <ref_manufacturer>ref_manufacturer</ref_manufacturer>
522
+ <ref_wholesaler>ref_wholesaler</ref_wholesaler>
523
+ <shipping_delay>shipping_delay</shipping_delay>
524
+ <shipping_send_delay>shipping_send_delay</shipping_send_delay>
525
+ <brand>brand</brand>
526
+ <brand_page_url>brand_page_url</brand_page_url>
527
+ <ecotaxe>ecotaxe</ecotaxe>
528
+ <short_name>short_name</short_name>
529
+ <characteristics>characteristics</characteristics>
530
+ <warranty>warranty</warranty>
531
+ <kind>kind</kind>
532
+ <matter>matter</matter>
533
+ <size>size</size>
534
+ <shoe_size>shoe_size</shoe_size>
535
+ <dimension>dimension</dimension>
536
+ </attributes_unknow>
537
+ <attributes_know>
538
+ <name>name</name>
539
+ <description>description</description>
540
+ <short_description>short_description</short_description>
541
+ <meta_keyword>meta_keyword</meta_keyword>
542
+ <weight>weight</weight>
543
+ <color>color</color>
544
+ </attributes_know>
545
+ <specific_prices>
546
+ <price>price</price>
547
+ <special_price>special_price</special_price>
548
+ </specific_prices>
549
+ </shoppingflux_export>
550
+ </default>
551
+ </config>
app/code/community/Profileolabs/Shoppingflux/etc/system.xml ADDED
@@ -0,0 +1,1137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <shoppingflux translate="label" module="profileolabs_shoppingflux">
5
+ <label>Shopping Flux</label>
6
+ <sort_order>210</sort_order>
7
+ </shoppingflux>
8
+ </tabs>
9
+ <sections>
10
+ <shoppingflux translate="label" module="profileolabs_shoppingflux">
11
+ <label>Général</label>
12
+ <tab>shoppingflux</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>10</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <configuration translate="label" module="profileolabs_shoppingflux">
20
+ <label>Configuration</label>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <sort_order>1</sort_order>
25
+ <fields>
26
+ <login>
27
+ <label>Identifiant Shopping flux</label>
28
+ <comment>Votre login de connexion à l'interface Shopping flux</comment>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>10</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ </login>
35
+ <api_key>
36
+ <label>Api key</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>20</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </api_key>
43
+ <id_tracking>
44
+ <label>ID de tracking</label>
45
+ <comment>Votre identifiant pour le tracking</comment>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>30</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </id_tracking>
52
+ <alert_email>
53
+ <label>Email pour les alertes</label>
54
+ <comment>En cas de problème lors des transfert de données, un mail vous sera envoyé à cette adresse.</comment>
55
+ <frontend_type>text</frontend_type>
56
+ <sort_order>100</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </alert_email>
61
+ </fields>
62
+ </configuration>
63
+ </groups>
64
+ </shoppingflux>
65
+ <shoppingflux_mo translate="label" module="profileolabs_shoppingflux">
66
+ <label>Manage Orders</label>
67
+ <tab>shoppingflux</tab>
68
+ <frontend_type>text</frontend_type>
69
+ <sort_order>100</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ <groups>
74
+ <manageorders translate="label" module="profileolabs_shoppingflux">
75
+ <label>Manage Orders</label>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ <sort_order>1</sort_order>
80
+ <fields>
81
+ <enabled>
82
+ <label>Enable manage orders</label>
83
+ <comment>Enable get orders from Shopping Flux</comment>
84
+ <frontend_type>select</frontend_type>
85
+ <sort_order>10</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ <source_model>adminhtml/system_config_source_yesno</source_model>
90
+ </enabled>
91
+ <limit_orders>
92
+ <label>Import by n orders</label>
93
+ <sort_order>22</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ <comment>Limit number of orders imported. 10 by default</comment>
98
+ </limit_orders>
99
+ <new_order_status translate="label">
100
+ <label>New order status</label>
101
+ <frontend_type>select</frontend_type>
102
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
103
+ <sort_order>80</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>0</show_in_store>
107
+ </new_order_status>
108
+ <create_invoice>
109
+ <label>Create invoice</label>
110
+ <comment>Invoice is created when order getted from Shopping Flux</comment>
111
+ <frontend_type>select</frontend_type>
112
+ <sort_order>25</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ <source_model>adminhtml/system_config_source_yesno</source_model>
117
+ </create_invoice>
118
+ <processing_order_status translate="label">
119
+ <label>Invoiced order status</label>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
122
+ <sort_order>80</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>0</show_in_store>
126
+ </processing_order_status>
127
+ <!--<import_store>
128
+ <label>Import Store</label>
129
+ <comment>Orders will be imported in selected store</comment>
130
+ <frontend_type>select</frontend_type>
131
+ <sort_order>26</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>0</show_in_website>
134
+ <show_in_store>0</show_in_store>
135
+ <source_model>adminhtml/system_config_source_store</source_model>
136
+ </import_store>-->
137
+ <!--<apply_tax>
138
+ <label>Apply tax</label>
139
+ <comment><![CDATA[Calculation of tax when order is created.<b style='color:red'>Do not active if you sell your products Excl. Tax</b>]]>
140
+ </comment>
141
+ <frontend_type>select</frontend_type>
142
+ <sort_order>27</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ <source_model>adminhtml/system_config_source_yesno</source_model>
147
+ </apply_tax>)-->
148
+ <!-- <is_test>
149
+ <label>Test</label>
150
+ <frontend_type>select</frontend_type>
151
+ <source_model>adminhtml/system_config_source_yesno</source_model>
152
+ <comment>Si oui, la requête se fait su l'url test de shopping flux</comment>
153
+ <sort_order>30</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>0</show_in_website>
156
+ <show_in_store>0</show_in_store>
157
+ </is_test> -->
158
+ </fields>
159
+ </manageorders>
160
+ <import_customer translate="label" module="profileolabs_shoppingflux">
161
+ <label>Import Customers</label>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ <sort_order>2</sort_order>
166
+ <fields>
167
+ <limit_address_length>
168
+ <label>Limiter la longueur des lignes d'adresse</label>
169
+ <comment>Laisser vide pour ne pas limiter. Valeur mini : 20</comment>
170
+ <frontend_type>text</frontend_type>
171
+ <sort_order>5</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>0</show_in_website>
174
+ <show_in_store>0</show_in_store>
175
+ </limit_address_length>
176
+ <default_group>
177
+ <label>Default customer group</label>
178
+ <comment>Set specific customer group for imported customer from Shopping Flux</comment>
179
+ <frontend_type>select</frontend_type>
180
+ <sort_order>10</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>0</show_in_website>
183
+ <show_in_store>0</show_in_store>
184
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
185
+ </default_group>
186
+ <amazon_group>
187
+ <label>Amazon customer group</label>
188
+ <comment>Set specific customer group for imported customer from Amazon. Leave empty to use default.</comment>
189
+ <frontend_type>select</frontend_type>
190
+ <sort_order>30</sort_order>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>0</show_in_website>
193
+ <show_in_store>0</show_in_store>
194
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
195
+ </amazon_group>
196
+ <cdiscount_group>
197
+ <label>Cdiscount customer group</label>
198
+ <comment>Set specific customer group for imported customer from Cdiscount. Leave empty to use default.</comment>
199
+ <frontend_type>select</frontend_type>
200
+ <sort_order>40</sort_order>
201
+ <show_in_default>1</show_in_default>
202
+ <show_in_website>0</show_in_website>
203
+ <show_in_store>0</show_in_store>
204
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
205
+ </cdiscount_group>
206
+ <ebay_group>
207
+ <label>Ebay customer group</label>
208
+ <comment>Set specific customer group for imported customer from Ebay. Leave empty to use default.</comment>
209
+ <frontend_type>select</frontend_type>
210
+ <sort_order>50</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>0</show_in_website>
213
+ <show_in_store>0</show_in_store>
214
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
215
+ </ebay_group>
216
+ <fnac_group>
217
+ <label>Fnac customer group</label>
218
+ <comment>Set specific customer group for imported customer from Fnac. Leave empty to use default.</comment>
219
+ <frontend_type>select</frontend_type>
220
+ <sort_order>50</sort_order>
221
+ <show_in_default>1</show_in_default>
222
+ <show_in_website>0</show_in_website>
223
+ <show_in_store>0</show_in_store>
224
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
225
+ </fnac_group>
226
+ <pixmania_group>
227
+ <label>Pixmania customer group</label>
228
+ <comment>Set specific customer group for imported customer from Pixmania. Leave empty to use default.</comment>
229
+ <frontend_type>select</frontend_type>
230
+ <sort_order>60</sort_order>
231
+ <show_in_default>1</show_in_default>
232
+ <show_in_website>0</show_in_website>
233
+ <show_in_store>0</show_in_store>
234
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
235
+ </pixmania_group>
236
+ <priceminister_group>
237
+ <label>Priceminister customer group</label>
238
+ <comment>Set specific customer group for imported customer from Priceminister. Leave empty to use default.</comment>
239
+ <frontend_type>select</frontend_type>
240
+ <sort_order>60</sort_order>
241
+ <show_in_default>1</show_in_default>
242
+ <show_in_website>0</show_in_website>
243
+ <show_in_store>0</show_in_store>
244
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
245
+ </priceminister_group>
246
+ <rueducommerce_group>
247
+ <label>Rueducommerce customer group</label>
248
+ <comment>Set specific customer group for imported customer from Rueducommerce. Leave empty to use default.</comment>
249
+ <frontend_type>select</frontend_type>
250
+ <sort_order>60</sort_order>
251
+ <show_in_default>1</show_in_default>
252
+ <show_in_website>0</show_in_website>
253
+ <show_in_store>0</show_in_store>
254
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
255
+ </rueducommerce_group>
256
+ <brandalley_group>
257
+ <label>Brandalley customer group</label>
258
+ <comment>Set specific customer group for imported customer from Brandalley Leave empty to use default.</comment>
259
+ <frontend_type>select</frontend_type>
260
+ <sort_order>60</sort_order>
261
+ <show_in_default>1</show_in_default>
262
+ <show_in_website>0</show_in_website>
263
+ <show_in_store>0</show_in_store>
264
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
265
+ </brandalley_group>
266
+ <toutaporter_group>
267
+ <label>ToutAPorter customer group</label>
268
+ <comment>Set specific customer group for imported customer from ToutAPorter Leave empty to use default.</comment>
269
+ <frontend_type>select</frontend_type>
270
+ <sort_order>60</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>0</show_in_website>
273
+ <show_in_store>0</show_in_store>
274
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
275
+ </toutaporter_group>
276
+ <greenrepublic_group>
277
+ <label>GreenRepublic customer group</label>
278
+ <comment>Set specific customer group for imported customer from GreenRepublic Leave empty to use default.</comment>
279
+ <frontend_type>select</frontend_type>
280
+ <sort_order>60</sort_order>
281
+ <show_in_default>1</show_in_default>
282
+ <show_in_website>0</show_in_website>
283
+ <show_in_store>0</show_in_store>
284
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
285
+ </greenrepublic_group>
286
+ <laredoute_group>
287
+ <label>Laredoute customer group</label>
288
+ <comment>Set specific customer group for imported customer from Laredoute Leave empty to use default.</comment>
289
+ <frontend_type>select</frontend_type>
290
+ <sort_order>60</sort_order>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>0</show_in_website>
293
+ <show_in_store>0</show_in_store>
294
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
295
+ </laredoute_group>
296
+ <babyssima_group>
297
+ <label>Babyssima customer group</label>
298
+ <comment>Set specific customer group for imported customer from Babyssima Leave empty to use default.</comment>
299
+ <frontend_type>select</frontend_type>
300
+ <sort_order>60</sort_order>
301
+ <show_in_default>1</show_in_default>
302
+ <show_in_website>0</show_in_website>
303
+ <show_in_store>0</show_in_store>
304
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
305
+ </babyssima_group>
306
+ <monechelle_group>
307
+ <label>Monechelle customer group</label>
308
+ <comment>Set specific customer group for imported customer from Monechelle Leave empty to use default.</comment>
309
+ <frontend_type>select</frontend_type>
310
+ <sort_order>60</sort_order>
311
+ <show_in_default>1</show_in_default>
312
+ <show_in_website>0</show_in_website>
313
+ <show_in_store>0</show_in_store>
314
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
315
+ </monechelle_group>
316
+ <ecitizen_group>
317
+ <label>Ecitizen customer group</label>
318
+ <comment>Set specific customer group for imported customer from Ecitizen Leave empty to use default.</comment>
319
+ <frontend_type>select</frontend_type>
320
+ <sort_order>60</sort_order>
321
+ <show_in_default>1</show_in_default>
322
+ <show_in_website>0</show_in_website>
323
+ <show_in_store>0</show_in_store>
324
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
325
+ </ecitizen_group>
326
+ <decofinder_group>
327
+ <label>Decofinder customer group</label>
328
+ <comment>Set specific customer group for imported customer from Decofinder Leave empty to use default.</comment>
329
+ <frontend_type>select</frontend_type>
330
+ <sort_order>60</sort_order>
331
+ <show_in_default>1</show_in_default>
332
+ <show_in_website>0</show_in_website>
333
+ <show_in_store>0</show_in_store>
334
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
335
+ </decofinder_group>
336
+ <docteurdiscount_group>
337
+ <label>Docteurdiscount customer group</label>
338
+ <comment>Set specific customer group for imported customer from Docteurdiscount Leave empty to use default.</comment>
339
+ <frontend_type>select</frontend_type>
340
+ <sort_order>60</sort_order>
341
+ <show_in_default>1</show_in_default>
342
+ <show_in_website>0</show_in_website>
343
+ <show_in_store>0</show_in_store>
344
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
345
+ </docteurdiscount_group>
346
+ <glamour_group>
347
+ <label>Glamour customer group</label>
348
+ <comment>Set specific customer group for imported customer from Glamour Leave empty to use default.</comment>
349
+ <frontend_type>select</frontend_type>
350
+ <sort_order>60</sort_order>
351
+ <show_in_default>1</show_in_default>
352
+ <show_in_website>0</show_in_website>
353
+ <show_in_store>0</show_in_store>
354
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
355
+ </glamour_group>
356
+ <gstk_group>
357
+ <label>Gstk customer group</label>
358
+ <comment>Set specific customer group for imported customer from Gstk Leave empty to use default.</comment>
359
+ <frontend_type>select</frontend_type>
360
+ <sort_order>60</sort_order>
361
+ <show_in_default>1</show_in_default>
362
+ <show_in_website>0</show_in_website>
363
+ <show_in_store>0</show_in_store>
364
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
365
+ </gstk_group>
366
+ </fields>
367
+ </import_customer>
368
+ <shipping_method translate="label" module="profileolabs_shoppingflux">
369
+ <label>Shipping Methods</label>
370
+ <show_in_default>1</show_in_default>
371
+ <show_in_website>1</show_in_website>
372
+ <show_in_store>1</show_in_store>
373
+ <sort_order>3</sort_order>
374
+ <fields>
375
+ <default_method>
376
+ <label>Default shipping method</label>
377
+ <comment>Set specific shipping method for imported order from Shopping Flux</comment>
378
+ <frontend_type>select</frontend_type>
379
+ <sort_order>10</sort_order>
380
+ <show_in_default>1</show_in_default>
381
+ <show_in_website>0</show_in_website>
382
+ <show_in_store>0</show_in_store>
383
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
384
+ </default_method>
385
+ <amazon_method>
386
+ <label>Amazon shipping method</label>
387
+ <comment>Set specific shipping method for imported order from Amazon. Leave empty to use default.</comment>
388
+ <frontend_type>select</frontend_type>
389
+ <sort_order>30</sort_order>
390
+ <show_in_default>1</show_in_default>
391
+ <show_in_website>0</show_in_website>
392
+ <show_in_store>0</show_in_store>
393
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
394
+ </amazon_method>
395
+ <cdiscount_method>
396
+ <label>Cdiscount shipping method</label>
397
+ <comment>Set specific shipping method for imported order from Cdiscount. Leave empty to use default.</comment>
398
+ <frontend_type>select</frontend_type>
399
+ <sort_order>40</sort_order>
400
+ <show_in_default>1</show_in_default>
401
+ <show_in_website>0</show_in_website>
402
+ <show_in_store>0</show_in_store>
403
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
404
+ </cdiscount_method>
405
+ <ebay_method>
406
+ <label>Ebay shipping method</label>
407
+ <comment>Set specific shipping method for imported order from Ebay. Leave empty to use default.</comment>
408
+ <frontend_type>select</frontend_type>
409
+ <sort_order>50</sort_order>
410
+ <show_in_default>1</show_in_default>
411
+ <show_in_website>0</show_in_website>
412
+ <show_in_store>0</show_in_store>
413
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
414
+ </ebay_method>
415
+ <fnac_method>
416
+ <label>Fnac shipping method</label>
417
+ <comment>Set specific shipping method for imported order from Fnac. Leave empty to use default.</comment>
418
+ <frontend_type>select</frontend_type>
419
+ <sort_order>50</sort_order>
420
+ <show_in_default>1</show_in_default>
421
+ <show_in_website>0</show_in_website>
422
+ <show_in_store>0</show_in_store>
423
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
424
+ </fnac_method>
425
+ <pixmania_method>
426
+ <label>Pixmania shipping method</label>
427
+ <comment>Set specific shipping method for imported order from Pixmania. Leave empty to use default.</comment>
428
+ <frontend_type>select</frontend_type>
429
+ <sort_order>60</sort_order>
430
+ <show_in_default>1</show_in_default>
431
+ <show_in_website>0</show_in_website>
432
+ <show_in_store>0</show_in_store>
433
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
434
+ </pixmania_method>
435
+ <priceminister_method>
436
+ <label>Priceminister shipping method</label>
437
+ <comment>Set specific shipping method for imported order from Priceminister. Leave empty to use default.</comment>
438
+ <frontend_type>select</frontend_type>
439
+ <sort_order>60</sort_order>
440
+ <show_in_default>1</show_in_default>
441
+ <show_in_website>0</show_in_website>
442
+ <show_in_store>0</show_in_store>
443
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
444
+ </priceminister_method>
445
+ <rueducommerce_method>
446
+ <label>Rueducommerce shipping method</label>
447
+ <comment>Set specific shipping method for imported order from Rueducommerce. Leave empty to use default.</comment>
448
+ <frontend_type>select</frontend_type>
449
+ <sort_order>60</sort_order>
450
+ <show_in_default>1</show_in_default>
451
+ <show_in_website>0</show_in_website>
452
+ <show_in_store>0</show_in_store>
453
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
454
+ </rueducommerce_method>
455
+ <brandalley_method>
456
+ <label>Brandalley shipping method</label>
457
+ <comment>Set specific shipping method for imported order from Brandalley. Leave empty to use default.</comment>
458
+ <frontend_type>select</frontend_type>
459
+ <sort_order>60</sort_order>
460
+ <show_in_default>1</show_in_default>
461
+ <show_in_website>0</show_in_website>
462
+ <show_in_store>0</show_in_store>
463
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
464
+ </brandalley_method>
465
+ <toutaporter_method>
466
+ <label>ToutAPorter shipping method</label>
467
+ <comment>Set specific shipping method for imported order from ToutAPorter. Leave empty to use default.</comment>
468
+ <frontend_type>select</frontend_type>
469
+ <sort_order>60</sort_order>
470
+ <show_in_default>1</show_in_default>
471
+ <show_in_website>0</show_in_website>
472
+ <show_in_store>0</show_in_store>
473
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
474
+ </toutaporter_method>
475
+ <greenrepublic_method>
476
+ <label>GreenRepublic shipping method</label>
477
+ <comment>Set specific shipping method for imported order from GreenRepublic. Leave empty to use default.</comment>
478
+ <frontend_type>select</frontend_type>
479
+ <sort_order>60</sort_order>
480
+ <show_in_default>1</show_in_default>
481
+ <show_in_website>0</show_in_website>
482
+ <show_in_store>0</show_in_store>
483
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
484
+ </greenrepublic_method>
485
+ <laredoute_method>
486
+ <label>Laredoute shipping method</label>
487
+ <comment>Set specific shipping method for imported order from Laredoute. Leave empty to use default.</comment>
488
+ <frontend_type>select</frontend_type>
489
+ <sort_order>60</sort_order>
490
+ <show_in_default>1</show_in_default>
491
+ <show_in_website>0</show_in_website>
492
+ <show_in_store>0</show_in_store>
493
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
494
+ </laredoute_method>
495
+ <babyssima_method>
496
+ <label>Babyssima shipping method</label>
497
+ <comment>Set specific shipping method for imported order from Babyssima. Leave empty to use default.</comment>
498
+ <frontend_type>select</frontend_type>
499
+ <sort_order>60</sort_order>
500
+ <show_in_default>1</show_in_default>
501
+ <show_in_website>0</show_in_website>
502
+ <show_in_store>0</show_in_store>
503
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
504
+ </babyssima_method>
505
+ <monechelle_method>
506
+ <label>Monechelle shipping method</label>
507
+ <comment>Set specific shipping method for imported order from Monechelle. Leave empty to use default.</comment>
508
+ <frontend_type>select</frontend_type>
509
+ <sort_order>60</sort_order>
510
+ <show_in_default>1</show_in_default>
511
+ <show_in_website>0</show_in_website>
512
+ <show_in_store>0</show_in_store>
513
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
514
+ </monechelle_method>
515
+ <ecitizen_method>
516
+ <label>Ecitizen shipping method</label>
517
+ <comment>Set specific shipping method for imported order from Ecitizen. Leave empty to use default.</comment>
518
+ <frontend_type>select</frontend_type>
519
+ <sort_order>60</sort_order>
520
+ <show_in_default>1</show_in_default>
521
+ <show_in_website>0</show_in_website>
522
+ <show_in_store>0</show_in_store>
523
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
524
+ </ecitizen_method>
525
+ <decofinder_method>
526
+ <label>Decofinder shipping method</label>
527
+ <comment>Set specific shipping method for imported order from Decofinder. Leave empty to use default.</comment>
528
+ <frontend_type>select</frontend_type>
529
+ <sort_order>60</sort_order>
530
+ <show_in_default>1</show_in_default>
531
+ <show_in_website>0</show_in_website>
532
+ <show_in_store>0</show_in_store>
533
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
534
+ </decofinder_method>
535
+ <docteurdiscount_method>
536
+ <label>Docteurdiscount shipping method</label>
537
+ <comment>Set specific shipping method for imported order from Docteurdiscount. Leave empty to use default.</comment>
538
+ <frontend_type>select</frontend_type>
539
+ <sort_order>60</sort_order>
540
+ <show_in_default>1</show_in_default>
541
+ <show_in_website>0</show_in_website>
542
+ <show_in_store>0</show_in_store>
543
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
544
+ </docteurdiscount_method>
545
+ <glamour_method>
546
+ <label>Glamour shipping method</label>
547
+ <comment>Set specific shipping method for imported order from Glamour. Leave empty to use default.</comment>
548
+ <frontend_type>select</frontend_type>
549
+ <sort_order>60</sort_order>
550
+ <show_in_default>1</show_in_default>
551
+ <show_in_website>0</show_in_website>
552
+ <show_in_store>0</show_in_store>
553
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
554
+ </glamour_method>
555
+ <gstk_method>
556
+ <label>Gstk shipping method</label>
557
+ <comment>Set specific shipping method for imported order from Gstk. Leave empty to use default.</comment>
558
+ <frontend_type>select</frontend_type>
559
+ <sort_order>60</sort_order>
560
+ <show_in_default>1</show_in_default>
561
+ <show_in_website>0</show_in_website>
562
+ <show_in_store>0</show_in_store>
563
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
564
+ </gstk_method>
565
+ </fields>
566
+ </shipping_method>
567
+ <advanced_shipping_method translate="label" module="profileolabs_shoppingflux">
568
+ <label>Advanced Shipping Methods Mapping</label>
569
+ <frontend_model>profileolabs_shoppingflux/manageorders_adminhtml_system_config_form_fieldset_shipping_method</frontend_model>
570
+ <show_in_default>1</show_in_default>
571
+ <show_in_website>1</show_in_website>
572
+ <show_in_store>1</show_in_store>
573
+ <sort_order>4</sort_order>
574
+ </advanced_shipping_method>
575
+ </groups>
576
+ </shoppingflux_mo>
577
+ <shoppingflux_export translate="label" module="profileolabs_shoppingflux">
578
+ <label>Gestion des produits</label>
579
+ <tab>shoppingflux</tab>
580
+ <frontend_type>text</frontend_type>
581
+ <sort_order>90</sort_order>
582
+ <show_in_default>1</show_in_default>
583
+ <show_in_website>1</show_in_website>
584
+ <show_in_store>1</show_in_store>
585
+ <groups>
586
+ <general translate="label">
587
+ <label>Generale</label>
588
+ <comment>
589
+ <![CDATA[<b style="color:red">Url de votre flux xml :</b>&nbsp;&nbsp;<span style="font-size:14px;font-style:italic;">http://{votre domaine}/shoppingflux/export_flux/</span><br /><br /><br />]]>
590
+ </comment>
591
+ <show_in_default>1</show_in_default>
592
+ <show_in_website>1</show_in_website>
593
+ <show_in_store>1</show_in_store>
594
+ <sort_order>1</sort_order>
595
+ <fields>
596
+ <active>
597
+ <label>Activer le module Shopping-flux</label>
598
+ <comment></comment>
599
+ <frontend_type>select</frontend_type>
600
+ <sort_order>1</sort_order>
601
+ <show_in_default>1</show_in_default>
602
+ <show_in_website>1</show_in_website>
603
+ <show_in_store>1</show_in_store>
604
+ <source_model>adminhtml/system_config_source_yesno</source_model>
605
+ </active>
606
+ <filter_by_attribute>
607
+ <label>Exporter uniquement les produits sélectionnés</label>
608
+ <comment>N'oubliez pas de sélectionner des produits à filtrer.
609
+ <strong>Shoppingflux > Sélectionnez les produits</strong>
610
+ </comment>
611
+ <frontend_type>select</frontend_type>
612
+ <sort_order>5</sort_order>
613
+ <show_in_default>1</show_in_default>
614
+ <show_in_website>1</show_in_website>
615
+ <show_in_store>1</show_in_store>
616
+ <source_model>adminhtml/system_config_source_yesno</source_model>
617
+ </filter_by_attribute>
618
+ <!-- <limit_product>
619
+ <label>Export par n produits</label>
620
+ <comment></comment>
621
+ <sort_order>10</sort_order>
622
+ <show_in_default>1</show_in_default>
623
+ <show_in_website>1</show_in_website>
624
+ <show_in_store>1</show_in_store>
625
+ <comment>Limite le nombre de produit par lots</comment>
626
+ </limit_product> -->
627
+ <default_shipping_delay>
628
+ <label>Délai de livraison</label>
629
+ <comment><![CDATA[Délai de livraison en <strong>jours</strong> par défaut si aucun attribut n'est mappé.]]>
630
+ </comment>
631
+ <frontend_type>text</frontend_type>
632
+ <sort_order>20</sort_order>
633
+ <show_in_default>1</show_in_default>
634
+ <show_in_website>1</show_in_website>
635
+ <show_in_store>1</show_in_store>
636
+ </default_shipping_delay>
637
+ <default_shipping_price>
638
+ <label>Frais de port</label>
639
+ <comment>Frais de port par défaut si aucune correpondance n'est trouvée.</comment>
640
+ <frontend_type>text</frontend_type>
641
+ <sort_order>40</sort_order>
642
+ <show_in_default>1</show_in_default>
643
+ <show_in_website>1</show_in_website>
644
+ <show_in_store>1</show_in_store>
645
+ </default_shipping_price>
646
+ <default_shipping_method>
647
+ <label>Méthode de livraison </label>
648
+ <comment>Méthode de livraison par défaut pour calculer les frais de livraison</comment>
649
+ <frontend_type>select</frontend_type>
650
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
651
+ <sort_order>30</sort_order>
652
+ <show_in_default>1</show_in_default>
653
+ <show_in_website>1</show_in_website>
654
+ <show_in_store>1</show_in_store>
655
+ </default_shipping_method>
656
+ <try_use_real_shipping_price>
657
+ <label>Essayer de récupérer les prix de livraison réels</label>
658
+ <comment>Désactiver cette option en cas de problème de mémoire.</comment>
659
+ <frontend_type>select</frontend_type>
660
+ <sort_order>40</sort_order>
661
+ <show_in_default>1</show_in_default>
662
+ <show_in_website>1</show_in_website>
663
+ <show_in_store>1</show_in_store>
664
+ <source_model>adminhtml/system_config_source_yesno</source_model>
665
+ </try_use_real_shipping_price>
666
+ <shipping_price_based_on>
667
+ <label>Pays de livraison</label>
668
+ <comment>Pays par défaut pour calculer les frais de livraison</comment>
669
+ <frontend_type>select</frontend_type>
670
+ <source_model>adminhtml/system_config_source_country</source_model>
671
+ <sort_order>50</sort_order>
672
+ <show_in_default>1</show_in_default>
673
+ <show_in_website>1</show_in_website>
674
+ <show_in_store>1</show_in_store>
675
+ </shipping_price_based_on>
676
+ <export_soldout>
677
+ <label>Exporter les produits hors stock</label>
678
+ <comment></comment>
679
+ <frontend_type>select</frontend_type>
680
+ <sort_order>60</sort_order>
681
+ <show_in_default>1</show_in_default>
682
+ <show_in_website>1</show_in_website>
683
+ <show_in_store>1</show_in_store>
684
+ <source_model>adminhtml/system_config_source_yesno</source_model>
685
+ </export_soldout>
686
+ <export_visibility>
687
+ <label>Exporter les produits avec la visibilité</label>
688
+ <comment></comment>
689
+ <frontend_type>multiselect</frontend_type>
690
+ <sort_order>70</sort_order>
691
+ <show_in_default>1</show_in_default>
692
+ <show_in_website>1</show_in_website>
693
+ <show_in_store>1</show_in_store>
694
+ <source_model>profileolabs_shoppingflux/export_source_visibility</source_model>
695
+ </export_visibility>
696
+ <memory_limit>
697
+ <label>Limite de mémoire</label>
698
+ <comment>Exprimé en MB. A ne modifier que si vous savez ce que vous faites.</comment>
699
+ <frontend_type>text</frontend_type>
700
+ <sort_order>100</sort_order>
701
+ <show_in_default>1</show_in_default>
702
+ <show_in_website>0</show_in_website>
703
+ <show_in_store>0</show_in_store>
704
+ </memory_limit>
705
+ <enable_sync>
706
+ <label>Activer les mises à jour automatique</label>
707
+ <comment>Mise à jour des stocks et des prix en temps réel. Cela peut ralentir les modifications de stock/prix.</comment>
708
+ <frontend_type>select</frontend_type>
709
+ <sort_order>120</sort_order>
710
+ <show_in_default>1</show_in_default>
711
+ <show_in_website>0</show_in_website>
712
+ <show_in_store>0</show_in_store>
713
+ <source_model>adminhtml/system_config_source_yesno</source_model>
714
+ </enable_sync>
715
+ <use_manage_stock>
716
+ <label>Prendre compte la gestion des stocks ?</label>
717
+ <comment>Si oui, les produits en "Gestion des stocks" : "Non" auront un stock à 100 dans le flux.</comment>
718
+ <frontend_type>select</frontend_type>
719
+ <sort_order>130</sort_order>
720
+ <show_in_default>1</show_in_default>
721
+ <show_in_website>0</show_in_website>
722
+ <show_in_store>0</show_in_store>
723
+ <source_model>adminhtml/system_config_source_yesno</source_model>
724
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
725
+ </use_manage_stock>
726
+ <all_store_products>
727
+ <label>Prendre les produits de tous les Magasins ?</label>
728
+ <comment>En cas de doute, laisser à non.</comment>
729
+ <frontend_type>select</frontend_type>
730
+ <sort_order>135</sort_order>
731
+ <show_in_default>1</show_in_default>
732
+ <show_in_website>0</show_in_website>
733
+ <show_in_store>0</show_in_store>
734
+ <source_model>adminhtml/system_config_source_yesno</source_model>
735
+ </all_store_products>
736
+ <all_store_categories>
737
+ <label>Prendre les catégories de tous les Magasins ?</label>
738
+ <comment>En cas de doute, laisser à non.</comment>
739
+ <frontend_type>select</frontend_type>
740
+ <sort_order>140</sort_order>
741
+ <show_in_default>1</show_in_default>
742
+ <show_in_website>0</show_in_website>
743
+ <show_in_store>0</show_in_store>
744
+ <source_model>adminhtml/system_config_source_yesno</source_model>
745
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
746
+ </all_store_categories>
747
+ <use_only_shoppingflux_category>
748
+ <label>N'utilisez que la catégorie ShoppingFlux</label>
749
+ <comment>Gain en performance si oui.</comment>
750
+ <frontend_type>select</frontend_type>
751
+ <sort_order>150</sort_order>
752
+ <show_in_default>1</show_in_default>
753
+ <show_in_website>1</show_in_website>
754
+ <show_in_store>1</show_in_store>
755
+ <source_model>adminhtml/system_config_source_yesno</source_model>
756
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
757
+ </use_only_shoppingflux_category>
758
+ <max_category_level>
759
+ <label>N'utilisez que les X premiers niveaux de catégories</label>
760
+ <frontend_type>select</frontend_type>
761
+ <sort_order>150</sort_order>
762
+ <show_in_default>1</show_in_default>
763
+ <show_in_website>1</show_in_website>
764
+ <show_in_store>1</show_in_store>
765
+ <source_model>profileolabs_shoppingflux/export_source_category_level</source_model>
766
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
767
+ </max_category_level>
768
+ <enable_events>
769
+ <label>Activer les évenements ShoppingFlux ?</label>
770
+ <comment>Utile uniquement en cas de développement spécifique. Désactiver pour gagner en performances.</comment>
771
+ <frontend_type>select</frontend_type>
772
+ <sort_order>160</sort_order>
773
+ <show_in_default>1</show_in_default>
774
+ <show_in_website>1</show_in_website>
775
+ <show_in_store>1</show_in_store>
776
+ <source_model>adminhtml/system_config_source_yesno</source_model>
777
+ </enable_events>
778
+ <manage_configurable>
779
+ <label>Gestion des produits configurables en mode avancé ?</label>
780
+ <comment>Si non, seuls les produits configurables seront transmis (sans leur enfants). Permet de gagner en performances si cette option n'est pas utile.</comment>
781
+ <frontend_type>select</frontend_type>
782
+ <sort_order>170</sort_order>
783
+ <show_in_default>1</show_in_default>
784
+ <show_in_website>1</show_in_website>
785
+ <show_in_store>1</show_in_store>
786
+ <source_model>adminhtml/system_config_source_yesno</source_model>
787
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
788
+ </manage_configurable>
789
+ <manage_catalog_rules>
790
+ <label>Gestion des règles de prix catalogue ?</label>
791
+ <frontend_type>select</frontend_type>
792
+ <sort_order>180</sort_order>
793
+ <show_in_default>1</show_in_default>
794
+ <show_in_website>1</show_in_website>
795
+ <show_in_store>1</show_in_store>
796
+ <source_model>adminhtml/system_config_source_yesno</source_model>
797
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
798
+ </manage_catalog_rules>
799
+ <manage_media_gallery>
800
+ <label>Gestion des galeries de photos produit ?</label>
801
+ <comment>Ne concerne pas l'image principale du produit. Mettre à non pour gain de performances.</comment>
802
+ <frontend_type>select</frontend_type>
803
+ <sort_order>190</sort_order>
804
+ <show_in_default>1</show_in_default>
805
+ <show_in_website>1</show_in_website>
806
+ <show_in_store>1</show_in_store>
807
+ <source_model>adminhtml/system_config_source_yesno</source_model>
808
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
809
+ </manage_media_gallery>
810
+ </fields>
811
+ </general>
812
+ <attributes_unknow translate="label">
813
+ <label>Mapping d'attributs Inconnus</label>
814
+ <show_in_default>1</show_in_default>
815
+ <show_in_website>1</show_in_website>
816
+ <show_in_store>1</show_in_store>
817
+ <sort_order>20</sort_order>
818
+ <fields>
819
+ <ean>
820
+ <label>Ean</label>
821
+ <comment></comment>
822
+ <frontend_type>select</frontend_type>
823
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
824
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
825
+ <sort_order>10</sort_order>
826
+ <show_in_default>1</show_in_default>
827
+ <show_in_website>1</show_in_website>
828
+ <show_in_store>1</show_in_store>
829
+ </ean>
830
+ <isbn>
831
+ <label>ISBN</label>
832
+ <comment></comment>
833
+ <frontend_type>select</frontend_type>
834
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
835
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
836
+ <sort_order>20</sort_order>
837
+ <show_in_default>1</show_in_default>
838
+ <show_in_website>1</show_in_website>
839
+ <show_in_store>1</show_in_store>
840
+ </isbn>
841
+ <ref_manufacturer>
842
+ <label>Référence constructeur</label>
843
+ <comment></comment>
844
+ <frontend_type>select</frontend_type>
845
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
846
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
847
+ <sort_order>30</sort_order>
848
+ <show_in_default>1</show_in_default>
849
+ <show_in_website>1</show_in_website>
850
+ <show_in_store>1</show_in_store>
851
+ </ref_manufacturer>
852
+ <ref_wholesaler>
853
+ <label>Référence fournisseur</label>
854
+ <comment></comment>
855
+ <frontend_type>select</frontend_type>
856
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
857
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
858
+ <sort_order>40</sort_order>
859
+ <show_in_default>1</show_in_default>
860
+ <show_in_website>1</show_in_website>
861
+ <show_in_store>1</show_in_store>
862
+ </ref_wholesaler>
863
+ <shipping_delay>
864
+ <label>Délai de livraison</label>
865
+ <comment></comment>
866
+ <frontend_type>select</frontend_type>
867
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
868
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
869
+ <sort_order>42</sort_order>
870
+ <show_in_default>1</show_in_default>
871
+ <show_in_website>1</show_in_website>
872
+ <show_in_store>1</show_in_store>
873
+ </shipping_delay>
874
+ <shipping_send_delay>
875
+ <label>Délai de d'expédition</label>
876
+ <comment></comment>
877
+ <frontend_type>select</frontend_type>
878
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
879
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
880
+ <sort_order>43</sort_order>
881
+ <show_in_default>1</show_in_default>
882
+ <show_in_website>1</show_in_website>
883
+ <show_in_store>1</show_in_store>
884
+ </shipping_send_delay>
885
+ <brand>
886
+ <label>Marque</label>
887
+ <comment></comment>
888
+ <frontend_type>select</frontend_type>
889
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
890
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
891
+ <sort_order>50</sort_order>
892
+ <show_in_default>1</show_in_default>
893
+ <show_in_website>1</show_in_website>
894
+ <show_in_store>1</show_in_store>
895
+ </brand>
896
+ <brand_page_url>
897
+ <label>URL de la page Marque</label>
898
+ <comment></comment>
899
+ <frontend_type>select</frontend_type>
900
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
901
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
902
+ <sort_order>55</sort_order>
903
+ <show_in_default>1</show_in_default>
904
+ <show_in_website>1</show_in_website>
905
+ <show_in_store>1</show_in_store>
906
+ </brand_page_url>
907
+ <ecotaxe>
908
+ <label>Ecotaxe</label>
909
+ <comment>Si vos produits ont une écotaxe</comment>
910
+ <frontend_type>select</frontend_type>
911
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
912
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
913
+ <sort_order>60</sort_order>
914
+ <show_in_default>1</show_in_default>
915
+ <show_in_website>1</show_in_website>
916
+ <show_in_store>1</show_in_store>
917
+ </ecotaxe>
918
+ <short_name>
919
+ <label>Nom court du produit</label>
920
+ <comment></comment>
921
+ <frontend_type>select</frontend_type>
922
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
923
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
924
+ <sort_order>70</sort_order>
925
+ <show_in_default>1</show_in_default>
926
+ <show_in_website>1</show_in_website>
927
+ <show_in_store>1</show_in_store>
928
+ </short_name>
929
+ <characteristics>
930
+ <label>Caractéristiques</label>
931
+ <comment></comment>
932
+ <frontend_type>select</frontend_type>
933
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
934
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
935
+ <sort_order>80</sort_order>
936
+ <show_in_default>1</show_in_default>
937
+ <show_in_website>1</show_in_website>
938
+ <show_in_store>1</show_in_store>
939
+ </characteristics>
940
+ <warranty>
941
+ <label>Garantie</label>
942
+ <comment></comment>
943
+ <frontend_type>select</frontend_type>
944
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
945
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
946
+ <sort_order>90</sort_order>
947
+ <show_in_default>1</show_in_default>
948
+ <show_in_website>1</show_in_website>
949
+ <show_in_store>1</show_in_store>
950
+ </warranty>
951
+ <kind>
952
+ <label>Genre</label>
953
+ <comment></comment>
954
+ <frontend_type>select</frontend_type>
955
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
956
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
957
+ <sort_order>100</sort_order>
958
+ <show_in_default>1</show_in_default>
959
+ <show_in_website>1</show_in_website>
960
+ <show_in_store>1</show_in_store>
961
+ </kind>
962
+ <matter>
963
+ <label>Matière</label>
964
+ <comment></comment>
965
+ <frontend_type>select</frontend_type>
966
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
967
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
968
+ <sort_order>100</sort_order>
969
+ <show_in_default>1</show_in_default>
970
+ <show_in_website>1</show_in_website>
971
+ <show_in_store>1</show_in_store>
972
+ </matter>
973
+ <size>
974
+ <label>Taille</label>
975
+ <comment></comment>
976
+ <frontend_type>select</frontend_type>
977
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
978
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
979
+ <sort_order>110</sort_order>
980
+ <show_in_default>1</show_in_default>
981
+ <show_in_website>1</show_in_website>
982
+ <show_in_store>1</show_in_store>
983
+ </size>
984
+ <shoe_size>
985
+ <label>Pointure</label>
986
+ <comment></comment>
987
+ <frontend_type>select</frontend_type>
988
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
989
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
990
+ <sort_order>115</sort_order>
991
+ <show_in_default>1</show_in_default>
992
+ <show_in_website>1</show_in_website>
993
+ <show_in_store>1</show_in_store>
994
+ </shoe_size>
995
+ <dimension>
996
+ <label>Dimension</label>
997
+ <comment></comment>
998
+ <frontend_type>select</frontend_type>
999
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1000
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1001
+ <sort_order>120</sort_order>
1002
+ <show_in_default>1</show_in_default>
1003
+ <show_in_website>1</show_in_website>
1004
+ <show_in_store>1</show_in_store>
1005
+ </dimension>
1006
+ </fields>
1007
+ </attributes_unknow>
1008
+ <attributes_know translate="label">
1009
+ <label>Mapping d'attributs Connus</label>
1010
+ <show_in_default>1</show_in_default>
1011
+ <show_in_website>1</show_in_website>
1012
+ <show_in_store>1</show_in_store>
1013
+ <sort_order>30</sort_order>
1014
+ <fields>
1015
+ <name>
1016
+ <label>Nom du produit</label>
1017
+ <comment></comment>
1018
+ <frontend_type>select</frontend_type>
1019
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1020
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1021
+ <sort_order>10</sort_order>
1022
+ <show_in_default>1</show_in_default>
1023
+ <show_in_website>1</show_in_website>
1024
+ <show_in_store>1</show_in_store>
1025
+ </name>
1026
+ <description>
1027
+ <label>Description du produit</label>
1028
+ <comment></comment>
1029
+ <frontend_type>select</frontend_type>
1030
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1031
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1032
+ <sort_order>20</sort_order>
1033
+ <show_in_default>1</show_in_default>
1034
+ <show_in_website>1</show_in_website>
1035
+ <show_in_store>1</show_in_store>
1036
+ </description>
1037
+ <short_description>
1038
+ <label>Description courte du produit</label>
1039
+ <comment></comment>
1040
+ <frontend_type>select</frontend_type>
1041
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1042
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1043
+ <sort_order>30</sort_order>
1044
+ <show_in_default>1</show_in_default>
1045
+ <show_in_website>1</show_in_website>
1046
+ <show_in_store>1</show_in_store>
1047
+ </short_description>
1048
+ <meta_keyword>
1049
+ <label>Mot clés</label>
1050
+ <comment></comment>
1051
+ <frontend_type>select</frontend_type>
1052
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1053
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1054
+ <sort_order>30</sort_order>
1055
+ <show_in_default>1</show_in_default>
1056
+ <show_in_website>1</show_in_website>
1057
+ <show_in_store>1</show_in_store>
1058
+ </meta_keyword>
1059
+ <weight>
1060
+ <label>Poids</label>
1061
+ <comment></comment>
1062
+ <frontend_type>select</frontend_type>
1063
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1064
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1065
+ <sort_order>40</sort_order>
1066
+ <show_in_default>1</show_in_default>
1067
+ <show_in_website>1</show_in_website>
1068
+ <show_in_store>1</show_in_store>
1069
+ </weight>
1070
+ <color>
1071
+ <label>Couleur</label>
1072
+ <comment></comment>
1073
+ <frontend_type>select</frontend_type>
1074
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1075
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1076
+ <sort_order>50</sort_order>
1077
+ <show_in_default>1</show_in_default>
1078
+ <show_in_website>1</show_in_website>
1079
+ <show_in_store>1</show_in_store>
1080
+ </color>
1081
+ </fields>
1082
+ </attributes_know>
1083
+ <specific_prices>
1084
+ <label>Prix spécifiques</label>
1085
+ <show_in_default>1</show_in_default>
1086
+ <show_in_website>1</show_in_website>
1087
+ <show_in_store>1</show_in_store>
1088
+ <sort_order>35</sort_order>
1089
+ <fields>
1090
+
1091
+ <price>
1092
+ <label>Prix TTC</label>
1093
+ <comment></comment>
1094
+ <frontend_type>select</frontend_type>
1095
+ <source_model>profileolabs_shoppingflux/export_source_attributesprice</source_model>
1096
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1097
+ <sort_order>60</sort_order>
1098
+ <show_in_default>1</show_in_default>
1099
+ <show_in_website>1</show_in_website>
1100
+ <show_in_store>1</show_in_store>
1101
+ </price>
1102
+ <special_price>
1103
+ <label>Prix Spécial</label>
1104
+ <comment></comment>
1105
+ <frontend_type>select</frontend_type>
1106
+ <source_model>profileolabs_shoppingflux/export_source_attributesprice</source_model>
1107
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1108
+ <sort_order>70</sort_order>
1109
+ <show_in_default>1</show_in_default>
1110
+ <show_in_website>1</show_in_website>
1111
+ <show_in_store>1</show_in_store>
1112
+ </special_price>
1113
+ </fields>
1114
+ </specific_prices>
1115
+ <attributes_additionnal>
1116
+ <label>Attributs supplémentaires</label>
1117
+ <show_in_default>1</show_in_default>
1118
+ <show_in_website>1</show_in_website>
1119
+ <show_in_store>1</show_in_store>
1120
+ <sort_order>40</sort_order>
1121
+ <fields>
1122
+ <list>
1123
+ <label>Autres attributs à transmettre</label>
1124
+ <frontend_type>multiselect</frontend_type>
1125
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1126
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1127
+ <sort_order>125</sort_order>
1128
+ <show_in_default>1</show_in_default>
1129
+ <show_in_website>1</show_in_website>
1130
+ <show_in_store>1</show_in_store>
1131
+ </list>
1132
+ </fields>
1133
+ </attributes_additionnal>
1134
+ </groups>
1135
+ </shoppingflux_export>
1136
+ </sections>
1137
+ </config>
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category ShoppingFlux
5
+ * @package ShoppingFLux_ManageOrders
6
+ * @author kassim belghait
7
+ */
8
+ $installerCustomer = new Mage_Customer_Model_Entity_Setup('profileolabs_shoppingflux_setup');
9
+ /* @var $installerCustomer Mage_Customer_Model_Entity_Setup */
10
+
11
+ $installerCustomer->startSetup();
12
+
13
+ //$attribute = Mage::getModel('eav/config')->getAttribute('customer', 'from_shoppingflux');
14
+ $entityId = $installerCustomer->getEntityTypeId('customer');
15
+ $attribute = $installerCustomer->getAttribute($entityId, 'from_shoppingflux');
16
+ if (!$attribute) {
17
+
18
+ $installerCustomer->addAttribute('customer', 'from_shoppingflux', array(
19
+ 'type' => 'int',
20
+ 'label' => 'From ShoppingFlux',
21
+ 'visible' => true,
22
+ 'required' => false,
23
+ 'unique' => false,
24
+ 'sort_order' => 700,
25
+ 'default' => 0,
26
+ 'input' => 'select',
27
+ 'source' => 'eav/entity_attribute_source_boolean',
28
+ ));
29
+
30
+ $usedInForms = array(
31
+ 'adminhtml_customer',
32
+ );
33
+
34
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'from_shoppingflux');
35
+ $attribute->setData('used_in_forms', $usedInForms);
36
+ $attribute->setData('sort_order', 700);
37
+
38
+ $attribute->save();
39
+ }
40
+
41
+ $installerCustomer->endSetup();
42
+
43
+ $installerSales = new Mage_Sales_Model_Mysql4_Setup('profileolabs_shoppingflux_setup');
44
+ /* @var $installerSales Mage_Sales_Model_Mysql4_Setup */
45
+
46
+ $installerSales->startSetup();
47
+ //if(!Mage::getSingleton('eav/config')->getAttribute('order', 'from_shoppingflux')->getId())
48
+ $entityId = $installerSales->getEntityTypeId('order');
49
+ $attribute = $installerSales->getAttribute($entityId, 'from_shoppingflux');
50
+ if (!$attribute)
51
+ $installerSales->addAttribute('order', 'from_shoppingflux', array(
52
+ 'type' => 'int',
53
+ 'label' => 'From ShoppingFlux',
54
+ 'visible' => true,
55
+ 'required' => false,
56
+ 'unique' => false,
57
+ 'sort_order' => 700,
58
+ 'default' => 0,
59
+ 'input' => 'select',
60
+ 'source' => 'eav/entity_attribute_source_boolean',
61
+ 'grid' => true,
62
+ ));
63
+
64
+ //if(!Mage::getSingleton('eav/config')->getAttribute('order', 'order_id_shoppingflux')->getId())
65
+ $attribute = $installerSales->getAttribute($entityId, 'order_id_shoppingflux');
66
+ if (!$attribute)
67
+ $installerSales->addAttribute('order', 'order_id_shoppingflux', array(
68
+ 'type' => 'varchar',
69
+ 'label' => 'ID Order ShoppingFlux',
70
+ 'visible' => true,
71
+ 'required' => false,
72
+ 'unique' => false,
73
+ 'sort_order' => 705,
74
+ 'input' => 'text',
75
+ 'grid' => true,
76
+ ));
77
+
78
+ //if(!Mage::getSingleton('eav/config')->getAttribute('order', 'marketplace_shoppingflux')->getId())
79
+ $attribute = $installerSales->getAttribute($entityId, 'marketplace_shoppingflux');
80
+ if (!$attribute)
81
+ $installerSales->addAttribute('order', 'marketplace_shoppingflux', array(
82
+ 'type' => 'varchar',
83
+ 'label' => 'Marketplace ShoppingFlux',
84
+ 'visible' => true,
85
+ 'required' => false,
86
+ 'unique' => false,
87
+ 'sort_order' => 710,
88
+ 'input' => 'text',
89
+ 'grid' => true,
90
+ ));
91
+
92
+ //if(!Mage::getSingleton('eav/config')->getAttribute('order', 'fees_shoppingflux')->getId())
93
+ $attribute = $installerSales->getAttribute($entityId, 'fees_shoppingflux');
94
+ if (!$attribute)
95
+ $installerSales->addAttribute('order', 'fees_shoppingflux', array(
96
+ 'type' => 'decimal',
97
+ 'label' => 'Fees ShoppingFlux',
98
+ 'visible' => true,
99
+ 'required' => false,
100
+ 'unique' => false,
101
+ 'sort_order' => 720,
102
+ 'input' => 'text',
103
+ 'grid' => true,
104
+ ));
105
+
106
+ $installerSales->endSetup();
107
+
108
+ $installer = $this;
109
+
110
+ $installer->startSetup();
111
+
112
+ $installer->run(
113
+ "CREATE TABLE IF NOT EXISTS `{$this->getTable('shoppingflux_log')}` (
114
+ `id` int(11) NOT NULL auto_increment,
115
+ `date` timestamp NOT NULL default CURRENT_TIMESTAMP,
116
+ `message` text NOT NULL,
117
+ PRIMARY KEY (`id`)
118
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
119
+
120
+ $installer->endSetup();
121
+
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shoppinflux
4
+ *
5
+ * @category Profileolabs
6
+ * @package Profileolabs_Shoppingflux
7
+ * @author kassim belghait kassim@profileo.com
8
+ */
9
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
10
+ $installer = Mage::getResourceModel('catalog/setup','profileolabs_shoppingflux_setup');
11
+
12
+ $installer->startSetup();
13
+
14
+ $entityId = $installer->getEntityTypeId('catalog_product');
15
+ $attribute = $installer->getAttribute($entityId,'shoppingflux_product');
16
+
17
+ if(!$attribute)
18
+ $installer->addAttribute('catalog_product', 'shoppingflux_product', array(
19
+ 'type' => 'int',
20
+ 'backend' => '',
21
+ 'frontend' => '',
22
+ 'label' => 'Filtrer la présence dans le flux',
23
+ 'input' => 'boolean',
24
+ 'global' => 1,
25
+ 'visible' => 1,
26
+ 'required' => 0,
27
+ 'user_defined' => 0,
28
+ 'default' => 1,
29
+ 'searchable' => 0,
30
+ 'filterable' => 0,
31
+ 'comparable' => 0,
32
+ 'visible_on_front' => 0,
33
+ 'unique' => 0,
34
+ 'used_in_product_listing' => 1
35
+ ));
36
+
37
+ $installer->endSetup();
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.3.13-0.3.14.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppinflux
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author Vincent Enjalbert - web-cooking.net
9
+ */
10
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
11
+ $installer = Mage::getResourceModel('catalog/setup', 'profileolabs_shoppingflux_setup');
12
+
13
+ $installer->startSetup();
14
+
15
+
16
+ $entityId = $installer->getEntityTypeId('catalog_product');
17
+ $attribute = $installer->getAttribute($entityId, 'shoppingflux_default_category');
18
+
19
+ if (!$attribute) {
20
+
21
+ $installer->addAttribute('catalog_product', 'shoppingflux_default_category', array(
22
+ 'group' => 'General',
23
+ 'type' => 'int',
24
+ 'backend' => '',
25
+ 'frontend_input' => '',
26
+ 'frontend' => '',
27
+ 'label' => 'Default Shoppingflux Category',
28
+ 'input' => 'select',
29
+ 'class' => '',
30
+ 'source' => 'profileolabs_shoppingflux/attribute_source_category',
31
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
32
+ 'visible' => true,
33
+ 'used_in_product_listing' => true,
34
+ 'frontend_class' => '',
35
+ 'required' => false,
36
+ 'user_defined' => false,
37
+ 'default' => '',
38
+ 'searchable' => false,
39
+ 'filterable' => false,
40
+ 'comparable' => false,
41
+ 'visible_on_front' => false,
42
+ 'unique' => false,
43
+ 'position' => 60,
44
+ ));
45
+ }
46
+
47
+
48
+
49
+
50
+
51
+ $installer->endSetup();
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.3.14-0.3.15.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppinflux
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author Vincent Enjalbert - web-cooking.net
9
+ */
10
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
11
+ $installer = Mage::getResourceModel('catalog/setup', 'profileolabs_shoppingflux_setup');
12
+
13
+ $installer->startSetup();
14
+
15
+ $installer->updateAttribute('catalog_product', 'shoppingflux_default_category', 'is_global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE);
16
+ $installer->updateAttribute('catalog_product', 'shoppingflux_product', 'is_global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE);
17
+
18
+
19
+
20
+ $installer->endSetup();
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.3.17-0.3.18.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppinflux
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author Vincent Enjalbert - web-cooking.net
9
+ */
10
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
11
+ $installer = Mage::getResourceModel('catalog/setup', 'profileolabs_shoppingflux_setup');
12
+
13
+ $installer->startSetup();
14
+
15
+ $installer->run(
16
+ "CREATE TABLE IF NOT EXISTS `{$this->getTable('shoppingflux_export_updates')}` (
17
+ `update_id` int(11) NOT NULL auto_increment,
18
+ `store_id` int(11) NOT NULL,
19
+ `product_sku` varchar(255) NOT NULL,
20
+ `stock_value` int(11) NOT NULL,
21
+ `price_value` decimal(12,4) NOT NULL,
22
+ `old_price_value` decimal(12,4) NOT NULL,
23
+ `updated_at` timestamp NOT NULL default CURRENT_TIMESTAMP,
24
+ PRIMARY KEY (`update_id`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
26
+
27
+ $installer->run(
28
+ "UPDATE `{$this->getTable('core_config_data')}` set path = 'shoppingflux/configuration/api_key' where path = 'shoppingflux_mo/manageorders/api_key'"
29
+ );
30
+
31
+
32
+ $installer->run(
33
+ "UPDATE `{$this->getTable('core_config_data')}` set path = 'shoppingflux/configuration/login' where path = 'shoppingflux_export/general/login'"
34
+ );
35
+
36
+
37
+ $installer->endSetup();
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.4.2-0.4.3.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppinflux
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author Vincent Enjalbert - web-cooking.net
9
+ */
10
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
11
+
12
+
13
+
14
+ $installerSales = new Mage_Sales_Model_Mysql4_Setup('profileolabs_shoppingflux_setup');
15
+ /* @var $installerSales Mage_Sales_Model_Mysql4_Setup */
16
+
17
+ $installerSales->startSetup();
18
+
19
+ $entityId = $installerSales->getEntityTypeId('order');
20
+
21
+ $attribute = $installerSales->getAttribute($entityId, 'shoppingflux_shipment_flag');
22
+ if (!$attribute) {
23
+ $installerSales->addAttribute('order', 'shoppingflux_shipment_flag', array(
24
+ 'type' => 'int',
25
+ 'label' => 'Is shipped in ShoppingFlux',
26
+ 'visible' => true,
27
+ 'required' => false,
28
+ 'unique' => false,
29
+ 'sort_order' => 705,
30
+ 'default' => 0,
31
+ 'input' => 'select',
32
+ 'source' => 'eav/entity_attribute_source_boolean',
33
+ 'grid' => true,
34
+ ));
35
+ }
36
+
37
+ $installerSales->endSetup();
38
+
39
+
40
+ $installer = $this;
41
+
42
+ $installer->startSetup();
43
+
44
+ $installer->endSetup();
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.4.6-0.5.0.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppinflux
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author Vincent Enjalbert - web-cooking.net
9
+ */
10
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
11
+
12
+
13
+ $installer = $this;
14
+
15
+ $installer->startSetup();
16
+ $installer->run(
17
+ "CREATE TABLE IF NOT EXISTS `{$this->getTable('shoppingflux_export_flux')}` (
18
+ `id` int(11) NOT NULL auto_increment,
19
+ `sku` varchar(255) NOT NULL default '',
20
+ `store_id` smallint(5) NOT NULL default 1,
21
+ `xml` MEDIUMTEXT NOT NULL,
22
+ `is_in_stock` tinyint(1) NOT NULL,
23
+ `is_in_flux` tinyint(1) NOT NULL,
24
+ `type` varchar(50) NOT NULL,
25
+ `visibility` varchar(50) NOT NULL,
26
+ `update_needed` tinyint(1) NOT NULL,
27
+ `should_export` tinyint(1) NOT NULL,
28
+ `updated_at` datetime NOT NULL,
29
+ PRIMARY KEY (`id`),
30
+ CONSTRAINT SF_E_F_UNIQUE UNIQUE (`sku`, `store_id`),
31
+ INDEX (`update_needed`),
32
+ INDEX (`is_in_stock`),
33
+ INDEX (`is_in_flux`),
34
+ INDEX (`type`),
35
+ INDEX (`visibility`),
36
+ INDEX (`should_export`),
37
+ INDEX (`type`, `is_in_stock`, `is_in_flux`, `visibility`, `store_id`, `should_export`),
38
+ INDEX (`type`, `is_in_flux`, `visibility`, `store_id`,`should_export`),
39
+ INDEX (`type`, `is_in_stock`, `visibility`, `store_id`, `should_export`),
40
+ INDEX (`type`, `visibility`, `store_id`, `should_export`),
41
+ INDEX (`sku`),
42
+ INDEX (`store_id`)
43
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
44
+
45
+ $installer->endSetup();
46
+
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.5.1-0.5.2.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppinflux
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author Vincent Enjalbert - web-cooking.net
9
+ */
10
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
11
+
12
+
13
+ //$installer = $this;
14
+
15
+ $installer = Mage::getResourceModel('catalog/setup','profileolabs_shoppingflux_setup');
16
+
17
+ $installer->startSetup();
18
+
19
+
20
+ $entityTypeId = $installer->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY);
21
+ $attrSetIds = $installer->getAllAttributeSetIds($entityTypeId);
22
+ foreach ($attrSetIds as $attrSetId) {
23
+ $group = $installer->getAttributeGroup($entityTypeId, $attrSetId, 'Shopping Flux');
24
+ if (!$group) {
25
+ $installer->addAttributeGroup(Mage_Catalog_Model_Product::ENTITY, $attrSetId, 'Shopping Flux');
26
+ }
27
+ $groupId = $installer->getAttributeGroupId(Mage_Catalog_Model_Product::ENTITY, $attrSetId, 'Shopping Flux');
28
+
29
+
30
+ $attributeId = $installer->getAttributeId($entityTypeId, 'shoppingflux_product');
31
+ $installer->addAttributeToGroup($entityTypeId, $attrSetId, $groupId, $attributeId);
32
+ $attributeId = $installer->getAttributeId($entityTypeId, 'shoppingflux_default_category');
33
+ $installer->addAttributeToGroup($entityTypeId, $attrSetId, $groupId, $attributeId);
34
+ }
35
+
36
+ $installer->updateAttribute('catalog_product', 'shoppingflux_default_category', 'is_user_defined', 0);
37
+ $installer->updateAttribute('catalog_product', 'shoppingflux_product', 'is_user_defined', 0);
38
+
39
+
40
+
41
+ $installer->endSetup();
42
+
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.5.3-0.5.4.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppinflux
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author Vincent Enjalbert - web-cooking.net
9
+ */
10
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
11
+
12
+
13
+ //$installer = $this;
14
+
15
+ $installer = Mage::getResourceModel('catalog/setup','profileolabs_shoppingflux_setup');
16
+
17
+ $installer->startSetup();
18
+
19
+ $installer->run(
20
+ "CREATE TABLE IF NOT EXISTS `{$this->getTable('shoppingflux_shipping_methods')}` (
21
+ `id` int(11) NOT NULL auto_increment,
22
+ `shipping_method` varchar(255) NOT NULL default '',
23
+ `marketplace` varchar(127) NOT NULL default '',
24
+ `last_seen_at` datetime NOT NULL,
25
+ PRIMARY KEY (`id`),
26
+ CONSTRAINT SF_S_M_UNIQUE UNIQUE (`shipping_method`, `marketplace`)
27
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
28
+
29
+ $installer->endSetup();
30
+
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.5.5-0.5.6.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppinflux
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author Vincent Enjalbert - web-cooking.net
9
+ */
10
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
11
+
12
+
13
+ //$installer = $this;
14
+
15
+ $installer = Mage::getResourceModel('catalog/setup','profileolabs_shoppingflux_setup');
16
+
17
+ $installer->startSetup();
18
+
19
+ $installer->run(
20
+ "CREATE TABLE IF NOT EXISTS `{$this->getTable('shoppingflux_manageorders_export_shipments')}` (
21
+ `update_id` int(11) NOT NULL auto_increment,
22
+ `shipment_id` int(11) NOT NULL,
23
+ `updated_at` timestamp NOT NULL default CURRENT_TIMESTAMP,
24
+ PRIMARY KEY (`update_id`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
26
+
27
+ $installer->endSetup();
28
+
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.6.5-0.6.6.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shoppinflux
5
+ *
6
+ * @category Profileolabs
7
+ * @package Profileolabs_Shoppingflux
8
+ * @author Vincent Enjalbert - web-cooking.net
9
+ */
10
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
11
+
12
+
13
+ //$installer = $this;
14
+
15
+ $installer = Mage::getResourceModel('catalog/setup','profileolabs_shoppingflux_setup');
16
+
17
+ $installer->startSetup();
18
+
19
+ $installer->run("
20
+ ALTER TABLE `{$this->getTable('shoppingflux_export_flux')}` ADD `stock_value` INT( 11 ) NOT NULL AFTER `xml`
21
+ ");
22
+
23
+
24
+ $installer->endSetup();
25
+
app/design/adminhtml/default/default/layout/profileolabs_shoppingflux.xml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <shoppingflux_manageorders_adminhtml_order_index>
4
+ <reference name="content">
5
+ <block type="profileolabs_shoppingflux/manageorders_adminhtml_order" name="manageorders.order.grid.container"></block>
6
+ </reference>
7
+ </shoppingflux_manageorders_adminhtml_order_index>
8
+ <shoppingflux_manageorders_adminhtml_log_index>
9
+ <reference name="content">
10
+ <block type="profileolabs_shoppingflux/manageorders_adminhtml_log" name="manageorders.log.grid.container"></block>
11
+ </reference>
12
+ </shoppingflux_manageorders_adminhtml_log_index>
13
+ <shoppingflux_manageorders_adminhtml_cron_index>
14
+ <reference name="content">
15
+ <block type="profileolabs_shoppingflux/manageorders_adminhtml_cron" name="manageorders.cron.grid.container"></block>
16
+ </reference>
17
+ </shoppingflux_manageorders_adminhtml_cron_index>
18
+ <shoppingflux_manageorders_adminhtml_import_index>
19
+ <reference name="content">
20
+ <block type="profileolabs_shoppingflux/manageorders_adminhtml_import" name="manageorders.import" template="profileolabs/shoppingflux/manageorders/import.phtml"></block>
21
+ </reference>
22
+ </shoppingflux_manageorders_adminhtml_import_index>
23
+ <shoppingflux_export_adminhtml_export_edit>
24
+ <reference name="content">
25
+ <block type="adminhtml/template" name="export.edit" template="profileolabs/shoppingflux/export/edit.phtml">
26
+ <block type="adminhtml/store_switcher" name="store.switcher" >
27
+ <action method="setUseConfirm">0</action>
28
+ </block>
29
+ </block>
30
+ </reference>
31
+ </shoppingflux_export_adminhtml_export_edit>
32
+ <shoppingflux_export_adminhtml_export_run>
33
+ <remove name="root"/>
34
+ <block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
35
+ <block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
36
+ <action method="addJs"><script>prototype/prototype.js</script></action>
37
+ <action method="addJs"><script>prototype/validation.js</script></action>
38
+ <action method="addJs"><script>varien/js.js</script></action>
39
+ <action method="addJs"><script>mage/translate.js</script></action>
40
+ <action method="addJs"><script>mage/adminhtml/tools.js</script></action>
41
+ </block>
42
+ <block type="profileolabs_shoppingflux/export_adminhtml_process" name="export.process.run" template="profileolabs/shoppingflux/export/process.phtml" output="toHtml"/>
43
+ </block>
44
+ </shoppingflux_export_adminhtml_export_run>
45
+ <shoppingflux_export_adminhtml_export_update>
46
+ <reference name="content">
47
+ <block type="profileolabs_shoppingflux/export_adminhtml_product" name="products_list">
48
+ <block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher">
49
+ <action method="setUseConfirm"><params>0</params></action>
50
+ </block>
51
+ </block>
52
+ </reference>
53
+ </shoppingflux_export_adminhtml_export_update>
54
+
55
+ <adminhtml_sales_order_view>
56
+ <reference name="order_totals">
57
+ <block type="adminhtml/sales_order_totals_item" name="fees_shoppingflux" template="profileolabs/shoppingflux/manageorders/sales/order/total.phtml">
58
+ </block>
59
+ <!--<block type="adminhtml/sales_order_totals_item" name="simplebundle.refunded" template="webcooking/simplebundle/sales/order/refunded.phtml">
60
+ <action method="setDisplayArea"><area>footer</area></action>
61
+ <action method="setAfterCondition"><condition>last</condition></action>
62
+ </block>-->
63
+ </reference>
64
+ </adminhtml_sales_order_view>
65
+ </layout>
app/design/adminhtml/default/default/template/profileolabs/shoppingflux/export/category/edit.phtml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+
28
+ <script type="text/javascript">
29
+ //<![CDATA[
30
+
31
+ <?php if(($block = $this->getLayout()->getBlock('shoppingflux.product.grid')) && ($_gridJsObject=$block->getJsObjectName())): ?>
32
+ if($('shoppingflux_in_category_products')) {
33
+ var shoppingfluxCategoryProducts = $H(<?php echo $this->getProductsJson() ?>);
34
+ $('shoppingflux_in_category_products').value = shoppingfluxCategoryProducts.toQueryString();
35
+
36
+ function shoppingfluxRegisterCategoryProduct(grid, element, checked){
37
+
38
+ if(checked){
39
+ shoppingfluxCategoryProducts.set(element.value, 1);
40
+ }
41
+ else{
42
+ shoppingfluxCategoryProducts.unset(element.value);
43
+ }
44
+ $('shoppingflux_in_category_products').value = shoppingfluxCategoryProducts.toQueryString();
45
+ grid.reloadParams = {'sf_selected_products[]':shoppingfluxCategoryProducts.keys()};
46
+ }
47
+
48
+
49
+ function shoppingfluxCategoryProductRowClick(grid, event){
50
+ var trElement = Event.findElement(event, 'tr');
51
+ var isInput = Event.element(event).tagName == 'INPUT';
52
+ if(trElement){
53
+ var checkbox = Element.getElementsBySelector(trElement, 'input');
54
+ if(checkbox[0]){
55
+ var checked = isInput ? checkbox[0].checked : !checkbox[0].checked;
56
+ <?php echo $_gridJsObject ?>.setCheckboxChecked(checkbox[0], checked);
57
+ }
58
+ }
59
+ }
60
+
61
+
62
+ function shoppingfluxCategoryProductRowInit(grid, row){
63
+ //var checkbox = $(row).getElementsByClassName('checkbox')[0];
64
+
65
+ }
66
+
67
+
68
+ <?php echo $_gridJsObject ?>.rowClickCallback = shoppingfluxCategoryProductRowClick;
69
+ <?php echo $_gridJsObject ?>.initRowCallback = shoppingfluxCategoryProductRowInit;
70
+ <?php echo $_gridJsObject ?>.checkboxCheckCallback = shoppingfluxRegisterCategoryProduct;
71
+ <?php echo $_gridJsObject ?>.rows.each(function(row){shoppingfluxCategoryProductRowInit(<?php echo $_gridJsObject ?>, row)});
72
+ }
73
+
74
+
75
+ <?php endif; ?>
76
+ //]]>
77
+ </script>
app/design/adminhtml/default/default/template/profileolabs/shoppingflux/export/edit.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_helper = $this->helper('profileolabs_shoppingflux')?>
2
+ <br/>
3
+ <div class="content-header">
4
+ <table cellspacing="0">
5
+ <tr>
6
+ <td><h3><?php echo Mage::helper('profileolabs_shoppingflux')->__('Génération du flux') ?></h3></td><td class="form-buttons"></td>
7
+ </tr>
8
+ </table>
9
+ </div>
10
+
11
+ <?php echo $this->getChildHtml('store.switcher'); ?>
12
+ <?php $storeId = $this->getRequest()->getParam('store',Mage::app()->getDefaultStoreView()->getId())?>
13
+ <table class="form-list">
14
+ <tr>
15
+ <td class="scope-label">
16
+ <button onclick="setLocation('<?php echo $this->getUrl('*/export_adminhtml_export/run',array('store'=>$storeId))?>')" type="button" class="scalable"><span><?php echo Mage::helper('profileolabs_shoppingflux')->__('Shopping flux Export') ?></span></button>
17
+ </td>
18
+ <td class="scope-label">
19
+ <?php echo Mage::helper('profileolabs_shoppingflux')->__('Shopping flux export')?>
20
+ </td>
21
+ </tr>
22
+ <?php $links = $_helper->getFilesGenerated() ?>
23
+ <?php if(count($links)) :?>
24
+ <tr class="scope-label">
25
+ <td class="scope-label"><?php echo Mage::helper('profileolabs_shoppingflux')->__('Vos flux')?></td>
26
+ <td>
27
+ <?php foreach($_helper->getFilesGenerated() as $link) : ?>
28
+ <a href="<?php echo $link ?>" target="_blank"><?php echo $link ?></a><br />
29
+ <?php endforeach; ?>
30
+ </td>
31
+ </tr>
32
+ <?php endif;?>
33
+ </table>
app/design/adminhtml/default/default/template/profileolabs/shoppingflux/export/process.phtml ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $flowModel = $this->getFlowModel()?>
2
+ <style type="text/css" >
3
+ ul { list-style-type:none; padding:0; margin:0; }
4
+ li { margin-left:0; border:1px solid #ccc; margin:2px; padding:2px 2px 2px 2px; font:normal 12px sans-serif; }
5
+ img { margin-right:5px; }
6
+ </style>
7
+ <script type="text/javascript">
8
+ var FORM_KEY = "<?php echo $this->getFormKey();?>";
9
+ </script>
10
+ <ul>
11
+ <li>
12
+ <img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif')?>" class="v-middle" style="margin-right:5px"/>
13
+ <?php echo $this->__("Starting profile execution, please wait...");?>
14
+ </li>
15
+ <li style="background-color:#FFD;">
16
+ <img src="<?php echo $this->getSkinUrl('images/fam_bullet_error.gif');?>" class="v-middle" style="margin-right:5px"/>
17
+ <?php echo $this->__("Warning: Please do not close the window during exporting data");?>
18
+ </li>
19
+ </ul>
20
+
21
+ <?php if (1/*$this->getProfile()->getId()*/):?>
22
+ <ul id="profileRows">
23
+ <?php foreach ($this->getExceptions() as $exceptionInfo):?>
24
+ <li style="<?php echo $exceptionInfo['style'];?>">
25
+ <img src="<?php echo $exceptionInfo['src'];?>" class="v-middle"/>
26
+ <?php echo $exceptionInfo['message'];?>
27
+ <?php if ($exceptionInfo['position']):?>
28
+ <small>(<?php echo $exceptionInfo['position'];?>)</small>
29
+ <?php endif;?>
30
+ </li>
31
+ <?php endforeach;?>
32
+ <li id="liFinished" style="display:none;">
33
+ <img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif');?>" class="v-middle" style="margin-right:5px"/>
34
+ <?php echo $this->__("Finished profile execution.");?>
35
+ </li>
36
+ </ul>
37
+ <script type="text/javascript">
38
+ var countOfStartedProfiles = 0;
39
+ var countOfUpdated = 0;
40
+ var countOfError = 0;
41
+ var importData = [];
42
+ var totalRecords = <?php echo $this->getFlowItemsCount();?>;
43
+ var config= <?php echo $this->getFlowConfigJson();?>;
44
+ </script>
45
+ <script type="text/javascript">
46
+ function addImportData(data) {
47
+ importData.push(data);
48
+ }
49
+
50
+ function execImportData() {
51
+ if (importData.length == 0) {
52
+ //$("updatedRows_img").src = config.styles.message.icon;
53
+ //$("updatedRows").style.backgroundColor = config.styles.message.bg;
54
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
55
+ style: "background-color:"+config.styles.message.bg,
56
+ image: config.styles.message.icon,
57
+ text: config.tplSccTxt.evaluate({updated:(countOfUpdated-countOfError)}),
58
+ id: "updatedFinish"
59
+ })});
60
+
61
+ if ($("liBeforeFinish")) {
62
+ Element.insert($("liFinished"), {before: $("liBeforeFinish")});
63
+ $("liBeforeFinish").show();
64
+ }
65
+
66
+ new Ajax.Request("<?php echo $this->getUrl('*/*/flowFinish');?>", {
67
+ method: "post",
68
+ parameters: {form_key: FORM_KEY,store: <?php echo $this->getRequest()->getParam('store') ?>},
69
+ onComplete: function(transport) {
70
+ if (transport.responseText.isJSON()) {
71
+ var response = transport.responseText.evalJSON();
72
+ if (response.error) {
73
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
74
+ style: "background-color:"+config.styles.error.bg,
75
+ image: config.styles.error.icon,
76
+ text: response.error.escapeHTML(),
77
+ id: "error-finish"
78
+ })});
79
+ }
80
+ else if(response.filename)
81
+ {
82
+ $("liFinished").update('<?php echo $this->__("Finished profile execution.");?> URL: <a href="'+response.filename+'" target="_blank">'+response.filename+' </a>');
83
+
84
+ }
85
+
86
+
87
+ }
88
+
89
+ if ($("before-finish-wait-img")) {
90
+ $("before-finish-wait-img").hide();
91
+ }
92
+
93
+ $('liFinished').show();
94
+ }
95
+ });
96
+ } else {
97
+ sendImportData(importData.shift());
98
+ }
99
+ }
100
+
101
+ function sendImportData(data) {
102
+
103
+ totalRecords = data.nbProducts;
104
+
105
+ if (!config.tpl) {
106
+ config.tpl = new Template(config.template);
107
+ config.tplTxt = new Template(config.text);
108
+ config.tplSccTxt = new Template(config.successText);
109
+ }
110
+ if (!$("updatedRows")) {
111
+ Element.insert($("liFinished"), {before: config.tpl.evaluate({
112
+ style: "background-color: #FFD;",
113
+ image: config.styles.loader,
114
+ text: config.tplTxt.evaluate({offset:data.offset, updated:0, percent:getPercent(0),savedRows:totalRecords}),
115
+ id: "updatedRows_"+data.offset
116
+ })});
117
+ }
118
+ countOfStartedProfiles++;
119
+ if (!data.form_key) {
120
+ data.form_key = FORM_KEY;
121
+ }
122
+
123
+ new Ajax.Request("<?php echo $this->getUrl('*/*/flowRun');?>", {
124
+ method: "post",
125
+ parameters: data,
126
+ onSuccess: function(transport) {
127
+ countOfStartedProfiles --;
128
+ countOfUpdated += data["nbProducts"];//data["rows[]"].length;
129
+ if (transport.responseText.isJSON()) {
130
+ addProfileRow(transport.responseText.evalJSON());
131
+ } else {
132
+ Element.insert($("updatedRows"), {before: config.tpl.evaluate({
133
+ style: "background-color:"+config.styles.error.bg,
134
+ image: config.styles.error.icon,
135
+ text: transport.responseText.escapeHTML(),
136
+ id: "error-" + countOfStartedProfiles
137
+ })});
138
+ countOfError += data["nbProducts"];//data["rows[]"].length;
139
+ }
140
+
141
+ execImportData();
142
+ }
143
+ });
144
+ }
145
+
146
+ function getPercent(countOfUpdated) {
147
+ return Math.ceil((countOfUpdated/totalRecords)*1000)/10;
148
+ }
149
+
150
+ function addProfileRow(data) {
151
+ if (data.errors.length > 0) {
152
+ for (var i=0, length=data.errors.length; i<length; i++) {
153
+ Element.insert($("updatedRows_"+data.offset), {before: config.tpl.evaluate({
154
+ style: "background-color:"+config.styles.error.bg,
155
+ image: config.styles.error.icon,
156
+ text: data.errors[i],
157
+ id: "id-" + (countOfUpdated + i + 1)
158
+ })});
159
+ countOfError ++;
160
+ }
161
+ }
162
+ $("updatedRows_"+data.offset+"_status").update(config.tplTxt.evaluate({offset:data.offset ,updated:data.savedRows, percent:getPercent(data.savedRows),savedRows:data.savedRows}));
163
+ $("updatedRows_"+data.offset+"_img").src = config.styles.message.icon;
164
+ $("updatedRows_"+data.offset).style.backgroundColor = config.styles.message.bg;
165
+ }
166
+ </script>
167
+ <?php $importData = $this->getImportData();?>
168
+ <script type="text/javascript">
169
+ <?php foreach ($importData as $importValue):?>
170
+ addImportData(<?php echo $this->jsonEncode($importValue);?>);
171
+ <?php endforeach;?>
172
+ execImportData();
173
+ </script>
174
+
175
+ <?php if ($this->getShowFinished()):?>
176
+ <script type="text/javascript">$('liFinished').show();</script>
177
+ <?php endif;?>
178
+ <?php endif;?>
app/design/adminhtml/default/default/template/profileolabs/shoppingflux/export/product.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var $this Profileolabs_Shoppingflux_Block_Export_Adminhtml_Product
4
+ * @see Profileolabs_Shoppingflux_Block_Export_Adminhtml_Product
5
+ */
6
+ ?>
7
+ <div class="content-header">
8
+ <table cellspacing="0">
9
+ <tr>
10
+ <td style="width:50%;"><h3 class="icon-head head-products"><?php echo Mage::helper('profileolabs_shoppingflux')->__('Sélectionnez les produits à importer') ?></h3></td>
11
+ <td class="a-right">
12
+ <?php echo $this->getButtonsHtml() ?>
13
+ </td>
14
+ </tr>
15
+ </table>
16
+ </div>
17
+ <?php if( !$this->isSingleStoreMode() ): ?>
18
+ <?php echo $this->getChildHtml('store_switcher');?>
19
+ <?php endif;?>
20
+ <div>
21
+ <?php echo $this->getGridHtml() ?>
22
+ </div>
app/design/adminhtml/default/default/template/profileolabs/shoppingflux/manageorders/import.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <br/>
2
+ <div class="content-header">
3
+ <table cellspacing="0">
4
+ <tr>
5
+ <td><h3><?php echo Mage::helper('profileolabs_shoppingflux')->__('Shopping flux import orders') ?></h3></td><td class="form-buttons"></td>
6
+ </tr>
7
+ </table>
8
+ </div>
9
+ <table class="form-list">
10
+ <tr>
11
+ <td class="scope-label">
12
+ <button onclick="setLocation('<?php echo $this->getImportOrdersUrl()?>')" type="button" class="scalable"><span><?php echo Mage::helper('profileolabs_shoppingflux')->__('Shopping flux import new orders') ?></span></button>
13
+ </td>
14
+ <td class="scope-label">
15
+ <?php echo Mage::helper('profileolabs_shoppingflux')->__('Shopping flux import new orders')?>
16
+ </td>
17
+ </table>
app/design/adminhtml/default/default/template/profileolabs/shoppingflux/manageorders/payment/info/purchaseorder.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <p><?php echo $this->__($this->getMethod()->getTitle()) ?></p>
28
+ <p><?php echo $this->__('Marketplace: %s', $this->htmlEscape($this->getInfo()->getAdditionalData())) ?></p>
app/design/adminhtml/default/default/template/profileolabs/shoppingflux/manageorders/sales/order/total.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php $this->setPriceDataObject($this->getSource()) ?>
2
+ <?php if ((float) $this->getSource()->getFeesShoppingflux()): ?>
3
+ <tr class="simplebundle">
4
+ <td class="label a-right" <?php echo $this->getColspan()?'colspan="'.$this->getColspan().'"':''?>><?php echo Mage::helper('profileolabs_shoppingflux')->formatFeesDescription($this->getSource()->getFeesShoppingflux(), $this->getSource()->getMarketplaceShoppingflux()) ?></td>
5
+ <td class="a-right">
6
+ <?php echo $this->displayPrices($this->getSource()->getFeesShoppingflux(), $this->getSource()->getFeesShoppingflux()); ?>
7
+ </td>
8
+ </tr>
9
+ <?php endif; ?>
app/design/frontend/base/default/layout/profileolabs_shoppingflux.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <checkout_onepage_success>
4
+ <reference name="before_body_end">
5
+ <block type="profileolabs_shoppingflux/tracking_roi" name="sf_tracking_roi" as="sf.track.roi" />
6
+ </reference>
7
+ </checkout_onepage_success>
8
+ <default>
9
+ <reference name="before_body_end">
10
+ <block type="profileolabs_shoppingflux/tracking_buyline" name="sf_tracking_buyline" as="sf.track.buyline" />
11
+ </reference>
12
+ </default>
13
+ </layout>
app/design/frontend/default/default/layout/profileolabs_shoppingflux.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <checkout_onepage_success>
4
+ <reference name="before_body_end">
5
+ <block type="profileolabs_shoppingflux/tracking_roi" name="sf_tracking_roi" as="sf.track.roi" />
6
+ </reference>
7
+ </checkout_onepage_success>
8
+ <default>
9
+ <reference name="before_body_end">
10
+ <block type="profileolabs_shoppingflux/tracking_buyline" name="sf_tracking_buyline" as="sf.track.buyline" />
11
+ </reference>
12
+ </default>
13
+ </layout>
app/etc/modules/Profileolabs_Shoppingflux.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Profileolabs_Shoppingflux>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Profileolabs_Shoppingflux>
8
+ </modules>
9
+ </config>
app/locale/fr_FR/Profileolabs_Shoppingflux.csv ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Shopping Flux","Shopping Flux"
2
+ "Shoppingflux Configuration","Configuration de Shoppingflux"
3
+ "Parameters","Paramètres"
4
+ "Manage Orders","Gestion des Commandes"
5
+ "Shoppingflux manage orders","Shoppingflux gestion des commandes"
6
+ "Enable manage orders","Activer la gestion des commandes"
7
+ "Enable get orders from Shopping Flux","Acitve la récupération des commandes depuis Shopping Flux"
8
+ "Api key","Clé de l'API"
9
+ "API key (Token) not valid","La clé d'API (Jeton) n'est pas valide"
10
+ "API Key (Token) is empty","La clé d'API (Jeton) est vide"
11
+ "Shopping Flux Purchase Order","Bon de commande Shopping Flux"
12
+ "Marketplace","Place de marché"
13
+ "Marketplace: %s","Place de marché: %s"
14
+ "Shopping Flux Purchase Order","Bon de commande Shopping FLux"
15
+ "Shopping Flux shipping","Frais de port Shopping Flux"
16
+ "Marketplace shipping","Frais de port de place de marché"
17
+ "Shopping flux orders","Commandes Shopping flux"
18
+ "Shopping flux import orders","Shopping flux import des commandes"
19
+ "Shopping flux import new orders","Shopping flux import des nouvelles commandes"
20
+ "Fees","Comission"
21
+ "%d orders are imported","%d commandes importées"
22
+ "Status of order ids sended: %s","Status des commandes remontées à Shopping Flux: %s"
23
+ "Orders can not getted.","Les commandes n'ont pu être récupérées"
24
+ "Error","Erreur"
25
+ "Shopping flux log","Journal Shopping flux"
26
+ "Created at","Créé le"
27
+ "OrderID","Id Commande"
28
+ "Log is empty.","Le journal d'évènements est vide."
29
+ "Delete","Effacer"
30
+ "Create invoice","Facturation automatique"
31
+ "Invoice is created when order getted from Shopping Flux","La facture est créée quand la commande est enregistrée."
32
+ "Apply tax","Appliquer la TVA"
33
+ "Calculation of tax when order is created.<b style='color:red'>Do not active if you sell your products Excl. Tax</b>","Application de la TVA lors de la création de la commande. <b style='color:red'>Ne pas activer si vous vendez vos produit Hors Taxe.</b>"
34
+ "Import by n orders","Importer par n commandes"
35
+ "Limit number of orders imported. 10 by default","Limit le nombre de commandes importées à chaque appel. 10 par défaut."
36
+ "Import Customers","Import Clients"
37
+ "Default customer group","Groupe client par défaut"
38
+ "Amazon customer group","Groupe client Amazon"
39
+ "Cdiscount customer group","Groupe client Cdiscount"
40
+ "Ebay customer group","Groupe client Ebay"
41
+ "Fnac customer group","Groupe client Fnac"
42
+ "Pixmania customer group","Groupe client Pixmania"
43
+ "Priceminister customer group","Groupe client Priceminister"
44
+ "Rueducommerce customer group","Groupe client Rueducommerce"
45
+ "Set specific customer group for imported customer from Shopping Flux","Attribuer un groupe client spécifique pour les clients importés depuis shopping flux"
46
+ "Set specific customer group for imported customer from Amazon. Leave empty to use default.","Attribuer un groupe client spécifique pour les clients importés depuis Amazon. Laisser vide pour utiliser le groupe par défaut."
47
+ "Set specific customer group for imported customer from Cdiscount. Leave empty to use default.","Attribuer un groupe client spécifique pour les clients importés depuis Cdiscount. Laisser vide pour utiliser le groupe par défaut."
48
+ "Set specific customer group for imported customer from Ebay. Leave empty to use default.","Attribuer un groupe client spécifique pour les clients importés depuis Ebay. Laisser vide pour utiliser le groupe par défaut."
49
+ "Set specific customer group for imported customer from Fnac. Leave empty to use default.","Attribuer un groupe client spécifique pour les clients importés depuis Fnac. Laisser vide pour utiliser le groupe par défaut."
50
+ "Set specific customer group for imported customer from Pixmania. Leave empty to use default.","Attribuer un groupe client spécifique pour les clients importés depuis Pixmania. Laisser vide pour utiliser le groupe par défaut."
51
+ "Set specific customer group for imported customer from Priceminister. Leave empty to use default.","Attribuer un groupe client spécifique pour les clients importés depuis Priceminister. Laisser vide pour utiliser le groupe par défaut."
52
+ "Set specific customer group for imported customer from Rueducommerce. Leave empty to use default.","Attribuer un groupe client spécifique pour les clients importés depuis Rueducommerce. Laisser vide pour utiliser le groupe par défaut."
53
+ "Default Shoppingflux Category","Catégorie Shoppingflux"
54
+ "Shoppingflux Category Products","Produits de la catégorie (Shoppingflux)"
55
+ "Current default category","Catégorie actuelle"
56
+ "Import Store","Vue magasin où importer les commandes"
57
+ "Orders will be imported in selected store","Les commandes shoppingflux seront importés dans la vue séléctionnée"
58
+ "Yes","Oui"
59
+ "No","Non"
60
+ "In category ?","Présent ?"
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Profileolabs_Shoppingflux</name>
4
+ <version>0.6.7</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Export your products on price comparison sites and marketplaces, with lift controls.</summary>
10
+ <description>This module will allow you to connect your Magento Shopping-Flux (monthly subscription from 79 &#x20AC; / month) to export your products on price comparison sites and marketplaces, with managing your commands directly into your Magento. You'll increase your sales by making available on: . Google Shopping . LeGuide.com . Shopping . Shopzilla . Twenga (and over a hundred other price comparison sites and buying guides) . eBay . Rue Du Commerce . C Market (CDsicount) . PixPlace (Pixmania) . Amazon . PriceMinister (and all, more than a dozen marketplaces) With rise in orders directly into your Magento for a quick and easy management of your orders for your products and the most profitable. with Shopping Flux, you can also create Adwords campaigns for each of your product descriptions, create a shop on FaceBook, etc. ... Shopping Flux Technology is the most innovative of the French market and has many Ecommer&#xE7;ants Magento. Ask a free trial for 1 month on our website : www.shopping-flux.com</description>
11
+ <notes>- Minor bugfixes &amp; improvements&#xD;
12
+ </notes>
13
+ <authors><author><name>ShoppingFlux</name><user>ShoppingFlux</user><email>olivier.levy@gmail.com</email></author></authors>
14
+ <date>2014-03-21</date>
15
+ <time>09:24:07</time>
16
+ <contents><target name="magecommunity"><dir name="Profileolabs"><dir name="Shoppingflux"><dir name="Block"><dir name="Export"><dir name="Adminhtml"><dir name="Catalog"><dir name="Category"><dir name="Edit"><file name="Form.php" hash="01fbc1b6a37bade4c42d16f69c81d521"/></dir><dir name="Tab"><file name="Default.php" hash="93984ddcd10a244848c4b50c2e2bdefd"/></dir></dir></dir><file name="Process.php" hash="089b7ff33cb86aca245c50039364b2c5"/><dir name="Product"><file name="Grid.php" hash="bbf320eb116782ab45b743583bd34dd6"/></dir><file name="Product.php" hash="7aa8758de0a8a735aed6e9d4eef411b4"/><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Bool.php" hash="e0ad22370abc5443a093a1fb00cba0f9"/></dir></dir></dir></dir></dir><file name="Flow.php" hash="dccf1b0eeafd1422b9133bd5b0a9f591"/><file name="Flux.php" hash="e08659e3143bf76fe0aaf2e08545dc37"/><file name="Tracking.php" hash="de73fdd979ea9f5469f0721bdbc00799"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Manageorders"><dir name="Adminhtml"><dir name="Cron"><file name="Grid.php" hash="a4227353008b4c991fc810396131a1c9"/></dir><file name="Cron.php" hash="4a8dc2d6428dcb2ec70ec12ed428f209"/><file name="Import.php" hash="4f68a94c2483202ceb3ded5b39b7d604"/><dir name="Log"><file name="Grid.php" hash="14630ac6613b016d08ee348349bcde3d"/></dir><file name="Log.php" hash="993f5b363ed6389f53108527b86fbf47"/><dir name="Order"><file name="Grid.php" hash="375bce23d1b4295c488a41182edb96b3"/></dir><file name="Order.php" hash="8531840a28d72445dcd6032d05a4cbd4"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Fieldset"><dir name="Shipping"><file name="Method.php" hash="4b3048d3b7e0efe1829d6fd5171fd5eb"/></dir></dir></dir></dir></dir></dir><dir name="Payment"><dir name="Info"><file name="Purchaseorder.php" hash="f9d3c51adaf43799f1e9d50c2bf686d5"/></dir></dir></dir><dir name="Tracking"><file name="Buyline.php" hash="56223e385f7184de124ccba731cba798"/><file name="Roi.php" hash="8c391add3840afbda814e05a0314dfe0"/></dir></dir><dir name="Helper"><file name="Data.php" hash="2c333d20264f2061eebf3f44514f7237"/></dir><dir name="Model"><dir name="Attribute"><dir name="Source"><file name="Category.php" hash="40371a9d5d8724000157cc475dc07a6d"/></dir></dir><file name="Config.php" hash="f23c276fc510f102edcc34de929df3d0"/><dir name="Export"><dir name="Convert"><dir name="Parser"><file name="Product.php" hash="44652262de3046a060189fe8383e2a82"/></dir></dir><file name="Flow.php" hash="c114f34d4c177af8e6395b86e28062b5"/><file name="Flux.php" hash="08cd550517b5df61e0581de975a5aa4e"/><file name="Observer.php" hash="a449b884bc418218c37a99d3c4ba0ecd"/><dir name="Rewrite"><dir name="Catalog"><file name="Config.php" hash="afc40785d2921dc6cb4361287211b499"/></dir><dir name="CatalogInventory"><dir name="Stock"><file name="Item.php" hash="000c348b538c8fe5c60b70405ce1270b"/></dir></dir></dir><dir name="Source"><file name="Attributes.php" hash="f71df1c5708605010b4d32f25ad79f8b"/><file name="Attributesprice.php" hash="53cfa2d7012b2c7cf08adbefcd2b2497"/><dir name="Category"><file name="Level.php" hash="64ad0ba3ca94a65cb15d122544688ae8"/></dir><file name="Visibility.php" hash="dac488668de43355198cef170c04db7d"/></dir><file name="Updates.php" hash="b8307e3ea5370ac72aa44c726ef0aed4"/><file name="Xml.php" hash="51143839a49d20699d42b1d258b194cf"/><file name="Xmlflow.deprecated.php" hash="4dd4c8b91d604629393083f3b069bdd5"/><file name="Xmlflow.php" hash="11ea8fb9cd25e2fc9971c4ee83c5a60a"/></dir><dir name="Manageorders"><dir name="Convert"><file name="Customer.php" hash="9278eb17790c07f189f9aff112a4536d"/></dir><dir name="Export"><file name="Shipments.php" hash="c9626f73c9ca7e2db632646a2896824c"/></dir><file name="Log.php" hash="7ecf8c683392f3fc587cbd85cfa335b5"/><file name="Observer.php" hash="5e3bcb44b2df2b0aa29de39f2064f1a6"/><file name="Order.php" hash="54ad2087484ba6ba08d89322af662a3e"/><file name="OrderOLD.php" hash="f25ef7553ce2a961365cbfa53b95267e"/><dir name="Payment"><dir name="Method"><file name="Purchaseorder.php" hash="441951c04ffa0e3609e2c6372d900ddc"/></dir></dir><file name="Product.php" hash="26590dfd5793317146d80e0abaf43af9"/><dir name="Shipping"><dir name="Carrier"><file name="Shoppingflux.php" hash="1ea781511bba2732263a460a29e4f3ad"/></dir><file name="Method.php" hash="f894777b2476abe9fd153a9b605f5271"/></dir></dir><dir name="Mysql4"><dir name="Export"><dir name="Flux"><file name="Collection.php" hash="d3d5f80d02ae2972a034275acde9ba75"/></dir><file name="Flux.php" hash="59fab20db24c08462fa622bb43d0e7f6"/><dir name="Updates"><file name="Collection.php" hash="c8dee69540209a885e9c18f68dfd7981"/></dir><file name="Updates.php" hash="c22ce2c522ef01b68396a4a5a2187329"/></dir><dir name="Manageorders"><dir name="Export"><dir name="Shipments"><file name="Collection.php" hash="df2796e36969734c837f0b2e4aa30bea"/></dir><file name="Shipments.php" hash="79718bc7bbeedc418397b3ebf7621390"/></dir><dir name="Log"><file name="Collection.php" hash="41de6a1957ec802d462aa3ae3a9fbf0c"/></dir><file name="Log.php" hash="420e8fbf57bda6a8d9e1bec430f6f896"/><dir name="Shipping"><dir name="Method"><file name="Collection.php" hash="5747561370f637a882c936c731dce4fb"/></dir><file name="Method.php" hash="6802529d19b0c37b094ca0b74cfd855d"/></dir></dir></dir><dir name="Service"><dir name="Http"><dir name="Client"><dir name="Adapter"><file name="Curl.php" hash="63aeccd067612f19595a50ce42fe03e0"/><file name="Stream.php" hash="51b6abc620dfb1ed3e6a71293ee891fd"/></dir></dir></dir></dir><file name="Service.php" hash="f3befb804d7e3379c5d043aebe44794e"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Apikey.php" hash="70b49a81b7385fc77122cb07793720ae"/><file name="Refresh.php" hash="febf057a44aaafbd0ae570ceceac3750"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="GeneralController.php" hash="23b0256de5f1a61b80036940b6ebd133"/></dir><dir name="Export"><dir name="Adminhtml"><file name="CategoryController.php" hash="d17ff4a65c4c9cf8a38ac0891f4163e0"/><file name="ExportController.php" hash="be2813874e68a9144615fee677ab00d4"/></dir><file name="FluxController.php" hash="804e8bc6ae0afd52212959ca3105ce44"/></dir><dir name="Manageorders"><dir name="Adminhtml"><file name="CronController.php" hash="b016f254c90c2baa9bc827cab09d9e16"/><file name="ImportController.php" hash="667de634db10e2a67503d04563f5ad93"/><file name="LogController.php" hash="d673aa055f1929bf0b54a605f66c24d2"/><file name="OrderController.php" hash="27a0fbf2006edd17c16c90c1a2b247b7"/></dir></dir></dir><dir name="doc"><file name="doc_module_1.4.pdf" hash="5590a49838bd67f70f0cacf9605cea2b"/></dir><dir name="etc"><file name="config.xml" hash="6fd7cdc178ea34cc6b330cb2ce5626d5"/><file name="system.xml" hash="9e9ea3532c0ca8e8e588b21afcdee905"/></dir><dir name="sql"><dir name="profileolabs_shoppingflux_setup"><file name="mysql4-install-0.1.0.php" hash="78dc4e1ca3b87d6f00a69e086edd2a9a"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="87d9f4fd1101aa6d80ae8bdd95078537"/><file name="mysql4-upgrade-0.3.13-0.3.14.php" hash="353aa460247b725e6a0f19cc2583135f"/><file name="mysql4-upgrade-0.3.14-0.3.15.php" hash="03bcf880520150709e72e48c46084527"/><file name="mysql4-upgrade-0.3.17-0.3.18.php" hash="52e5bb3ede5b0eced0ba4ce06d81942f"/><file name="mysql4-upgrade-0.4.2-0.4.3.php" hash="59405e81c1fe8a2dd09e66443e2a1af5"/><file name="mysql4-upgrade-0.4.6-0.5.0.php" hash="142867a005bc7753ff3c444df48dbe1e"/><file name="mysql4-upgrade-0.5.1-0.5.2.php" hash="1316f407c3702c68aec45b0e033d5998"/><file name="mysql4-upgrade-0.5.3-0.5.4.php" hash="0897056ab7ccfe96529b8144f1164b7b"/><file name="mysql4-upgrade-0.5.5-0.5.6.php" hash="6c32c4579a9db52569b9bc175325fe16"/><file name="mysql4-upgrade-0.6.5-0.6.6.php" hash="9b5f4b2f8430c049b9819aa66280859d"/></dir></dir></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></target><target name="mageetc"><dir name="modules"><file name="Profileolabs_Shoppingflux.xml" hash="1b5b08eb5a2aaa7a8175ecf31b5b437b"/></dir></target><target name="magelocale"><dir><dir name="fr_FR"><file name="Profileolabs_Shoppingflux.csv" hash="976e5917ba859e727c4468e2a06478ab"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="profileolabs_shoppingflux.xml" hash="312665223f2cdd4525da2104b5e3791c"/></dir><dir name="template"><dir name="profileolabs"><dir name="shoppingflux"><dir name="export"><dir name="category"><file name="edit.phtml" hash="b58cb4fa38c720ee720bd28f663795c8"/></dir><file name="edit.phtml" hash="f890cb858463ee3e952e30b0ec6fff48"/><file name="process.phtml" hash="b879d59b49fbb81351719aba4a96f0f2"/><file name="product.phtml" hash="9acb09ef66883fc4d3f4904536973124"/></dir><dir name="manageorders"><file name="import.phtml" hash="a67e19249b8a25b9c23f09056f356237"/><dir name="payment"><dir name="info"><file name="purchaseorder.phtml" hash="e6a5e1685f976d0ca93eb1d59dc8d652"/></dir></dir><dir name="sales"><dir name="order"><file name="total.phtml" hash="ded51585527ad918412dd5f0d0a9b2a7"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="profileolabs_shoppingflux.xml" hash="73d44ae89c7cc6e03e5ef11dacf12f33"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><file name="profileolabs_shoppingflux.xml" hash="73d44ae89c7cc6e03e5ef11dacf12f33"/></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>