Profileolabs_Shoppingflux - Version 0.7.1

Version Notes

- Minor bugfixes & improvements

Download this release

Release Info

Developer ShoppingFlux
Extension Profileolabs_Shoppingflux
Version 0.7.1
Comparing to
See all releases


Code changes from version 0.7.0 to 0.7.1

Files changed (85) hide show
  1. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Catalog/Category/Edit/Form.php +38 -38
  2. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Catalog/Category/Tab/Default.php +191 -191
  3. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Process.php +149 -149
  4. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Product.php +64 -64
  5. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Product/Grid.php +228 -228
  6. app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Widget/Grid/Column/Renderer/Bool.php +33 -33
  7. app/code/community/Profileolabs/Shoppingflux/Block/Export/Flow.php +981 -981
  8. app/code/community/Profileolabs/Shoppingflux/Block/Export/Flux.php +65 -65
  9. app/code/community/Profileolabs/Shoppingflux/Block/Export/Tracking.php +68 -68
  10. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Cron.php +21 -21
  11. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Cron/Grid.php +107 -107
  12. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Import.php +12 -12
  13. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Log.php +24 -24
  14. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Log/Grid.php +64 -64
  15. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Order.php +19 -19
  16. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/Order/Grid.php +235 -235
  17. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Adminhtml/System/Config/Form/Fieldset/Shipping/Method.php +91 -91
  18. app/code/community/Profileolabs/Shoppingflux/Block/Manageorders/Payment/Info/Purchaseorder.php +17 -17
  19. app/code/community/Profileolabs/Shoppingflux/Block/Tracking/Buyline.php +40 -40
  20. app/code/community/Profileolabs/Shoppingflux/Block/Tracking/Roi.php +44 -44
  21. app/code/community/Profileolabs/Shoppingflux/Helper/Data.php +330 -330
  22. app/code/community/Profileolabs/Shoppingflux/Model/Attribute/Source/Category.php +66 -66
  23. app/code/community/Profileolabs/Shoppingflux/Model/Config.php +270 -270
  24. app/code/community/Profileolabs/Shoppingflux/Model/Export/Convert/Parser/Product.php +39 -42
  25. app/code/community/Profileolabs/Shoppingflux/Model/Export/Flow.php +799 -799
  26. app/code/community/Profileolabs/Shoppingflux/Model/Export/Flux.php +940 -937
  27. app/code/community/Profileolabs/Shoppingflux/Model/Export/Observer.php +428 -413
  28. app/code/community/Profileolabs/Shoppingflux/Model/Export/Rewrite/Catalog/Config.php +58 -58
  29. app/code/community/Profileolabs/Shoppingflux/Model/Export/Rewrite/CatalogInventory/Stock/Item.php +32 -32
  30. app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Attributes.php +48 -48
  31. app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Attributesprice.php +31 -31
  32. app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Category/Level.php +18 -18
  33. app/code/community/Profileolabs/Shoppingflux/Model/Export/Source/Visibility.php +21 -21
  34. app/code/community/Profileolabs/Shoppingflux/Model/Export/Updates.php +31 -31
  35. app/code/community/Profileolabs/Shoppingflux/Model/Export/Xml.php +149 -149
  36. app/code/community/Profileolabs/Shoppingflux/Model/Export/Xmlflow.deprecated.php +250 -250
  37. app/code/community/Profileolabs/Shoppingflux/Model/Export/Xmlflow.php +139 -139
  38. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Convert/Customer.php +107 -107
  39. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Export/Shipments.php +19 -19
  40. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Log.php +35 -35
  41. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Observer.php +179 -179
  42. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Order.php +816 -816
  43. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/OrderOLD.php +682 -682
  44. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Payment/Method/Purchaseorder.php +45 -45
  45. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Product.php +17 -17
  46. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Shipping/Carrier/Shoppingflux.php +81 -81
  47. app/code/community/Profileolabs/Shoppingflux/Model/Manageorders/Shipping/Method.php +45 -45
  48. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Flux.php +16 -16
  49. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Flux/Collection.php +14 -14
  50. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Updates.php +16 -16
  51. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Export/Updates/Collection.php +14 -14
  52. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Export/Shipments.php +12 -12
  53. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Export/Shipments/Collection.php +13 -13
  54. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Log.php +14 -14
  55. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Log/Collection.php +14 -14
  56. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Shipping/Method.php +14 -14
  57. app/code/community/Profileolabs/Shoppingflux/Model/Mysql4/Manageorders/Shipping/Method/Collection.php +14 -14
  58. app/code/community/Profileolabs/Shoppingflux/Model/Service.php +287 -285
  59. app/code/community/Profileolabs/Shoppingflux/Model/Service/Http/Client/Adapter/Curl.php +507 -507
  60. app/code/community/Profileolabs/Shoppingflux/Model/Service/Http/Client/Adapter/Stream.php +46 -46
  61. app/code/community/Profileolabs/Shoppingflux/Model/System/Config/Backend/Apikey.php +38 -38
  62. app/code/community/Profileolabs/Shoppingflux/Model/System/Config/Backend/Refresh.php +60 -60
  63. app/code/community/Profileolabs/Shoppingflux/controllers/Adminhtml/GeneralController.php +45 -40
  64. app/code/community/Profileolabs/Shoppingflux/controllers/Export/Adminhtml/CategoryController.php +28 -28
  65. app/code/community/Profileolabs/Shoppingflux/controllers/Export/Adminhtml/ExportController.php +123 -123
  66. app/code/community/Profileolabs/Shoppingflux/controllers/Export/FluxController.php +150 -150
  67. app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/CronController.php +37 -37
  68. app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/ImportController.php +54 -54
  69. app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/LogController.php +47 -47
  70. app/code/community/Profileolabs/Shoppingflux/controllers/Manageorders/Adminhtml/OrderController.php +56 -56
  71. app/code/community/Profileolabs/Shoppingflux/etc/config.xml +560 -552
  72. app/code/community/Profileolabs/Shoppingflux/etc/system.xml +1265 -1265
  73. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-install-0.1.0.php +121 -121
  74. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.1.0-0.1.1.php +36 -36
  75. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.3.13-0.3.14.php +50 -50
  76. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.3.14-0.3.15.php +19 -19
  77. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.3.17-0.3.18.php +36 -36
  78. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.4.2-0.4.3.php +44 -44
  79. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.4.6-0.5.0.php +46 -46
  80. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.5.1-0.5.2.php +42 -42
  81. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.5.3-0.5.4.php +30 -30
  82. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.5.5-0.5.6.php +28 -28
  83. app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-upgrade-0.6.5-0.6.6.php +25 -25
  84. app/design/adminhtml/default/default/layout/profileolabs_shoppingflux.xml +65 -65
  85. app/design/adminhtml/default/default/template/profileolabs/shoppingflux/export/category/edit.phtml +69 -77
app/code/community/Profileolabs/Shoppingflux/Block/Export/Adminhtml/Catalog/Category/Edit/Form.php CHANGED
@@ -1,39 +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
  }
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 CHANGED
@@ -1,192 +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
  }
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 CHANGED
@@ -1,150 +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
  }
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 CHANGED
@@ -1,64 +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
- }
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 CHANGED
@@ -1,228 +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
- }
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 CHANGED
@@ -1,33 +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
- }
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 CHANGED
@@ -1,982 +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
  }
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 CHANGED
@@ -1,65 +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
- }
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 CHANGED
@@ -1,68 +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
- }
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 CHANGED
@@ -1,21 +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
- }
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 CHANGED
@@ -1,107 +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
- }
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 CHANGED
@@ -1,12 +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
- }
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 CHANGED
@@ -1,25 +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
  }
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 CHANGED
@@ -1,64 +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
- }
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 CHANGED
@@ -1,20 +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
  }
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 CHANGED
@@ -1,235 +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
- }
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 CHANGED
@@ -1,92 +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
  }
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 CHANGED
@@ -1,17 +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
- }
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 CHANGED
@@ -1,40 +1,40 @@
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
- $idTracking = Mage::getSingleton('profileolabs_shoppingflux/config')->getIdTracking();
11
-
12
- if (!$idTracking) {
13
- return '';
14
- }
15
-
16
- if(Mage::getSingleton('profileolabs_shoppingflux/config')->isBuylineEnabled()) {
17
- $this->addText("
18
- <!-- BEGIN Shopping flux Tracking -->
19
- <script type=\"text/javascript\">
20
- var sf2 = sf2 || [];
21
- sf2.push(['".$idTracking."'],[escape(document.referrer)]);
22
- (function() {
23
- var sf_script = document.createElement('script');
24
- sf_script.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'tag.shopping-feed.com/buyline.js';
25
- sf_script.setAttribute('async', 'true');
26
- document.documentElement.firstChild.appendChild(sf_script);
27
- })();
28
- </script>
29
- <!-- END Shopping flux Tracking -->
30
- ");
31
- /*$this->addText('
32
- <!-- BEGIN Shopping flux Tracking -->
33
- <script type="text/javascript" src="http://tracking.shopping-flux.com/gg.js"></script>
34
- <!-- END Shopping flux Tracking -->
35
- ');*/
36
- }
37
- return parent::_toHtml();
38
- }
39
-
40
- }
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
+ $idTracking = Mage::getSingleton('profileolabs_shoppingflux/config')->getIdTracking();
11
+
12
+ if (!$idTracking) {
13
+ return '';
14
+ }
15
+
16
+ if(Mage::getSingleton('profileolabs_shoppingflux/config')->isBuylineEnabled()) {
17
+ $this->addText("
18
+ <!-- BEGIN Shopping flux Tracking -->
19
+ <script type=\"text/javascript\">
20
+ var sf2 = sf2 || [];
21
+ sf2.push(['".$idTracking."'],[escape(document.referrer)]);
22
+ (function() {
23
+ var sf_script = document.createElement('script');
24
+ sf_script.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'tag.shopping-feed.com/buyline.js';
25
+ sf_script.setAttribute('async', 'true');
26
+ document.documentElement.firstChild.appendChild(sf_script);
27
+ })();
28
+ </script>
29
+ <!-- END Shopping flux Tracking -->
30
+ ");
31
+ /*$this->addText('
32
+ <!-- BEGIN Shopping flux Tracking -->
33
+ <script type="text/javascript" src="http://tracking.shopping-flux.com/gg.js"></script>
34
+ <!-- END Shopping flux Tracking -->
35
+ ');*/
36
+ }
37
+ return parent::_toHtml();
38
+ }
39
+
40
+ }
app/code/community/Profileolabs/Shoppingflux/Block/Tracking/Roi.php CHANGED
@@ -1,44 +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
- }
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 CHANGED
@@ -1,331 +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
  }
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 CHANGED
@@ -1,67 +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
  }
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 CHANGED
@@ -1,271 +1,271 @@
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
-
47
- public function isBuylineEnabled($storeId = null) {
48
- return $this->getConfigFlag('shoppingflux_export/configuration/enable_buyline', $storeId);
49
- }
50
-
51
- /*
52
- * Define is in test mode
53
- * @return boolean
54
- */
55
-
56
- public function isSandbox() {
57
- return $this->getConfigFlag('shoppingflux/configuration/is_sandbox');
58
- }
59
-
60
- /**
61
- * Get WS URI
62
- * @return string uri of web service
63
- */
64
- public function getWsUri() {
65
- if ($this->isSandbox())
66
- return $this->getConfigData('shoppingflux/configuration/ws_uri_sandbox');
67
- return $this->getConfigData('shoppingflux/configuration/ws_uri_prod');
68
- }
69
-
70
- public function isExportEnabled($storeId = null) {
71
- return $this->getConfigFlag('shoppingflux_export/general/active', $storeId);
72
- }
73
-
74
- public function isExportFilteredByAttribute($storeId = null) {
75
- return $this->getConfigFlag('shoppingflux_export/general/filter_by_attribute', $storeId);
76
- }
77
-
78
- /**
79
- * Retrieve if export sold out products
80
- *
81
- * @return boolean
82
- */
83
- public function isExportSoldout($storeId = null) {
84
- return $this->getConfigFlag('shoppingflux_export/general/export_soldout', $storeId);
85
- }
86
-
87
-
88
- public function getVisibilitiesToExport($storeId = null) {
89
- return explode(',', $this->getConfigData('shoppingflux_export/general/export_visibility', $storeId));
90
- }
91
-
92
- /**
93
- * Retrieve limit of product in query
94
- *
95
- * @return int
96
- */
97
- public function getExportProductLimit($storeId = null) {
98
- return (int) $this->getConfigData('shoppingflux_export/general/limit_product', $storeId);
99
- }
100
-
101
- public function getUseAllStoreCategories($storeId = null) {
102
- return $this->getConfigFlag('shoppingflux_export/general/all_store_categories', $storeId);
103
- }
104
-
105
- public function getUseAllStoreProducts($storeId = null) {
106
- return $this->getConfigFlag('shoppingflux_export/general/all_store_products', $storeId);
107
- }
108
-
109
- public function getUseOnlySFCategory($storeId = null) {
110
- return $this->getConfigFlag('shoppingflux_export/general/use_only_shoppingflux_category', $storeId);
111
- }
112
-
113
- public function getMaxCategoryLevel($storeId = null) {
114
- return $this->getConfigData('shoppingflux_export/general/max_category_level', $storeId);
115
- }
116
-
117
- public function getEnableEvents($storeId = null) {
118
- return $this->getConfigFlag('shoppingflux_export/general/enable_events', $storeId);
119
- }
120
-
121
- public function getManageConfigurables($storeId = null) {
122
- return $this->getConfigFlag('shoppingflux_export/general/manage_configurable', $storeId);
123
- }
124
-
125
- public function getManageCatalogRules($storeId = null) {
126
- return $this->getConfigFlag('shoppingflux_export/general/manage_catalog_rules', $storeId);
127
- }
128
-
129
- public function getManageMediaGallery($storeId = null) {
130
- return $this->getConfigFlag('shoppingflux_export/general/manage_media_gallery', $storeId);
131
- }
132
-
133
-
134
-
135
- /**
136
- * Return Attributes Knowed in array with key=>value
137
- * key = node adn value = inner text
138
- * @return array
139
- */
140
- public function getMappingAttributesKnow($storeId = null) {
141
- return $this->getConfigData('shoppingflux_export/attributes_know', $storeId);
142
- }
143
-
144
- /**
145
- * Return Attributes Unknowed in array with key=>value
146
- * key = node adn value = inner text
147
- * @param int $storeId
148
- * @return array
149
- */
150
- public function getMappgingAttributesUnKnow($storeId = null) {
151
- return $this->getConfigData('shoppingflux_export/attributes_unknow', $storeId);
152
- }
153
-
154
- /**
155
- * Return Attributes Unknowed in array with key=>value
156
- * key = node adn value = inner text
157
- * @param int $storeId
158
- * @return array
159
- */
160
- public function getAdditionalAttributes($storeId = null) {
161
- $additionnal = explode(',',$this->getConfigData('shoppingflux_export/attributes_additionnal/list', $storeId));
162
- $unknow = $this->getMappgingAttributesUnKnow($storeId);
163
- $know = $this->getMappingAttributesKnow($storeId);
164
- //We do not want attributes that are already in known or unknown lists
165
- $additionnal = array_diff($additionnal, $know, $unknow);
166
- return $additionnal;
167
- }
168
-
169
- /**
170
- * Return ALL Attributes Knowed and Unknowed in array with key=>value
171
- * key = node adn value = inner text
172
- * @return array
173
- * @param int $storeId
174
- */
175
- public function getMappingAllAttributes($storeId = null) {
176
- return array_merge($this->getMappingAttributesKnow($storeId), $this->getMappgingAttributesUnKnow($storeId));
177
- }
178
-
179
- public function getMemoryLimit() {
180
- $memoryLimit = intval($this->getConfigData('shoppingflux_export/general/memory_limit'));
181
- if($memoryLimit>10) {
182
- return $memoryLimit;
183
- }
184
- return 512;
185
- }
186
-
187
- public function isSyncEnabled($storeId = null) {
188
- return $this->getConfigFlag('shoppingflux_export/general/enable_sync', $storeId);
189
- }
190
-
191
- public function useManageStock($storeId = null) {
192
- return $this->getConfigFlag('shoppingflux_export/general/use_manage_stock', $storeId);
193
- }
194
-
195
- /** ORDERS * */
196
- public function isOrdersEnabled($storeId = null) {
197
- return $this->getConfigFlag('shoppingflux_mo/manageorders/enabled', $storeId);
198
- }
199
-
200
- /**
201
- * Get Limit orders
202
- * @return int
203
- */
204
- public function getLimitOrders($storeId = null) {
205
- $limit = $this->getConfigData('shoppingflux_mo/manageorders/limit_orders', $storeId);
206
- if ($limit < 1)
207
- $limit = 10;
208
- return $limit;
209
- }
210
-
211
- public function getAddressLengthLimit($storeId = null) {
212
- $limit = $this->getConfigData('shoppingflux_mo/import_customer/limit_address_length');
213
- if(!$limit || $limit < 20)
214
- return false;
215
- return $limit;
216
- }
217
-
218
- /**
219
- * get customer Group
220
- */
221
- public function getCustomerGroupIdFor($marketplace = false, $storeId = null) {
222
- if ($marketplace) {
223
- $marketplace = strtolower($marketplace);
224
- $customerGroupId = $this->getConfigData('shoppingflux_mo/import_customer/' . $marketplace . "_group", $storeId);
225
- if ($customerGroupId)
226
- return $customerGroupId;
227
- }
228
- $customerGroupId = $this->getConfigData("shoppingflux_mo/import_customer/default_group", $storeId);
229
- if ($customerGroupId)
230
- return $customerGroupId;
231
- return false;
232
- }
233
-
234
-
235
-
236
- public function getShippingMethodFor($marketplace = false, $sfShippingMethod = false, $storeId = null) {
237
- $defaultShippingMethod = Mage::getStoreConfig('shoppingflux_mo/shipping_method/default_method', $storeId);
238
- if(!$marketplace) {
239
- return $defaultShippingMethod;
240
- }
241
- $marketplace = strtolower($marketplace);
242
- $marketplaceShippingMode = Mage::getStoreConfig('shoppingflux_mo/shipping_method/' . $marketplace . '_method', $storeId);
243
- if(!$sfShippingMethod) {
244
- return $marketplaceShippingMode?$marketplaceShippingMode:$defaultShippingMethod;
245
- }
246
- $sfShippingMethodCode = Mage::getModel('profileolabs_shoppingflux/manageorders_shipping_method')->getFullShippingMethodCodeFor($marketplace, $sfShippingMethod);
247
- $sfShippingMethodCode = preg_replace('%[^a-zA-Z0-9_]%', '', $sfShippingMethodCode);
248
- $shippingMethod = Mage::getStoreConfig('shoppingflux_mo/advanced_shipping_method/' . $sfShippingMethodCode, $storeId);
249
- return $shippingMethod?$shippingMethod:($marketplaceShippingMode?$marketplaceShippingMode:$defaultShippingMethod);
250
- }
251
-
252
- /**
253
- * Retrieve if we must to create invoice
254
- *
255
- * @return boolean
256
- */
257
- public function createInvoice($storeId = null) {
258
- return $this->getConfigFlag('shoppingflux_mo/manageorders/create_invoice', $storeId);
259
- }
260
-
261
- /**
262
- * Retrieve if we must to apply tax
263
- *
264
- * @return boolean
265
- */
266
- public function applyTax($storeId = null) {
267
- return true;
268
- //return $this->getConfigFlag('shoppingflux_mo/manageorders/apply_tax', $storeId);
269
- }
270
-
271
  }
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
+
47
+ public function isBuylineEnabled($storeId = null) {
48
+ return $this->getConfigFlag('shoppingflux_export/configuration/enable_buyline', $storeId);
49
+ }
50
+
51
+ /*
52
+ * Define is in test mode
53
+ * @return boolean
54
+ */
55
+
56
+ public function isSandbox() {
57
+ return $this->getConfigFlag('shoppingflux/configuration/is_sandbox');
58
+ }
59
+
60
+ /**
61
+ * Get WS URI
62
+ * @return string uri of web service
63
+ */
64
+ public function getWsUri() {
65
+ if ($this->isSandbox())
66
+ return $this->getConfigData('shoppingflux/configuration/ws_uri_sandbox');
67
+ return $this->getConfigData('shoppingflux/configuration/ws_uri_prod');
68
+ }
69
+
70
+ public function isExportEnabled($storeId = null) {
71
+ return $this->getConfigFlag('shoppingflux_export/general/active', $storeId);
72
+ }
73
+
74
+ public function isExportFilteredByAttribute($storeId = null) {
75
+ return $this->getConfigFlag('shoppingflux_export/general/filter_by_attribute', $storeId);
76
+ }
77
+
78
+ /**
79
+ * Retrieve if export sold out products
80
+ *
81
+ * @return boolean
82
+ */
83
+ public function isExportSoldout($storeId = null) {
84
+ return $this->getConfigFlag('shoppingflux_export/general/export_soldout', $storeId);
85
+ }
86
+
87
+
88
+ public function getVisibilitiesToExport($storeId = null) {
89
+ return explode(',', $this->getConfigData('shoppingflux_export/general/export_visibility', $storeId));
90
+ }
91
+
92
+ /**
93
+ * Retrieve limit of product in query
94
+ *
95
+ * @return int
96
+ */
97
+ public function getExportProductLimit($storeId = null) {
98
+ return (int) $this->getConfigData('shoppingflux_export/general/limit_product', $storeId);
99
+ }
100
+
101
+ public function getUseAllStoreCategories($storeId = null) {
102
+ return $this->getConfigFlag('shoppingflux_export/general/all_store_categories', $storeId);
103
+ }
104
+
105
+ public function getUseAllStoreProducts($storeId = null) {
106
+ return $this->getConfigFlag('shoppingflux_export/general/all_store_products', $storeId);
107
+ }
108
+
109
+ public function getUseOnlySFCategory($storeId = null) {
110
+ return $this->getConfigFlag('shoppingflux_export/general/use_only_shoppingflux_category', $storeId);
111
+ }
112
+
113
+ public function getMaxCategoryLevel($storeId = null) {
114
+ return $this->getConfigData('shoppingflux_export/general/max_category_level', $storeId);
115
+ }
116
+
117
+ public function getEnableEvents($storeId = null) {
118
+ return $this->getConfigFlag('shoppingflux_export/general/enable_events', $storeId);
119
+ }
120
+
121
+ public function getManageConfigurables($storeId = null) {
122
+ return $this->getConfigFlag('shoppingflux_export/general/manage_configurable', $storeId);
123
+ }
124
+
125
+ public function getManageCatalogRules($storeId = null) {
126
+ return $this->getConfigFlag('shoppingflux_export/general/manage_catalog_rules', $storeId);
127
+ }
128
+
129
+ public function getManageMediaGallery($storeId = null) {
130
+ return $this->getConfigFlag('shoppingflux_export/general/manage_media_gallery', $storeId);
131
+ }
132
+
133
+
134
+
135
+ /**
136
+ * Return Attributes Knowed in array with key=>value
137
+ * key = node adn value = inner text
138
+ * @return array
139
+ */
140
+ public function getMappingAttributesKnow($storeId = null) {
141
+ return $this->getConfigData('shoppingflux_export/attributes_know', $storeId);
142
+ }
143
+
144
+ /**
145
+ * Return Attributes Unknowed in array with key=>value
146
+ * key = node adn value = inner text
147
+ * @param int $storeId
148
+ * @return array
149
+ */
150
+ public function getMappgingAttributesUnKnow($storeId = null) {
151
+ return $this->getConfigData('shoppingflux_export/attributes_unknow', $storeId);
152
+ }
153
+
154
+ /**
155
+ * Return Attributes Unknowed in array with key=>value
156
+ * key = node adn value = inner text
157
+ * @param int $storeId
158
+ * @return array
159
+ */
160
+ public function getAdditionalAttributes($storeId = null) {
161
+ $additionnal = explode(',',$this->getConfigData('shoppingflux_export/attributes_additionnal/list', $storeId));
162
+ $unknow = $this->getMappgingAttributesUnKnow($storeId);
163
+ $know = $this->getMappingAttributesKnow($storeId);
164
+ //We do not want attributes that are already in known or unknown lists
165
+ $additionnal = array_diff($additionnal, $know, $unknow);
166
+ return $additionnal;
167
+ }
168
+
169
+ /**
170
+ * Return ALL Attributes Knowed and Unknowed in array with key=>value
171
+ * key = node adn value = inner text
172
+ * @return array
173
+ * @param int $storeId
174
+ */
175
+ public function getMappingAllAttributes($storeId = null) {
176
+ return array_merge($this->getMappingAttributesKnow($storeId), $this->getMappgingAttributesUnKnow($storeId));
177
+ }
178
+
179
+ public function getMemoryLimit() {
180
+ $memoryLimit = intval($this->getConfigData('shoppingflux_export/general/memory_limit'));
181
+ if($memoryLimit>10) {
182
+ return $memoryLimit;
183
+ }
184
+ return 512;
185
+ }
186
+
187
+ public function isSyncEnabled($storeId = null) {
188
+ return $this->getConfigFlag('shoppingflux_export/general/enable_sync', $storeId);
189
+ }
190
+
191
+ public function useManageStock($storeId = null) {
192
+ return $this->getConfigFlag('shoppingflux_export/general/use_manage_stock', $storeId);
193
+ }
194
+
195
+ /** ORDERS * */
196
+ public function isOrdersEnabled($storeId = null) {
197
+ return $this->getConfigFlag('shoppingflux_mo/manageorders/enabled', $storeId);
198
+ }
199
+
200
+ /**
201
+ * Get Limit orders
202
+ * @return int
203
+ */
204
+ public function getLimitOrders($storeId = null) {
205
+ $limit = $this->getConfigData('shoppingflux_mo/manageorders/limit_orders', $storeId);
206
+ if ($limit < 1)
207
+ $limit = 10;
208
+ return $limit;
209
+ }
210
+
211
+ public function getAddressLengthLimit($storeId = null) {
212
+ $limit = $this->getConfigData('shoppingflux_mo/import_customer/limit_address_length');
213
+ if(!$limit || $limit < 20)
214
+ return false;
215
+ return $limit;
216
+ }
217
+
218
+ /**
219
+ * get customer Group
220
+ */
221
+ public function getCustomerGroupIdFor($marketplace = false, $storeId = null) {
222
+ if ($marketplace) {
223
+ $marketplace = strtolower($marketplace);
224
+ $customerGroupId = $this->getConfigData('shoppingflux_mo/import_customer/' . $marketplace . "_group", $storeId);
225
+ if ($customerGroupId)
226
+ return $customerGroupId;
227
+ }
228
+ $customerGroupId = $this->getConfigData("shoppingflux_mo/import_customer/default_group", $storeId);
229
+ if ($customerGroupId)
230
+ return $customerGroupId;
231
+ return false;
232
+ }
233
+
234
+
235
+
236
+ public function getShippingMethodFor($marketplace = false, $sfShippingMethod = false, $storeId = null) {
237
+ $defaultShippingMethod = Mage::getStoreConfig('shoppingflux_mo/shipping_method/default_method', $storeId);
238
+ if(!$marketplace) {
239
+ return $defaultShippingMethod;
240
+ }
241
+ $marketplace = strtolower($marketplace);
242
+ $marketplaceShippingMode = Mage::getStoreConfig('shoppingflux_mo/shipping_method/' . $marketplace . '_method', $storeId);
243
+ if(!$sfShippingMethod) {
244
+ return $marketplaceShippingMode?$marketplaceShippingMode:$defaultShippingMethod;
245
+ }
246
+ $sfShippingMethodCode = Mage::getModel('profileolabs_shoppingflux/manageorders_shipping_method')->getFullShippingMethodCodeFor($marketplace, $sfShippingMethod);
247
+ $sfShippingMethodCode = preg_replace('%[^a-zA-Z0-9_]%', '', $sfShippingMethodCode);
248
+ $shippingMethod = Mage::getStoreConfig('shoppingflux_mo/advanced_shipping_method/' . $sfShippingMethodCode, $storeId);
249
+ return $shippingMethod?$shippingMethod:($marketplaceShippingMode?$marketplaceShippingMode:$defaultShippingMethod);
250
+ }
251
+
252
+ /**
253
+ * Retrieve if we must to create invoice
254
+ *
255
+ * @return boolean
256
+ */
257
+ public function createInvoice($storeId = null) {
258
+ return $this->getConfigFlag('shoppingflux_mo/manageorders/create_invoice', $storeId);
259
+ }
260
+
261
+ /**
262
+ * Retrieve if we must to apply tax
263
+ *
264
+ * @return boolean
265
+ */
266
+ public function applyTax($storeId = null) {
267
+ return true;
268
+ //return $this->getConfigFlag('shoppingflux_mo/manageorders/apply_tax', $storeId);
269
+ }
270
+
271
  }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Convert/Parser/Product.php CHANGED
@@ -1,42 +1,39 @@
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
- }
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
+ $entityTypeId = Mage::getSingleton('eav/config')->getEntityType('catalog_product')->getId();
20
+ $productAttributes = Mage::getResourceModel('eav/entity_attribute_collection')
21
+ ->setEntityTypeFilter($entityTypeId)
22
+ ->load();
23
+ }
24
+ $attributes = $this->_externalFields;
25
+
26
+ foreach ($productAttributes as $attr) {
27
+ $code = $attr->getAttributeCode();
28
+ if (in_array($code, $this->_internalFields) || $attr->getFrontendInput() == 'hidden') {
29
+ continue;
30
+ }
31
+ $attributes[$code] = $code;
32
+ }
33
+
34
+ foreach ($this->_inventoryFields as $field) {
35
+ $attributes[$field] = $field;
36
+ }
37
+ return $attributes;
38
+ }
39
+ }
 
 
 
app/code/community/Profileolabs/Shoppingflux/Model/Export/Flow.php CHANGED
@@ -1,800 +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
  }
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 CHANGED
@@ -1,937 +1,940 @@
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
- if(!$categoryId) {
460
- return $this->getCategoriesViaProductCategories($data, $product);
461
- }
462
- $category = Mage::helper('profileolabs_shoppingflux')->getCategoriesWithParents(false, $product->getStoreId());
463
- //Varien_Profiler::stop("SF::Flux::getCategoriesViaShoppingfluxCategory-1");
464
- if (!isset($category['name'][$categoryId])) {
465
- return $this->getCategoriesViaProductCategories($data, $product);
466
- }
467
-
468
- //Varien_Profiler::start("SF::Flux::getCategoriesViaShoppingfluxCategory");
469
-
470
- $categoryNames = explode(' > ', $category['name'][$categoryId]);
471
- $categoryUrls = explode(' > ', $category['url'][$categoryId]);
472
-
473
-
474
- //we drop root category, which is useless here
475
- array_shift($categoryNames);
476
- array_shift($categoryUrls);
477
-
478
-
479
- $data['category-breadcrumb'] = trim(implode(' > ', $categoryNames));
480
-
481
- $data["category-main"] = trim($categoryNames[0]);
482
- $data["category-url-main"] = $categoryUrls[0];
483
-
484
-
485
- for ($i = 1; $i <= 5; $i++) {
486
- if (isset($categoryNames[$i])) {
487
- $data["category-sub-" . ($i)] = trim($categoryNames[$i]);
488
- } else {
489
- $data["category-sub-" . ($i)] = '';
490
- }
491
- if (isset($categoryUrls[$i])) {
492
- $data["category-url-sub-" . ($i)] = $categoryUrls[$i];
493
- } else {
494
- $data["category-url-sub-" . ($i)] = '';
495
- }
496
- }
497
-
498
- //Varien_Profiler::stop("SF::Flux::getCategoriesViaShoppingfluxCategory");
499
- return $data;
500
- }
501
-
502
- protected function getCategoriesViaProductCategories($data, $product) {
503
-
504
- //Varien_Profiler::start("SF::Flux::getCategoriesViaProductCategories");
505
- $cnt = 0;
506
-
507
- if (!$this->getConfig()->getUseOnlySFCategory()) {
508
- $rootCategoryId = Mage::app()->getStore($product->getStoreId())->getRootCategoryId();
509
-
510
- $categoryWithParents = Mage::helper('profileolabs_shoppingflux')->getCategoriesWithParents(false, $product->getStoreId());
511
- $maxLevelCategory = $this->getConfig()->getMaxCategoryLevel()>0?$this->getConfig()->getMaxCategoryLevel():5;
512
-
513
- /*$productCategoryCollection = $product->getCategoryCollection()
514
- ->addAttributeToSelect(array('name'))
515
- ->addFieldToFilter('level', array('lteq' => $maxLevelCategory+1))
516
- ->addUrlRewriteToResult()
517
- ->groupByAttribute('level')
518
- ->setOrder('level', 'ASC');
519
- if (!Mage::getSingleton('profileolabs_shoppingflux/config')->getUseAllStoreCategories()) {
520
- $productCategoryCollection->addFieldToFilter('path', array('like' => "1/{$rootCategoryId}/%"));
521
- }
522
- $lastCategory = null;
523
- foreach ($productCategoryCollection as $category) {
524
- $name = $category->getName();
525
- $level = $category->getLevel();
526
- $url = $this->cleanUrl($category->getUrl());
527
- if ($cnt == 0) {
528
-
529
- $data["category-main"] = trim($name);
530
- $data["category-url-main"] = $url;
531
- } else {
532
-
533
- $data["category-sub-" . ($cnt)] = trim($name);
534
- $data["category-url-sub-" . ($cnt)] = $url;
535
- }
536
-
537
- $lastCategory = $category;
538
-
539
- $cnt++;
540
- }
541
-
542
- $data['category-breadcrumb'] = "";
543
- if (!is_null($lastCategory) && is_object($lastCategory)) {
544
-
545
- $breadCrumb = array();
546
-
547
- $pathInStore = $category->getPathInStore();
548
- $pathIds = array_reverse(explode(',', $pathInStore));
549
-
550
- $categories = $category->getParentCategories();
551
-
552
- // add category path breadcrumb
553
- foreach ($pathIds as $categoryId) {
554
- if ($categoryId != $rootCategoryId && isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
555
- $breadCrumb[] = trim($categories[$categoryId]->getName());
556
- }
557
- }
558
- unset($categories);
559
- $data['category-breadcrumb'] = trim(implode(" > ", $breadCrumb));
560
- }
561
-
562
-
563
-
564
- unset($productCategoryCollection);*/
565
-
566
- $productCategoryIds = $product->getCategoryIds();
567
- foreach($productCategoryIds as $productCategoryId) {
568
- if(isset($categoryWithParents['name'][$productCategoryId])) {
569
- $categoryNames = explode(' > ', $categoryWithParents['name'][$productCategoryId]);
570
- $categoryUrls = explode(' > ', $categoryWithParents['url'][$productCategoryId]);
571
- //we drop root category, which is useless here
572
- array_shift($categoryNames);
573
- array_shift($categoryUrls);
574
- $categoryNames = array_slice($categoryNames, 0, $maxLevelCategory, true);
575
- $categoryUrls = array_slice($categoryUrls, 0, $maxLevelCategory, true);
576
- $data['category-breadcrumb'] = trim(implode(' > ', $categoryNames));
577
-
578
- $data["category-main"] = trim($categoryNames[0]);
579
- $data["category-url-main"] = $categoryUrls[0];
580
-
581
-
582
- for ($i = 1; $i <= 5; $i++) {
583
- if (isset($categoryNames[$i])) {
584
- $data["category-sub-" . ($i)] = trim($categoryNames[$i]);
585
- } else {
586
- $data["category-sub-" . ($i)] = '';
587
- }
588
- if (isset($categoryUrls[$i])) {
589
- $data["category-url-sub-" . ($i)] = $categoryUrls[$i];
590
- } else {
591
- $data["category-url-sub-" . ($i)] = '';
592
- }
593
- }
594
- break;
595
- }
596
- }
597
-
598
- }
599
-
600
- if (!isset($data["category-main"])) {
601
- $data["category-main"] = "";
602
- $data["category-url-main"] = "";
603
- $cnt++;
604
- }
605
-
606
-
607
- for ($i = 1; $i <= 5; $i++) {
608
- if(!isset($data["category-sub-" . ($i)])) {
609
- $data["category-sub-" . ($i)] = "";
610
- $data["category-url-sub-" . ($i)] = "";
611
- }
612
- }
613
-
614
-
615
- //Varien_Profiler::stop("SF::Flux::getCategoriesViaProductCategories");
616
- return $data;
617
- }
618
-
619
- public function cleanUrl($url) {
620
- $url = str_replace("index.php/", "", $url);
621
- $url = preg_replace('%(.*)\?.*$%i', '$1', $url);
622
- return $url;
623
- }
624
-
625
- public function getImages($data, $product, $storeId) {
626
-
627
-
628
-
629
- $mediaUrl = Mage::getBaseUrl('media') . 'catalog/product';
630
-
631
- $i = 1;
632
-
633
- if ($product->getImage() != "" && $product->getImage() != 'no_selection') {
634
- $data["image-url-" . $i] = $mediaUrl . $product->getImage();
635
- $data["image-label-" . $i] = $product->getImageLabel();
636
- $i++;
637
- }
638
-
639
-
640
- if($this->getConfig()->getManageMediaGallery()) {
641
- //LOAD media gallery for this product
642
- $mediaGallery = $product->getResource()->getAttribute('media_gallery');
643
- $mediaGallery->getBackend()->afterLoad($product);
644
-
645
-
646
- foreach ($product->getMediaGallery('images') as $image) {
647
- if ($mediaUrl . $product->getImage() == $product->getMediaConfig()->getMediaUrl($image['file']))
648
- continue;
649
-
650
- $data["image-url-" . $i] = $product->getMediaConfig()->getMediaUrl($image['file']);
651
- $data["image-label-" . $i] = $image['label'];
652
- $i++;
653
- if (($i - 6) == 0)
654
- break;
655
- }
656
- }
657
-
658
-
659
- //Complet with empty nodes
660
- for ($j = $i; $j < 6; $j++) {
661
- $data["image-url-" . $i] = "";
662
- $data["image-label-" . $i] = "";
663
- $i++;
664
- }
665
- return $data;
666
- }
667
-
668
- protected function getPercent($product) {
669
-
670
- /* if($product->getTypeId() == 'bundle')
671
- return 0; */
672
- $price = round($product->getPrice(), 2);
673
- if ($price == "0") {
674
- $price = round($product->getMinimalPrice(), 2);
675
- }
676
-
677
- if ($price == "0")
678
- return 0;
679
-
680
- $special = round($product->getFinalPrice(), 2);
681
- $tmp = $price - $special;
682
- $tmp = ($tmp * 100) / $price;
683
- return round($tmp);
684
- }
685
-
686
- /**
687
- *
688
- */
689
- protected function getAttributesFromConfig($checkIfExist = false, $withAdditional = true) {
690
-
691
- if (is_null($this->_attributesFromConfig)) {
692
- $attributes = $this->getConfig()->getMappingAllAttributes();
693
- if ($withAdditional) {
694
- $additionalAttributes = $this->getConfig()->getAdditionalAttributes();
695
- foreach ($additionalAttributes as $attributeCode) {
696
- $attributes[$attributeCode] = trim($attributeCode);
697
- }
698
- }
699
-
700
- if ($checkIfExist) {
701
- $product = Mage::getModel('catalog/product');
702
- foreach ($attributes as $key => $code) {
703
- $attribute = $this->_getAttribute($code);
704
- if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute && $attribute->getId() && $attribute->getFrontendInput() != 'weee') {
705
- $this->_attributesFromConfig[$key] = $code;
706
- }
707
- }
708
- } else
709
- $this->_attributesFromConfig = $attributes;
710
- }
711
-
712
- return $this->_attributesFromConfig;
713
- }
714
-
715
- protected function getRequiredAttributes() {
716
-
717
- $requiredAttributes = array("sku" => "sku",
718
- "price" => "price",
719
- "image" => "image");
720
-
721
- return $requiredAttributes;
722
- }
723
-
724
- protected function getAllAttributes() {
725
- return array_merge($this->getAttributesFromConfig(true), $this->getRequiredAttributes());
726
- }
727
-
728
- /**
729
- * Retrieve Catalog Product Flat Helper object
730
- *
731
- * @return Mage_Catalog_Helper_Product_Flat
732
- */
733
- public function getFlatHelper() {
734
- return Mage::helper('catalog/product_flat');
735
- }
736
-
737
- protected function getShippingInfo($data, $product, $storeId) {
738
-
739
- $data["shipping-name"] = "";
740
- $data["shipping-price"] = "";
741
-
742
- $carrier = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_method');
743
- if (empty($carrier)) {
744
- $data["shipping-price"] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_price');
745
- return $data;
746
- }
747
-
748
- $carrierTab = explode('_', $carrier);
749
- list($carrierCode, $methodCode) = $carrierTab;
750
- $data["shipping-name"] = ucfirst($methodCode);
751
-
752
-
753
- $shippingPrice = 0;
754
- if ($this->getConfig()->getConfigData('shoppingflux_export/general/try_use_real_shipping_price')) {
755
- $countryCode = $this->getConfig()->getConfigData('shoppingflux_export/general/shipping_price_based_on');
756
- $shippingPrice = Mage::helper('profileolabs_shoppingflux')->getShippingPrice($product, $carrier, $countryCode);
757
- }
758
-
759
- if (!$shippingPrice) {
760
- $shippingPrice = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_price');
761
- }
762
-
763
- $data["shipping-price"] = $shippingPrice;
764
-
765
- return $data;
766
- }
767
-
768
- protected function getConfigurableAttributes($data, $product, $storeId) {
769
-
770
- $xmlObj = Mage::getModel('profileolabs_shoppingflux/export_xml');
771
- $data["configurable_attributes"] = "";
772
- $data["childs_product"] = "";
773
- $images = array();
774
-
775
- $labels = array();
776
- if ($product->getTypeId() == "configurable") {
777
-
778
- $attributes = Mage::helper('profileolabs_shoppingflux')->getAttributesConfigurable($product);
779
-
780
- $attributesToOptions = array();
781
-
782
- foreach ($attributes as $attribute) {
783
- $attributesToOptions[$attribute['attribute_code']] = array();
784
- }
785
-
786
- $usedProducts = $product->getTypeInstance(true)
787
- ->getUsedProductCollection($product);
788
-
789
-
790
- $configurableAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
791
-
792
-
793
- $usedProductsArray = array();
794
- $salable = false;
795
- foreach (Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($usedProducts->getSelect()) as $usedProduct) { //Prevent Old magento bug
796
- $usedProduct = $this->_getProduct($usedProduct['entity_id'], $storeId);
797
-
798
- if(!$usedProduct) {
799
- continue;
800
- }
801
-
802
- $salable = $salable || $usedProduct->isSalable();
803
-
804
-
805
- if (Mage::helper('profileolabs_shoppingflux')->isModuleInstalled('OrganicInternet_SimpleConfigurableProducts') || Mage::helper('profileolabs_shoppingflux')->isModuleInstalled('DerModPro_BCP')) {
806
-
807
- $tmpData = $this->getPrices(array(), $usedProduct, $storeId);
808
- $price = $tmpData['price-ttc'] > 0 ? $tmpData['price-ttc'] : $data['price-ttc'];
809
- if ($data['price-ttc'] <= 0 || ($price > 0 && $price < $data['price-ttc'])) {
810
- $data['price-ttc'] = $price;
811
- }
812
- $priceBeforeDiscount = $tmpData["price-before-discount"];
813
- $discountAmount = $tmpData["discount-amount"];
814
- $startDateDiscount = $tmpData["start-date-discount"];
815
- $endDateDiscount = $tmpData["end-date-discount"];
816
- } else {
817
-
818
- $price = $data['price-ttc'];
819
- $priceBeforeDiscount = $data["price-before-discount"];
820
- $discountAmount = $data["discount-amount"];
821
- $startDateDiscount = $data["start-date-discount"];
822
- $endDateDiscount = $data["end-date-discount"];
823
-
824
- foreach ($configurableAttributes as $configurableAttribute) {
825
- $attributeCode = $configurableAttribute['attribute_code'];
826
- foreach ($configurableAttribute['values'] as $confAttributeValue) {
827
- if ($confAttributeValue['pricing_value'] && $usedProduct->getData($attributeCode) == $confAttributeValue['value_index']) {
828
- if ($confAttributeValue['is_percent']) {
829
- $price += $data['price-ttc'] * $confAttributeValue['pricing_value'] / 100;
830
- $priceBeforeDiscount += $data['price-before-discount'] * $confAttributeValue['pricing_value'] / 100;
831
- } else {
832
- $price += $confAttributeValue['pricing_value'];
833
- $priceBeforeDiscount += $confAttributeValue['pricing_value'];
834
- }
835
- }
836
- }
837
- }
838
- }
839
-
840
- $attributesFromConfig = $this->getAttributesFromConfig(true, true);
841
-
842
- $discountPercent = 0;
843
- if($priceBeforeDiscount) {
844
- $discountPercent = round((($priceBeforeDiscount - $price) * 100) / $priceBeforeDiscount);
845
- }
846
-
847
- $isInStock = 0;
848
- $qty = 0;
849
- if ($usedProduct->getStockItem()) {
850
- if ($this->getConfig()->useManageStock()) {
851
- $_configManageStock = (int) Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK, $storeId);
852
- $_manageStock = $usedProduct->getStockItem()->getUseConfigManageStock() ? $_configManageStock : $usedProduct->getStockItem()->getManageStock();
853
- } else {
854
- $_manageStock = true;
855
- }
856
-
857
- $isInStock = $_manageStock ? $usedProduct->getStockItem()->getIsInStock() : 1;
858
-
859
- $qty = $_manageStock ? $usedProduct->getStockItem()->getQty() : 100;
860
- }
861
-
862
- $usedProductsArray[$usedProduct->getId()]['child']["sku"] = $usedProduct->getSku();
863
- $usedProductsArray[$usedProduct->getId()]['child']["id"] = $usedProduct->getId();
864
- $usedProductsArray[$usedProduct->getId()]['child']["price-ttc"] = $price;
865
- $usedProductsArray[$usedProduct->getId()]['child']["price-before-discount"] = $priceBeforeDiscount;
866
- $usedProductsArray[$usedProduct->getId()]['child']["discount-amount"] = $discountAmount;
867
- $usedProductsArray[$usedProduct->getId()]['child']["discount-percent"] = $discountPercent;
868
- $usedProductsArray[$usedProduct->getId()]['child']["start-date-discount"] = $startDateDiscount;
869
- $usedProductsArray[$usedProduct->getId()]['child']["end-date-discount"] = $endDateDiscount;
870
- $usedProductsArray[$usedProduct->getId()]['child']['is-in-stock'] = $isInStock;
871
- $usedProductsArray[$usedProduct->getId()]['child']['qty'] = round($qty);
872
- $usedProductsArray[$usedProduct->getId()]['child']['tax-rate'] = $usedProduct->getTaxPercent();
873
- if (!$data['tax-rate'] && $usedProductsArray[$usedProduct->getId()]['child']['tax-rate']) {
874
- $data['tax-rate'] = $usedProductsArray[$usedProduct->getId()]['child']['tax-rate'];
875
- }
876
- if ($qty > 0 && $qty > $data['qty']) {
877
- $data['qty'] = round($qty);
878
- }
879
- $usedProductsArray[$usedProduct->getId()]['child']["ean"] = isset($attributesFromConfig['ean']) ? $usedProduct->getData($attributesFromConfig['ean']) : '';
880
-
881
- $images = $this->getImages($images, $usedProduct, $storeId);
882
- if (!$images['image-url-1']) {
883
- $images = $this->getImages($images, $product, $storeId);
884
- }
885
- foreach ($images as $key => $value) {
886
- $usedProductsArray[$usedProduct->getId()]['child'][$key] = trim($value);
887
- }
888
-
889
- foreach ($attributesFromConfig as $nameNode => $attributeCode) {
890
- $usedProductsArray[$usedProduct->getId()]['child'][$nameNode] = $this->_getAttributeDataForProduct($nameNode, $attributeCode, $usedProduct); //$xmlObj->extractData($nameNode, $attributeCode, $usedProduct);
891
- }
892
-
893
-
894
- $attributes = Mage::helper('profileolabs_shoppingflux')->getAttributesConfigurable($product);
895
- foreach ($attributes as $attribute) {
896
- $attributeCode = $attribute['attribute_code'];
897
- $attributeId = $attribute['attribute_id'];
898
-
899
- if (!isset($this->_attributesConfigurable[$attributeId]))
900
- $this->_attributesConfigurable[$attributeId] = $product->getResource()->getAttribute($attributeId);
901
-
902
- $attributeModel = $this->_attributesConfigurable[$attributeId];
903
-
904
- $value = '';
905
- if ($usedProduct->getData($attributeCode)) {
906
- $value = $attributeModel->getFrontend()->getValue($usedProduct);
907
- }
908
-
909
- if (!isset($attributesToOptions[$attributeCode]) || !in_array($value, $attributesToOptions[$attributeCode]))
910
- $attributesToOptions[$attributeCode][] = $value;
911
-
912
- $usedProductsArray[$usedProduct->getId()]['child'][$attributeCode] = trim($value);
913
- }
914
-
915
-
916
- if (!isset($usedProductsArray[$usedProduct->getId()]['child']['shipping_delay']) || !$usedProductsArray[$usedProduct->getId()]['child']['shipping_delay'])
917
- $usedProductsArray[$usedProduct->getId()]['child']['shipping_delay'] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
918
- }
919
-
920
-
921
-
922
-
923
- $data['is-in-stock'] = (int) $salable;
924
-
925
- foreach ($attributesToOptions as $attributeCode => $value) {
926
-
927
- $data["configurable_attributes"][$attributeCode] = implode(",", $value);
928
- }
929
- $data["childs_product"] = $usedProductsArray;
930
-
931
- unset($usedProducts);
932
- unset($usedProductsArray);
933
- }
934
- return $data;
935
- }
936
-
937
- }
 
 
 
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
+ if(!$categoryId) {
460
+ return $this->getCategoriesViaProductCategories($data, $product);
461
+ }
462
+ $category = Mage::helper('profileolabs_shoppingflux')->getCategoriesWithParents(false, $product->getStoreId());
463
+ //Varien_Profiler::stop("SF::Flux::getCategoriesViaShoppingfluxCategory-1");
464
+ if (!isset($category['name'][$categoryId])) {
465
+ return $this->getCategoriesViaProductCategories($data, $product);
466
+ }
467
+
468
+ //Varien_Profiler::start("SF::Flux::getCategoriesViaShoppingfluxCategory");
469
+
470
+ $categoryNames = explode(' > ', $category['name'][$categoryId]);
471
+ $categoryUrls = explode(' > ', $category['url'][$categoryId]);
472
+
473
+
474
+ //we drop root category, which is useless here
475
+ array_shift($categoryNames);
476
+ array_shift($categoryUrls);
477
+
478
+
479
+ $data['category-breadcrumb'] = trim(implode(' > ', $categoryNames));
480
+
481
+ $data["category-main"] = trim($categoryNames[0]);
482
+ $data["category-url-main"] = $categoryUrls[0];
483
+
484
+
485
+ for ($i = 1; $i <= 5; $i++) {
486
+ if (isset($categoryNames[$i])) {
487
+ $data["category-sub-" . ($i)] = trim($categoryNames[$i]);
488
+ } else {
489
+ $data["category-sub-" . ($i)] = '';
490
+ }
491
+ if (isset($categoryUrls[$i])) {
492
+ $data["category-url-sub-" . ($i)] = $categoryUrls[$i];
493
+ } else {
494
+ $data["category-url-sub-" . ($i)] = '';
495
+ }
496
+ }
497
+
498
+ //Varien_Profiler::stop("SF::Flux::getCategoriesViaShoppingfluxCategory");
499
+ return $data;
500
+ }
501
+
502
+ protected function getCategoriesViaProductCategories($data, $product) {
503
+
504
+ //Varien_Profiler::start("SF::Flux::getCategoriesViaProductCategories");
505
+ $cnt = 0;
506
+
507
+ if (!$this->getConfig()->getUseOnlySFCategory()) {
508
+ $rootCategoryId = Mage::app()->getStore($product->getStoreId())->getRootCategoryId();
509
+
510
+ $categoryWithParents = Mage::helper('profileolabs_shoppingflux')->getCategoriesWithParents(false, $product->getStoreId());
511
+ $maxLevelCategory = $this->getConfig()->getMaxCategoryLevel()>0?$this->getConfig()->getMaxCategoryLevel():5;
512
+
513
+ /*$productCategoryCollection = $product->getCategoryCollection()
514
+ ->addAttributeToSelect(array('name'))
515
+ ->addFieldToFilter('level', array('lteq' => $maxLevelCategory+1))
516
+ ->addUrlRewriteToResult()
517
+ ->groupByAttribute('level')
518
+ ->setOrder('level', 'ASC');
519
+ if (!Mage::getSingleton('profileolabs_shoppingflux/config')->getUseAllStoreCategories()) {
520
+ $productCategoryCollection->addFieldToFilter('path', array('like' => "1/{$rootCategoryId}/%"));
521
+ }
522
+ $lastCategory = null;
523
+ foreach ($productCategoryCollection as $category) {
524
+ $name = $category->getName();
525
+ $level = $category->getLevel();
526
+ $url = $this->cleanUrl($category->getUrl());
527
+ if ($cnt == 0) {
528
+
529
+ $data["category-main"] = trim($name);
530
+ $data["category-url-main"] = $url;
531
+ } else {
532
+
533
+ $data["category-sub-" . ($cnt)] = trim($name);
534
+ $data["category-url-sub-" . ($cnt)] = $url;
535
+ }
536
+
537
+ $lastCategory = $category;
538
+
539
+ $cnt++;
540
+ }
541
+
542
+ $data['category-breadcrumb'] = "";
543
+ if (!is_null($lastCategory) && is_object($lastCategory)) {
544
+
545
+ $breadCrumb = array();
546
+
547
+ $pathInStore = $category->getPathInStore();
548
+ $pathIds = array_reverse(explode(',', $pathInStore));
549
+
550
+ $categories = $category->getParentCategories();
551
+
552
+ // add category path breadcrumb
553
+ foreach ($pathIds as $categoryId) {
554
+ if ($categoryId != $rootCategoryId && isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
555
+ $breadCrumb[] = trim($categories[$categoryId]->getName());
556
+ }
557
+ }
558
+ unset($categories);
559
+ $data['category-breadcrumb'] = trim(implode(" > ", $breadCrumb));
560
+ }
561
+
562
+
563
+
564
+ unset($productCategoryCollection);*/
565
+
566
+ $productCategoryIds = $product->getCategoryIds();
567
+ foreach($productCategoryIds as $productCategoryId) {
568
+ if(isset($categoryWithParents['name'][$productCategoryId])) {
569
+ $categoryNames = explode(' > ', $categoryWithParents['name'][$productCategoryId]);
570
+ $categoryUrls = explode(' > ', $categoryWithParents['url'][$productCategoryId]);
571
+ //we drop root category, which is useless here
572
+ array_shift($categoryNames);
573
+ array_shift($categoryUrls);
574
+ $categoryNames = array_slice($categoryNames, 0, $maxLevelCategory, true);
575
+ $categoryUrls = array_slice($categoryUrls, 0, $maxLevelCategory, true);
576
+ $data['category-breadcrumb'] = trim(implode(' > ', $categoryNames));
577
+
578
+ $data["category-main"] = trim($categoryNames[0]);
579
+ $data["category-url-main"] = $categoryUrls[0];
580
+
581
+
582
+ for ($i = 1; $i <= 5; $i++) {
583
+ if (isset($categoryNames[$i])) {
584
+ $data["category-sub-" . ($i)] = trim($categoryNames[$i]);
585
+ } else {
586
+ $data["category-sub-" . ($i)] = '';
587
+ }
588
+ if (isset($categoryUrls[$i])) {
589
+ $data["category-url-sub-" . ($i)] = $categoryUrls[$i];
590
+ } else {
591
+ $data["category-url-sub-" . ($i)] = '';
592
+ }
593
+ }
594
+ break;
595
+ }
596
+ }
597
+
598
+ }
599
+
600
+ if (!isset($data["category-main"])) {
601
+ $data["category-main"] = "";
602
+ $data["category-url-main"] = "";
603
+ $cnt++;
604
+ }
605
+
606
+
607
+ for ($i = 1; $i <= 5; $i++) {
608
+ if(!isset($data["category-sub-" . ($i)])) {
609
+ $data["category-sub-" . ($i)] = "";
610
+ $data["category-url-sub-" . ($i)] = "";
611
+ }
612
+ }
613
+
614
+
615
+ //Varien_Profiler::stop("SF::Flux::getCategoriesViaProductCategories");
616
+ return $data;
617
+ }
618
+
619
+ public function cleanUrl($url) {
620
+ $url = str_replace("index.php/", "", $url);
621
+ $url = preg_replace('%(.*)\?.*$%i', '$1', $url);
622
+ return $url;
623
+ }
624
+
625
+ public function getImages($data, $product, $storeId) {
626
+
627
+
628
+
629
+ $mediaUrl = Mage::getBaseUrl('media') . 'catalog/product';
630
+
631
+ $i = 1;
632
+
633
+ if ($product->getImage() != "" && $product->getImage() != 'no_selection') {
634
+ $data["image-url-" . $i] = $mediaUrl . $product->getImage();
635
+ $data["image-label-" . $i] = $product->getImageLabel();
636
+ $i++;
637
+ }
638
+
639
+
640
+ if($this->getConfig()->getManageMediaGallery()) {
641
+ //LOAD media gallery for this product
642
+ $mediaGallery = $product->getResource()->getAttribute('media_gallery');
643
+ $mediaGallery->getBackend()->afterLoad($product);
644
+
645
+
646
+ foreach ($product->getMediaGallery('images') as $image) {
647
+ if ($mediaUrl . $product->getImage() == $product->getMediaConfig()->getMediaUrl($image['file']))
648
+ continue;
649
+
650
+ $data["image-url-" . $i] = $product->getMediaConfig()->getMediaUrl($image['file']);
651
+ $data["image-label-" . $i] = $image['label'];
652
+ $i++;
653
+ if (($i - 6) == 0)
654
+ break;
655
+ }
656
+ }
657
+
658
+
659
+ //Complet with empty nodes
660
+ for ($j = $i; $j < 6; $j++) {
661
+ $data["image-url-" . $i] = "";
662
+ $data["image-label-" . $i] = "";
663
+ $i++;
664
+ }
665
+ return $data;
666
+ }
667
+
668
+ protected function getPercent($product) {
669
+
670
+ /* if($product->getTypeId() == 'bundle')
671
+ return 0; */
672
+ $price = round($product->getPrice(), 2);
673
+ if ($price == "0") {
674
+ $price = round($product->getMinimalPrice(), 2);
675
+ }
676
+
677
+ if ($price == "0")
678
+ return 0;
679
+
680
+ $special = round($product->getFinalPrice(), 2);
681
+ $tmp = $price - $special;
682
+ $tmp = ($tmp * 100) / $price;
683
+ return round($tmp);
684
+ }
685
+
686
+ /**
687
+ *
688
+ */
689
+ protected function getAttributesFromConfig($checkIfExist = false, $withAdditional = true) {
690
+
691
+ if (is_null($this->_attributesFromConfig)) {
692
+ $attributes = $this->getConfig()->getMappingAllAttributes();
693
+ if ($withAdditional) {
694
+ $additionalAttributes = $this->getConfig()->getAdditionalAttributes();
695
+ foreach ($additionalAttributes as $attributeCode) {
696
+ $attributes[$attributeCode] = trim($attributeCode);
697
+ }
698
+ }
699
+
700
+ if ($checkIfExist) {
701
+ $product = Mage::getModel('catalog/product');
702
+ foreach ($attributes as $key => $code) {
703
+ $attribute = $this->_getAttribute($code);
704
+ if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute && $attribute->getId() && $attribute->getFrontendInput() != 'weee') {
705
+ $this->_attributesFromConfig[$key] = $code;
706
+ }
707
+ }
708
+ } else
709
+ $this->_attributesFromConfig = $attributes;
710
+ }
711
+
712
+ return $this->_attributesFromConfig;
713
+ }
714
+
715
+ protected function getRequiredAttributes() {
716
+
717
+ $requiredAttributes = array("sku" => "sku",
718
+ "price" => "price",
719
+ "image" => "image");
720
+
721
+ return $requiredAttributes;
722
+ }
723
+
724
+ protected function getAllAttributes() {
725
+ return array_merge($this->getAttributesFromConfig(true), $this->getRequiredAttributes());
726
+ }
727
+
728
+ /**
729
+ * Retrieve Catalog Product Flat Helper object
730
+ *
731
+ * @return Mage_Catalog_Helper_Product_Flat
732
+ */
733
+ public function getFlatHelper() {
734
+ return Mage::helper('catalog/product_flat');
735
+ }
736
+
737
+ protected function getShippingInfo($data, $product, $storeId) {
738
+
739
+ $data["shipping-name"] = "";
740
+ $data["shipping-price"] = "";
741
+
742
+ $carrier = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_method');
743
+ if (empty($carrier)) {
744
+ $data["shipping-price"] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_price');
745
+ return $data;
746
+ }
747
+
748
+ $carrierTab = explode('_', $carrier);
749
+ list($carrierCode, $methodCode) = $carrierTab;
750
+ $data["shipping-name"] = ucfirst($methodCode);
751
+
752
+
753
+ $shippingPrice = 0;
754
+ if ($this->getConfig()->getConfigData('shoppingflux_export/general/try_use_real_shipping_price')) {
755
+ $countryCode = $this->getConfig()->getConfigData('shoppingflux_export/general/shipping_price_based_on');
756
+ $shippingPrice = Mage::helper('profileolabs_shoppingflux')->getShippingPrice($product, $carrier, $countryCode);
757
+ }
758
+
759
+ if (!$shippingPrice) {
760
+ $shippingPrice = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_price');
761
+ }
762
+
763
+ $data["shipping-price"] = $shippingPrice;
764
+
765
+ return $data;
766
+ }
767
+
768
+ protected function getConfigurableAttributes($data, $product, $storeId) {
769
+
770
+ $xmlObj = Mage::getModel('profileolabs_shoppingflux/export_xml');
771
+ $data["configurable_attributes"] = "";
772
+ $data["childs_product"] = "";
773
+ $images = array();
774
+
775
+ $labels = array();
776
+ if ($product->getTypeId() == "configurable") {
777
+
778
+ $attributes = Mage::helper('profileolabs_shoppingflux')->getAttributesConfigurable($product);
779
+
780
+ $attributesToOptions = array();
781
+
782
+ foreach ($attributes as $attribute) {
783
+ $attributesToOptions[$attribute['attribute_code']] = array();
784
+ }
785
+
786
+ $usedProducts = $product->getTypeInstance(true)
787
+ ->getUsedProductCollection($product);
788
+
789
+
790
+ $configurableAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
791
+
792
+
793
+ $usedProductsArray = array();
794
+ $salable = false;
795
+ foreach (Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($usedProducts->getSelect()) as $usedProduct) { //Prevent Old magento bug
796
+ $usedProduct = $this->_getProduct($usedProduct['entity_id'], $storeId);
797
+
798
+ if(!$usedProduct) {
799
+ continue;
800
+ }
801
+ if($usedProduct->getStatus() == 2) {
802
+ continue;
803
+ }
804
+
805
+ $salable = $salable || $usedProduct->isSalable();
806
+
807
+
808
+ if (Mage::helper('profileolabs_shoppingflux')->isModuleInstalled('OrganicInternet_SimpleConfigurableProducts') || Mage::helper('profileolabs_shoppingflux')->isModuleInstalled('DerModPro_BCP')) {
809
+
810
+ $tmpData = $this->getPrices(array(), $usedProduct, $storeId);
811
+ $price = $tmpData['price-ttc'] > 0 ? $tmpData['price-ttc'] : $data['price-ttc'];
812
+ if ($data['price-ttc'] <= 0 || ($price > 0 && $price < $data['price-ttc'])) {
813
+ $data['price-ttc'] = $price;
814
+ }
815
+ $priceBeforeDiscount = $tmpData["price-before-discount"];
816
+ $discountAmount = $tmpData["discount-amount"];
817
+ $startDateDiscount = $tmpData["start-date-discount"];
818
+ $endDateDiscount = $tmpData["end-date-discount"];
819
+ } else {
820
+
821
+ $price = $data['price-ttc'];
822
+ $priceBeforeDiscount = $data["price-before-discount"];
823
+ $discountAmount = $data["discount-amount"];
824
+ $startDateDiscount = $data["start-date-discount"];
825
+ $endDateDiscount = $data["end-date-discount"];
826
+
827
+ foreach ($configurableAttributes as $configurableAttribute) {
828
+ $attributeCode = $configurableAttribute['attribute_code'];
829
+ foreach ($configurableAttribute['values'] as $confAttributeValue) {
830
+ if ($confAttributeValue['pricing_value'] && $usedProduct->getData($attributeCode) == $confAttributeValue['value_index']) {
831
+ if ($confAttributeValue['is_percent']) {
832
+ $price += $data['price-ttc'] * $confAttributeValue['pricing_value'] / 100;
833
+ $priceBeforeDiscount += $data['price-before-discount'] * $confAttributeValue['pricing_value'] / 100;
834
+ } else {
835
+ $price += $confAttributeValue['pricing_value'];
836
+ $priceBeforeDiscount += $confAttributeValue['pricing_value'];
837
+ }
838
+ }
839
+ }
840
+ }
841
+ }
842
+
843
+ $attributesFromConfig = $this->getAttributesFromConfig(true, true);
844
+
845
+ $discountPercent = 0;
846
+ if($priceBeforeDiscount) {
847
+ $discountPercent = round((($priceBeforeDiscount - $price) * 100) / $priceBeforeDiscount);
848
+ }
849
+
850
+ $isInStock = 0;
851
+ $qty = 0;
852
+ if ($usedProduct->getStockItem()) {
853
+ if ($this->getConfig()->useManageStock()) {
854
+ $_configManageStock = (int) Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK, $storeId);
855
+ $_manageStock = $usedProduct->getStockItem()->getUseConfigManageStock() ? $_configManageStock : $usedProduct->getStockItem()->getManageStock();
856
+ } else {
857
+ $_manageStock = true;
858
+ }
859
+
860
+ $isInStock = $_manageStock ? $usedProduct->getStockItem()->getIsInStock() : 1;
861
+
862
+ $qty = $_manageStock ? $usedProduct->getStockItem()->getQty() : 100;
863
+ }
864
+
865
+ $usedProductsArray[$usedProduct->getId()]['child']["sku"] = $usedProduct->getSku();
866
+ $usedProductsArray[$usedProduct->getId()]['child']["id"] = $usedProduct->getId();
867
+ $usedProductsArray[$usedProduct->getId()]['child']["price-ttc"] = $price;
868
+ $usedProductsArray[$usedProduct->getId()]['child']["price-before-discount"] = $priceBeforeDiscount;
869
+ $usedProductsArray[$usedProduct->getId()]['child']["discount-amount"] = $discountAmount;
870
+ $usedProductsArray[$usedProduct->getId()]['child']["discount-percent"] = $discountPercent;
871
+ $usedProductsArray[$usedProduct->getId()]['child']["start-date-discount"] = $startDateDiscount;
872
+ $usedProductsArray[$usedProduct->getId()]['child']["end-date-discount"] = $endDateDiscount;
873
+ $usedProductsArray[$usedProduct->getId()]['child']['is-in-stock'] = $isInStock;
874
+ $usedProductsArray[$usedProduct->getId()]['child']['qty'] = round($qty);
875
+ $usedProductsArray[$usedProduct->getId()]['child']['tax-rate'] = $usedProduct->getTaxPercent();
876
+ if (!$data['tax-rate'] && $usedProductsArray[$usedProduct->getId()]['child']['tax-rate']) {
877
+ $data['tax-rate'] = $usedProductsArray[$usedProduct->getId()]['child']['tax-rate'];
878
+ }
879
+ if ($qty > 0 && $qty > $data['qty']) {
880
+ $data['qty'] = round($qty);
881
+ }
882
+ $usedProductsArray[$usedProduct->getId()]['child']["ean"] = isset($attributesFromConfig['ean']) ? $usedProduct->getData($attributesFromConfig['ean']) : '';
883
+
884
+ $images = $this->getImages($images, $usedProduct, $storeId);
885
+ if (!$images['image-url-1']) {
886
+ $images = $this->getImages($images, $product, $storeId);
887
+ }
888
+ foreach ($images as $key => $value) {
889
+ $usedProductsArray[$usedProduct->getId()]['child'][$key] = trim($value);
890
+ }
891
+
892
+ foreach ($attributesFromConfig as $nameNode => $attributeCode) {
893
+ $usedProductsArray[$usedProduct->getId()]['child'][$nameNode] = $this->_getAttributeDataForProduct($nameNode, $attributeCode, $usedProduct); //$xmlObj->extractData($nameNode, $attributeCode, $usedProduct);
894
+ }
895
+
896
+
897
+ $attributes = Mage::helper('profileolabs_shoppingflux')->getAttributesConfigurable($product);
898
+ foreach ($attributes as $attribute) {
899
+ $attributeCode = $attribute['attribute_code'];
900
+ $attributeId = $attribute['attribute_id'];
901
+
902
+ if (!isset($this->_attributesConfigurable[$attributeId]))
903
+ $this->_attributesConfigurable[$attributeId] = $product->getResource()->getAttribute($attributeId);
904
+
905
+ $attributeModel = $this->_attributesConfigurable[$attributeId];
906
+
907
+ $value = '';
908
+ if ($usedProduct->getData($attributeCode)) {
909
+ $value = $attributeModel->getFrontend()->getValue($usedProduct);
910
+ }
911
+
912
+ if (!isset($attributesToOptions[$attributeCode]) || !in_array($value, $attributesToOptions[$attributeCode]))
913
+ $attributesToOptions[$attributeCode][] = $value;
914
+
915
+ $usedProductsArray[$usedProduct->getId()]['child'][$attributeCode] = trim($value);
916
+ }
917
+
918
+
919
+ if (!isset($usedProductsArray[$usedProduct->getId()]['child']['shipping_delay']) || !$usedProductsArray[$usedProduct->getId()]['child']['shipping_delay'])
920
+ $usedProductsArray[$usedProduct->getId()]['child']['shipping_delay'] = $this->getConfig()->getConfigData('shoppingflux_export/general/default_shipping_delay');
921
+ }
922
+
923
+
924
+
925
+
926
+ $data['is-in-stock'] = (int) $salable;
927
+
928
+ foreach ($attributesToOptions as $attributeCode => $value) {
929
+
930
+ $data["configurable_attributes"][$attributeCode] = implode(",", $value);
931
+ }
932
+ $data["childs_product"] = $usedProductsArray;
933
+
934
+ unset($usedProducts);
935
+ unset($usedProductsArray);
936
+ }
937
+ return $data;
938
+ }
939
+
940
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Observer.php CHANGED
@@ -1,413 +1,428 @@
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
- }
31
-
32
- public function updateFlux() {
33
- Mage::getModel('profileolabs_shoppingflux/export_flux')->getCollection();
34
- Mage::getModel('profileolabs_shoppingflux/export_flux')->updateFlux();
35
- }
36
-
37
-
38
- protected function generateFluxInFileForStore($storeId) {
39
- $filePath = Mage::getBaseDir('media') . DS . 'shoppingflux_'.$storeId.'.xml';
40
- $handle = fopen($filePath, 'a');
41
- ftruncate($handle, 0);
42
-
43
- Mage::getModel('profileolabs_shoppingflux/export_flux')->updateFlux($storeId, 1000000);
44
- $collection = Mage::getModel('profileolabs_shoppingflux/export_flux')->getCollection();
45
- $collection->addFieldToFilter('should_export', 1);
46
- $collection->addFieldToFilter('store_id', $storeId);
47
- $sizeTotal = $collection->count();
48
- $collection->clear();
49
-
50
- if (!$this->getConfig()->isExportSoldout($storeId)) {
51
- $collection->addFieldToFilter('is_in_stock', 1);
52
- }
53
- if ($this->getConfig()->isExportFilteredByAttribute($storeId)) {
54
- $collection->addFieldToFilter('is_in_flux', 1);
55
- }
56
- $visibilities = $this->getConfig()->getVisibilitiesToExport($storeId);
57
- $collection->getSelect()->where("find_in_set(visibility, '" . implode(',', $visibilities) . "')");
58
-
59
-
60
-
61
- $xmlObj = Mage::getModel('profileolabs_shoppingflux/export_xml');
62
- $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)));
63
- fwrite($handle, $startXml);
64
- Mage::getSingleton('core/resource_iterator')
65
- ->walk($collection->getSelect(), array(array($this, 'saveProductXml')), array('handle'=>$handle));
66
- $endXml = $xmlObj->endXml();
67
- fwrite($handle, $endXml);
68
- fclose($handle);
69
- }
70
-
71
- public function saveProductXml($args) {
72
- fwrite($args['handle'], $args['row']['xml']);
73
- }
74
-
75
- public function generateFluxInFile() {
76
- //foreach(Mage::app()->getStores() as $store) {
77
- // $this->generateFluxInFileForStore($store->getId());
78
- //}
79
- $this->generateFluxInFileForStore(Mage::app()->getDefaultStoreView()->getId());
80
- }
81
-
82
- /**
83
- * @deprecated deprecated since 0.1.1
84
- * @param Varien_Object $observer
85
- */
86
- public function generateFlow($observer) {
87
- try {
88
-
89
- $url = str_replace("index.php/", "", Mage::getBaseUrl() . 'Script_Profileolabs/generate_flow.php');
90
- $curl = curl_init($url);
91
- curl_setopt($curl, CURLOPT_POST, false);
92
- curl_setopt($curl, CURLOPT_HEADER, false);
93
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
94
- curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1800);
95
- $curl_response = curl_exec($curl);
96
- curl_close($curl);
97
- } catch (Exception $e) {
98
- Mage::throwException($e);
99
- }
100
-
101
- return $this;
102
- }
103
-
104
- /**
105
- * Add shoppingflux product tab in category edit page
106
- * @param $observer
107
- */
108
- public function addShoppingfluxProductsTab($observer) {
109
- $tabs = $observer->getTabs();
110
- $tabs->addTab('shoppingflux_products', array(
111
- 'label' => Mage::helper('catalog')->__('Shoppingflux Category Products'),
112
- 'content' => $tabs->getLayout()->createBlock(
113
- 'profileolabs_shoppingflux/export_adminhtml_catalog_category_tab_default', 'shoppingflux.product.grid'
114
- )->toHtml(),
115
- ));
116
- }
117
-
118
- public function catalogProductAttributeUpdateBefore($observer) {
119
- $productIds = $observer->getEvent()->getProductIds();
120
- foreach ($productIds as $productId) {
121
- Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($productId);
122
- }
123
- }
124
-
125
- public function catalogProductSaveCommitAfter($observer) {
126
- $product = $observer->getEvent()->getProduct();
127
- Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($product->getId());
128
- }
129
-
130
- /**
131
- * update default category for selected products
132
- */
133
- public function saveShoppingfluxCategoryProducts($observer) {
134
- $category = $observer->getEvent()->getCategory();
135
- $request = $observer->getEvent()->getRequest();
136
- $postedProducts = $request->getParam('shoppingflux_category_products');
137
- $products = array();
138
- $storeId = intval($request->getParam('store', 0));
139
- parse_str($postedProducts, $products);
140
- if (isset($products['on']))
141
- unset($products['on']);
142
- $products = array_keys($products);
143
- if (!empty($products)) {
144
- $currentVersion = Mage::getVersion();
145
- /* if (version_compare($currentVersion, '1.4.0') < 0) { */
146
- $product = Mage::getModel('catalog/product');
147
- foreach ($products as $productId) {
148
-
149
- $product->setData(array());
150
- $product->setStoreId($storeId)
151
- ->load($productId)
152
- ->setIsMassupdate(true)
153
- ->setExcludeUrlRewrite(true);
154
-
155
- if (!$product->getId()) {
156
- continue;
157
- }
158
-
159
- $product->addData(array('shoppingflux_default_category' => $category->getId()));
160
- $dataChanged = $product->dataHasChangedFor('shoppingflux_default_category');
161
-
162
- if ($dataChanged) {
163
- $product->save();
164
- }
165
- }
166
- // This method may be faster alone, but put all updated products to "Need Update" even if no changes
167
- /* } else {
168
- Mage::getSingleton('catalog/product_action')
169
- ->updateAttributes($products, array('shoppingflux_default_category' => $category->getId()), $storeId);
170
-
171
- //var_dump($products);die();
172
- } */
173
- }
174
- }
175
-
176
- public function manageUpdates() {
177
- $apiKeyManaged = array();
178
- foreach (Mage::app()->getStores() as $store) {
179
- $apiKey = $this->getConfig()->getApiKey($store->getId());
180
- if (!$apiKey || in_array($apiKey, $apiKeyManaged))
181
- continue;
182
- $apiKeyManaged[] = $apiKey;
183
-
184
-
185
- $updates = Mage::getModel('profileolabs_shoppingflux/export_updates')->getCollection();
186
- $updates->addFieldToFilter('store_id', $store->getId());
187
-
188
- $wsUri = $this->getConfig()->getWsUri();
189
- $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
190
- try {
191
- $service->updateProducts($updates);
192
- $updates->walk('delete');
193
- } catch (Exception $e) {
194
-
195
- }
196
- }
197
- }
198
-
199
- protected function _scheduleProductUpdate(array $data) {
200
- /* * REALTIME* */
201
- $object = new Varien_Object();
202
- $object->setData($data);
203
- $collection = new Varien_Data_Collection();
204
- $collection->addItem($object);
205
- $apiKey = $this->getConfig()->getApiKey($data['store_id']);
206
- $wsUri = $this->getConfig()->getWsUri();
207
- $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
208
- $service->updateProducts($collection);
209
- /* * SCHEDULED* */
210
- /*
211
- $data['updated_at'] = date('Y-m-d H:i:s');
212
- $updates = Mage::getModel('profileolabs_shoppingflux/export_updates');
213
- $updates->loadWithData($data);
214
- foreach ($data as $k => $v)
215
- $updates->setData($k, $v);
216
- $updates->save();
217
- * *
218
- */
219
- }
220
-
221
- /**
222
- * @param mixed $product product id, or Mage_Catalog_Model_Product
223
- */
224
- protected function _scheduleProductUpdates($product, array $forceData = array()) {
225
- if ($product) {
226
- if (is_numeric($product))
227
- $product = Mage::getModel('catalog/product')->load($product);
228
- $productStoresIds = $product->getStoreIds();
229
- $apiKeyManaged = array();
230
- foreach ($productStoresIds as $storeId) {
231
- $apiKey = $this->getConfig()->getApiKey($storeId);
232
- if (!$apiKey || in_array($apiKey, $apiKeyManaged))
233
- continue;
234
- $apiKeyManaged[] = $apiKey;
235
- $storeProduct = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product->getId());
236
-
237
- $stock = $storeProduct->getStockItem()->getQty();
238
- if ($this->getConfig()->isExportFilteredByAttribute($storeId) && $storeProduct->getData('shoppingflux_product') != 1) {
239
- $stock = 0;
240
- }
241
- if ($storeProduct->getStatus() != 1) {
242
- $stock = 0;
243
- }
244
- $data = array(
245
- 'store_id' => $storeId,
246
- 'product_sku' => $storeProduct->getSku(),
247
- 'stock_value' => $stock,
248
- 'price_value' => $storeProduct->getFinalPrice(),
249
- 'old_price_value' => $storeProduct->getPrice()
250
- );
251
- foreach ($forceData as $key => $val) {
252
- $data[$key] = $val;
253
- }
254
- $this->_scheduleProductUpdate($data);
255
- }
256
- }
257
- }
258
-
259
- /**
260
- * cataloginventory_stock_item_save_after (adminhtml,frontend)
261
- * @param type $observer
262
- */
263
- public function realtimeUpdateStock($observer) {
264
- Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getItem()->getProductId());
265
- if (!$this->getConfig()->isSyncEnabled())
266
- return;
267
-
268
- $oldStock = (int) $observer->getItem()->getOrigData('qty');
269
- $newStock = (int) $observer->getItem()->getData('qty');
270
- if ($oldStock != $newStock) {
271
-
272
- //Mage::log('realtimeUpdateStock');
273
- $productId = $observer->getItem()->getProductId();
274
- $this->_scheduleProductUpdates($productId);
275
- }
276
- }
277
-
278
- /**
279
- * catalog_product_save_after (adminhtml)
280
- * @param type $observer
281
- */
282
- public function realtimeUpdatePrice($observer) {
283
- if ($observer->getProduct()->getSku() != $observer->getProduct()->getOrigData('sku')) {
284
- Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFluxForAllStores($observer->getProduct()->getOrigData('sku'));
285
- Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFluxForAllStores($observer->getProduct()->getSku());
286
- }
287
- Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getProduct());
288
-
289
-
290
- if (!$this->getConfig()->isSyncEnabled())
291
- return;
292
-
293
- $product = $observer->getProduct();
294
- $storeId = $product->getStoreId();
295
- $attributesToCheck = array('price', 'tax_class_id', 'special_price', 'special_to_date', 'special_from_date');
296
- /*
297
- $ecotaxeAttributeCode = Mage::getStoreConfigFlag('shoppingflux_export/attributes_unknow/ecotaxe', $storeId);
298
- if ($ecotaxeAttributeCode) {
299
- $attributesToCheck[] = $ecotaxeAttributeCode;
300
- }
301
- */
302
- $somePriceChanged = false;
303
- foreach ($attributesToCheck as $attributeCode) {
304
- if ($product->getData($attributeCode) != $product->getOrigData($attributeCode)) {
305
- $somePriceChanged = true;
306
- }
307
- }
308
-
309
- if ($somePriceChanged) {
310
- //Mage::log('realtimeUpdatePrice');
311
- if ($storeId == 0) { // update for all stores
312
- $this->_scheduleProductUpdates($product);
313
- } else { // change happened in one store, update only this one
314
- $stock = $product->getStockItem()->getQty();
315
- $this->_scheduleProductUpdate(array(
316
- 'store_id' => $storeId,
317
- 'product_sku' => $product->getSku(),
318
- 'stock_value' => $stock,
319
- 'price_value' => $product->getFinalPrice(),
320
- 'old_price_value' => $product->getPrice()
321
- ));
322
- }
323
- }
324
- }
325
-
326
- /**
327
- * catalog_product_save_after (adminhtml)
328
- * @param type $observer
329
- */
330
- public function realtimeUpdateDeletedProduct($observer) {
331
- if (!$this->getConfig()->isSyncEnabled())
332
- return;
333
-
334
- $product = $observer->getProduct();
335
- $apiKeyManaged = array();
336
- foreach (Mage::app()->getStores() as $store) {
337
- $apiKey = $this->getConfig()->getApiKey($store->getId());
338
- if (!$apiKey || in_array($apiKey, $apiKeyManaged))
339
- continue;
340
- $apiKeyManaged[] = $apiKey;
341
- //Mage::log('realtimeUpdateDeletedProduct');
342
-
343
- $this->_scheduleProductUpdate(array(
344
- 'store_id' => $store->getId(),
345
- 'product_sku' => $product->getSku(),
346
- 'stock_value' => 0,
347
- 'price_value' => $product->getPrice(),
348
- 'old_price_value' => $product->getPrice()
349
- ));
350
- }
351
- }
352
-
353
- /**
354
- * catalog_product_status_update (adminhtml)
355
- * @param type $observer
356
- */
357
- public function realtimeUpdateDisabledProduct($observer) {
358
- Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getProductId());
359
- if (!$this->getConfig()->isSyncEnabled())
360
- return;
361
-
362
- //Mage::log('realtimeUpdateDisabledProduct');
363
- $this->_scheduleProductUpdates($observer->getProductId());
364
- }
365
-
366
- /**
367
- * catalog_product_save_after (adminhtml)
368
- * @param type $observer
369
- */
370
- public function realtimeUpdateDisabledProductSave($observer) {
371
- if (!$this->getConfig()->isSyncEnabled())
372
- return;
373
-
374
- $product = $observer->getProduct();
375
- if ($product->getStatus() != $product->getOrigData('status')) {
376
- //Mage::log('realtimeUpdateDisabledProductSave');
377
- $this->_scheduleProductUpdates($product);
378
- }
379
- }
380
-
381
- /**
382
- * catalog_product_save_after (adminhtml)
383
- * @param type $observer
384
- */
385
- public function realtimeUpdateInSf($observer) {
386
- if (!$this->getConfig()->isSyncEnabled())
387
- return;
388
-
389
- $product = $observer->getProduct();
390
- if ($product->getData('shoppingflux_product') != 1 && $product->getOrigData('shoppingflux_product') == 1) {
391
- //Mage::log('realtimeUpdateInSf');
392
- $this->_scheduleProductUpdates($product, array('stock_value' => 0));
393
- }
394
- }
395
-
396
- /**
397
- * shoppingflux_mass_publish_save_item (adminhtml)
398
- * @param type $observer
399
- */
400
- public function realtimeUpdateInSfMass($observer) {
401
- Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getProductId());
402
- if (!$this->getConfig()->isSyncEnabled())
403
- return;
404
-
405
- $productId = $observer->getProductId();
406
- $publish = $observer->getShoppingfluxProduct();
407
- if ($publish != 1) {
408
- //Mage::log('realtimeUpdateInSfMass');
409
- $this->_scheduleProductUpdates($productId, array('stock_value' => 0));
410
- }
411
- }
412
-
413
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
31
+
32
+ public function updateFlux() {
33
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->getCollection();
34
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateFlux();
35
+ }
36
+
37
+
38
+ protected function generateFluxInFileForStore($storeId) {
39
+ $filePath = Mage::getBaseDir('media') . DS . 'shoppingflux_'.$storeId.'.xml';
40
+ $handle = fopen($filePath, 'a');
41
+ ftruncate($handle, 0);
42
+
43
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateFlux($storeId, 1000000);
44
+ $collection = Mage::getModel('profileolabs_shoppingflux/export_flux')->getCollection();
45
+ $collection->addFieldToFilter('should_export', 1);
46
+ $collection->addFieldToFilter('store_id', $storeId);
47
+ $sizeTotal = $collection->count();
48
+ $collection->clear();
49
+
50
+ if (!$this->getConfig()->isExportSoldout($storeId)) {
51
+ $collection->addFieldToFilter('is_in_stock', 1);
52
+ }
53
+ if ($this->getConfig()->isExportFilteredByAttribute($storeId)) {
54
+ $collection->addFieldToFilter('is_in_flux', 1);
55
+ }
56
+ $visibilities = $this->getConfig()->getVisibilitiesToExport($storeId);
57
+ $collection->getSelect()->where("find_in_set(visibility, '" . implode(',', $visibilities) . "')");
58
+
59
+
60
+
61
+ $xmlObj = Mage::getModel('profileolabs_shoppingflux/export_xml');
62
+ $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)));
63
+ fwrite($handle, $startXml);
64
+ Mage::getSingleton('core/resource_iterator')
65
+ ->walk($collection->getSelect(), array(array($this, 'saveProductXml')), array('handle'=>$handle));
66
+ $endXml = $xmlObj->endXml();
67
+ fwrite($handle, $endXml);
68
+ fclose($handle);
69
+ }
70
+
71
+ public function saveProductXml($args) {
72
+ fwrite($args['handle'], $args['row']['xml']);
73
+ }
74
+
75
+ public function generateFluxInFile() {
76
+ //foreach(Mage::app()->getStores() as $store) {
77
+ // $this->generateFluxInFileForStore($store->getId());
78
+ //}
79
+ $this->generateFluxInFileForStore(Mage::app()->getDefaultStoreView()->getId());
80
+ }
81
+
82
+ /**
83
+ * @deprecated deprecated since 0.1.1
84
+ * @param Varien_Object $observer
85
+ */
86
+ public function generateFlow($observer) {
87
+ try {
88
+
89
+ $url = str_replace("index.php/", "", Mage::getBaseUrl() . 'Script_Profileolabs/generate_flow.php');
90
+ $curl = curl_init($url);
91
+ curl_setopt($curl, CURLOPT_POST, false);
92
+ curl_setopt($curl, CURLOPT_HEADER, false);
93
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
94
+ curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1800);
95
+ $curl_response = curl_exec($curl);
96
+ curl_close($curl);
97
+ } catch (Exception $e) {
98
+ Mage::throwException($e);
99
+ }
100
+
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Add shoppingflux product tab in category edit page
106
+ * @param $observer
107
+ */
108
+ public function addShoppingfluxProductsTab($observer) {
109
+ $tabs = $observer->getTabs();
110
+ $tabs->addTab('shoppingflux_products', array(
111
+ 'label' => Mage::helper('catalog')->__('Shoppingflux Category Products'),
112
+ 'content' => $tabs->getLayout()->createBlock(
113
+ 'profileolabs_shoppingflux/export_adminhtml_catalog_category_tab_default', 'shoppingflux.product.grid'
114
+ )->toHtml(),
115
+ ));
116
+ }
117
+
118
+ public function catalogProductAttributeUpdateBefore($observer) {
119
+ $productIds = $observer->getEvent()->getProductIds();
120
+ foreach ($productIds as $productId) {
121
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($productId);
122
+ }
123
+ }
124
+
125
+ public function catalogProductSaveCommitAfter($observer) {
126
+ $product = $observer->getEvent()->getProduct();
127
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($product->getId());
128
+ }
129
+
130
+ /**
131
+ * update default category for selected products
132
+ */
133
+ public function saveShoppingfluxCategoryProducts($observer) {
134
+ $category = $observer->getEvent()->getCategory();
135
+ $request = $observer->getEvent()->getRequest();
136
+ $postedProducts = $request->getParam('shoppingflux_category_products');
137
+ $products = array();
138
+ $storeId = intval($request->getParam('store', 0));
139
+ parse_str($postedProducts, $products);
140
+ if (isset($products['on']))
141
+ unset($products['on']);
142
+ $products = array_keys($products);
143
+ if (!empty($products)) {
144
+ $currentVersion = Mage::getVersion();
145
+ /* if (version_compare($currentVersion, '1.4.0') < 0) { */
146
+ $product = Mage::getModel('catalog/product');
147
+ foreach ($products as $productId) {
148
+
149
+ $product->setData(array());
150
+ $product->setStoreId($storeId)
151
+ ->load($productId)
152
+ ->setIsMassupdate(true)
153
+ ->setExcludeUrlRewrite(true);
154
+
155
+ if (!$product->getId()) {
156
+ continue;
157
+ }
158
+
159
+ $product->addData(array('shoppingflux_default_category' => $category->getId()));
160
+ $dataChanged = $product->dataHasChangedFor('shoppingflux_default_category');
161
+
162
+ if ($dataChanged) {
163
+ $product->save();
164
+ }
165
+ }
166
+ // This method may be faster alone, but put all updated products to "Need Update" even if no changes
167
+ /* } else {
168
+ Mage::getSingleton('catalog/product_action')
169
+ ->updateAttributes($products, array('shoppingflux_default_category' => $category->getId()), $storeId);
170
+
171
+ //var_dump($products);die();
172
+ } */
173
+ }
174
+ }
175
+
176
+ public function fillMainCategory() {
177
+ $productCollection = Mage::getModel('catalog/product')->getCollection();
178
+ $productCollection->addAttributeToSelect('shoppingflux_default_category', 'left');
179
+ $productCollection->addAttributeToFilter('shoppingflux_default_category', array(array('null'=>true), array('eq'=>'')));
180
+ foreach($productCollection as $product) {
181
+ $categories = $product->getCategoryIds();
182
+ if(!empty($categories)) {
183
+ shuffle($categories);
184
+ $categoryId = array_shift($categories);
185
+ $product->setData('shoppingflux_default_category', $categoryId);
186
+ $product->save();
187
+ }
188
+ }
189
+ }
190
+
191
+ public function manageUpdates() {
192
+ $apiKeyManaged = array();
193
+ foreach (Mage::app()->getStores() as $store) {
194
+ $apiKey = $this->getConfig()->getApiKey($store->getId());
195
+ if (!$apiKey || in_array($apiKey, $apiKeyManaged))
196
+ continue;
197
+ $apiKeyManaged[] = $apiKey;
198
+
199
+
200
+ $updates = Mage::getModel('profileolabs_shoppingflux/export_updates')->getCollection();
201
+ $updates->addFieldToFilter('store_id', $store->getId());
202
+
203
+ $wsUri = $this->getConfig()->getWsUri();
204
+ $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
205
+ try {
206
+ $service->updateProducts($updates);
207
+ $updates->walk('delete');
208
+ } catch (Exception $e) {
209
+
210
+ }
211
+ }
212
+ }
213
+
214
+ protected function _scheduleProductUpdate(array $data) {
215
+ /* * REALTIME* */
216
+ $object = new Varien_Object();
217
+ $object->setData($data);
218
+ $collection = new Varien_Data_Collection();
219
+ $collection->addItem($object);
220
+ $apiKey = $this->getConfig()->getApiKey($data['store_id']);
221
+ $wsUri = $this->getConfig()->getWsUri();
222
+ $service = new Profileolabs_Shoppingflux_Model_Service($apiKey, $wsUri);
223
+ $service->updateProducts($collection);
224
+ /* * SCHEDULED* */
225
+ /*
226
+ $data['updated_at'] = date('Y-m-d H:i:s');
227
+ $updates = Mage::getModel('profileolabs_shoppingflux/export_updates');
228
+ $updates->loadWithData($data);
229
+ foreach ($data as $k => $v)
230
+ $updates->setData($k, $v);
231
+ $updates->save();
232
+ * *
233
+ */
234
+ }
235
+
236
+ /**
237
+ * @param mixed $product product id, or Mage_Catalog_Model_Product
238
+ */
239
+ protected function _scheduleProductUpdates($product, array $forceData = array()) {
240
+ if ($product) {
241
+ if (is_numeric($product))
242
+ $product = Mage::getModel('catalog/product')->load($product);
243
+ $productStoresIds = $product->getStoreIds();
244
+ $apiKeyManaged = array();
245
+ foreach ($productStoresIds as $storeId) {
246
+ $apiKey = $this->getConfig()->getApiKey($storeId);
247
+ if (!$apiKey || in_array($apiKey, $apiKeyManaged))
248
+ continue;
249
+ $apiKeyManaged[] = $apiKey;
250
+ $storeProduct = Mage::getModel('catalog/product')->setStoreId($storeId)->load($product->getId());
251
+
252
+ $stock = $storeProduct->getStockItem()->getQty();
253
+ if ($this->getConfig()->isExportFilteredByAttribute($storeId) && $storeProduct->getData('shoppingflux_product') != 1) {
254
+ $stock = 0;
255
+ }
256
+ if ($storeProduct->getStatus() != 1) {
257
+ $stock = 0;
258
+ }
259
+ $data = array(
260
+ 'store_id' => $storeId,
261
+ 'product_sku' => $storeProduct->getSku(),
262
+ 'stock_value' => $stock,
263
+ 'price_value' => $storeProduct->getFinalPrice(),
264
+ 'old_price_value' => $storeProduct->getPrice()
265
+ );
266
+ foreach ($forceData as $key => $val) {
267
+ $data[$key] = $val;
268
+ }
269
+ $this->_scheduleProductUpdate($data);
270
+ }
271
+ }
272
+ }
273
+
274
+ /**
275
+ * cataloginventory_stock_item_save_after (adminhtml,frontend)
276
+ * @param type $observer
277
+ */
278
+ public function realtimeUpdateStock($observer) {
279
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getItem()->getProductId());
280
+ if (!$this->getConfig()->isSyncEnabled())
281
+ return;
282
+
283
+ $oldStock = (int) $observer->getItem()->getOrigData('qty');
284
+ $newStock = (int) $observer->getItem()->getData('qty');
285
+ if ($oldStock != $newStock) {
286
+
287
+ //Mage::log('realtimeUpdateStock');
288
+ $productId = $observer->getItem()->getProductId();
289
+ $this->_scheduleProductUpdates($productId);
290
+ }
291
+ }
292
+
293
+ /**
294
+ * catalog_product_save_after (adminhtml)
295
+ * @param type $observer
296
+ */
297
+ public function realtimeUpdatePrice($observer) {
298
+ if ($observer->getProduct()->getSku() != $observer->getProduct()->getOrigData('sku')) {
299
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFluxForAllStores($observer->getProduct()->getOrigData('sku'));
300
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->updateProductInFluxForAllStores($observer->getProduct()->getSku());
301
+ }
302
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getProduct());
303
+
304
+
305
+ if (!$this->getConfig()->isSyncEnabled())
306
+ return;
307
+
308
+ $product = $observer->getProduct();
309
+ $storeId = $product->getStoreId();
310
+ $attributesToCheck = array('price', 'tax_class_id', 'special_price', 'special_to_date', 'special_from_date');
311
+ /*
312
+ $ecotaxeAttributeCode = Mage::getStoreConfigFlag('shoppingflux_export/attributes_unknow/ecotaxe', $storeId);
313
+ if ($ecotaxeAttributeCode) {
314
+ $attributesToCheck[] = $ecotaxeAttributeCode;
315
+ }
316
+ */
317
+ $somePriceChanged = false;
318
+ foreach ($attributesToCheck as $attributeCode) {
319
+ if ($product->getData($attributeCode) != $product->getOrigData($attributeCode)) {
320
+ $somePriceChanged = true;
321
+ }
322
+ }
323
+
324
+ if ($somePriceChanged) {
325
+ //Mage::log('realtimeUpdatePrice');
326
+ if ($storeId == 0) { // update for all stores
327
+ $this->_scheduleProductUpdates($product);
328
+ } else { // change happened in one store, update only this one
329
+ $stock = $product->getStockItem()->getQty();
330
+ $this->_scheduleProductUpdate(array(
331
+ 'store_id' => $storeId,
332
+ 'product_sku' => $product->getSku(),
333
+ 'stock_value' => $stock,
334
+ 'price_value' => $product->getFinalPrice(),
335
+ 'old_price_value' => $product->getPrice()
336
+ ));
337
+ }
338
+ }
339
+ }
340
+
341
+ /**
342
+ * catalog_product_save_after (adminhtml)
343
+ * @param type $observer
344
+ */
345
+ public function realtimeUpdateDeletedProduct($observer) {
346
+ if (!$this->getConfig()->isSyncEnabled())
347
+ return;
348
+
349
+ $product = $observer->getProduct();
350
+ $apiKeyManaged = array();
351
+ foreach (Mage::app()->getStores() as $store) {
352
+ $apiKey = $this->getConfig()->getApiKey($store->getId());
353
+ if (!$apiKey || in_array($apiKey, $apiKeyManaged))
354
+ continue;
355
+ $apiKeyManaged[] = $apiKey;
356
+ //Mage::log('realtimeUpdateDeletedProduct');
357
+
358
+ $this->_scheduleProductUpdate(array(
359
+ 'store_id' => $store->getId(),
360
+ 'product_sku' => $product->getSku(),
361
+ 'stock_value' => 0,
362
+ 'price_value' => $product->getPrice(),
363
+ 'old_price_value' => $product->getPrice()
364
+ ));
365
+ }
366
+ }
367
+
368
+ /**
369
+ * catalog_product_status_update (adminhtml)
370
+ * @param type $observer
371
+ */
372
+ public function realtimeUpdateDisabledProduct($observer) {
373
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getProductId());
374
+ if (!$this->getConfig()->isSyncEnabled())
375
+ return;
376
+
377
+ //Mage::log('realtimeUpdateDisabledProduct');
378
+ $this->_scheduleProductUpdates($observer->getProductId());
379
+ }
380
+
381
+ /**
382
+ * catalog_product_save_after (adminhtml)
383
+ * @param type $observer
384
+ */
385
+ public function realtimeUpdateDisabledProductSave($observer) {
386
+ if (!$this->getConfig()->isSyncEnabled())
387
+ return;
388
+
389
+ $product = $observer->getProduct();
390
+ if ($product->getStatus() != $product->getOrigData('status')) {
391
+ //Mage::log('realtimeUpdateDisabledProductSave');
392
+ $this->_scheduleProductUpdates($product);
393
+ }
394
+ }
395
+
396
+ /**
397
+ * catalog_product_save_after (adminhtml)
398
+ * @param type $observer
399
+ */
400
+ public function realtimeUpdateInSf($observer) {
401
+ if (!$this->getConfig()->isSyncEnabled())
402
+ return;
403
+
404
+ $product = $observer->getProduct();
405
+ if ($product->getData('shoppingflux_product') != 1 && $product->getOrigData('shoppingflux_product') == 1) {
406
+ //Mage::log('realtimeUpdateInSf');
407
+ $this->_scheduleProductUpdates($product, array('stock_value' => 0));
408
+ }
409
+ }
410
+
411
+ /**
412
+ * shoppingflux_mass_publish_save_item (adminhtml)
413
+ * @param type $observer
414
+ */
415
+ public function realtimeUpdateInSfMass($observer) {
416
+ Mage::getModel('profileolabs_shoppingflux/export_flux')->productNeedUpdate($observer->getProductId());
417
+ if (!$this->getConfig()->isSyncEnabled())
418
+ return;
419
+
420
+ $productId = $observer->getProductId();
421
+ $publish = $observer->getShoppingfluxProduct();
422
+ if ($publish != 1) {
423
+ //Mage::log('realtimeUpdateInSfMass');
424
+ $this->_scheduleProductUpdates($productId, array('stock_value' => 0));
425
+ }
426
+ }
427
+
428
+ }
app/code/community/Profileolabs/Shoppingflux/Model/Export/Rewrite/Catalog/Config.php CHANGED
@@ -1,58 +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
- }
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 CHANGED
@@ -1,33 +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
  }
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 CHANGED
@@ -1,48 +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
- }
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 CHANGED
@@ -1,31 +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
- }
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 CHANGED
@@ -1,18 +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
- }
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 CHANGED
@@ -1,21 +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
- }
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 CHANGED
@@ -1,32 +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
  }
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 CHANGED
@@ -1,150 +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
  }
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 CHANGED
@@ -1,251 +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
  }
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 CHANGED
@@ -1,140 +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
  }
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 CHANGED
@@ -1,108 +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
  }
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 CHANGED
@@ -1,20 +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
  }
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 CHANGED
@@ -1,36 +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
  }
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 CHANGED
@@ -1,180 +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->getResult();
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() && !preg_match('%Error in cURL request: connect.. timed out%', $message)) {
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
  }
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->getResult();
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() && !preg_match('%Error in cURL request: connect.. timed out%', $message)) {
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 CHANGED
@@ -1,817 +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
  }
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 CHANGED
@@ -1,683 +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
  }
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 CHANGED
@@ -1,45 +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
- }
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 CHANGED
@@ -1,18 +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
  }
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 CHANGED
@@ -1,81 +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
- }
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 CHANGED
@@ -1,46 +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
  }
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 CHANGED
@@ -1,17 +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
  }
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 CHANGED
@@ -1,15 +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
  }
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 CHANGED
@@ -1,17 +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
  }
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 CHANGED
@@ -1,15 +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
  }
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 CHANGED
@@ -1,13 +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
  }
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 CHANGED
@@ -1,14 +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
  }
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 CHANGED
@@ -1,15 +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
  }
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 CHANGED
@@ -1,15 +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
  }
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 CHANGED
@@ -1,15 +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
  }
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 CHANGED
@@ -1,15 +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
  }
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 CHANGED
@@ -1,286 +1,288 @@
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
  }
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 => 10,
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::log($responseText, null, 'shoppingflux.log');
150
+ Mage::throwException(Mage::helper('profileolabs_shoppingflux')->__("Result is not Varien_Simplexml_Element"));
151
+ } elseif ($this->_xml->error) {
152
+ Mage::throwException(Mage::helper('profileolabs_shoppingflux')->__('API key (Token) not valid'));
153
+ }
154
+
155
+ /* } catch (Exception $e) {
156
+ Mage::throwException($e);
157
+ } */
158
+
159
+ return $this->_xml;
160
+ }
161
+
162
+ /**
163
+ * Retrieve orders
164
+ *
165
+ */
166
+ public function getOrders() {
167
+ $data = $this->_connect($this->_getApiKey(), self::METHOD_GET_ORDERS);
168
+ return $data->Response->Orders;
169
+ }
170
+
171
+ /**
172
+ * Send orders ids imported
173
+ * @param array $orderIds
174
+ */
175
+ public function sendValidOrders(array $orderIds) {
176
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
177
+ $xml .= '<ValidOrders>';
178
+ foreach($orderIds as $orderId => $orderInfo) {
179
+ if(isset($orderInfo['ErrorOrder']) && $orderInfo['ErrorOrder'] !== false && !$orderInfo['ErrorOrder']) {
180
+ $orderInfo['ErrorOrder'] = 'Une erreur s\'est produite';
181
+ }
182
+ $xml .= '<Order>';
183
+ $xml .= '<IdOrder>' . $orderId . '</IdOrder>';
184
+ $xml .= '<Marketplace>' . $orderInfo['Marketplace'] . '</Marketplace>';
185
+ $xml .= '<MerchantIdOrder>' . $orderInfo['MageOrderId'] . '</MerchantIdOrder>';
186
+ if(isset($orderInfo['ErrorOrder']) && $orderInfo['ErrorOrder']) {
187
+ $xml .= '<ErrorOrder>' . $orderInfo['ErrorOrder'] . '</ErrorOrder>';
188
+ }
189
+ $xml .= '</Order>';
190
+ }
191
+ $xml .= '</ValidOrders>';
192
+
193
+
194
+ $dataObj = new Varien_Object(array('xml' => $xml));
195
+ Mage::dispatchEvent('shoppingflux_send_valid_orders', array('data_obj' => $dataObj));
196
+ $xml = $dataObj->getXml();
197
+ return $this->_connect($this->_getApiKey(), self::METHOD_VALIDATE_ORDERS, $xml);
198
+ }
199
+
200
+ /**
201
+ * Update orders id shipped
202
+ * @param string $orderId
203
+ */
204
+ public function updateShippedOrder($orderId, $marketplace, $status, $trackNum = '', $trackCarrier = '', $trackUrl = '') {
205
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
206
+ $xml .= '<UpdateOrders>';
207
+ $xml .= '<Order>';
208
+ $xml .= '<IdOrder>' . $orderId . '</IdOrder>';
209
+ $xml .= '<Marketplace>' . $marketplace . '</Marketplace>';
210
+ $xml .= '<Status>' . $status . '</Status>';
211
+ if ($trackNum) {
212
+ $xml .= '<TrackingNumber><![CDATA[' . $trackNum . ']]></TrackingNumber>';
213
+ }
214
+ if ($trackUrl) {
215
+ $xml .= '<TrackingUrl><![CDATA[' . $trackUrl . ']]></TrackingUrl>';
216
+ }
217
+ if ($trackCarrier) {
218
+ $xml .= '<CarrierName><![CDATA[' . $trackCarrier . ']]></CarrierName>';
219
+ }
220
+ $xml .= '</Order>';
221
+ $xml .= '</UpdateOrders>';
222
+ $dataObj = new Varien_Object(array('xml' => $xml));
223
+ Mage::dispatchEvent('shoppingflux_update_shipped_orders', array('data_obj' => $dataObj));
224
+ $xml = $dataObj->getXml();
225
+ return $this->_connect(
226
+ $this->_getApiKey(), self::METHOD_UPDATE_ORDERS, $xml
227
+ );
228
+ }
229
+
230
+ public function updateCanceledOrder($orderId, $marketplace, $status) {
231
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
232
+ $xml .= '<UpdateOrders>';
233
+ $xml .= '<Order>';
234
+ $xml .= '<IdOrder>' . $orderId . '</IdOrder>';
235
+ $xml .= '<Marketplace>' . $marketplace . '</Marketplace>';
236
+ $xml .= '<Status>' . $status . '</Status>';
237
+ $xml .= '</Order>';
238
+ $xml .= '</UpdateOrders>';
239
+ $dataObj = new Varien_Object(array('xml' => $xml));
240
+ Mage::dispatchEvent('shoppingflux_update_canceled_orders', array('data_obj' => $dataObj));
241
+ $xml = $dataObj->getXml();
242
+ return $this->_connect(
243
+ $this->_getApiKey(), self::METHOD_UPDATE_ORDERS, $xml
244
+ );
245
+ }
246
+
247
+
248
+ public function updateProducts($updates) {
249
+ if($updates->getSize() <=0) return;
250
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
251
+ $xml .= '<UpdateProduct>';
252
+ foreach($updates as $update) {
253
+ $xml .= '<Product>';
254
+ $xml .= '<SKU>' . $update->getProductSku() . '</SKU>';
255
+ $xml .= '<Quantity>' . $update->getStockValue() . '</Quantity>';
256
+ $xml .= '<Price>' . $update->getPriceValue() . '</Price>';
257
+ $xml .= '<OldPrice>' . $update->getOldPriceValue() . '</OldPrice>';
258
+ $xml .= '</Product>';
259
+ }
260
+ $xml .= '</UpdateProduct>';
261
+ $this->_connect(
262
+ $this->_getApiKey(), self::METHOD_UPDATE_PRODUCT, $xml
263
+ );
264
+ }
265
+
266
+ /**
267
+ * Retrieve login
268
+ * @param string|null $apiKey
269
+ */
270
+ public function getLogin($apiKey = null) {
271
+ if (is_null($apiKey))
272
+ $apiKey = $this->_getApiKey();
273
+
274
+ return $this->_connect($apiKey, self::METHOD_LOGIN);
275
+ }
276
+
277
+ /**
278
+ * Check if ApiKey is valid
279
+ * @param string $apiKey
280
+ */
281
+ public function checkApiKey($apiKey) {
282
+ if ($this->getLogin($apiKey)->error)
283
+ return false;
284
+
285
+ return true;
286
+ }
287
+
288
  }
app/code/community/Profileolabs/Shoppingflux/Model/Service/Http/Client/Adapter/Curl.php CHANGED
@@ -1,507 +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
- }
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 CHANGED
@@ -1,46 +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
- }
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 CHANGED
@@ -1,39 +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
  }
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 CHANGED
@@ -1,61 +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
  }
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 CHANGED
@@ -1,41 +1,46 @@
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
- public function testAction() {
24
- ini_set('display_errors',1);
25
- error_reporting(-1);
26
- //$write = Mage::getSingleton('core/resource')->getConnection('core_write');
27
- //$query = "delete from " . Mage::getConfig()->getTablePrefix() . 'core_resource' . " where code = 'profileolabs_shoppingflux_setup' ";
28
- //$write->query($query);
29
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
30
- $select = $read->select()
31
- ->distinct()
32
- ->from(Mage::getConfig()->getTablePrefix() . 'core_resource', array('code', 'version', 'data_version'))
33
- ->where('code = ?', 'profileolabs_shoppingflux_setup');
34
- $values = $read->fetchAll($select);
35
- foreach($values as $value) {
36
- var_dump($value);
37
- }
38
- }
39
-
40
-
 
 
 
 
 
41
  }
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
+ public function testAction() {
24
+ Profileolabs_Shoppingflux_Model_Export_Observer::fillMainCategory();
25
+ return;
26
+
27
+
28
+
29
+ ini_set('display_errors',1);
30
+ error_reporting(-1);
31
+ //$write = Mage::getSingleton('core/resource')->getConnection('core_write');
32
+ //$query = "delete from " . Mage::getConfig()->getTablePrefix() . 'core_resource' . " where code = 'profileolabs_shoppingflux_setup' ";
33
+ //$write->query($query);
34
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
35
+ $select = $read->select()
36
+ ->distinct()
37
+ ->from(Mage::getConfig()->getTablePrefix() . 'core_resource', array('code', 'version', 'data_version'))
38
+ ->where('code = ?', 'profileolabs_shoppingflux_setup');
39
+ $values = $read->fetchAll($select);
40
+ foreach($values as $value) {
41
+ var_dump($value);
42
+ }
43
+ }
44
+
45
+
46
  }
app/code/community/Profileolabs/Shoppingflux/controllers/Export/Adminhtml/CategoryController.php CHANGED
@@ -1,29 +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
  }
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 CHANGED
@@ -1,124 +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
  }
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 CHANGED
@@ -1,150 +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
- }
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 CHANGED
@@ -1,38 +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
  }
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 CHANGED
@@ -1,55 +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
  }
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 CHANGED
@@ -1,48 +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
  }
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 CHANGED
@@ -1,57 +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
  }
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/etc/config.xml CHANGED
@@ -1,552 +1,560 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Profileolabs_Shoppingflux>
5
- <version>0.7.0</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
- <enable_buyline>1</enable_buyline>
467
- </configuration>
468
- </shoppingflux>
469
- <shoppingflux_mo>
470
- <manageorders>
471
- <enabled>0</enabled>
472
- <limit_orders>30</limit_orders>
473
- <new_order_status>pending</new_order_status>
474
- <create_invoice>1</create_invoice>
475
- <processing_order_status>processing</processing_order_status>
476
- <apply_tax>0</apply_tax>
477
- </manageorders>
478
- </shoppingflux_mo>
479
- <payment>
480
- <shoppingflux_purchaseorder>
481
- <active>0</active>
482
- <model>profileolabs_shoppingflux/manageorders_payment_method_purchaseorder</model>
483
- <order_status>new</order_status>
484
- <title>Shopping Flux Purchase Order</title>
485
- <allowspecific>0</allowspecific>
486
- </shoppingflux_purchaseorder>
487
- </payment>
488
- <carriers>
489
- <shoppingflux>
490
- <active>1</active>
491
- <sallowspecific>0</sallowspecific>
492
- <model>profileolabs_shoppingflux/manageorders_shipping_carrier_shoppingflux</model>
493
- <name>Frais de port de la place de marché</name>
494
- <title></title>
495
- </shoppingflux>
496
- </carriers>
497
- <shoppingflux_export>
498
- <general>
499
- <active>1</active>
500
- <filter_by_attribute>0</filter_by_attribute>
501
- <limit_product>100</limit_product>
502
- <default_shipping_delay>2</default_shipping_delay>
503
- <default_shipping_price></default_shipping_price>
504
- <default_shipping_method>flatrate_flatrate</default_shipping_method>
505
- <shipping_price_based_on>FR</shipping_price_based_on>
506
- <export_soldout>1</export_soldout>
507
- <export_visibility>2,3,4</export_visibility>
508
- <memory_limit>512</memory_limit>
509
- <use_manage_stock>1</use_manage_stock>
510
- <all_store_categories>0</all_store_categories>
511
- <all_store_products>0</all_store_products>
512
- <use_only_shoppingflux_category>0</use_only_shoppingflux_category>
513
- <max_category_level>5</max_category_level>
514
- <enable_events>0</enable_events>
515
- <manage_configurable>1</manage_configurable>
516
- <manage_catalog_rules>1</manage_catalog_rules>
517
- <manage_media_gallery>1</manage_media_gallery>
518
- </general>
519
- <attributes_unknow>
520
- <ean>ean</ean>
521
- <isbn>isbn</isbn>
522
- <ref_manufacturer>ref_manufacturer</ref_manufacturer>
523
- <ref_wholesaler>ref_wholesaler</ref_wholesaler>
524
- <shipping_delay>shipping_delay</shipping_delay>
525
- <shipping_send_delay>shipping_send_delay</shipping_send_delay>
526
- <brand>brand</brand>
527
- <brand_page_url>brand_page_url</brand_page_url>
528
- <ecotaxe>ecotaxe</ecotaxe>
529
- <short_name>short_name</short_name>
530
- <characteristics>characteristics</characteristics>
531
- <warranty>warranty</warranty>
532
- <kind>kind</kind>
533
- <matter>matter</matter>
534
- <size>size</size>
535
- <shoe_size>shoe_size</shoe_size>
536
- <dimension>dimension</dimension>
537
- </attributes_unknow>
538
- <attributes_know>
539
- <name>name</name>
540
- <description>description</description>
541
- <short_description>short_description</short_description>
542
- <meta_keyword>meta_keyword</meta_keyword>
543
- <weight>weight</weight>
544
- <color>color</color>
545
- </attributes_know>
546
- <specific_prices>
547
- <price>price</price>
548
- <special_price>special_price</special_price>
549
- </specific_prices>
550
- </shoppingflux_export>
551
- </default>
552
- </config>
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Profileolabs_Shoppingflux>
5
+ <version>0.7.1</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
+ <fill_main_category>
436
+ <schedule>
437
+ <cron_expr>0 2 * * *</cron_expr>
438
+ </schedule>
439
+ <run>
440
+ <model>profileolabs_shoppingflux/export_observer::fillMainCategory</model>
441
+ </run>
442
+ </fill_main_category>
443
+ <export_shipments_shoppingflux>
444
+ <schedule>
445
+ <cron_expr>*/10 * * * *</cron_expr>
446
+ </schedule>
447
+ <run>
448
+ <model>profileolabs_shoppingflux/manageorders_observer::sendScheduledShipments</model>
449
+ </run>
450
+ </export_shipments_shoppingflux>
451
+ <!--<export_updates_shoppingflux>
452
+ <schedule>
453
+ <cron_expr>*/5 * * * *</cron_expr>
454
+ </schedule>
455
+ <run>
456
+ <model>profileolabs_shoppingflux/export_observer::manageUpdates</model>
457
+ </run>
458
+ </export_updates_shoppingflux>-->
459
+ <!-- <generate_flow_shoppingflux>
460
+ <schedule><cron_expr>30 03 * * *</cron_expr></schedule>
461
+ <run><model>profileolabs_shoppingflux/export_observer::generateFlow</model></run>
462
+ </generate_flow_shoppingflux> -->
463
+ </jobs>
464
+ </crontab>
465
+ <default>
466
+ <shoppingflux>
467
+ <configuration>
468
+ <is_sandbox>0</is_sandbox>
469
+ <ws_uri_test>http://test.shopping-flux.com/ws/</ws_uri_test>
470
+ <ws_uri_prod>http://ws.shopping-flux.com</ws_uri_prod>
471
+ <!--<ws_uri_prod>https://clients.shopping-flux.com/webservice/</ws_uri_prod>-->
472
+ <!--<ws_uri_prod>https://clients.shopping-flux.com/webservice/magento/</ws_uri_prod>-->
473
+ <api_key></api_key>
474
+ <enable_buyline>1</enable_buyline>
475
+ </configuration>
476
+ </shoppingflux>
477
+ <shoppingflux_mo>
478
+ <manageorders>
479
+ <enabled>0</enabled>
480
+ <limit_orders>30</limit_orders>
481
+ <new_order_status>pending</new_order_status>
482
+ <create_invoice>1</create_invoice>
483
+ <processing_order_status>processing</processing_order_status>
484
+ <apply_tax>0</apply_tax>
485
+ </manageorders>
486
+ </shoppingflux_mo>
487
+ <payment>
488
+ <shoppingflux_purchaseorder>
489
+ <active>0</active>
490
+ <model>profileolabs_shoppingflux/manageorders_payment_method_purchaseorder</model>
491
+ <order_status>new</order_status>
492
+ <title>Shopping Flux Purchase Order</title>
493
+ <allowspecific>0</allowspecific>
494
+ </shoppingflux_purchaseorder>
495
+ </payment>
496
+ <carriers>
497
+ <shoppingflux>
498
+ <active>1</active>
499
+ <sallowspecific>0</sallowspecific>
500
+ <model>profileolabs_shoppingflux/manageorders_shipping_carrier_shoppingflux</model>
501
+ <name>Frais de port de la place de marché</name>
502
+ <title></title>
503
+ </shoppingflux>
504
+ </carriers>
505
+ <shoppingflux_export>
506
+ <general>
507
+ <active>1</active>
508
+ <filter_by_attribute>0</filter_by_attribute>
509
+ <limit_product>100</limit_product>
510
+ <default_shipping_delay>2</default_shipping_delay>
511
+ <default_shipping_price></default_shipping_price>
512
+ <default_shipping_method>flatrate_flatrate</default_shipping_method>
513
+ <shipping_price_based_on>FR</shipping_price_based_on>
514
+ <export_soldout>1</export_soldout>
515
+ <export_visibility>2,3,4</export_visibility>
516
+ <memory_limit>512</memory_limit>
517
+ <use_manage_stock>1</use_manage_stock>
518
+ <all_store_categories>0</all_store_categories>
519
+ <all_store_products>0</all_store_products>
520
+ <use_only_shoppingflux_category>0</use_only_shoppingflux_category>
521
+ <max_category_level>5</max_category_level>
522
+ <enable_events>0</enable_events>
523
+ <manage_configurable>1</manage_configurable>
524
+ <manage_catalog_rules>1</manage_catalog_rules>
525
+ <manage_media_gallery>1</manage_media_gallery>
526
+ </general>
527
+ <attributes_unknow>
528
+ <ean>ean</ean>
529
+ <isbn>isbn</isbn>
530
+ <ref_manufacturer>ref_manufacturer</ref_manufacturer>
531
+ <ref_wholesaler>ref_wholesaler</ref_wholesaler>
532
+ <shipping_delay>shipping_delay</shipping_delay>
533
+ <shipping_send_delay>shipping_send_delay</shipping_send_delay>
534
+ <brand>brand</brand>
535
+ <brand_page_url>brand_page_url</brand_page_url>
536
+ <ecotaxe>ecotaxe</ecotaxe>
537
+ <short_name>short_name</short_name>
538
+ <characteristics>characteristics</characteristics>
539
+ <warranty>warranty</warranty>
540
+ <kind>kind</kind>
541
+ <matter>matter</matter>
542
+ <size>size</size>
543
+ <shoe_size>shoe_size</shoe_size>
544
+ <dimension>dimension</dimension>
545
+ </attributes_unknow>
546
+ <attributes_know>
547
+ <name>name</name>
548
+ <description>description</description>
549
+ <short_description>short_description</short_description>
550
+ <meta_keyword>meta_keyword</meta_keyword>
551
+ <weight>weight</weight>
552
+ <color>color</color>
553
+ </attributes_know>
554
+ <specific_prices>
555
+ <price>price</price>
556
+ <special_price>special_price</special_price>
557
+ </specific_prices>
558
+ </shoppingflux_export>
559
+ </default>
560
+ </config>
app/code/community/Profileolabs/Shoppingflux/etc/system.xml CHANGED
@@ -1,1266 +1,1266 @@
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
- <enable_buyline>
53
- <label>Activer le buyline ?</label>
54
- <frontend_type>select</frontend_type>
55
- <source_model>adminhtml/system_config_source_yesno</source_model>
56
- <sort_order>30</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
- </enable_buyline>
61
- <alert_email>
62
- <label>Email pour les alertes</label>
63
- <comment>En cas de problème lors des transfert de données, un mail vous sera envoyé à cette adresse.</comment>
64
- <frontend_type>text</frontend_type>
65
- <sort_order>100</sort_order>
66
- <show_in_default>1</show_in_default>
67
- <show_in_website>1</show_in_website>
68
- <show_in_store>1</show_in_store>
69
- </alert_email>
70
- </fields>
71
- </configuration>
72
- </groups>
73
- </shoppingflux>
74
- <shoppingflux_mo translate="label" module="profileolabs_shoppingflux">
75
- <label>Manage Orders</label>
76
- <tab>shoppingflux</tab>
77
- <frontend_type>text</frontend_type>
78
- <sort_order>100</sort_order>
79
- <show_in_default>1</show_in_default>
80
- <show_in_website>1</show_in_website>
81
- <show_in_store>1</show_in_store>
82
- <groups>
83
- <manageorders translate="label" module="profileolabs_shoppingflux">
84
- <label>Manage Orders</label>
85
- <show_in_default>1</show_in_default>
86
- <show_in_website>1</show_in_website>
87
- <show_in_store>1</show_in_store>
88
- <sort_order>1</sort_order>
89
- <fields>
90
- <enabled>
91
- <label>Enable manage orders</label>
92
- <comment>Enable get orders from Shopping Flux</comment>
93
- <frontend_type>select</frontend_type>
94
- <sort_order>10</sort_order>
95
- <show_in_default>1</show_in_default>
96
- <show_in_website>1</show_in_website>
97
- <show_in_store>1</show_in_store>
98
- <source_model>adminhtml/system_config_source_yesno</source_model>
99
- </enabled>
100
- <limit_orders>
101
- <label>Import by n orders</label>
102
- <sort_order>22</sort_order>
103
- <show_in_default>1</show_in_default>
104
- <show_in_website>1</show_in_website>
105
- <show_in_store>1</show_in_store>
106
- <comment>Limit number of orders imported. 10 by default</comment>
107
- </limit_orders>
108
- <new_order_status translate="label">
109
- <label>New order status</label>
110
- <frontend_type>select</frontend_type>
111
- <source_model>adminhtml/system_config_source_order_status_new</source_model>
112
- <sort_order>80</sort_order>
113
- <show_in_default>1</show_in_default>
114
- <show_in_website>1</show_in_website>
115
- <show_in_store>0</show_in_store>
116
- </new_order_status>
117
- <create_invoice>
118
- <label>Create invoice</label>
119
- <comment>Invoice is created when order getted from Shopping Flux</comment>
120
- <frontend_type>select</frontend_type>
121
- <sort_order>25</sort_order>
122
- <show_in_default>1</show_in_default>
123
- <show_in_website>1</show_in_website>
124
- <show_in_store>1</show_in_store>
125
- <source_model>adminhtml/system_config_source_yesno</source_model>
126
- </create_invoice>
127
- <processing_order_status translate="label">
128
- <label>Invoiced order status</label>
129
- <frontend_type>select</frontend_type>
130
- <source_model>adminhtml/system_config_source_order_status_processing</source_model>
131
- <sort_order>80</sort_order>
132
- <show_in_default>1</show_in_default>
133
- <show_in_website>1</show_in_website>
134
- <show_in_store>0</show_in_store>
135
- </processing_order_status>
136
- <!--<import_store>
137
- <label>Import Store</label>
138
- <comment>Orders will be imported in selected store</comment>
139
- <frontend_type>select</frontend_type>
140
- <sort_order>26</sort_order>
141
- <show_in_default>1</show_in_default>
142
- <show_in_website>0</show_in_website>
143
- <show_in_store>0</show_in_store>
144
- <source_model>adminhtml/system_config_source_store</source_model>
145
- </import_store>-->
146
- <!--<apply_tax>
147
- <label>Apply tax</label>
148
- <comment><![CDATA[Calculation of tax when order is created.<b style='color:red'>Do not active if you sell your products Excl. Tax</b>]]>
149
- </comment>
150
- <frontend_type>select</frontend_type>
151
- <sort_order>27</sort_order>
152
- <show_in_default>1</show_in_default>
153
- <show_in_website>1</show_in_website>
154
- <show_in_store>1</show_in_store>
155
- <source_model>adminhtml/system_config_source_yesno</source_model>
156
- </apply_tax>)-->
157
- <!-- <is_test>
158
- <label>Test</label>
159
- <frontend_type>select</frontend_type>
160
- <source_model>adminhtml/system_config_source_yesno</source_model>
161
- <comment>Si oui, la requête se fait su l'url test de shopping flux</comment>
162
- <sort_order>30</sort_order>
163
- <show_in_default>1</show_in_default>
164
- <show_in_website>0</show_in_website>
165
- <show_in_store>0</show_in_store>
166
- </is_test> -->
167
- </fields>
168
- </manageorders>
169
- <import_customer translate="label" module="profileolabs_shoppingflux">
170
- <label>Import Customers</label>
171
- <show_in_default>1</show_in_default>
172
- <show_in_website>1</show_in_website>
173
- <show_in_store>1</show_in_store>
174
- <sort_order>2</sort_order>
175
- <fields>
176
- <limit_address_length>
177
- <label>Limiter la longueur des lignes d'adresse</label>
178
- <comment>Laisser vide pour ne pas limiter. Valeur mini : 20</comment>
179
- <frontend_type>text</frontend_type>
180
- <sort_order>5</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
- </limit_address_length>
185
- <default_group>
186
- <label>Default customer group</label>
187
- <comment>Set specific customer group for imported customer from Shopping Flux</comment>
188
- <frontend_type>select</frontend_type>
189
- <sort_order>10</sort_order>
190
- <show_in_default>1</show_in_default>
191
- <show_in_website>0</show_in_website>
192
- <show_in_store>0</show_in_store>
193
- <source_model>adminhtml/system_config_source_customer_group</source_model>
194
- </default_group>
195
- <amazon_group>
196
- <label>Amazon customer group</label>
197
- <comment>Set specific customer group for imported customer from Amazon. Leave empty to use default.</comment>
198
- <frontend_type>select</frontend_type>
199
- <sort_order>30</sort_order>
200
- <show_in_default>1</show_in_default>
201
- <show_in_website>0</show_in_website>
202
- <show_in_store>0</show_in_store>
203
- <source_model>adminhtml/system_config_source_customer_group</source_model>
204
- </amazon_group>
205
- <cdiscount_group>
206
- <label>Cdiscount customer group</label>
207
- <comment>Set specific customer group for imported customer from Cdiscount. Leave empty to use default.</comment>
208
- <frontend_type>select</frontend_type>
209
- <sort_order>40</sort_order>
210
- <show_in_default>1</show_in_default>
211
- <show_in_website>0</show_in_website>
212
- <show_in_store>0</show_in_store>
213
- <source_model>adminhtml/system_config_source_customer_group</source_model>
214
- </cdiscount_group>
215
- <ebay_group>
216
- <label>Ebay customer group</label>
217
- <comment>Set specific customer group for imported customer from Ebay. Leave empty to use default.</comment>
218
- <frontend_type>select</frontend_type>
219
- <sort_order>50</sort_order>
220
- <show_in_default>1</show_in_default>
221
- <show_in_website>0</show_in_website>
222
- <show_in_store>0</show_in_store>
223
- <source_model>adminhtml/system_config_source_customer_group</source_model>
224
- </ebay_group>
225
- <fnac_group>
226
- <label>Fnac customer group</label>
227
- <comment>Set specific customer group for imported customer from Fnac. Leave empty to use default.</comment>
228
- <frontend_type>select</frontend_type>
229
- <sort_order>50</sort_order>
230
- <show_in_default>1</show_in_default>
231
- <show_in_website>0</show_in_website>
232
- <show_in_store>0</show_in_store>
233
- <source_model>adminhtml/system_config_source_customer_group</source_model>
234
- </fnac_group>
235
- <pixmania_group>
236
- <label>Pixmania customer group</label>
237
- <comment>Set specific customer group for imported customer from Pixmania. Leave empty to use default.</comment>
238
- <frontend_type>select</frontend_type>
239
- <sort_order>60</sort_order>
240
- <show_in_default>1</show_in_default>
241
- <show_in_website>0</show_in_website>
242
- <show_in_store>0</show_in_store>
243
- <source_model>adminhtml/system_config_source_customer_group</source_model>
244
- </pixmania_group>
245
- <priceminister_group>
246
- <label>Priceminister customer group</label>
247
- <comment>Set specific customer group for imported customer from Priceminister. Leave empty to use default.</comment>
248
- <frontend_type>select</frontend_type>
249
- <sort_order>60</sort_order>
250
- <show_in_default>1</show_in_default>
251
- <show_in_website>0</show_in_website>
252
- <show_in_store>0</show_in_store>
253
- <source_model>adminhtml/system_config_source_customer_group</source_model>
254
- </priceminister_group>
255
- <rueducommerce_group>
256
- <label>Rueducommerce customer group</label>
257
- <comment>Set specific customer group for imported customer from Rueducommerce. Leave empty to use default.</comment>
258
- <frontend_type>select</frontend_type>
259
- <sort_order>60</sort_order>
260
- <show_in_default>1</show_in_default>
261
- <show_in_website>0</show_in_website>
262
- <show_in_store>0</show_in_store>
263
- <source_model>adminhtml/system_config_source_customer_group</source_model>
264
- </rueducommerce_group>
265
- <brandalley_group>
266
- <label>Brandalley customer group</label>
267
- <comment>Set specific customer group for imported customer from Brandalley Leave empty to use default.</comment>
268
- <frontend_type>select</frontend_type>
269
- <sort_order>60</sort_order>
270
- <show_in_default>1</show_in_default>
271
- <show_in_website>0</show_in_website>
272
- <show_in_store>0</show_in_store>
273
- <source_model>adminhtml/system_config_source_customer_group</source_model>
274
- </brandalley_group>
275
- <toutaporter_group>
276
- <label>ToutAPorter customer group</label>
277
- <comment>Set specific customer group for imported customer from ToutAPorter Leave empty to use default.</comment>
278
- <frontend_type>select</frontend_type>
279
- <sort_order>60</sort_order>
280
- <show_in_default>1</show_in_default>
281
- <show_in_website>0</show_in_website>
282
- <show_in_store>0</show_in_store>
283
- <source_model>adminhtml/system_config_source_customer_group</source_model>
284
- </toutaporter_group>
285
- <greenrepublic_group>
286
- <label>GreenRepublic customer group</label>
287
- <comment>Set specific customer group for imported customer from GreenRepublic Leave empty to use default.</comment>
288
- <frontend_type>select</frontend_type>
289
- <sort_order>60</sort_order>
290
- <show_in_default>1</show_in_default>
291
- <show_in_website>0</show_in_website>
292
- <show_in_store>0</show_in_store>
293
- <source_model>adminhtml/system_config_source_customer_group</source_model>
294
- </greenrepublic_group>
295
- <laredoute_group>
296
- <label>Laredoute customer group</label>
297
- <comment>Set specific customer group for imported customer from Laredoute Leave empty to use default.</comment>
298
- <frontend_type>select</frontend_type>
299
- <sort_order>60</sort_order>
300
- <show_in_default>1</show_in_default>
301
- <show_in_website>0</show_in_website>
302
- <show_in_store>0</show_in_store>
303
- <source_model>adminhtml/system_config_source_customer_group</source_model>
304
- </laredoute_group>
305
- <babyssima_group>
306
- <label>Babyssima customer group</label>
307
- <comment>Set specific customer group for imported customer from Babyssima Leave empty to use default.</comment>
308
- <frontend_type>select</frontend_type>
309
- <sort_order>60</sort_order>
310
- <show_in_default>1</show_in_default>
311
- <show_in_website>0</show_in_website>
312
- <show_in_store>0</show_in_store>
313
- <source_model>adminhtml/system_config_source_customer_group</source_model>
314
- </babyssima_group>
315
- <monechelle_group>
316
- <label>Monechelle customer group</label>
317
- <comment>Set specific customer group for imported customer from Monechelle Leave empty to use default.</comment>
318
- <frontend_type>select</frontend_type>
319
- <sort_order>60</sort_order>
320
- <show_in_default>1</show_in_default>
321
- <show_in_website>0</show_in_website>
322
- <show_in_store>0</show_in_store>
323
- <source_model>adminhtml/system_config_source_customer_group</source_model>
324
- </monechelle_group>
325
- <ecitizen_group>
326
- <label>Ecitizen customer group</label>
327
- <comment>Set specific customer group for imported customer from Ecitizen Leave empty to use default.</comment>
328
- <frontend_type>select</frontend_type>
329
- <sort_order>60</sort_order>
330
- <show_in_default>1</show_in_default>
331
- <show_in_website>0</show_in_website>
332
- <show_in_store>0</show_in_store>
333
- <source_model>adminhtml/system_config_source_customer_group</source_model>
334
- </ecitizen_group>
335
- <decofinder_group>
336
- <label>Decofinder customer group</label>
337
- <comment>Set specific customer group for imported customer from Decofinder Leave empty to use default.</comment>
338
- <frontend_type>select</frontend_type>
339
- <sort_order>60</sort_order>
340
- <show_in_default>1</show_in_default>
341
- <show_in_website>0</show_in_website>
342
- <show_in_store>0</show_in_store>
343
- <source_model>adminhtml/system_config_source_customer_group</source_model>
344
- </decofinder_group>
345
- <docteurdiscount_group>
346
- <label>Docteurdiscount customer group</label>
347
- <comment>Set specific customer group for imported customer from Docteurdiscount Leave empty to use default.</comment>
348
- <frontend_type>select</frontend_type>
349
- <sort_order>60</sort_order>
350
- <show_in_default>1</show_in_default>
351
- <show_in_website>0</show_in_website>
352
- <show_in_store>0</show_in_store>
353
- <source_model>adminhtml/system_config_source_customer_group</source_model>
354
- </docteurdiscount_group>
355
- <glamour_group>
356
- <label>Glamour customer group</label>
357
- <comment>Set specific customer group for imported customer from Glamour Leave empty to use default.</comment>
358
- <frontend_type>select</frontend_type>
359
- <sort_order>60</sort_order>
360
- <show_in_default>1</show_in_default>
361
- <show_in_website>0</show_in_website>
362
- <show_in_store>0</show_in_store>
363
- <source_model>adminhtml/system_config_source_customer_group</source_model>
364
- </glamour_group>
365
- <gstk_group>
366
- <label>Gstk customer group</label>
367
- <comment>Set specific customer group for imported customer from Gstk Leave empty to use default.</comment>
368
- <frontend_type>select</frontend_type>
369
- <sort_order>60</sort_order>
370
- <show_in_default>1</show_in_default>
371
- <show_in_website>0</show_in_website>
372
- <show_in_store>0</show_in_store>
373
- <source_model>adminhtml/system_config_source_customer_group</source_model>
374
- </gstk_group>
375
- <mistergooddeal>
376
- <label>MisterGoodDeal customer group</label>
377
- <comment>Set specific customer group for imported customer from MisterGoodDeal Leave empty to use default.</comment>
378
- <frontend_type>select</frontend_type>
379
- <sort_order>70</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_customer_group</source_model>
384
- </mistergooddeal>
385
- <placedumariage>
386
- <label>PlaceDuMariage customer group</label>
387
- <comment>Set specific customer group for imported customer from PlaceDuMariage Leave empty to use default.</comment>
388
- <frontend_type>select</frontend_type>
389
- <sort_order>70</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_customer_group</source_model>
394
- </placedumariage>
395
- <tap>
396
- <label>Tap customer group</label>
397
- <comment>Set specific customer group for imported customer from Tap Leave empty to use default.</comment>
398
- <frontend_type>select</frontend_type>
399
- <sort_order>70</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_customer_group</source_model>
404
- </tap>
405
- <spartoo>
406
- <label>Spartoo customer group</label>
407
- <comment>Set specific customer group for imported customer from Spartoo Leave empty to use default.</comment>
408
- <frontend_type>select</frontend_type>
409
- <sort_order>70</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_customer_group</source_model>
414
- </spartoo>
415
- <jardinermalin>
416
- <label>Jardinermalin customer group</label>
417
- <comment>Set specific customer group for imported customer from Jardinermalin Leave empty to use default.</comment>
418
- <frontend_type>select</frontend_type>
419
- <sort_order>70</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_customer_group</source_model>
424
- </jardinermalin>
425
- <monechelle>
426
- <label>Monechelle customer group</label>
427
- <comment>Set specific customer group for imported customer from Monechelle Leave empty to use default.</comment>
428
- <frontend_type>select</frontend_type>
429
- <sort_order>70</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_customer_group</source_model>
434
- </monechelle>
435
- </fields>
436
- </import_customer>
437
- <shipping_method translate="label" module="profileolabs_shoppingflux">
438
- <label>Shipping Methods</label>
439
- <show_in_default>1</show_in_default>
440
- <show_in_website>1</show_in_website>
441
- <show_in_store>1</show_in_store>
442
- <sort_order>3</sort_order>
443
- <fields>
444
- <default_method>
445
- <label>Default shipping method</label>
446
- <comment>Set specific shipping method for imported order from Shopping Flux</comment>
447
- <frontend_type>select</frontend_type>
448
- <sort_order>10</sort_order>
449
- <show_in_default>1</show_in_default>
450
- <show_in_website>0</show_in_website>
451
- <show_in_store>0</show_in_store>
452
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
453
- </default_method>
454
- <amazon_method>
455
- <label>Amazon shipping method</label>
456
- <comment>Set specific shipping method for imported order from Amazon. Leave empty to use default.</comment>
457
- <frontend_type>select</frontend_type>
458
- <sort_order>30</sort_order>
459
- <show_in_default>1</show_in_default>
460
- <show_in_website>0</show_in_website>
461
- <show_in_store>0</show_in_store>
462
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
463
- </amazon_method>
464
- <cdiscount_method>
465
- <label>Cdiscount shipping method</label>
466
- <comment>Set specific shipping method for imported order from Cdiscount. Leave empty to use default.</comment>
467
- <frontend_type>select</frontend_type>
468
- <sort_order>40</sort_order>
469
- <show_in_default>1</show_in_default>
470
- <show_in_website>0</show_in_website>
471
- <show_in_store>0</show_in_store>
472
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
473
- </cdiscount_method>
474
- <ebay_method>
475
- <label>Ebay shipping method</label>
476
- <comment>Set specific shipping method for imported order from Ebay. Leave empty to use default.</comment>
477
- <frontend_type>select</frontend_type>
478
- <sort_order>50</sort_order>
479
- <show_in_default>1</show_in_default>
480
- <show_in_website>0</show_in_website>
481
- <show_in_store>0</show_in_store>
482
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
483
- </ebay_method>
484
- <fnac_method>
485
- <label>Fnac shipping method</label>
486
- <comment>Set specific shipping method for imported order from Fnac. Leave empty to use default.</comment>
487
- <frontend_type>select</frontend_type>
488
- <sort_order>50</sort_order>
489
- <show_in_default>1</show_in_default>
490
- <show_in_website>0</show_in_website>
491
- <show_in_store>0</show_in_store>
492
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
493
- </fnac_method>
494
- <pixmania_method>
495
- <label>Pixmania shipping method</label>
496
- <comment>Set specific shipping method for imported order from Pixmania. Leave empty to use default.</comment>
497
- <frontend_type>select</frontend_type>
498
- <sort_order>60</sort_order>
499
- <show_in_default>1</show_in_default>
500
- <show_in_website>0</show_in_website>
501
- <show_in_store>0</show_in_store>
502
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
503
- </pixmania_method>
504
- <priceminister_method>
505
- <label>Priceminister shipping method</label>
506
- <comment>Set specific shipping method for imported order from Priceminister. Leave empty to use default.</comment>
507
- <frontend_type>select</frontend_type>
508
- <sort_order>60</sort_order>
509
- <show_in_default>1</show_in_default>
510
- <show_in_website>0</show_in_website>
511
- <show_in_store>0</show_in_store>
512
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
513
- </priceminister_method>
514
- <rueducommerce_method>
515
- <label>Rueducommerce shipping method</label>
516
- <comment>Set specific shipping method for imported order from Rueducommerce. Leave empty to use default.</comment>
517
- <frontend_type>select</frontend_type>
518
- <sort_order>60</sort_order>
519
- <show_in_default>1</show_in_default>
520
- <show_in_website>0</show_in_website>
521
- <show_in_store>0</show_in_store>
522
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
523
- </rueducommerce_method>
524
- <brandalley_method>
525
- <label>Brandalley shipping method</label>
526
- <comment>Set specific shipping method for imported order from Brandalley. Leave empty to use default.</comment>
527
- <frontend_type>select</frontend_type>
528
- <sort_order>60</sort_order>
529
- <show_in_default>1</show_in_default>
530
- <show_in_website>0</show_in_website>
531
- <show_in_store>0</show_in_store>
532
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
533
- </brandalley_method>
534
- <toutaporter_method>
535
- <label>ToutAPorter shipping method</label>
536
- <comment>Set specific shipping method for imported order from ToutAPorter. Leave empty to use default.</comment>
537
- <frontend_type>select</frontend_type>
538
- <sort_order>60</sort_order>
539
- <show_in_default>1</show_in_default>
540
- <show_in_website>0</show_in_website>
541
- <show_in_store>0</show_in_store>
542
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
543
- </toutaporter_method>
544
- <greenrepublic_method>
545
- <label>GreenRepublic shipping method</label>
546
- <comment>Set specific shipping method for imported order from GreenRepublic. Leave empty to use default.</comment>
547
- <frontend_type>select</frontend_type>
548
- <sort_order>60</sort_order>
549
- <show_in_default>1</show_in_default>
550
- <show_in_website>0</show_in_website>
551
- <show_in_store>0</show_in_store>
552
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
553
- </greenrepublic_method>
554
- <laredoute_method>
555
- <label>Laredoute shipping method</label>
556
- <comment>Set specific shipping method for imported order from Laredoute. Leave empty to use default.</comment>
557
- <frontend_type>select</frontend_type>
558
- <sort_order>60</sort_order>
559
- <show_in_default>1</show_in_default>
560
- <show_in_website>0</show_in_website>
561
- <show_in_store>0</show_in_store>
562
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
563
- </laredoute_method>
564
- <babyssima_method>
565
- <label>Babyssima shipping method</label>
566
- <comment>Set specific shipping method for imported order from Babyssima. Leave empty to use default.</comment>
567
- <frontend_type>select</frontend_type>
568
- <sort_order>60</sort_order>
569
- <show_in_default>1</show_in_default>
570
- <show_in_website>0</show_in_website>
571
- <show_in_store>0</show_in_store>
572
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
573
- </babyssima_method>
574
- <monechelle_method>
575
- <label>Monechelle shipping method</label>
576
- <comment>Set specific shipping method for imported order from Monechelle. Leave empty to use default.</comment>
577
- <frontend_type>select</frontend_type>
578
- <sort_order>60</sort_order>
579
- <show_in_default>1</show_in_default>
580
- <show_in_website>0</show_in_website>
581
- <show_in_store>0</show_in_store>
582
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
583
- </monechelle_method>
584
- <ecitizen_method>
585
- <label>Ecitizen shipping method</label>
586
- <comment>Set specific shipping method for imported order from Ecitizen. Leave empty to use default.</comment>
587
- <frontend_type>select</frontend_type>
588
- <sort_order>60</sort_order>
589
- <show_in_default>1</show_in_default>
590
- <show_in_website>0</show_in_website>
591
- <show_in_store>0</show_in_store>
592
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
593
- </ecitizen_method>
594
- <decofinder_method>
595
- <label>Decofinder shipping method</label>
596
- <comment>Set specific shipping method for imported order from Decofinder. Leave empty to use default.</comment>
597
- <frontend_type>select</frontend_type>
598
- <sort_order>60</sort_order>
599
- <show_in_default>1</show_in_default>
600
- <show_in_website>0</show_in_website>
601
- <show_in_store>0</show_in_store>
602
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
603
- </decofinder_method>
604
- <docteurdiscount_method>
605
- <label>Docteurdiscount shipping method</label>
606
- <comment>Set specific shipping method for imported order from Docteurdiscount. Leave empty to use default.</comment>
607
- <frontend_type>select</frontend_type>
608
- <sort_order>60</sort_order>
609
- <show_in_default>1</show_in_default>
610
- <show_in_website>0</show_in_website>
611
- <show_in_store>0</show_in_store>
612
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
613
- </docteurdiscount_method>
614
- <glamour_method>
615
- <label>Glamour shipping method</label>
616
- <comment>Set specific shipping method for imported order from Glamour. Leave empty to use default.</comment>
617
- <frontend_type>select</frontend_type>
618
- <sort_order>60</sort_order>
619
- <show_in_default>1</show_in_default>
620
- <show_in_website>0</show_in_website>
621
- <show_in_store>0</show_in_store>
622
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
623
- </glamour_method>
624
- <gstk_method>
625
- <label>Gstk shipping method</label>
626
- <comment>Set specific shipping method for imported order from Gstk. Leave empty to use default.</comment>
627
- <frontend_type>select</frontend_type>
628
- <sort_order>60</sort_order>
629
- <show_in_default>1</show_in_default>
630
- <show_in_website>0</show_in_website>
631
- <show_in_store>0</show_in_store>
632
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
633
- </gstk_method>
634
- <mistergooddeal_method>
635
- <label>Mistergooddeal shipping method</label>
636
- <comment>Set specific shipping method for imported order from Mistergooddeal Leave empty to use default.</comment>
637
- <frontend_type>select</frontend_type>
638
- <sort_order>60</sort_order>
639
- <show_in_default>1</show_in_default>
640
- <show_in_website>0</show_in_website>
641
- <show_in_store>0</show_in_store>
642
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
643
- </mistergooddeal_method>
644
- <placedumariage_method>
645
- <label>PlaceDuMariage shipping method</label>
646
- <comment>Set specific shipping method for imported order from PlaceDuMariage. Leave empty to use default.</comment>
647
- <frontend_type>select</frontend_type>
648
- <sort_order>60</sort_order>
649
- <show_in_default>1</show_in_default>
650
- <show_in_website>0</show_in_website>
651
- <show_in_store>0</show_in_store>
652
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
653
- </placedumariage_method>
654
- <tap_method>
655
- <label>Tout à porter shipping method</label>
656
- <comment>Set specific shipping method for imported order from Tout à porter. Leave empty to use default.</comment>
657
- <frontend_type>select</frontend_type>
658
- <sort_order>60</sort_order>
659
- <show_in_default>1</show_in_default>
660
- <show_in_website>0</show_in_website>
661
- <show_in_store>0</show_in_store>
662
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
663
- </tap_method>
664
- <spartoo_method>
665
- <label>Spartoo shipping method</label>
666
- <comment>Set specific shipping method for imported order from Spartoo. Leave empty to use default.</comment>
667
- <frontend_type>select</frontend_type>
668
- <sort_order>60</sort_order>
669
- <show_in_default>1</show_in_default>
670
- <show_in_website>0</show_in_website>
671
- <show_in_store>0</show_in_store>
672
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
673
- </spartoo_method>
674
- <jardinermalin_method>
675
- <label>Jardinermalin shipping method</label>
676
- <comment>Set specific shipping method for imported order from Jardinermalin. Leave empty to use default.</comment>
677
- <frontend_type>select</frontend_type>
678
- <sort_order>60</sort_order>
679
- <show_in_default>1</show_in_default>
680
- <show_in_website>0</show_in_website>
681
- <show_in_store>0</show_in_store>
682
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
683
- </jardinermalin_method>
684
- <monechelle_method>
685
- <label>Monechelle shipping method</label>
686
- <comment>Set specific shipping method for imported order from Monechelle. Leave empty to use default.</comment>
687
- <frontend_type>select</frontend_type>
688
- <sort_order>60</sort_order>
689
- <show_in_default>1</show_in_default>
690
- <show_in_website>0</show_in_website>
691
- <show_in_store>0</show_in_store>
692
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
693
- </monechelle_method>
694
- </fields>
695
- </shipping_method>
696
- <advanced_shipping_method translate="label" module="profileolabs_shoppingflux">
697
- <label>Advanced Shipping Methods Mapping</label>
698
- <frontend_model>profileolabs_shoppingflux/manageorders_adminhtml_system_config_form_fieldset_shipping_method</frontend_model>
699
- <show_in_default>1</show_in_default>
700
- <show_in_website>1</show_in_website>
701
- <show_in_store>1</show_in_store>
702
- <sort_order>4</sort_order>
703
- </advanced_shipping_method>
704
- </groups>
705
- </shoppingflux_mo>
706
- <shoppingflux_export translate="label" module="profileolabs_shoppingflux">
707
- <label>Gestion des produits</label>
708
- <tab>shoppingflux</tab>
709
- <frontend_type>text</frontend_type>
710
- <sort_order>90</sort_order>
711
- <show_in_default>1</show_in_default>
712
- <show_in_website>1</show_in_website>
713
- <show_in_store>1</show_in_store>
714
- <groups>
715
- <general translate="label">
716
- <label>Generale</label>
717
- <comment>
718
- <![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 />]]>
719
- </comment>
720
- <show_in_default>1</show_in_default>
721
- <show_in_website>1</show_in_website>
722
- <show_in_store>1</show_in_store>
723
- <sort_order>1</sort_order>
724
- <fields>
725
- <active>
726
- <label>Activer le module Shopping-flux</label>
727
- <comment></comment>
728
- <frontend_type>select</frontend_type>
729
- <sort_order>1</sort_order>
730
- <show_in_default>1</show_in_default>
731
- <show_in_website>1</show_in_website>
732
- <show_in_store>1</show_in_store>
733
- <source_model>adminhtml/system_config_source_yesno</source_model>
734
- </active>
735
- <filter_by_attribute>
736
- <label>Exporter uniquement les produits sélectionnés</label>
737
- <comment>N'oubliez pas de sélectionner des produits à filtrer.
738
- <strong>Shoppingflux > Sélectionnez les produits</strong>
739
- </comment>
740
- <frontend_type>select</frontend_type>
741
- <sort_order>5</sort_order>
742
- <show_in_default>1</show_in_default>
743
- <show_in_website>1</show_in_website>
744
- <show_in_store>1</show_in_store>
745
- <source_model>adminhtml/system_config_source_yesno</source_model>
746
- </filter_by_attribute>
747
- <!-- <limit_product>
748
- <label>Export par n produits</label>
749
- <comment></comment>
750
- <sort_order>10</sort_order>
751
- <show_in_default>1</show_in_default>
752
- <show_in_website>1</show_in_website>
753
- <show_in_store>1</show_in_store>
754
- <comment>Limite le nombre de produit par lots</comment>
755
- </limit_product> -->
756
- <default_shipping_delay>
757
- <label>Délai de livraison</label>
758
- <comment><![CDATA[Délai de livraison en <strong>jours</strong> par défaut si aucun attribut n'est mappé.]]>
759
- </comment>
760
- <frontend_type>text</frontend_type>
761
- <sort_order>20</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
- </default_shipping_delay>
766
- <default_shipping_price>
767
- <label>Frais de port</label>
768
- <comment>Frais de port par défaut si aucune correpondance n'est trouvée.</comment>
769
- <frontend_type>text</frontend_type>
770
- <sort_order>40</sort_order>
771
- <show_in_default>1</show_in_default>
772
- <show_in_website>1</show_in_website>
773
- <show_in_store>1</show_in_store>
774
- </default_shipping_price>
775
- <default_shipping_method>
776
- <label>Méthode de livraison </label>
777
- <comment>Méthode de livraison par défaut pour calculer les frais de livraison</comment>
778
- <frontend_type>select</frontend_type>
779
- <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
780
- <sort_order>30</sort_order>
781
- <show_in_default>1</show_in_default>
782
- <show_in_website>1</show_in_website>
783
- <show_in_store>1</show_in_store>
784
- </default_shipping_method>
785
- <try_use_real_shipping_price>
786
- <label>Essayer de récupérer les prix de livraison réels</label>
787
- <comment>Désactiver cette option en cas de problème de mémoire.</comment>
788
- <frontend_type>select</frontend_type>
789
- <sort_order>40</sort_order>
790
- <show_in_default>1</show_in_default>
791
- <show_in_website>1</show_in_website>
792
- <show_in_store>1</show_in_store>
793
- <source_model>adminhtml/system_config_source_yesno</source_model>
794
- </try_use_real_shipping_price>
795
- <shipping_price_based_on>
796
- <label>Pays de livraison</label>
797
- <comment>Pays par défaut pour calculer les frais de livraison</comment>
798
- <frontend_type>select</frontend_type>
799
- <source_model>adminhtml/system_config_source_country</source_model>
800
- <sort_order>50</sort_order>
801
- <show_in_default>1</show_in_default>
802
- <show_in_website>1</show_in_website>
803
- <show_in_store>1</show_in_store>
804
- </shipping_price_based_on>
805
- <export_soldout>
806
- <label>Exporter les produits hors stock</label>
807
- <comment></comment>
808
- <frontend_type>select</frontend_type>
809
- <sort_order>60</sort_order>
810
- <show_in_default>1</show_in_default>
811
- <show_in_website>1</show_in_website>
812
- <show_in_store>1</show_in_store>
813
- <source_model>adminhtml/system_config_source_yesno</source_model>
814
- </export_soldout>
815
- <export_visibility>
816
- <label>Exporter les produits avec la visibilité</label>
817
- <comment></comment>
818
- <frontend_type>multiselect</frontend_type>
819
- <sort_order>70</sort_order>
820
- <show_in_default>1</show_in_default>
821
- <show_in_website>1</show_in_website>
822
- <show_in_store>1</show_in_store>
823
- <source_model>profileolabs_shoppingflux/export_source_visibility</source_model>
824
- </export_visibility>
825
- <memory_limit>
826
- <label>Limite de mémoire</label>
827
- <comment>Exprimé en MB. A ne modifier que si vous savez ce que vous faites.</comment>
828
- <frontend_type>text</frontend_type>
829
- <sort_order>100</sort_order>
830
- <show_in_default>1</show_in_default>
831
- <show_in_website>0</show_in_website>
832
- <show_in_store>0</show_in_store>
833
- </memory_limit>
834
- <enable_sync>
835
- <label>Activer les mises à jour automatique</label>
836
- <comment>Mise à jour des stocks et des prix en temps réel. Cela peut ralentir les modifications de stock/prix.</comment>
837
- <frontend_type>select</frontend_type>
838
- <sort_order>120</sort_order>
839
- <show_in_default>1</show_in_default>
840
- <show_in_website>0</show_in_website>
841
- <show_in_store>0</show_in_store>
842
- <source_model>adminhtml/system_config_source_yesno</source_model>
843
- </enable_sync>
844
- <use_manage_stock>
845
- <label>Prendre compte la gestion des stocks ?</label>
846
- <comment>Si oui, les produits en "Gestion des stocks" : "Non" auront un stock à 100 dans le flux.</comment>
847
- <frontend_type>select</frontend_type>
848
- <sort_order>130</sort_order>
849
- <show_in_default>1</show_in_default>
850
- <show_in_website>0</show_in_website>
851
- <show_in_store>0</show_in_store>
852
- <source_model>adminhtml/system_config_source_yesno</source_model>
853
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
854
- </use_manage_stock>
855
- <all_store_products>
856
- <label>Prendre les produits de tous les Magasins ?</label>
857
- <comment>En cas de doute, laisser à non.</comment>
858
- <frontend_type>select</frontend_type>
859
- <sort_order>135</sort_order>
860
- <show_in_default>1</show_in_default>
861
- <show_in_website>0</show_in_website>
862
- <show_in_store>0</show_in_store>
863
- <source_model>adminhtml/system_config_source_yesno</source_model>
864
- </all_store_products>
865
- <all_store_categories>
866
- <label>Prendre les catégories de tous les Magasins ?</label>
867
- <comment>En cas de doute, laisser à non.</comment>
868
- <frontend_type>select</frontend_type>
869
- <sort_order>140</sort_order>
870
- <show_in_default>1</show_in_default>
871
- <show_in_website>0</show_in_website>
872
- <show_in_store>0</show_in_store>
873
- <source_model>adminhtml/system_config_source_yesno</source_model>
874
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
875
- </all_store_categories>
876
- <use_only_shoppingflux_category>
877
- <label>N'utilisez que la catégorie ShoppingFlux</label>
878
- <comment>Gain en performance si oui.</comment>
879
- <frontend_type>select</frontend_type>
880
- <sort_order>150</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
- <source_model>adminhtml/system_config_source_yesno</source_model>
885
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
886
- </use_only_shoppingflux_category>
887
- <max_category_level>
888
- <label>N'utilisez que les X premiers niveaux de catégories</label>
889
- <frontend_type>select</frontend_type>
890
- <sort_order>150</sort_order>
891
- <show_in_default>1</show_in_default>
892
- <show_in_website>1</show_in_website>
893
- <show_in_store>1</show_in_store>
894
- <source_model>profileolabs_shoppingflux/export_source_category_level</source_model>
895
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
896
- </max_category_level>
897
- <enable_events>
898
- <label>Activer les évenements ShoppingFlux ?</label>
899
- <comment>Utile uniquement en cas de développement spécifique. Désactiver pour gagner en performances.</comment>
900
- <frontend_type>select</frontend_type>
901
- <sort_order>160</sort_order>
902
- <show_in_default>1</show_in_default>
903
- <show_in_website>1</show_in_website>
904
- <show_in_store>1</show_in_store>
905
- <source_model>adminhtml/system_config_source_yesno</source_model>
906
- </enable_events>
907
- <manage_configurable>
908
- <label>Gestion des produits configurables en mode avancé ?</label>
909
- <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>
910
- <frontend_type>select</frontend_type>
911
- <sort_order>170</sort_order>
912
- <show_in_default>1</show_in_default>
913
- <show_in_website>1</show_in_website>
914
- <show_in_store>1</show_in_store>
915
- <source_model>adminhtml/system_config_source_yesno</source_model>
916
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
917
- </manage_configurable>
918
- <manage_catalog_rules>
919
- <label>Gestion des règles de prix catalogue ?</label>
920
- <frontend_type>select</frontend_type>
921
- <sort_order>180</sort_order>
922
- <show_in_default>1</show_in_default>
923
- <show_in_website>1</show_in_website>
924
- <show_in_store>1</show_in_store>
925
- <source_model>adminhtml/system_config_source_yesno</source_model>
926
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
927
- </manage_catalog_rules>
928
- <manage_media_gallery>
929
- <label>Gestion des galeries de photos produit ?</label>
930
- <comment>Ne concerne pas l'image principale du produit. Mettre à non pour gain de performances.</comment>
931
- <frontend_type>select</frontend_type>
932
- <sort_order>190</sort_order>
933
- <show_in_default>1</show_in_default>
934
- <show_in_website>1</show_in_website>
935
- <show_in_store>1</show_in_store>
936
- <source_model>adminhtml/system_config_source_yesno</source_model>
937
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
938
- </manage_media_gallery>
939
- </fields>
940
- </general>
941
- <attributes_unknow translate="label">
942
- <label>Mapping d'attributs Inconnus</label>
943
- <show_in_default>1</show_in_default>
944
- <show_in_website>1</show_in_website>
945
- <show_in_store>1</show_in_store>
946
- <sort_order>20</sort_order>
947
- <fields>
948
- <ean>
949
- <label>Ean</label>
950
- <comment></comment>
951
- <frontend_type>select</frontend_type>
952
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
953
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
954
- <sort_order>10</sort_order>
955
- <show_in_default>1</show_in_default>
956
- <show_in_website>1</show_in_website>
957
- <show_in_store>1</show_in_store>
958
- </ean>
959
- <isbn>
960
- <label>ISBN</label>
961
- <comment></comment>
962
- <frontend_type>select</frontend_type>
963
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
964
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
965
- <sort_order>20</sort_order>
966
- <show_in_default>1</show_in_default>
967
- <show_in_website>1</show_in_website>
968
- <show_in_store>1</show_in_store>
969
- </isbn>
970
- <ref_manufacturer>
971
- <label>Référence constructeur</label>
972
- <comment></comment>
973
- <frontend_type>select</frontend_type>
974
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
975
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
976
- <sort_order>30</sort_order>
977
- <show_in_default>1</show_in_default>
978
- <show_in_website>1</show_in_website>
979
- <show_in_store>1</show_in_store>
980
- </ref_manufacturer>
981
- <ref_wholesaler>
982
- <label>Référence fournisseur</label>
983
- <comment></comment>
984
- <frontend_type>select</frontend_type>
985
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
986
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
987
- <sort_order>40</sort_order>
988
- <show_in_default>1</show_in_default>
989
- <show_in_website>1</show_in_website>
990
- <show_in_store>1</show_in_store>
991
- </ref_wholesaler>
992
- <shipping_delay>
993
- <label>Délai de livraison</label>
994
- <comment></comment>
995
- <frontend_type>select</frontend_type>
996
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
997
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
998
- <sort_order>42</sort_order>
999
- <show_in_default>1</show_in_default>
1000
- <show_in_website>1</show_in_website>
1001
- <show_in_store>1</show_in_store>
1002
- </shipping_delay>
1003
- <shipping_send_delay>
1004
- <label>Délai de d'expédition</label>
1005
- <comment></comment>
1006
- <frontend_type>select</frontend_type>
1007
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1008
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1009
- <sort_order>43</sort_order>
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
- </shipping_send_delay>
1014
- <brand>
1015
- <label>Marque</label>
1016
- <comment></comment>
1017
- <frontend_type>select</frontend_type>
1018
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1019
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1020
- <sort_order>50</sort_order>
1021
- <show_in_default>1</show_in_default>
1022
- <show_in_website>1</show_in_website>
1023
- <show_in_store>1</show_in_store>
1024
- </brand>
1025
- <brand_page_url>
1026
- <label>URL de la page Marque</label>
1027
- <comment></comment>
1028
- <frontend_type>select</frontend_type>
1029
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1030
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1031
- <sort_order>55</sort_order>
1032
- <show_in_default>1</show_in_default>
1033
- <show_in_website>1</show_in_website>
1034
- <show_in_store>1</show_in_store>
1035
- </brand_page_url>
1036
- <ecotaxe>
1037
- <label>Ecotaxe</label>
1038
- <comment>Si vos produits ont une écotaxe</comment>
1039
- <frontend_type>select</frontend_type>
1040
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1041
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1042
- <sort_order>60</sort_order>
1043
- <show_in_default>1</show_in_default>
1044
- <show_in_website>1</show_in_website>
1045
- <show_in_store>1</show_in_store>
1046
- </ecotaxe>
1047
- <short_name>
1048
- <label>Nom court du produit</label>
1049
- <comment></comment>
1050
- <frontend_type>select</frontend_type>
1051
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1052
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1053
- <sort_order>70</sort_order>
1054
- <show_in_default>1</show_in_default>
1055
- <show_in_website>1</show_in_website>
1056
- <show_in_store>1</show_in_store>
1057
- </short_name>
1058
- <characteristics>
1059
- <label>Caractéristiques</label>
1060
- <comment></comment>
1061
- <frontend_type>select</frontend_type>
1062
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1063
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1064
- <sort_order>80</sort_order>
1065
- <show_in_default>1</show_in_default>
1066
- <show_in_website>1</show_in_website>
1067
- <show_in_store>1</show_in_store>
1068
- </characteristics>
1069
- <warranty>
1070
- <label>Garantie</label>
1071
- <comment></comment>
1072
- <frontend_type>select</frontend_type>
1073
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1074
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1075
- <sort_order>90</sort_order>
1076
- <show_in_default>1</show_in_default>
1077
- <show_in_website>1</show_in_website>
1078
- <show_in_store>1</show_in_store>
1079
- </warranty>
1080
- <kind>
1081
- <label>Genre</label>
1082
- <comment></comment>
1083
- <frontend_type>select</frontend_type>
1084
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1085
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1086
- <sort_order>100</sort_order>
1087
- <show_in_default>1</show_in_default>
1088
- <show_in_website>1</show_in_website>
1089
- <show_in_store>1</show_in_store>
1090
- </kind>
1091
- <matter>
1092
- <label>Matière</label>
1093
- <comment></comment>
1094
- <frontend_type>select</frontend_type>
1095
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1096
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1097
- <sort_order>100</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
- </matter>
1102
- <size>
1103
- <label>Taille</label>
1104
- <comment></comment>
1105
- <frontend_type>select</frontend_type>
1106
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1107
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1108
- <sort_order>110</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
- </size>
1113
- <shoe_size>
1114
- <label>Pointure</label>
1115
- <comment></comment>
1116
- <frontend_type>select</frontend_type>
1117
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1118
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1119
- <sort_order>115</sort_order>
1120
- <show_in_default>1</show_in_default>
1121
- <show_in_website>1</show_in_website>
1122
- <show_in_store>1</show_in_store>
1123
- </shoe_size>
1124
- <dimension>
1125
- <label>Dimension</label>
1126
- <comment></comment>
1127
- <frontend_type>select</frontend_type>
1128
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1129
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1130
- <sort_order>120</sort_order>
1131
- <show_in_default>1</show_in_default>
1132
- <show_in_website>1</show_in_website>
1133
- <show_in_store>1</show_in_store>
1134
- </dimension>
1135
- </fields>
1136
- </attributes_unknow>
1137
- <attributes_know translate="label">
1138
- <label>Mapping d'attributs Connus</label>
1139
- <show_in_default>1</show_in_default>
1140
- <show_in_website>1</show_in_website>
1141
- <show_in_store>1</show_in_store>
1142
- <sort_order>30</sort_order>
1143
- <fields>
1144
- <name>
1145
- <label>Nom du produit</label>
1146
- <comment></comment>
1147
- <frontend_type>select</frontend_type>
1148
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1149
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1150
- <sort_order>10</sort_order>
1151
- <show_in_default>1</show_in_default>
1152
- <show_in_website>1</show_in_website>
1153
- <show_in_store>1</show_in_store>
1154
- </name>
1155
- <description>
1156
- <label>Description du produit</label>
1157
- <comment></comment>
1158
- <frontend_type>select</frontend_type>
1159
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1160
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1161
- <sort_order>20</sort_order>
1162
- <show_in_default>1</show_in_default>
1163
- <show_in_website>1</show_in_website>
1164
- <show_in_store>1</show_in_store>
1165
- </description>
1166
- <short_description>
1167
- <label>Description courte du produit</label>
1168
- <comment></comment>
1169
- <frontend_type>select</frontend_type>
1170
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1171
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1172
- <sort_order>30</sort_order>
1173
- <show_in_default>1</show_in_default>
1174
- <show_in_website>1</show_in_website>
1175
- <show_in_store>1</show_in_store>
1176
- </short_description>
1177
- <meta_keyword>
1178
- <label>Mot clés</label>
1179
- <comment></comment>
1180
- <frontend_type>select</frontend_type>
1181
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1182
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1183
- <sort_order>30</sort_order>
1184
- <show_in_default>1</show_in_default>
1185
- <show_in_website>1</show_in_website>
1186
- <show_in_store>1</show_in_store>
1187
- </meta_keyword>
1188
- <weight>
1189
- <label>Poids</label>
1190
- <comment></comment>
1191
- <frontend_type>select</frontend_type>
1192
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1193
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1194
- <sort_order>40</sort_order>
1195
- <show_in_default>1</show_in_default>
1196
- <show_in_website>1</show_in_website>
1197
- <show_in_store>1</show_in_store>
1198
- </weight>
1199
- <color>
1200
- <label>Couleur</label>
1201
- <comment></comment>
1202
- <frontend_type>select</frontend_type>
1203
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1204
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1205
- <sort_order>50</sort_order>
1206
- <show_in_default>1</show_in_default>
1207
- <show_in_website>1</show_in_website>
1208
- <show_in_store>1</show_in_store>
1209
- </color>
1210
- </fields>
1211
- </attributes_know>
1212
- <specific_prices>
1213
- <label>Prix spécifiques</label>
1214
- <show_in_default>1</show_in_default>
1215
- <show_in_website>1</show_in_website>
1216
- <show_in_store>1</show_in_store>
1217
- <sort_order>35</sort_order>
1218
- <fields>
1219
-
1220
- <price>
1221
- <label>Prix TTC</label>
1222
- <comment></comment>
1223
- <frontend_type>select</frontend_type>
1224
- <source_model>profileolabs_shoppingflux/export_source_attributesprice</source_model>
1225
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1226
- <sort_order>60</sort_order>
1227
- <show_in_default>1</show_in_default>
1228
- <show_in_website>1</show_in_website>
1229
- <show_in_store>1</show_in_store>
1230
- </price>
1231
- <special_price>
1232
- <label>Prix Spécial</label>
1233
- <comment></comment>
1234
- <frontend_type>select</frontend_type>
1235
- <source_model>profileolabs_shoppingflux/export_source_attributesprice</source_model>
1236
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1237
- <sort_order>70</sort_order>
1238
- <show_in_default>1</show_in_default>
1239
- <show_in_website>1</show_in_website>
1240
- <show_in_store>1</show_in_store>
1241
- </special_price>
1242
- </fields>
1243
- </specific_prices>
1244
- <attributes_additionnal>
1245
- <label>Attributs supplémentaires</label>
1246
- <show_in_default>1</show_in_default>
1247
- <show_in_website>1</show_in_website>
1248
- <show_in_store>1</show_in_store>
1249
- <sort_order>40</sort_order>
1250
- <fields>
1251
- <list>
1252
- <label>Autres attributs à transmettre</label>
1253
- <frontend_type>multiselect</frontend_type>
1254
- <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1255
- <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1256
- <sort_order>125</sort_order>
1257
- <show_in_default>1</show_in_default>
1258
- <show_in_website>1</show_in_website>
1259
- <show_in_store>1</show_in_store>
1260
- </list>
1261
- </fields>
1262
- </attributes_additionnal>
1263
- </groups>
1264
- </shoppingflux_export>
1265
- </sections>
1266
  </config>
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
+ <enable_buyline>
53
+ <label>Activer le buyline ?</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>adminhtml/system_config_source_yesno</source_model>
56
+ <sort_order>30</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
+ </enable_buyline>
61
+ <alert_email>
62
+ <label>Email pour les alertes</label>
63
+ <comment>En cas de problème lors des transfert de données, un mail vous sera envoyé à cette adresse.</comment>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>100</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </alert_email>
70
+ </fields>
71
+ </configuration>
72
+ </groups>
73
+ </shoppingflux>
74
+ <shoppingflux_mo translate="label" module="profileolabs_shoppingflux">
75
+ <label>Manage Orders</label>
76
+ <tab>shoppingflux</tab>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>100</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ <groups>
83
+ <manageorders translate="label" module="profileolabs_shoppingflux">
84
+ <label>Manage Orders</label>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ <sort_order>1</sort_order>
89
+ <fields>
90
+ <enabled>
91
+ <label>Enable manage orders</label>
92
+ <comment>Enable get orders from Shopping Flux</comment>
93
+ <frontend_type>select</frontend_type>
94
+ <sort_order>10</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ <source_model>adminhtml/system_config_source_yesno</source_model>
99
+ </enabled>
100
+ <limit_orders>
101
+ <label>Import by n orders</label>
102
+ <sort_order>22</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ <comment>Limit number of orders imported. 10 by default</comment>
107
+ </limit_orders>
108
+ <new_order_status translate="label">
109
+ <label>New order status</label>
110
+ <frontend_type>select</frontend_type>
111
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
112
+ <sort_order>80</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </new_order_status>
117
+ <create_invoice>
118
+ <label>Create invoice</label>
119
+ <comment>Invoice is created when order getted from Shopping Flux</comment>
120
+ <frontend_type>select</frontend_type>
121
+ <sort_order>25</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ <source_model>adminhtml/system_config_source_yesno</source_model>
126
+ </create_invoice>
127
+ <processing_order_status translate="label">
128
+ <label>Invoiced order status</label>
129
+ <frontend_type>select</frontend_type>
130
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
131
+ <sort_order>80</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>0</show_in_store>
135
+ </processing_order_status>
136
+ <!--<import_store>
137
+ <label>Import Store</label>
138
+ <comment>Orders will be imported in selected store</comment>
139
+ <frontend_type>select</frontend_type>
140
+ <sort_order>26</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>0</show_in_website>
143
+ <show_in_store>0</show_in_store>
144
+ <source_model>adminhtml/system_config_source_store</source_model>
145
+ </import_store>-->
146
+ <!--<apply_tax>
147
+ <label>Apply tax</label>
148
+ <comment><![CDATA[Calculation of tax when order is created.<b style='color:red'>Do not active if you sell your products Excl. Tax</b>]]>
149
+ </comment>
150
+ <frontend_type>select</frontend_type>
151
+ <sort_order>27</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>1</show_in_store>
155
+ <source_model>adminhtml/system_config_source_yesno</source_model>
156
+ </apply_tax>)-->
157
+ <!-- <is_test>
158
+ <label>Test</label>
159
+ <frontend_type>select</frontend_type>
160
+ <source_model>adminhtml/system_config_source_yesno</source_model>
161
+ <comment>Si oui, la requête se fait su l'url test de shopping flux</comment>
162
+ <sort_order>30</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>0</show_in_website>
165
+ <show_in_store>0</show_in_store>
166
+ </is_test> -->
167
+ </fields>
168
+ </manageorders>
169
+ <import_customer translate="label" module="profileolabs_shoppingflux">
170
+ <label>Import Customers</label>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>1</show_in_store>
174
+ <sort_order>2</sort_order>
175
+ <fields>
176
+ <limit_address_length>
177
+ <label>Limiter la longueur des lignes d'adresse</label>
178
+ <comment>Laisser vide pour ne pas limiter. Valeur mini : 20</comment>
179
+ <frontend_type>text</frontend_type>
180
+ <sort_order>5</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
+ </limit_address_length>
185
+ <default_group>
186
+ <label>Default customer group</label>
187
+ <comment>Set specific customer group for imported customer from Shopping Flux</comment>
188
+ <frontend_type>select</frontend_type>
189
+ <sort_order>10</sort_order>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>0</show_in_website>
192
+ <show_in_store>0</show_in_store>
193
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
194
+ </default_group>
195
+ <amazon_group>
196
+ <label>Amazon customer group</label>
197
+ <comment>Set specific customer group for imported customer from Amazon. Leave empty to use default.</comment>
198
+ <frontend_type>select</frontend_type>
199
+ <sort_order>30</sort_order>
200
+ <show_in_default>1</show_in_default>
201
+ <show_in_website>0</show_in_website>
202
+ <show_in_store>0</show_in_store>
203
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
204
+ </amazon_group>
205
+ <cdiscount_group>
206
+ <label>Cdiscount customer group</label>
207
+ <comment>Set specific customer group for imported customer from Cdiscount. Leave empty to use default.</comment>
208
+ <frontend_type>select</frontend_type>
209
+ <sort_order>40</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>0</show_in_website>
212
+ <show_in_store>0</show_in_store>
213
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
214
+ </cdiscount_group>
215
+ <ebay_group>
216
+ <label>Ebay customer group</label>
217
+ <comment>Set specific customer group for imported customer from Ebay. Leave empty to use default.</comment>
218
+ <frontend_type>select</frontend_type>
219
+ <sort_order>50</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>0</show_in_website>
222
+ <show_in_store>0</show_in_store>
223
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
224
+ </ebay_group>
225
+ <fnac_group>
226
+ <label>Fnac customer group</label>
227
+ <comment>Set specific customer group for imported customer from Fnac. Leave empty to use default.</comment>
228
+ <frontend_type>select</frontend_type>
229
+ <sort_order>50</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>0</show_in_website>
232
+ <show_in_store>0</show_in_store>
233
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
234
+ </fnac_group>
235
+ <pixmania_group>
236
+ <label>Pixmania customer group</label>
237
+ <comment>Set specific customer group for imported customer from Pixmania. Leave empty to use default.</comment>
238
+ <frontend_type>select</frontend_type>
239
+ <sort_order>60</sort_order>
240
+ <show_in_default>1</show_in_default>
241
+ <show_in_website>0</show_in_website>
242
+ <show_in_store>0</show_in_store>
243
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
244
+ </pixmania_group>
245
+ <priceminister_group>
246
+ <label>Priceminister customer group</label>
247
+ <comment>Set specific customer group for imported customer from Priceminister. Leave empty to use default.</comment>
248
+ <frontend_type>select</frontend_type>
249
+ <sort_order>60</sort_order>
250
+ <show_in_default>1</show_in_default>
251
+ <show_in_website>0</show_in_website>
252
+ <show_in_store>0</show_in_store>
253
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
254
+ </priceminister_group>
255
+ <rueducommerce_group>
256
+ <label>Rueducommerce customer group</label>
257
+ <comment>Set specific customer group for imported customer from Rueducommerce. Leave empty to use default.</comment>
258
+ <frontend_type>select</frontend_type>
259
+ <sort_order>60</sort_order>
260
+ <show_in_default>1</show_in_default>
261
+ <show_in_website>0</show_in_website>
262
+ <show_in_store>0</show_in_store>
263
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
264
+ </rueducommerce_group>
265
+ <brandalley_group>
266
+ <label>Brandalley customer group</label>
267
+ <comment>Set specific customer group for imported customer from Brandalley Leave empty to use default.</comment>
268
+ <frontend_type>select</frontend_type>
269
+ <sort_order>60</sort_order>
270
+ <show_in_default>1</show_in_default>
271
+ <show_in_website>0</show_in_website>
272
+ <show_in_store>0</show_in_store>
273
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
274
+ </brandalley_group>
275
+ <toutaporter_group>
276
+ <label>ToutAPorter customer group</label>
277
+ <comment>Set specific customer group for imported customer from ToutAPorter Leave empty to use default.</comment>
278
+ <frontend_type>select</frontend_type>
279
+ <sort_order>60</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>0</show_in_website>
282
+ <show_in_store>0</show_in_store>
283
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
284
+ </toutaporter_group>
285
+ <greenrepublic_group>
286
+ <label>GreenRepublic customer group</label>
287
+ <comment>Set specific customer group for imported customer from GreenRepublic Leave empty to use default.</comment>
288
+ <frontend_type>select</frontend_type>
289
+ <sort_order>60</sort_order>
290
+ <show_in_default>1</show_in_default>
291
+ <show_in_website>0</show_in_website>
292
+ <show_in_store>0</show_in_store>
293
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
294
+ </greenrepublic_group>
295
+ <laredoute_group>
296
+ <label>Laredoute customer group</label>
297
+ <comment>Set specific customer group for imported customer from Laredoute Leave empty to use default.</comment>
298
+ <frontend_type>select</frontend_type>
299
+ <sort_order>60</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>0</show_in_website>
302
+ <show_in_store>0</show_in_store>
303
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
304
+ </laredoute_group>
305
+ <babyssima_group>
306
+ <label>Babyssima customer group</label>
307
+ <comment>Set specific customer group for imported customer from Babyssima Leave empty to use default.</comment>
308
+ <frontend_type>select</frontend_type>
309
+ <sort_order>60</sort_order>
310
+ <show_in_default>1</show_in_default>
311
+ <show_in_website>0</show_in_website>
312
+ <show_in_store>0</show_in_store>
313
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
314
+ </babyssima_group>
315
+ <monechelle_group>
316
+ <label>Monechelle customer group</label>
317
+ <comment>Set specific customer group for imported customer from Monechelle Leave empty to use default.</comment>
318
+ <frontend_type>select</frontend_type>
319
+ <sort_order>60</sort_order>
320
+ <show_in_default>1</show_in_default>
321
+ <show_in_website>0</show_in_website>
322
+ <show_in_store>0</show_in_store>
323
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
324
+ </monechelle_group>
325
+ <ecitizen_group>
326
+ <label>Ecitizen customer group</label>
327
+ <comment>Set specific customer group for imported customer from Ecitizen Leave empty to use default.</comment>
328
+ <frontend_type>select</frontend_type>
329
+ <sort_order>60</sort_order>
330
+ <show_in_default>1</show_in_default>
331
+ <show_in_website>0</show_in_website>
332
+ <show_in_store>0</show_in_store>
333
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
334
+ </ecitizen_group>
335
+ <decofinder_group>
336
+ <label>Decofinder customer group</label>
337
+ <comment>Set specific customer group for imported customer from Decofinder Leave empty to use default.</comment>
338
+ <frontend_type>select</frontend_type>
339
+ <sort_order>60</sort_order>
340
+ <show_in_default>1</show_in_default>
341
+ <show_in_website>0</show_in_website>
342
+ <show_in_store>0</show_in_store>
343
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
344
+ </decofinder_group>
345
+ <docteurdiscount_group>
346
+ <label>Docteurdiscount customer group</label>
347
+ <comment>Set specific customer group for imported customer from Docteurdiscount Leave empty to use default.</comment>
348
+ <frontend_type>select</frontend_type>
349
+ <sort_order>60</sort_order>
350
+ <show_in_default>1</show_in_default>
351
+ <show_in_website>0</show_in_website>
352
+ <show_in_store>0</show_in_store>
353
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
354
+ </docteurdiscount_group>
355
+ <glamour_group>
356
+ <label>Glamour customer group</label>
357
+ <comment>Set specific customer group for imported customer from Glamour Leave empty to use default.</comment>
358
+ <frontend_type>select</frontend_type>
359
+ <sort_order>60</sort_order>
360
+ <show_in_default>1</show_in_default>
361
+ <show_in_website>0</show_in_website>
362
+ <show_in_store>0</show_in_store>
363
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
364
+ </glamour_group>
365
+ <gstk_group>
366
+ <label>Gstk customer group</label>
367
+ <comment>Set specific customer group for imported customer from Gstk Leave empty to use default.</comment>
368
+ <frontend_type>select</frontend_type>
369
+ <sort_order>60</sort_order>
370
+ <show_in_default>1</show_in_default>
371
+ <show_in_website>0</show_in_website>
372
+ <show_in_store>0</show_in_store>
373
+ <source_model>adminhtml/system_config_source_customer_group</source_model>
374
+ </gstk_group>
375
+ <mistergooddeal_group>
376
+ <label>MisterGoodDeal customer group</label>
377
+ <comment>Set specific customer group for imported customer from MisterGoodDeal Leave empty to use default.</comment>
378
+ <frontend_type>select</frontend_type>
379
+ <sort_order>70</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_customer_group</source_model>
384
+ </mistergooddeal_group>
385
+ <placedumariage_group>
386
+ <label>PlaceDuMariage customer group</label>
387
+ <comment>Set specific customer group for imported customer from PlaceDuMariage Leave empty to use default.</comment>
388
+ <frontend_type>select</frontend_type>
389
+ <sort_order>70</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_customer_group</source_model>
394
+ </placedumariage_group>
395
+ <tap_group>
396
+ <label>Tap customer group</label>
397
+ <comment>Set specific customer group for imported customer from Tap Leave empty to use default.</comment>
398
+ <frontend_type>select</frontend_type>
399
+ <sort_order>70</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_customer_group</source_model>
404
+ </tap_group>
405
+ <spartoo_group>
406
+ <label>Spartoo customer group</label>
407
+ <comment>Set specific customer group for imported customer from Spartoo Leave empty to use default.</comment>
408
+ <frontend_type>select</frontend_type>
409
+ <sort_order>70</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_customer_group</source_model>
414
+ </spartoo_group>
415
+ <jardinermalin_group>
416
+ <label>Jardinermalin customer group</label>
417
+ <comment>Set specific customer group for imported customer from Jardinermalin Leave empty to use default.</comment>
418
+ <frontend_type>select</frontend_type>
419
+ <sort_order>70</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_customer_group</source_model>
424
+ </jardinermalin_group>
425
+ <monechelle_group>
426
+ <label>Monechelle customer group</label>
427
+ <comment>Set specific customer group for imported customer from Monechelle Leave empty to use default.</comment>
428
+ <frontend_type>select</frontend_type>
429
+ <sort_order>70</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_customer_group</source_model>
434
+ </monechelle_group>
435
+ </fields>
436
+ </import_customer>
437
+ <shipping_method translate="label" module="profileolabs_shoppingflux">
438
+ <label>Shipping Methods</label>
439
+ <show_in_default>1</show_in_default>
440
+ <show_in_website>1</show_in_website>
441
+ <show_in_store>1</show_in_store>
442
+ <sort_order>3</sort_order>
443
+ <fields>
444
+ <default_method>
445
+ <label>Default shipping method</label>
446
+ <comment>Set specific shipping method for imported order from Shopping Flux</comment>
447
+ <frontend_type>select</frontend_type>
448
+ <sort_order>10</sort_order>
449
+ <show_in_default>1</show_in_default>
450
+ <show_in_website>0</show_in_website>
451
+ <show_in_store>0</show_in_store>
452
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
453
+ </default_method>
454
+ <amazon_method>
455
+ <label>Amazon shipping method</label>
456
+ <comment>Set specific shipping method for imported order from Amazon. Leave empty to use default.</comment>
457
+ <frontend_type>select</frontend_type>
458
+ <sort_order>30</sort_order>
459
+ <show_in_default>1</show_in_default>
460
+ <show_in_website>0</show_in_website>
461
+ <show_in_store>0</show_in_store>
462
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
463
+ </amazon_method>
464
+ <cdiscount_method>
465
+ <label>Cdiscount shipping method</label>
466
+ <comment>Set specific shipping method for imported order from Cdiscount. Leave empty to use default.</comment>
467
+ <frontend_type>select</frontend_type>
468
+ <sort_order>40</sort_order>
469
+ <show_in_default>1</show_in_default>
470
+ <show_in_website>0</show_in_website>
471
+ <show_in_store>0</show_in_store>
472
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
473
+ </cdiscount_method>
474
+ <ebay_method>
475
+ <label>Ebay shipping method</label>
476
+ <comment>Set specific shipping method for imported order from Ebay. Leave empty to use default.</comment>
477
+ <frontend_type>select</frontend_type>
478
+ <sort_order>50</sort_order>
479
+ <show_in_default>1</show_in_default>
480
+ <show_in_website>0</show_in_website>
481
+ <show_in_store>0</show_in_store>
482
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
483
+ </ebay_method>
484
+ <fnac_method>
485
+ <label>Fnac shipping method</label>
486
+ <comment>Set specific shipping method for imported order from Fnac. Leave empty to use default.</comment>
487
+ <frontend_type>select</frontend_type>
488
+ <sort_order>50</sort_order>
489
+ <show_in_default>1</show_in_default>
490
+ <show_in_website>0</show_in_website>
491
+ <show_in_store>0</show_in_store>
492
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
493
+ </fnac_method>
494
+ <pixmania_method>
495
+ <label>Pixmania shipping method</label>
496
+ <comment>Set specific shipping method for imported order from Pixmania. Leave empty to use default.</comment>
497
+ <frontend_type>select</frontend_type>
498
+ <sort_order>60</sort_order>
499
+ <show_in_default>1</show_in_default>
500
+ <show_in_website>0</show_in_website>
501
+ <show_in_store>0</show_in_store>
502
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
503
+ </pixmania_method>
504
+ <priceminister_method>
505
+ <label>Priceminister shipping method</label>
506
+ <comment>Set specific shipping method for imported order from Priceminister. Leave empty to use default.</comment>
507
+ <frontend_type>select</frontend_type>
508
+ <sort_order>60</sort_order>
509
+ <show_in_default>1</show_in_default>
510
+ <show_in_website>0</show_in_website>
511
+ <show_in_store>0</show_in_store>
512
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
513
+ </priceminister_method>
514
+ <rueducommerce_method>
515
+ <label>Rueducommerce shipping method</label>
516
+ <comment>Set specific shipping method for imported order from Rueducommerce. Leave empty to use default.</comment>
517
+ <frontend_type>select</frontend_type>
518
+ <sort_order>60</sort_order>
519
+ <show_in_default>1</show_in_default>
520
+ <show_in_website>0</show_in_website>
521
+ <show_in_store>0</show_in_store>
522
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
523
+ </rueducommerce_method>
524
+ <brandalley_method>
525
+ <label>Brandalley shipping method</label>
526
+ <comment>Set specific shipping method for imported order from Brandalley. Leave empty to use default.</comment>
527
+ <frontend_type>select</frontend_type>
528
+ <sort_order>60</sort_order>
529
+ <show_in_default>1</show_in_default>
530
+ <show_in_website>0</show_in_website>
531
+ <show_in_store>0</show_in_store>
532
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
533
+ </brandalley_method>
534
+ <toutaporter_method>
535
+ <label>ToutAPorter shipping method</label>
536
+ <comment>Set specific shipping method for imported order from ToutAPorter. Leave empty to use default.</comment>
537
+ <frontend_type>select</frontend_type>
538
+ <sort_order>60</sort_order>
539
+ <show_in_default>1</show_in_default>
540
+ <show_in_website>0</show_in_website>
541
+ <show_in_store>0</show_in_store>
542
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
543
+ </toutaporter_method>
544
+ <greenrepublic_method>
545
+ <label>GreenRepublic shipping method</label>
546
+ <comment>Set specific shipping method for imported order from GreenRepublic. Leave empty to use default.</comment>
547
+ <frontend_type>select</frontend_type>
548
+ <sort_order>60</sort_order>
549
+ <show_in_default>1</show_in_default>
550
+ <show_in_website>0</show_in_website>
551
+ <show_in_store>0</show_in_store>
552
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
553
+ </greenrepublic_method>
554
+ <laredoute_method>
555
+ <label>Laredoute shipping method</label>
556
+ <comment>Set specific shipping method for imported order from Laredoute. Leave empty to use default.</comment>
557
+ <frontend_type>select</frontend_type>
558
+ <sort_order>60</sort_order>
559
+ <show_in_default>1</show_in_default>
560
+ <show_in_website>0</show_in_website>
561
+ <show_in_store>0</show_in_store>
562
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
563
+ </laredoute_method>
564
+ <babyssima_method>
565
+ <label>Babyssima shipping method</label>
566
+ <comment>Set specific shipping method for imported order from Babyssima. Leave empty to use default.</comment>
567
+ <frontend_type>select</frontend_type>
568
+ <sort_order>60</sort_order>
569
+ <show_in_default>1</show_in_default>
570
+ <show_in_website>0</show_in_website>
571
+ <show_in_store>0</show_in_store>
572
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
573
+ </babyssima_method>
574
+ <monechelle_method>
575
+ <label>Monechelle shipping method</label>
576
+ <comment>Set specific shipping method for imported order from Monechelle. Leave empty to use default.</comment>
577
+ <frontend_type>select</frontend_type>
578
+ <sort_order>60</sort_order>
579
+ <show_in_default>1</show_in_default>
580
+ <show_in_website>0</show_in_website>
581
+ <show_in_store>0</show_in_store>
582
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
583
+ </monechelle_method>
584
+ <ecitizen_method>
585
+ <label>Ecitizen shipping method</label>
586
+ <comment>Set specific shipping method for imported order from Ecitizen. Leave empty to use default.</comment>
587
+ <frontend_type>select</frontend_type>
588
+ <sort_order>60</sort_order>
589
+ <show_in_default>1</show_in_default>
590
+ <show_in_website>0</show_in_website>
591
+ <show_in_store>0</show_in_store>
592
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
593
+ </ecitizen_method>
594
+ <decofinder_method>
595
+ <label>Decofinder shipping method</label>
596
+ <comment>Set specific shipping method for imported order from Decofinder. Leave empty to use default.</comment>
597
+ <frontend_type>select</frontend_type>
598
+ <sort_order>60</sort_order>
599
+ <show_in_default>1</show_in_default>
600
+ <show_in_website>0</show_in_website>
601
+ <show_in_store>0</show_in_store>
602
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
603
+ </decofinder_method>
604
+ <docteurdiscount_method>
605
+ <label>Docteurdiscount shipping method</label>
606
+ <comment>Set specific shipping method for imported order from Docteurdiscount. Leave empty to use default.</comment>
607
+ <frontend_type>select</frontend_type>
608
+ <sort_order>60</sort_order>
609
+ <show_in_default>1</show_in_default>
610
+ <show_in_website>0</show_in_website>
611
+ <show_in_store>0</show_in_store>
612
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
613
+ </docteurdiscount_method>
614
+ <glamour_method>
615
+ <label>Glamour shipping method</label>
616
+ <comment>Set specific shipping method for imported order from Glamour. Leave empty to use default.</comment>
617
+ <frontend_type>select</frontend_type>
618
+ <sort_order>60</sort_order>
619
+ <show_in_default>1</show_in_default>
620
+ <show_in_website>0</show_in_website>
621
+ <show_in_store>0</show_in_store>
622
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
623
+ </glamour_method>
624
+ <gstk_method>
625
+ <label>Gstk shipping method</label>
626
+ <comment>Set specific shipping method for imported order from Gstk. Leave empty to use default.</comment>
627
+ <frontend_type>select</frontend_type>
628
+ <sort_order>60</sort_order>
629
+ <show_in_default>1</show_in_default>
630
+ <show_in_website>0</show_in_website>
631
+ <show_in_store>0</show_in_store>
632
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
633
+ </gstk_method>
634
+ <mistergooddeal_method>
635
+ <label>Mistergooddeal shipping method</label>
636
+ <comment>Set specific shipping method for imported order from Mistergooddeal Leave empty to use default.</comment>
637
+ <frontend_type>select</frontend_type>
638
+ <sort_order>60</sort_order>
639
+ <show_in_default>1</show_in_default>
640
+ <show_in_website>0</show_in_website>
641
+ <show_in_store>0</show_in_store>
642
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
643
+ </mistergooddeal_method>
644
+ <placedumariage_method>
645
+ <label>PlaceDuMariage shipping method</label>
646
+ <comment>Set specific shipping method for imported order from PlaceDuMariage. Leave empty to use default.</comment>
647
+ <frontend_type>select</frontend_type>
648
+ <sort_order>60</sort_order>
649
+ <show_in_default>1</show_in_default>
650
+ <show_in_website>0</show_in_website>
651
+ <show_in_store>0</show_in_store>
652
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
653
+ </placedumariage_method>
654
+ <tap_method>
655
+ <label>Tout à porter shipping method</label>
656
+ <comment>Set specific shipping method for imported order from Tout à porter. Leave empty to use default.</comment>
657
+ <frontend_type>select</frontend_type>
658
+ <sort_order>60</sort_order>
659
+ <show_in_default>1</show_in_default>
660
+ <show_in_website>0</show_in_website>
661
+ <show_in_store>0</show_in_store>
662
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
663
+ </tap_method>
664
+ <spartoo_method>
665
+ <label>Spartoo shipping method</label>
666
+ <comment>Set specific shipping method for imported order from Spartoo. Leave empty to use default.</comment>
667
+ <frontend_type>select</frontend_type>
668
+ <sort_order>60</sort_order>
669
+ <show_in_default>1</show_in_default>
670
+ <show_in_website>0</show_in_website>
671
+ <show_in_store>0</show_in_store>
672
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
673
+ </spartoo_method>
674
+ <jardinermalin_method>
675
+ <label>Jardinermalin shipping method</label>
676
+ <comment>Set specific shipping method for imported order from Jardinermalin. Leave empty to use default.</comment>
677
+ <frontend_type>select</frontend_type>
678
+ <sort_order>60</sort_order>
679
+ <show_in_default>1</show_in_default>
680
+ <show_in_website>0</show_in_website>
681
+ <show_in_store>0</show_in_store>
682
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
683
+ </jardinermalin_method>
684
+ <monechelle_method>
685
+ <label>Monechelle shipping method</label>
686
+ <comment>Set specific shipping method for imported order from Monechelle. Leave empty to use default.</comment>
687
+ <frontend_type>select</frontend_type>
688
+ <sort_order>60</sort_order>
689
+ <show_in_default>1</show_in_default>
690
+ <show_in_website>0</show_in_website>
691
+ <show_in_store>0</show_in_store>
692
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
693
+ </monechelle_method>
694
+ </fields>
695
+ </shipping_method>
696
+ <advanced_shipping_method translate="label" module="profileolabs_shoppingflux">
697
+ <label>Advanced Shipping Methods Mapping</label>
698
+ <frontend_model>profileolabs_shoppingflux/manageorders_adminhtml_system_config_form_fieldset_shipping_method</frontend_model>
699
+ <show_in_default>1</show_in_default>
700
+ <show_in_website>1</show_in_website>
701
+ <show_in_store>1</show_in_store>
702
+ <sort_order>4</sort_order>
703
+ </advanced_shipping_method>
704
+ </groups>
705
+ </shoppingflux_mo>
706
+ <shoppingflux_export translate="label" module="profileolabs_shoppingflux">
707
+ <label>Gestion des produits</label>
708
+ <tab>shoppingflux</tab>
709
+ <frontend_type>text</frontend_type>
710
+ <sort_order>90</sort_order>
711
+ <show_in_default>1</show_in_default>
712
+ <show_in_website>1</show_in_website>
713
+ <show_in_store>1</show_in_store>
714
+ <groups>
715
+ <general translate="label">
716
+ <label>Generale</label>
717
+ <comment>
718
+ <![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 />]]>
719
+ </comment>
720
+ <show_in_default>1</show_in_default>
721
+ <show_in_website>1</show_in_website>
722
+ <show_in_store>1</show_in_store>
723
+ <sort_order>1</sort_order>
724
+ <fields>
725
+ <active>
726
+ <label>Activer le module Shopping-flux</label>
727
+ <comment></comment>
728
+ <frontend_type>select</frontend_type>
729
+ <sort_order>1</sort_order>
730
+ <show_in_default>1</show_in_default>
731
+ <show_in_website>1</show_in_website>
732
+ <show_in_store>1</show_in_store>
733
+ <source_model>adminhtml/system_config_source_yesno</source_model>
734
+ </active>
735
+ <filter_by_attribute>
736
+ <label>Exporter uniquement les produits sélectionnés</label>
737
+ <comment>N'oubliez pas de sélectionner des produits à filtrer.
738
+ <strong>Shoppingflux > Sélectionnez les produits</strong>
739
+ </comment>
740
+ <frontend_type>select</frontend_type>
741
+ <sort_order>5</sort_order>
742
+ <show_in_default>1</show_in_default>
743
+ <show_in_website>1</show_in_website>
744
+ <show_in_store>1</show_in_store>
745
+ <source_model>adminhtml/system_config_source_yesno</source_model>
746
+ </filter_by_attribute>
747
+ <!-- <limit_product>
748
+ <label>Export par n produits</label>
749
+ <comment></comment>
750
+ <sort_order>10</sort_order>
751
+ <show_in_default>1</show_in_default>
752
+ <show_in_website>1</show_in_website>
753
+ <show_in_store>1</show_in_store>
754
+ <comment>Limite le nombre de produit par lots</comment>
755
+ </limit_product> -->
756
+ <default_shipping_delay>
757
+ <label>Délai de livraison</label>
758
+ <comment><![CDATA[Délai de livraison en <strong>jours</strong> par défaut si aucun attribut n'est mappé.]]>
759
+ </comment>
760
+ <frontend_type>text</frontend_type>
761
+ <sort_order>20</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
+ </default_shipping_delay>
766
+ <default_shipping_price>
767
+ <label>Frais de port</label>
768
+ <comment>Frais de port par défaut si aucune correpondance n'est trouvée.</comment>
769
+ <frontend_type>text</frontend_type>
770
+ <sort_order>40</sort_order>
771
+ <show_in_default>1</show_in_default>
772
+ <show_in_website>1</show_in_website>
773
+ <show_in_store>1</show_in_store>
774
+ </default_shipping_price>
775
+ <default_shipping_method>
776
+ <label>Méthode de livraison </label>
777
+ <comment>Méthode de livraison par défaut pour calculer les frais de livraison</comment>
778
+ <frontend_type>select</frontend_type>
779
+ <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
780
+ <sort_order>30</sort_order>
781
+ <show_in_default>1</show_in_default>
782
+ <show_in_website>1</show_in_website>
783
+ <show_in_store>1</show_in_store>
784
+ </default_shipping_method>
785
+ <try_use_real_shipping_price>
786
+ <label>Essayer de récupérer les prix de livraison réels</label>
787
+ <comment>Désactiver cette option en cas de problème de mémoire.</comment>
788
+ <frontend_type>select</frontend_type>
789
+ <sort_order>40</sort_order>
790
+ <show_in_default>1</show_in_default>
791
+ <show_in_website>1</show_in_website>
792
+ <show_in_store>1</show_in_store>
793
+ <source_model>adminhtml/system_config_source_yesno</source_model>
794
+ </try_use_real_shipping_price>
795
+ <shipping_price_based_on>
796
+ <label>Pays de livraison</label>
797
+ <comment>Pays par défaut pour calculer les frais de livraison</comment>
798
+ <frontend_type>select</frontend_type>
799
+ <source_model>adminhtml/system_config_source_country</source_model>
800
+ <sort_order>50</sort_order>
801
+ <show_in_default>1</show_in_default>
802
+ <show_in_website>1</show_in_website>
803
+ <show_in_store>1</show_in_store>
804
+ </shipping_price_based_on>
805
+ <export_soldout>
806
+ <label>Exporter les produits hors stock</label>
807
+ <comment></comment>
808
+ <frontend_type>select</frontend_type>
809
+ <sort_order>60</sort_order>
810
+ <show_in_default>1</show_in_default>
811
+ <show_in_website>1</show_in_website>
812
+ <show_in_store>1</show_in_store>
813
+ <source_model>adminhtml/system_config_source_yesno</source_model>
814
+ </export_soldout>
815
+ <export_visibility>
816
+ <label>Exporter les produits avec la visibilité</label>
817
+ <comment></comment>
818
+ <frontend_type>multiselect</frontend_type>
819
+ <sort_order>70</sort_order>
820
+ <show_in_default>1</show_in_default>
821
+ <show_in_website>1</show_in_website>
822
+ <show_in_store>1</show_in_store>
823
+ <source_model>profileolabs_shoppingflux/export_source_visibility</source_model>
824
+ </export_visibility>
825
+ <memory_limit>
826
+ <label>Limite de mémoire</label>
827
+ <comment>Exprimé en MB. A ne modifier que si vous savez ce que vous faites.</comment>
828
+ <frontend_type>text</frontend_type>
829
+ <sort_order>100</sort_order>
830
+ <show_in_default>1</show_in_default>
831
+ <show_in_website>0</show_in_website>
832
+ <show_in_store>0</show_in_store>
833
+ </memory_limit>
834
+ <enable_sync>
835
+ <label>Activer les mises à jour automatique</label>
836
+ <comment>Mise à jour des stocks et des prix en temps réel. Cela peut ralentir les modifications de stock/prix.</comment>
837
+ <frontend_type>select</frontend_type>
838
+ <sort_order>120</sort_order>
839
+ <show_in_default>1</show_in_default>
840
+ <show_in_website>0</show_in_website>
841
+ <show_in_store>0</show_in_store>
842
+ <source_model>adminhtml/system_config_source_yesno</source_model>
843
+ </enable_sync>
844
+ <use_manage_stock>
845
+ <label>Prendre compte la gestion des stocks ?</label>
846
+ <comment>Si oui, les produits en "Gestion des stocks" : "Non" auront un stock à 100 dans le flux.</comment>
847
+ <frontend_type>select</frontend_type>
848
+ <sort_order>130</sort_order>
849
+ <show_in_default>1</show_in_default>
850
+ <show_in_website>0</show_in_website>
851
+ <show_in_store>0</show_in_store>
852
+ <source_model>adminhtml/system_config_source_yesno</source_model>
853
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
854
+ </use_manage_stock>
855
+ <all_store_products>
856
+ <label>Prendre les produits de tous les Magasins ?</label>
857
+ <comment>En cas de doute, laisser à non.</comment>
858
+ <frontend_type>select</frontend_type>
859
+ <sort_order>135</sort_order>
860
+ <show_in_default>1</show_in_default>
861
+ <show_in_website>0</show_in_website>
862
+ <show_in_store>0</show_in_store>
863
+ <source_model>adminhtml/system_config_source_yesno</source_model>
864
+ </all_store_products>
865
+ <all_store_categories>
866
+ <label>Prendre les catégories de tous les Magasins ?</label>
867
+ <comment>En cas de doute, laisser à non.</comment>
868
+ <frontend_type>select</frontend_type>
869
+ <sort_order>140</sort_order>
870
+ <show_in_default>1</show_in_default>
871
+ <show_in_website>0</show_in_website>
872
+ <show_in_store>0</show_in_store>
873
+ <source_model>adminhtml/system_config_source_yesno</source_model>
874
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
875
+ </all_store_categories>
876
+ <use_only_shoppingflux_category>
877
+ <label>N'utilisez que la catégorie ShoppingFlux</label>
878
+ <comment>Gain en performance si oui.</comment>
879
+ <frontend_type>select</frontend_type>
880
+ <sort_order>150</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
+ <source_model>adminhtml/system_config_source_yesno</source_model>
885
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
886
+ </use_only_shoppingflux_category>
887
+ <max_category_level>
888
+ <label>N'utilisez que les X premiers niveaux de catégories</label>
889
+ <frontend_type>select</frontend_type>
890
+ <sort_order>150</sort_order>
891
+ <show_in_default>1</show_in_default>
892
+ <show_in_website>1</show_in_website>
893
+ <show_in_store>1</show_in_store>
894
+ <source_model>profileolabs_shoppingflux/export_source_category_level</source_model>
895
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
896
+ </max_category_level>
897
+ <enable_events>
898
+ <label>Activer les évenements ShoppingFlux ?</label>
899
+ <comment>Utile uniquement en cas de développement spécifique. Désactiver pour gagner en performances.</comment>
900
+ <frontend_type>select</frontend_type>
901
+ <sort_order>160</sort_order>
902
+ <show_in_default>1</show_in_default>
903
+ <show_in_website>1</show_in_website>
904
+ <show_in_store>1</show_in_store>
905
+ <source_model>adminhtml/system_config_source_yesno</source_model>
906
+ </enable_events>
907
+ <manage_configurable>
908
+ <label>Gestion des produits configurables en mode avancé ?</label>
909
+ <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>
910
+ <frontend_type>select</frontend_type>
911
+ <sort_order>170</sort_order>
912
+ <show_in_default>1</show_in_default>
913
+ <show_in_website>1</show_in_website>
914
+ <show_in_store>1</show_in_store>
915
+ <source_model>adminhtml/system_config_source_yesno</source_model>
916
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
917
+ </manage_configurable>
918
+ <manage_catalog_rules>
919
+ <label>Gestion des règles de prix catalogue ?</label>
920
+ <frontend_type>select</frontend_type>
921
+ <sort_order>180</sort_order>
922
+ <show_in_default>1</show_in_default>
923
+ <show_in_website>1</show_in_website>
924
+ <show_in_store>1</show_in_store>
925
+ <source_model>adminhtml/system_config_source_yesno</source_model>
926
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
927
+ </manage_catalog_rules>
928
+ <manage_media_gallery>
929
+ <label>Gestion des galeries de photos produit ?</label>
930
+ <comment>Ne concerne pas l'image principale du produit. Mettre à non pour gain de performances.</comment>
931
+ <frontend_type>select</frontend_type>
932
+ <sort_order>190</sort_order>
933
+ <show_in_default>1</show_in_default>
934
+ <show_in_website>1</show_in_website>
935
+ <show_in_store>1</show_in_store>
936
+ <source_model>adminhtml/system_config_source_yesno</source_model>
937
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
938
+ </manage_media_gallery>
939
+ </fields>
940
+ </general>
941
+ <attributes_unknow translate="label">
942
+ <label>Mapping d'attributs Inconnus</label>
943
+ <show_in_default>1</show_in_default>
944
+ <show_in_website>1</show_in_website>
945
+ <show_in_store>1</show_in_store>
946
+ <sort_order>20</sort_order>
947
+ <fields>
948
+ <ean>
949
+ <label>Ean</label>
950
+ <comment></comment>
951
+ <frontend_type>select</frontend_type>
952
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
953
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
954
+ <sort_order>10</sort_order>
955
+ <show_in_default>1</show_in_default>
956
+ <show_in_website>1</show_in_website>
957
+ <show_in_store>1</show_in_store>
958
+ </ean>
959
+ <isbn>
960
+ <label>ISBN</label>
961
+ <comment></comment>
962
+ <frontend_type>select</frontend_type>
963
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
964
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
965
+ <sort_order>20</sort_order>
966
+ <show_in_default>1</show_in_default>
967
+ <show_in_website>1</show_in_website>
968
+ <show_in_store>1</show_in_store>
969
+ </isbn>
970
+ <ref_manufacturer>
971
+ <label>Référence constructeur</label>
972
+ <comment></comment>
973
+ <frontend_type>select</frontend_type>
974
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
975
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
976
+ <sort_order>30</sort_order>
977
+ <show_in_default>1</show_in_default>
978
+ <show_in_website>1</show_in_website>
979
+ <show_in_store>1</show_in_store>
980
+ </ref_manufacturer>
981
+ <ref_wholesaler>
982
+ <label>Référence fournisseur</label>
983
+ <comment></comment>
984
+ <frontend_type>select</frontend_type>
985
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
986
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
987
+ <sort_order>40</sort_order>
988
+ <show_in_default>1</show_in_default>
989
+ <show_in_website>1</show_in_website>
990
+ <show_in_store>1</show_in_store>
991
+ </ref_wholesaler>
992
+ <shipping_delay>
993
+ <label>Délai de livraison</label>
994
+ <comment></comment>
995
+ <frontend_type>select</frontend_type>
996
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
997
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
998
+ <sort_order>42</sort_order>
999
+ <show_in_default>1</show_in_default>
1000
+ <show_in_website>1</show_in_website>
1001
+ <show_in_store>1</show_in_store>
1002
+ </shipping_delay>
1003
+ <shipping_send_delay>
1004
+ <label>Délai de d'expédition</label>
1005
+ <comment></comment>
1006
+ <frontend_type>select</frontend_type>
1007
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1008
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1009
+ <sort_order>43</sort_order>
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
+ </shipping_send_delay>
1014
+ <brand>
1015
+ <label>Marque</label>
1016
+ <comment></comment>
1017
+ <frontend_type>select</frontend_type>
1018
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1019
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1020
+ <sort_order>50</sort_order>
1021
+ <show_in_default>1</show_in_default>
1022
+ <show_in_website>1</show_in_website>
1023
+ <show_in_store>1</show_in_store>
1024
+ </brand>
1025
+ <brand_page_url>
1026
+ <label>URL de la page Marque</label>
1027
+ <comment></comment>
1028
+ <frontend_type>select</frontend_type>
1029
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1030
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1031
+ <sort_order>55</sort_order>
1032
+ <show_in_default>1</show_in_default>
1033
+ <show_in_website>1</show_in_website>
1034
+ <show_in_store>1</show_in_store>
1035
+ </brand_page_url>
1036
+ <ecotaxe>
1037
+ <label>Ecotaxe</label>
1038
+ <comment>Si vos produits ont une écotaxe</comment>
1039
+ <frontend_type>select</frontend_type>
1040
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1041
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1042
+ <sort_order>60</sort_order>
1043
+ <show_in_default>1</show_in_default>
1044
+ <show_in_website>1</show_in_website>
1045
+ <show_in_store>1</show_in_store>
1046
+ </ecotaxe>
1047
+ <short_name>
1048
+ <label>Nom court du produit</label>
1049
+ <comment></comment>
1050
+ <frontend_type>select</frontend_type>
1051
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1052
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1053
+ <sort_order>70</sort_order>
1054
+ <show_in_default>1</show_in_default>
1055
+ <show_in_website>1</show_in_website>
1056
+ <show_in_store>1</show_in_store>
1057
+ </short_name>
1058
+ <characteristics>
1059
+ <label>Caractéristiques</label>
1060
+ <comment></comment>
1061
+ <frontend_type>select</frontend_type>
1062
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1063
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1064
+ <sort_order>80</sort_order>
1065
+ <show_in_default>1</show_in_default>
1066
+ <show_in_website>1</show_in_website>
1067
+ <show_in_store>1</show_in_store>
1068
+ </characteristics>
1069
+ <warranty>
1070
+ <label>Garantie</label>
1071
+ <comment></comment>
1072
+ <frontend_type>select</frontend_type>
1073
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1074
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1075
+ <sort_order>90</sort_order>
1076
+ <show_in_default>1</show_in_default>
1077
+ <show_in_website>1</show_in_website>
1078
+ <show_in_store>1</show_in_store>
1079
+ </warranty>
1080
+ <kind>
1081
+ <label>Genre</label>
1082
+ <comment></comment>
1083
+ <frontend_type>select</frontend_type>
1084
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1085
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1086
+ <sort_order>100</sort_order>
1087
+ <show_in_default>1</show_in_default>
1088
+ <show_in_website>1</show_in_website>
1089
+ <show_in_store>1</show_in_store>
1090
+ </kind>
1091
+ <matter>
1092
+ <label>Matière</label>
1093
+ <comment></comment>
1094
+ <frontend_type>select</frontend_type>
1095
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1096
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1097
+ <sort_order>100</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
+ </matter>
1102
+ <size>
1103
+ <label>Taille</label>
1104
+ <comment></comment>
1105
+ <frontend_type>select</frontend_type>
1106
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1107
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1108
+ <sort_order>110</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
+ </size>
1113
+ <shoe_size>
1114
+ <label>Pointure</label>
1115
+ <comment></comment>
1116
+ <frontend_type>select</frontend_type>
1117
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1118
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1119
+ <sort_order>115</sort_order>
1120
+ <show_in_default>1</show_in_default>
1121
+ <show_in_website>1</show_in_website>
1122
+ <show_in_store>1</show_in_store>
1123
+ </shoe_size>
1124
+ <dimension>
1125
+ <label>Dimension</label>
1126
+ <comment></comment>
1127
+ <frontend_type>select</frontend_type>
1128
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1129
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1130
+ <sort_order>120</sort_order>
1131
+ <show_in_default>1</show_in_default>
1132
+ <show_in_website>1</show_in_website>
1133
+ <show_in_store>1</show_in_store>
1134
+ </dimension>
1135
+ </fields>
1136
+ </attributes_unknow>
1137
+ <attributes_know translate="label">
1138
+ <label>Mapping d'attributs Connus</label>
1139
+ <show_in_default>1</show_in_default>
1140
+ <show_in_website>1</show_in_website>
1141
+ <show_in_store>1</show_in_store>
1142
+ <sort_order>30</sort_order>
1143
+ <fields>
1144
+ <name>
1145
+ <label>Nom du produit</label>
1146
+ <comment></comment>
1147
+ <frontend_type>select</frontend_type>
1148
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1149
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1150
+ <sort_order>10</sort_order>
1151
+ <show_in_default>1</show_in_default>
1152
+ <show_in_website>1</show_in_website>
1153
+ <show_in_store>1</show_in_store>
1154
+ </name>
1155
+ <description>
1156
+ <label>Description du produit</label>
1157
+ <comment></comment>
1158
+ <frontend_type>select</frontend_type>
1159
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1160
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1161
+ <sort_order>20</sort_order>
1162
+ <show_in_default>1</show_in_default>
1163
+ <show_in_website>1</show_in_website>
1164
+ <show_in_store>1</show_in_store>
1165
+ </description>
1166
+ <short_description>
1167
+ <label>Description courte du produit</label>
1168
+ <comment></comment>
1169
+ <frontend_type>select</frontend_type>
1170
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1171
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1172
+ <sort_order>30</sort_order>
1173
+ <show_in_default>1</show_in_default>
1174
+ <show_in_website>1</show_in_website>
1175
+ <show_in_store>1</show_in_store>
1176
+ </short_description>
1177
+ <meta_keyword>
1178
+ <label>Mot clés</label>
1179
+ <comment></comment>
1180
+ <frontend_type>select</frontend_type>
1181
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1182
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1183
+ <sort_order>30</sort_order>
1184
+ <show_in_default>1</show_in_default>
1185
+ <show_in_website>1</show_in_website>
1186
+ <show_in_store>1</show_in_store>
1187
+ </meta_keyword>
1188
+ <weight>
1189
+ <label>Poids</label>
1190
+ <comment></comment>
1191
+ <frontend_type>select</frontend_type>
1192
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1193
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1194
+ <sort_order>40</sort_order>
1195
+ <show_in_default>1</show_in_default>
1196
+ <show_in_website>1</show_in_website>
1197
+ <show_in_store>1</show_in_store>
1198
+ </weight>
1199
+ <color>
1200
+ <label>Couleur</label>
1201
+ <comment></comment>
1202
+ <frontend_type>select</frontend_type>
1203
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1204
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1205
+ <sort_order>50</sort_order>
1206
+ <show_in_default>1</show_in_default>
1207
+ <show_in_website>1</show_in_website>
1208
+ <show_in_store>1</show_in_store>
1209
+ </color>
1210
+ </fields>
1211
+ </attributes_know>
1212
+ <specific_prices>
1213
+ <label>Prix spécifiques</label>
1214
+ <show_in_default>1</show_in_default>
1215
+ <show_in_website>1</show_in_website>
1216
+ <show_in_store>1</show_in_store>
1217
+ <sort_order>35</sort_order>
1218
+ <fields>
1219
+
1220
+ <price>
1221
+ <label>Prix TTC</label>
1222
+ <comment></comment>
1223
+ <frontend_type>select</frontend_type>
1224
+ <source_model>profileolabs_shoppingflux/export_source_attributesprice</source_model>
1225
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1226
+ <sort_order>60</sort_order>
1227
+ <show_in_default>1</show_in_default>
1228
+ <show_in_website>1</show_in_website>
1229
+ <show_in_store>1</show_in_store>
1230
+ </price>
1231
+ <special_price>
1232
+ <label>Prix Spécial</label>
1233
+ <comment></comment>
1234
+ <frontend_type>select</frontend_type>
1235
+ <source_model>profileolabs_shoppingflux/export_source_attributesprice</source_model>
1236
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1237
+ <sort_order>70</sort_order>
1238
+ <show_in_default>1</show_in_default>
1239
+ <show_in_website>1</show_in_website>
1240
+ <show_in_store>1</show_in_store>
1241
+ </special_price>
1242
+ </fields>
1243
+ </specific_prices>
1244
+ <attributes_additionnal>
1245
+ <label>Attributs supplémentaires</label>
1246
+ <show_in_default>1</show_in_default>
1247
+ <show_in_website>1</show_in_website>
1248
+ <show_in_store>1</show_in_store>
1249
+ <sort_order>40</sort_order>
1250
+ <fields>
1251
+ <list>
1252
+ <label>Autres attributs à transmettre</label>
1253
+ <frontend_type>multiselect</frontend_type>
1254
+ <source_model>profileolabs_shoppingflux/export_source_attributes</source_model>
1255
+ <backend_model>profileolabs_shoppingflux/system_config_backend_refresh</backend_model>
1256
+ <sort_order>125</sort_order>
1257
+ <show_in_default>1</show_in_default>
1258
+ <show_in_website>1</show_in_website>
1259
+ <show_in_store>1</show_in_store>
1260
+ </list>
1261
+ </fields>
1262
+ </attributes_additionnal>
1263
+ </groups>
1264
+ </shoppingflux_export>
1265
+ </sections>
1266
  </config>
app/code/community/Profileolabs/Shoppingflux/sql/profileolabs_shoppingflux_setup/mysql4-install-0.1.0.php CHANGED
@@ -1,121 +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
-
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 CHANGED
@@ -1,37 +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();
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 CHANGED
@@ -1,51 +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();
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 CHANGED
@@ -1,20 +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();
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 CHANGED
@@ -1,37 +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();
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 CHANGED
@@ -1,44 +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();
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 CHANGED
@@ -1,46 +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
-
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 CHANGED
@@ -1,42 +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
-
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 CHANGED
@@ -1,30 +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
-
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 CHANGED
@@ -1,28 +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
-
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 CHANGED
@@ -1,25 +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
-
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 CHANGED
@@ -1,65 +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>
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 CHANGED
@@ -1,77 +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>
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 = shop