neteven_netevensync - Version 2.2.4

Version Notes

Fix images synchronization.

Download this release

Release Info

Developer Jacques Bodin-Hullin
Extension neteven_netevensync
Version 2.2.4
Comparing to
See all releases


Code changes from version 1.0.8.7 to 2.2.4

Files changed (43) hide show
  1. app/code/community/Neteven/NetevenSync/Block/Adminhtml/Js/Alert.php +50 -0
  2. app/code/community/Neteven/NetevenSync/Block/Adminhtml/Notifications.php +46 -40
  3. app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Fieldset/Hint.php +31 -0
  4. app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Form/Field/Datetime.php +63 -0
  5. app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Form/Field/Order/Mapping.php +74 -0
  6. app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Form/Field/Order/Mapping/Select.php +51 -0
  7. app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Logs.php +111 -0
  8. app/code/community/Neteven/NetevenSync/Helper/Data.php +150 -99
  9. app/code/community/Neteven/NetevenSync/Helper/Logger.php +642 -0
  10. app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Backend/Datetime.php +73 -0
  11. app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Order/Mapping.php +19 -0
  12. app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/Logs.php +70 -0
  13. app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/MagentoOrderStatus.php +49 -38
  14. app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/NetevenOrderStatus.php +38 -33
  15. app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/Order/Pdm.php +14 -7
  16. app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/Start.php +0 -43
  17. app/code/community/Neteven/NetevenSync/Model/Config.php +199 -119
  18. app/code/community/Neteven/NetevenSync/Model/Config/Process.php +1 -1
  19. app/code/community/Neteven/NetevenSync/Model/Cron.php +83 -49
  20. app/code/community/Neteven/NetevenSync/Model/Observer.php +125 -122
  21. app/code/community/Neteven/NetevenSync/Model/Process/Abstract.php +328 -309
  22. app/code/community/Neteven/NetevenSync/Model/Process/Inventory.php +350 -164
  23. app/code/community/Neteven/NetevenSync/Model/Process/Order.php +190 -25
  24. app/code/community/Neteven/NetevenSync/Model/Process/Order/Convertor.php +266 -106
  25. app/code/community/Neteven/NetevenSync/Model/Process/Stock.php +149 -145
  26. app/code/community/Neteven/NetevenSync/Model/Soap.php +312 -306
  27. app/code/community/Neteven/NetevenSync/controllers/Adminhtml/NetevensyncController.php +414 -361
  28. app/code/community/Neteven/NetevenSync/etc/config.xml +79 -82
  29. app/code/community/Neteven/NetevenSync/etc/marketplace_country.csv +69 -67
  30. app/code/community/Neteven/NetevenSync/etc/neteven_wsdl.xml +424 -421
  31. app/code/community/Neteven/NetevenSync/etc/pdm_mapping.xml +0 -23
  32. app/code/community/Neteven/NetevenSync/etc/system.xml +365 -280
  33. app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.0.0.6-2.1.0.php +30 -0
  34. app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.1.0-2.1.1.php +47 -0
  35. app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.1.1-2.1.3.php +36 -0
  36. app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.1.4-2.1.5.php +27 -0
  37. app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.1.5-2.1.6.php +36 -0
  38. app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.2.2-2.2.3.php +37 -0
  39. app/design/adminhtml/default/default/layout/netevensync.xml +3 -0
  40. app/design/adminhtml/default/default/template/netevensync/js/alert.phtml +17 -0
  41. app/locale/fr_FR/Neteven_NetevenSync.csv +33 -15
  42. package.xml +13 -14
  43. shell/neteven/process.php +148 -0
app/code/community/Neteven/NetevenSync/Block/Adminhtml/Js/Alert.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ /**
13
+ * Adminhtml_Js_Alert Block
14
+ * @package Neteven_NetevenSync
15
+ */
16
+ class Neteven_NetevenSync_Block_Adminhtml_Js_Alert extends Mage_Adminhtml_Block_Template
17
+ {
18
+
19
+ // Neteven Tag NEW_CONST
20
+
21
+ // Neteven Tag NEW_VAR
22
+
23
+ /**
24
+ * Is the store/marketplace/country mapping misconfigured?
25
+ * @return bool
26
+ */
27
+ public function isMarketplaceMappingMisconfigured()
28
+ {
29
+ // Check config by store
30
+ $stores = Mage::app()->getStores();
31
+ $marketplaces = array();
32
+ foreach ($stores as $store) {
33
+ $config = Mage::getStoreConfig('netevensync/order/pdm_mapping', $store);
34
+ if (null !== $config) {
35
+ $mapping = unserialize($config);
36
+ foreach ($mapping as $map) {
37
+ if (isset($marketplaces[$map['pdm']])) {
38
+ return true;
39
+ }
40
+ $marketplaces[$map['pdm']] = true;
41
+ }
42
+ }
43
+ }
44
+
45
+ return false; // Well configured
46
+ }
47
+
48
+ // Neteven Tag NEW_METHOD
49
+
50
+ }
app/code/community/Neteven/NetevenSync/Block/Adminhtml/Notifications.php CHANGED
@@ -8,43 +8,49 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template {
12
-
13
- /**
14
- * Get array of errors
15
- *
16
- * @return array $errors
17
- */
18
- public function getErrors() {
19
- $errors = array();
20
- $errorCodes = Mage::getModel('netevensync/config')->getErrorLabels();
21
- $collection = Mage::getModel('netevensync/log')->getCollection()->addErrorFilter();
22
-
23
- foreach($collection as $logType) {
24
- $errors[$logType->getCode()] = $errorCodes[$logType->getCode()];
25
- }
26
-
27
- return $errors;
28
- }
29
-
30
- /**
31
- * Get clean log url
32
- *
33
- * @return string
34
- */
35
- public function getCleanUrl() {
36
- return $this->getUrl('adminhtml/netevensync/cleanLog');
37
- }
38
-
39
- /**
40
- * ACL validation before html generation
41
- *
42
- * @return string
43
- */
44
- protected function _toHtml() {
45
- if(Mage::getSingleton('admin/session')->isAllowed('catalog/netevensync')) {
46
- return parent::_toHtml();
47
- }
48
- return '';
49
- }
50
- }
 
 
 
 
 
 
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
+
12
+ class Neteven_NetevenSync_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template
13
+ {
14
+
15
+ /**
16
+ * Get array of errors
17
+ *
18
+ * @return array $errors
19
+ */
20
+ public function getErrors()
21
+ {
22
+ $errors = array();
23
+ $errorCodes = Mage::getModel('netevensync/config')->getErrorLabels();
24
+ $collection = Mage::getModel('netevensync/log')->getCollection()->addErrorFilter();
25
+
26
+ foreach ($collection as $logType) {
27
+ $errors[$logType->getCode()] = isset($errorCodes[$logType->getCode()]) ? $errorCodes[$logType->getCode()] : null;
28
+ }
29
+
30
+ return $errors;
31
+ }
32
+
33
+ /**
34
+ * Get clean log url
35
+ *
36
+ * @return string
37
+ */
38
+ public function getCleanUrl()
39
+ {
40
+ return $this->getUrl('adminhtml/netevensync/cleanLog');
41
+ }
42
+
43
+ /**
44
+ * ACL validation before html generation
45
+ *
46
+ * @return string
47
+ */
48
+ protected function _toHtml()
49
+ {
50
+ if (Mage::getSingleton('admin/session')->isAllowed('catalog/netevensync')) {
51
+ return parent::_toHtml();
52
+ }
53
+ return '';
54
+ }
55
+
56
+ }
app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Fieldset/Hint.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ /**
13
+ * Adminhtml_System_Config_Fieldset_Hint Block
14
+ * @package Neteven_NetevenSync
15
+ */
16
+ class Neteven_NetevenSync_Block_Adminhtml_System_Config_Fieldset_Hint
17
+ extends Mage_Adminhtml_Block_Abstract
18
+ implements Varien_Data_Form_Element_Renderer_Interface
19
+ {
20
+
21
+ /**
22
+ * Render fieldset html
23
+ * @param Varien_Data_Form_Element_Abstract $element
24
+ * @return string
25
+ */
26
+ public function render(Varien_Data_Form_Element_Abstract $element)
27
+ {
28
+ return '<div style="text-align: right;">' . $this->__("Magento module version %s by Neteven", $this->helper('netevensync')->getVersion()) . '</div>';
29
+ }
30
+
31
+ }
app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Form/Field/Datetime.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ /**
13
+ * Adminhtml_System_Config_Form_Field_Datetime Block
14
+ * @package Neteven_NetevenSync
15
+ */
16
+ class Neteven_NetevenSync_Block_Adminhtml_System_Config_Form_Field_Datetime extends Mage_Adminhtml_Block_System_Config_Form_Field
17
+ {
18
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
19
+ {
20
+ // Current date value (as array)
21
+ $value = $element->getValue();
22
+
23
+ // Date field
24
+ $dateField = new Varien_Data_Form_Element_Date;
25
+ $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
26
+
27
+ $data = array(
28
+ 'name' => $element->getName() . '[]',
29
+ 'html_id' => $element->getId(), // We keep the original ID here to avoid JS bugs
30
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
31
+ );
32
+
33
+ $dateField
34
+ ->setData($data)
35
+ ->setValue(sprintf('%d-%d-%d', $value[0], $value[1], $value[2]), Varien_Date::DATE_INTERNAL_FORMAT)
36
+ ->setFormat($format)
37
+ ->setForm($element->getForm())
38
+ ;
39
+
40
+ // Time field
41
+ $timeField = new Varien_Data_Form_Element_Time;
42
+
43
+ $data = array(
44
+ 'name' => $element->getName() . '[]',
45
+ 'html_id' => $element->getId() . '_time',
46
+ );
47
+
48
+ $timeField
49
+ ->setData($data)
50
+ ->setValue(implode(',', array($value[3], $value[4], $value[5])))
51
+ ->setForm($element->getForm())
52
+ ;
53
+
54
+ // Classes
55
+ if ($element->getFieldConfig()->validate) {
56
+ $class = $element->getFieldConfig()->validate->asArray();
57
+ $dateField->setClass($class);
58
+ $timeField->setClass($class);
59
+ }
60
+
61
+ return $dateField->getElementHtml() . "&nbsp;" . $timeField->getElementHtml();
62
+ }
63
+ }
app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Form/Field/Order/Mapping.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This file is part of Neteven_NetevenSync for Magento.
5
+ *
6
+ * @license All rights reserved
7
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
8
+ * @category Neteven
9
+ * @package Neteven_NetevenSync
10
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
11
+ */
12
+
13
+ /**
14
+ * Adminhtml_System_Config_Form_Field_Order_Mapping Block
15
+ * @package Neteven_NetevenSync
16
+ */
17
+ class Neteven_NetevenSync_Block_Adminhtml_System_Config_Form_Field_Order_Mapping extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
18
+ {
19
+
20
+ public function __construct()
21
+ {
22
+ // Prepare Marketplace select
23
+ $pdmSelect = Mage::app()->getLayout()->createBlock('netevensync/adminhtml_system_config_form_field_order_mapping_select');
24
+ $pdmList = Mage::getSingleton('netevensync/config')->getMarketplacesAsOptionArray();
25
+ $pdmSelect
26
+ ->setOptions(array('empty' => array(
27
+ 'value' => '',
28
+ 'label' => Mage::helper('adminhtml')->__('--Please Select--'),
29
+ )) + $pdmList)
30
+ ->setClass('js-neteven-marketplace')
31
+ ;
32
+
33
+ // Add column wth the prepared select as renderer
34
+ $this->addColumn('pdm', array(
35
+ 'label' => Mage::helper('netevensync')->__('Marketplace'),
36
+ 'style' => 'width:120px',
37
+ 'renderer' => $pdmSelect
38
+ ));
39
+
40
+ // Prepare countries select
41
+ $countrySelect = Mage::app()->getLayout()->createBlock('netevensync/adminhtml_system_config_form_field_order_mapping_select');
42
+ $countryList = Mage::getSingleton('netevensync/adminhtml_system_config_source_order_pdm')->toOptionArray();
43
+ $countrySelect
44
+ ->setOptions($countryList)
45
+ ->setClass('js-neteven-country')
46
+ ;
47
+
48
+ // Add column wth the prepared select as renderer
49
+ $this->addColumn('country', array(
50
+ 'label' => Mage::helper('adminhtml')->__('Country'),
51
+ 'style' => 'width:120px',
52
+ 'renderer' => $countrySelect,
53
+ ));
54
+
55
+ $this->_addAfter = false;
56
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add Marketplace');
57
+
58
+ // Add JS
59
+ $jsBlock = Mage::app()->getLayout()->getBlock('js');
60
+ $js = <<<JS
61
+ Event.observe(document, 'dom:loaded', function () {
62
+ // update selects
63
+ $$('select.js-neteven-marketplace, select.js-neteven-country').each(function (elmt) {
64
+ var val = elmt.readAttribute('data-template-value');
65
+ elmt.value = val;
66
+ });
67
+ });
68
+ JS;
69
+ $jsBlock->append(Mage::app()->getLayout()->createBlock('core/text')->setText('<script>' . $js . '</script>'));
70
+
71
+ parent::__construct();
72
+ }
73
+
74
+ }
app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Form/Field/Order/Mapping/Select.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ /**
13
+ * Adminhtml_System_Config_Form_Field_Order_Mapping_Select Block
14
+ * @package Neteven_NetevenSync
15
+ */
16
+ class Neteven_NetevenSync_Block_Adminhtml_System_Config_Form_Field_Order_Mapping_Select extends Mage_Adminhtml_Block_Html_Select
17
+ {
18
+
19
+ // Neteven Tag NEW_CONST
20
+
21
+ // Neteven Tag NEW_VAR
22
+
23
+ /**
24
+ * Alias of setName
25
+ * @param string $name
26
+ * @return Neteven_NetevenSync_Block_Adminhtml_System_Config_Form_Field_Order_Mapping_Select
27
+ */
28
+ public function setInputName($name)
29
+ {
30
+ return $this->setName($name);
31
+ }
32
+
33
+ /**
34
+ * Set column name for config field
35
+ * @param string $columnName
36
+ * @return Neteven_NetevenSync_Block_Adminhtml_System_Config_Form_Field_Order_Mapping_Select
37
+ */
38
+ public function setColumnName($columnName)
39
+ {
40
+ // update the extra params
41
+ $extraParams = $this->getExtraParams();
42
+ $extraParams .= ' data-template-value="#{' . $columnName . '}" ';
43
+ $this->setExtraParams($extraParams);
44
+
45
+ return $this;
46
+ }
47
+
48
+
49
+ // Neteven Tag NEW_METHOD
50
+
51
+ }
app/code/community/Neteven/NetevenSync/Block/Adminhtml/System/Config/Logs.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This file is part of Neteven_NetevenSync for Magento.
5
+ *
6
+ * @license All rights reserved
7
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
8
+ * @category Neteven
9
+ * @package Neteven_NetevenSync
10
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
11
+ */
12
+
13
+ /**
14
+ * Adminhtml_System_Config_Logs Block
15
+ * @package Neteven_NetevenSync
16
+ */
17
+ class Neteven_NetevenSync_Block_Adminhtml_System_Config_Logs extends Mage_Adminhtml_Block_System_Config_Form_Field
18
+ {
19
+
20
+ /**
21
+ * {@inheritdoc}
22
+ */
23
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
24
+ {
25
+ $this->setElement($element);
26
+
27
+ // Find log files
28
+ $logFiles = Mage::getSingleton('netevensync/adminhtml_system_config_source_logs')->toArray(true);
29
+
30
+ // No logs?
31
+ if (empty($logFiles)) {
32
+ return "<em>" . $this->__("No log") . "</em>";
33
+ }
34
+
35
+ // Create select element
36
+ /* @var $select Mage_Adminhtml_Block_Html_Select */
37
+ $select = $this->getLayout()->createBlock('adminhtml/html_select');
38
+ $select->setId($selectId = uniqid());
39
+ $select->setExtraParams('onchange="netevensync_toggle_buttons(this);"');
40
+ $select->addOption('', $this->__('--Please Select--'));
41
+
42
+ foreach ($logFiles as $value => $label) {
43
+ $select->addOption($value, $label);
44
+ }
45
+
46
+ // Append buttons to the select (display none)
47
+ $html = $select->toHtml() . '<br/><div id="' . $selectId . '-parent" style="margin-top:5px; display: none;">';
48
+ // Download button
49
+ $html .= $this->getLayout()->createBlock('adminhtml/widget_button')
50
+ ->setType('button')
51
+ ->setLabel($this->__('Download this log'))
52
+ ->setOnClick("netevensync_download('$selectId');")
53
+ ->setId($element->getHtmlId())
54
+ ->toHtml()
55
+ ;
56
+ // Delete button
57
+ $html .= ' ' . $this->getLayout()->createBlock('adminhtml/widget_button')
58
+ ->setType('button')
59
+ ->setLabel($this->__('Delete this log'))
60
+ ->setClass('delete')
61
+ ->setOnClick("netevensync_delete('$selectId');")
62
+ ->setId($element->getHtmlId())
63
+ ->toHtml()
64
+ ;
65
+ $html .= "</div>";
66
+
67
+ return $html;
68
+ }
69
+
70
+ /**
71
+ * {@inheritdoc}
72
+ */
73
+ protected function _prepareLayout()
74
+ {
75
+ parent::_prepareLayout();
76
+
77
+ // URLs
78
+ $downloadUrl = $this->getUrl('adminhtml/netevensync/downloadlog', array('log' => 'logname'));
79
+ $deleteUrl = $this->getUrl('adminhtml/netevensync/deletelog', array('log' => 'logname'));
80
+
81
+ // Add script to the bottom
82
+ $js = <<<JS
83
+ <script type="text/javascript">
84
+ var netevensync_toggle_buttons = function (select)
85
+ {
86
+ if (select.value !== '') {
87
+ $(select.id + '-parent').show();
88
+ } else {
89
+ $(select.id + '-parent').hide();
90
+ }
91
+ };
92
+ var netevensync_download = function (select_id)
93
+ {
94
+ var select = $(select_id);
95
+ setLocation('{$downloadUrl}'.replace('logname', encodeURIComponent(select.value)));
96
+ };
97
+ var netevensync_delete = function (select_id)
98
+ {
99
+ var select = $(select_id);
100
+ setLocation('{$deleteUrl}'.replace('logname', encodeURIComponent(select.value)));
101
+ };
102
+ </script>
103
+ JS;
104
+ $jsBlock = $this->getLayout()->createBlock('core/text');
105
+ $jsBlock->setText($js);
106
+ $this->getLayout()->getBlock('js')->append($jsBlock);
107
+
108
+ return $this;
109
+ }
110
+
111
+ }
app/code/community/Neteven/NetevenSync/Helper/Data.php CHANGED
@@ -8,102 +8,153 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Helper_Data extends Mage_Core_Helper_Abstract {
12
-
13
- /**
14
- * Log message
15
- *
16
- * @param string $message
17
- * @param bool || string $error
18
- */
19
- public function log($message, $error = false) {
20
- Mage::log($message, null, 'neteven.log');
21
-
22
- if($error) {
23
- $log = Mage::getModel('netevensync/log')->loadByCode($error);
24
- $log->setHasError(true)->save();
25
- }
26
- }
27
-
28
- /**
29
- * Log debug message
30
- *
31
- * @param string $message
32
- */
33
- public function logDebug($message) {
34
- if(Mage::getStoreConfigFlag('netevensync/general/debug')) {
35
- Mage::log($message, null, 'neteven_debug.log');
36
- }
37
- }
38
-
39
- /**
40
- * Check if SKU is valid
41
- *
42
- * @param string $sku
43
- * @param string $processType
44
- * @return string | bool
45
- */
46
- public function checkSku($sku, $processType) {
47
- if(strlen($sku) > 50) {
48
- $this->log($this->__('SKU length must be max 50 letters for SKU %s', $sku), $processType);
49
- return false;
50
- }
51
- return $sku;
52
- }
53
-
54
- /**
55
- * Retrieve args node of observer config
56
- *
57
- * @param Varien_Event_Observer $observer
58
- * @return array $observerArgs
59
- */
60
- public function getObserverArgs(Varien_Event_Observer $observer, $callingClass, $callingMethod) {
61
-
62
- /**
63
- * Define vars
64
- */
65
- $usedObservers = array();
66
- $observerArgs = array();
67
- $eventObservers = array();
68
-
69
- /**
70
- * Load Magento config
71
- */
72
- $config = Mage::getConfig();
73
-
74
- /**
75
- * Retrieve all observers attached to the current observer's event
76
- */
77
- $eventObservers = (array) $config->getXpath('//events/' . $observer->getEvent()->getName() . '/observers/*');
78
-
79
- /**
80
- * Retrieve all XML nodes of the current observer (including <args>!)
81
- * and populate $usedObservers with observers that:
82
- * - call the same class and method than the $observer passed as arguments for this function
83
- * - have an <args> node declared in config
84
- */
85
- foreach($eventObservers as $eventObserver) {
86
- $className = $config->getModelClassName($eventObserver->class);
87
- $method = $eventObserver->method;
88
- $args = (bool) $eventObserver->args;
89
- if($className == $callingClass && $method == $callingMethod && $args) {
90
- $usedObservers[] = $eventObserver;
91
- }
92
- }
93
-
94
- /**
95
- * Create array of args
96
- */
97
- foreach($usedObservers as $usedObserver) {
98
- $args = (array) $usedObserver->args;
99
- foreach($args as $name => $value) {
100
- $observerArgs[$name] = $value;
101
- }
102
- }
103
-
104
- $args = new Varien_Object;
105
- $args->setData($observerArgs);
106
-
107
- return $args;
108
- }
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
+
12
+ class Neteven_NetevenSync_Helper_Data extends Mage_Core_Helper_Abstract
13
+ {
14
+
15
+ /**
16
+ * Retrieve version number
17
+ * @return string
18
+ */
19
+ public function getVersion()
20
+ {
21
+ $neteven = Mage::getConfig()->getModuleConfig("Neteven_NetevenSync");
22
+ if ($neteven->version_name) {
23
+ return $neteven->version_name;
24
+ }
25
+ return $neteven->version;
26
+ }
27
+
28
+ /**
29
+ * Log message
30
+ *
31
+ * @param string $message
32
+ * @param bool|string $error Neteven log to mark as error in database
33
+ * @param int $level See Zend_Log constants (if $message is an Exception we force it on CRITICAL)
34
+ * @param string $logFilename
35
+ */
36
+ public function log($message, $error = false, $level = Zend_Log::ERR, $logFilename = 'neteven.log')
37
+ {
38
+ $forceLog = Mage::getStoreConfigFlag('netevensync/general/debug');
39
+ if ($message instanceof Exception) {
40
+ Mage::log("\n" . $message->__toString(), Zend_Log::CRIT, $logFilename, $forceLog);
41
+ } else {
42
+ Mage::log($message, $level, $logFilename, $forceLog);
43
+ }
44
+
45
+ if ($error) {
46
+ $log = Mage::getModel('netevensync/log')->loadByCode($error);
47
+ $log->setCode($error);
48
+ $log->setHasError(true)->save();
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Log debug message
54
+ *
55
+ * @param string $message
56
+ */
57
+ public function logDebug($message)
58
+ {
59
+ $this->log($message, false, Zend_Log::DEBUG, 'neteven_debug.log');
60
+ }
61
+
62
+ /**
63
+ * Check if SKU is valid
64
+ *
65
+ * @param string $sku
66
+ * @param string $processType
67
+ * @return string | bool
68
+ */
69
+ public function checkSku($sku, $processType)
70
+ {
71
+ if (strlen($sku) > 50) {
72
+ $this->log($this->__('SKU length must be max 50 letters for SKU %s', $sku), $processType);
73
+ return false;
74
+ }
75
+ return $sku;
76
+ }
77
+
78
+ /**
79
+ * Retrieve args node of observer config
80
+ *
81
+ * @param Varien_Event_Observer $observer
82
+ * @return array $observerArgs
83
+ */
84
+ public function getObserverArgs(Varien_Event_Observer $observer, $callingClass, $callingMethod)
85
+ {
86
+
87
+ /**
88
+ * Define vars
89
+ */
90
+ $usedObservers = array();
91
+ $observerArgs = array();
92
+ $eventObservers = array();
93
+
94
+ /**
95
+ * Load Magento config
96
+ */
97
+ $config = Mage::getConfig();
98
+
99
+ /**
100
+ * Retrieve all observers attached to the current observer's event
101
+ */
102
+ $eventObservers = (array) $config->getXpath('//events/' . $observer->getEvent()->getName() . '/observers/*');
103
+
104
+ /**
105
+ * Retrieve all XML nodes of the current observer (including <args>!)
106
+ * and populate $usedObservers with observers that:
107
+ * - call the same class and method than the $observer passed as arguments for this function
108
+ * - have an <args> node declared in config
109
+ */
110
+ foreach ($eventObservers as $eventObserver) {
111
+ $className = $config->getModelClassName($eventObserver->class);
112
+ $method = $eventObserver->method;
113
+ $args = (bool) $eventObserver->args;
114
+ if ($className == $callingClass && $method == $callingMethod && $args) {
115
+ $usedObservers[] = $eventObserver;
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Create array of args
121
+ */
122
+ foreach ($usedObservers as $usedObserver) {
123
+ $args = (array) $usedObserver->args;
124
+ foreach ($args as $name => $value) {
125
+ $observerArgs[$name] = $value;
126
+ }
127
+ }
128
+
129
+ $args = new Varien_Object;
130
+ $args->setData($observerArgs);
131
+
132
+ return $args;
133
+ }
134
+
135
+ /**
136
+ * Update store configuration - requirements
137
+ * @param Mage_Core_Model_Store $store
138
+ * @return Neteven_NetevenSync_Helper_Data
139
+ */
140
+ public function updateStoreConfiguration(Mage_Core_Model_Store $store)
141
+ {
142
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
143
+ $logger = Mage::helper('netevensync/logger');
144
+
145
+ // Considering prices with taxes, because Neteven prices are tax included
146
+ $paths = array(
147
+ 'tax/calculation/price_includes_tax' => '1',
148
+ 'tax/calculation/cross_border_trade_enabled' => '1',
149
+ );
150
+ foreach ($paths as $path => $correctValue) {
151
+ if ($store->getConfig($path) != $correctValue) {
152
+ $logger->info("Switch $path from " . $store->getConfig($path) . " to $correctValue.");
153
+ $store->setConfig($path, $correctValue);
154
+ }
155
+ }
156
+
157
+ return $this;
158
+ }
159
+
160
+ }
app/code/community/Neteven/NetevenSync/Helper/Logger.php ADDED
@@ -0,0 +1,642 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ /**
13
+ * Logger Helper
14
+ * @package Neteven_NetevenSync
15
+ */
16
+ class Neteven_NetevenSync_Helper_Logger
17
+ {
18
+
19
+ /**
20
+ * Log filename
21
+ * @const string
22
+ */
23
+ const LOG_FILENAME = 'netevensync_execution-traces.log';
24
+
25
+ /**
26
+ * Is init?
27
+ * <p>If the logger is not initialized, it won't log.</p>
28
+ * @var bool
29
+ */
30
+ protected $_isInit = false;
31
+
32
+ /**
33
+ * Depth of the next line
34
+ * @var int
35
+ */
36
+ protected $_depth = 0;
37
+
38
+ /**
39
+ * Current trace
40
+ * @var string
41
+ */
42
+ protected $_trace = "";
43
+
44
+ /**
45
+ * Not logged traces
46
+ * @var array
47
+ */
48
+ protected $_traces = array();
49
+
50
+ /**
51
+ * Tab characters
52
+ * @var string
53
+ */
54
+ protected $_tab = " ";
55
+
56
+ /**
57
+ * Timer of the current execution
58
+ * <p>Using microtime(true);</p>
59
+ * @var float
60
+ */
61
+ protected $_timer = null;
62
+
63
+ /**
64
+ * Left comparison array
65
+ * @var array
66
+ */
67
+ protected $_leftComparison = null;
68
+
69
+ /**
70
+ * Label of the comparison
71
+ * @var string
72
+ */
73
+ protected $_labelComparison = null;
74
+
75
+ /**
76
+ * Transaction trace
77
+ * <p>NULL if no transaction running.</p>
78
+ * @var string|null
79
+ */
80
+ protected $_transactionTrace = null;
81
+
82
+ /**
83
+ * Depth of the next line in transaction
84
+ * @var int
85
+ */
86
+ protected $_transactionDepth = null;
87
+
88
+ /**
89
+ * Init a log trace
90
+ * @param string $title Trace's title
91
+ * @return Neteven_NetevenSync_Helper_Logger
92
+ */
93
+ public function init($title)
94
+ {
95
+ $this->_cleanup();
96
+ $this->_isInit = true;
97
+ $version = Mage::helper('netevensync')->getVersion();
98
+ $this->_addLine("[v$version] " . strtoupper($title), '#');
99
+ return $this;
100
+ }
101
+
102
+ /**
103
+ * Start new part in the current trace
104
+ * @param string $title Part's title
105
+ * @return Neteven_NetevenSync_Helper_Logger
106
+ */
107
+ public function part($title)
108
+ {
109
+ $this->_setDepth(0);
110
+ $this->_addLine($title . ":");
111
+ $this->up();
112
+ return $this;
113
+ }
114
+
115
+ /**
116
+ * Add tabulation for the next elements
117
+ * @return Neteven_NetevenSync_Helper_Logger
118
+ */
119
+ public function up()
120
+ {
121
+ if ($this->_transactionTrace !== null) {
122
+ $this->_transactionDepth++;
123
+ } else {
124
+ $this->_depth++;
125
+ }
126
+ return $this;
127
+ }
128
+
129
+ /**
130
+ * Remove tabulation for the next elements
131
+ * <p>Can't be negative</p>
132
+ * @param int $depth How many levels to down
133
+ * @return Neteven_NetevenSync_Helper_Logger
134
+ */
135
+ public function down($depth = 1)
136
+ {
137
+ if ($this->_transactionTrace !== null) {
138
+ $this->_transactionDepth -= $depth;
139
+ if ($this->_transactionDepth < 0) {
140
+ $this->_transactionDepth = 0;
141
+ }
142
+ } else {
143
+ $this->_depth -= $depth;
144
+ if ($this->_depth < 0) {
145
+ $this->_depth = 0;
146
+ }
147
+ }
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * Add step in the current trace
153
+ * @param string $label Step's label
154
+ * @param mixed $message Step's message. Default to empty string.
155
+ * @return Neteven_NetevenSync_Helper_Logger
156
+ */
157
+ public function step($label, $message = "")
158
+ {
159
+ // Check message
160
+ if (is_bool($message)) {
161
+ $message = $message ? "yes" : "no";
162
+ } elseif (!is_string($message)) {
163
+ $data = $message;
164
+ $message = "";
165
+ }
166
+
167
+ // If question mark is present, remove the colon
168
+ if (strpos($label, "?") !== false) {
169
+ $format = "%s %s";
170
+ } else {
171
+ $format = "%s: %s";
172
+ }
173
+
174
+ $this->_addLine(sprintf($format, $label, $message));
175
+
176
+ if (isset($data)) {
177
+ $this
178
+ ->up()
179
+ ->data($data)
180
+ ->down()
181
+ ;
182
+ }
183
+
184
+ return $this;
185
+ }
186
+
187
+ /**
188
+ * Add data in the current trace
189
+ * @param array|string $data Label of the $value, or array of data
190
+ * @param mixed $value Value (with $data as string)
191
+ * @param int $recursive Number of recursive iterations
192
+ * @return Neteven_NetevenSync_Helper_Logger
193
+ */
194
+ public function data($data, $value = null, $recursive = 1)
195
+ {
196
+ if ($data instanceof Varien_Object) {
197
+ $data = $data->getData();
198
+ }
199
+
200
+ if (is_array($data)) {
201
+ if (!empty($data)) {
202
+ foreach ($data as $label => $message) {
203
+ $this->data($label, $message);
204
+ }
205
+ } else {
206
+ $this->_addLine("_empty array_");
207
+ }
208
+ } else {
209
+ $this->_addLine(sprintf("`%s` = `%s`", $data, $this->_getVarDump($value)));
210
+ if ($recursive > 0) {
211
+ $this->up();
212
+ if ($value instanceof Varien_Object) {
213
+ $this->data($value->getData(), null, --$recursive);
214
+ } elseif (is_array($value)) {
215
+ $this->data($value, null, --$recursive);
216
+ }
217
+ $this->down();
218
+ }
219
+ }
220
+ return $this;
221
+ }
222
+
223
+ /**
224
+ * Add store information in the current trace
225
+ * @param Mage_Core_Model_Store $store The store to log
226
+ * @return Neteven_NetevenSync_Helper_Logger
227
+ */
228
+ public function logStore(Mage_Core_Model_Store $store)
229
+ {
230
+ $this->step("**[STORE] {$store->getName()} store view**", array(
231
+ "id" => $store->getId(),
232
+ "code" => $store->getCode(),
233
+ "name" => $store->getName(),
234
+ "base_currency" => $store->getBaseCurrencyCode(),
235
+ "default_currency" => $store->getDefaultCurrencyCode(),
236
+ "current_currency" => $store->getCurrentCurrencyCode(),
237
+ "available_currencies" => $store->getAvailableCurrencyCodes(),
238
+ ));
239
+ return $this;
240
+ }
241
+
242
+ /**
243
+ * Add information in the current trace
244
+ * @param string $info Info message
245
+ * @return Neteven_NetevenSync_Helper_Logger
246
+ */
247
+ public function info($info)
248
+ {
249
+ $this->_addLine(sprintf("[i] *%s*", $info));
250
+ return $this;
251
+ }
252
+
253
+ /**
254
+ * Add error in the current trace
255
+ * @param string $error Error message
256
+ * @return Neteven_NetevenSync_Helper_Logger
257
+ */
258
+ public function err($error)
259
+ {
260
+ $this->_addLine(sprintf("[!!!] *%s*", $error));
261
+ return $this;
262
+ }
263
+
264
+ /**
265
+ * Add condition to trace and return it
266
+ * @param string $label
267
+ * @param mixed $condition
268
+ * @return $condition
269
+ */
270
+ public function condition($label, $condition)
271
+ {
272
+ $this
273
+ ->step($label)
274
+ ->up()
275
+ ->result($condition)
276
+ ->down()
277
+ ;
278
+ return $condition;
279
+ }
280
+
281
+ /**
282
+ * Add an exception message to the trace
283
+ * @param Exception $e
284
+ * @return Neteven_NetevenSync_Helper_Logger
285
+ */
286
+ public function exception(Exception $e)
287
+ {
288
+ $this->_addLine(sprintf("**[!!! Exception] %s**", $e->getMessage()));
289
+ return $this;
290
+ }
291
+
292
+ /**
293
+ * Start an array comparison
294
+ * @param string $label Label of the comparison
295
+ * @param array $left Left element to compare
296
+ * @return Neteven_NetevenSync_Helper_Logger
297
+ */
298
+ public function startComparison($label, array $left)
299
+ {
300
+ $this->_labelComparison = $label;
301
+ $this->_leftComparison = $left;
302
+ return $this;
303
+ }
304
+
305
+ /**
306
+ * End an array comparison
307
+ * @param array $right Right element to compare
308
+ * @return Neteven_NetevenSync_Helper_Logger
309
+ */
310
+ public function endComparison(array $right)
311
+ {
312
+ $comparison = array();
313
+
314
+ // Compare left to right
315
+ foreach ($this->_leftComparison as $key => $leftValue) {
316
+ $rightValue = !isset($right[$key]) ? null : $right[$key];
317
+ if ($leftValue !== $rightValue) {
318
+ $comparison[$key] = array(
319
+ 'left' => $leftValue,
320
+ 'right' => $rightValue
321
+ );
322
+ }
323
+ }
324
+
325
+ // Compare right to left
326
+ foreach ($right as $key => $rightValue) {
327
+ if (isset($comparison[$key])) {
328
+ continue;
329
+ }
330
+ $leftValue = !isset($this->_leftComparison[$key]) ? null : $this->_leftComparison[$key];
331
+ if ($leftValue !== $rightValue) {
332
+ $comparison[$key] = array(
333
+ 'left' => $leftValue,
334
+ 'right' => $rightValue
335
+ );
336
+ }
337
+ }
338
+
339
+ // Display
340
+ $this
341
+ ->step(sprintf("Comparison - %s", $this->_labelComparison))
342
+ ->up()
343
+ ;
344
+ foreach ($comparison as $key => $element) {
345
+ $this->_addLine(sprintf(
346
+ "`%s`: `%s` => `%s`",
347
+ $key,
348
+ $this->_getVarDump($element['left']),
349
+ $this->_getVarDump($element['right'])
350
+ ));
351
+ }
352
+
353
+ // Reset
354
+ $this->_leftComparison = null;
355
+ $this->_labelComparison = null;
356
+
357
+ return $this;
358
+ }
359
+
360
+ /**
361
+ * Add result to the current trace
362
+ * @param mixed $result The result to log
363
+ * @param null|string $label Label of the result if you want
364
+ * @return Neteven_NetevenSync_Helper_Logger
365
+ */
366
+ public function result($result, $label = null)
367
+ {
368
+ if (is_string($label)) {
369
+ $this->_addLine(sprintf("=> **%s** (%s)", $this->_getVarDump($result), $label));
370
+ } else {
371
+ $this->_addLine(sprintf("=> **%s**", $this->_getVarDump($result)));
372
+ }
373
+ return $this;
374
+ }
375
+
376
+ /**
377
+ * End the current trace
378
+ * <p>We just add the word END… technicaly the trace is still opened</p>
379
+ * @param bool $log Log the trace at the end. Default to TRUE
380
+ * @param bool $reset Reset after logging. Default to FALSE. Otherwise we cleanup.
381
+ * @param null|int $level Log level
382
+ * @param string Log filename
383
+ * @return Neteven_NetevenSync_Helper_Logger
384
+ */
385
+ public function end($log = true, $reset = true, $level = null, $file = self::LOG_FILENAME)
386
+ {
387
+ $this->_setDepth(0);
388
+ $this->_addLine("END");
389
+ if ($log) {
390
+ $this->log($reset, $level, $file);
391
+ }
392
+ return $this;
393
+ }
394
+
395
+ /**
396
+ * Reset the current trace
397
+ * @return Neteven_NetevenSync_Helper_Logger
398
+ */
399
+ public function reset()
400
+ {
401
+ $this->_trace = "";
402
+ $this->_depth = 0;
403
+ $this->_timer = null;
404
+ $this->_isInit = false;
405
+ $this->_transactionDepth = null;
406
+ $this->_transactionTrace = null;
407
+
408
+ return $this;
409
+ }
410
+
411
+ /**
412
+ * Retrieve the current trace
413
+ * @param bool $cleanup TRUE if you want to cleanup at the same time. Default to FALSE.
414
+ * @return string The current trace
415
+ */
416
+ public function getTrace($cleanup = false)
417
+ {
418
+ $trace = $this->_trace;
419
+ if ($cleanup) {
420
+ $this->_cleanup();
421
+ }
422
+ return $trace;
423
+ }
424
+
425
+ /**
426
+ * Retrieve all the traces (which are stored in the Logger)
427
+ * @param bool $cleanup TRUE if you want to cleanup at the same time. Default to FALSE.
428
+ * @return array
429
+ */
430
+ public function getTraces($cleanup = false)
431
+ {
432
+ if ($cleanup) {
433
+ $this->_cleanup();
434
+ }
435
+ return $this->_traces;
436
+ }
437
+
438
+ /**
439
+ * Log the current trace
440
+ * @param bool $reset Reset after logging. Default to TRUE. Otherwise we cleanup.
441
+ * @param null|int $level Log level
442
+ * @param string Log filename
443
+ * @return Neteven_NetevenSync_Helper_Logger
444
+ */
445
+ public function log($reset = true, $level = null, $file = self::LOG_FILENAME)
446
+ {
447
+ if (Mage::getStoreConfigFlag('netevensync/general/debug_advanced')) {
448
+ if (strlen($this->_trace)) {
449
+ if (strpos(strtolower($file), 'neteven') === false) {
450
+ // Add neteven because we use this to filter the log files in config
451
+ $file = sprintf("neteven_%s", $file);
452
+ }
453
+ Mage::log("\n" . $this->_trace, $level, $file, true);
454
+ }
455
+ }
456
+ if ($reset) {
457
+ $this->reset();
458
+ } else {
459
+ $this->_cleanup();
460
+ }
461
+ return $this;
462
+ }
463
+
464
+ /**
465
+ * Start transaction
466
+ * @return Neteven_NetevenSync_Helper_Logger
467
+ */
468
+ public function transaction()
469
+ {
470
+ $this->_transactionTrace = "";
471
+ $this->_transactionDepth = $this->_depth;
472
+ return $this;
473
+ }
474
+
475
+ /**
476
+ * Commit transaction
477
+ * @return Neteven_NetevenSync_Helper_Logger
478
+ */
479
+ public function commit()
480
+ {
481
+ $this->_trace .= $this->_transactionTrace;
482
+ $this->_depth = $this->_transactionDepth;
483
+ return $this->rollback();
484
+ }
485
+
486
+ /**
487
+ * Rollback transaction
488
+ * @return Neteven_NetevenSync_Helper_Logger
489
+ */
490
+ public function rollback()
491
+ {
492
+ $this->_transactionTrace = null;
493
+ $this->_transactionDepth = null;
494
+ return $this;
495
+ }
496
+
497
+ /**
498
+ * Add a new line in the trace
499
+ * @param string $line The line to add
500
+ * @param bool|string $bullet The bullet to use.
501
+ * <p>If TRUE: default bullet ("*")
502
+ * If FALSE: no bullet.
503
+ * If string: use it as bullet.</p>
504
+ */
505
+ protected function _addLine($line, $bullet = true)
506
+ {
507
+ // Not initialized?
508
+ if (!$this->_isInit) {
509
+ return;
510
+ }
511
+
512
+ $newLine = "";
513
+ if ($this->_transactionTrace !== null) {
514
+ if ($this->_transactionDepth > 0) {
515
+ $newLine .= str_repeat($this->_tab, $this->_transactionDepth);
516
+ }
517
+ } else {
518
+ if ($this->_depth > 0) {
519
+ $newLine .= str_repeat($this->_tab, $this->_depth);
520
+ }
521
+ }
522
+ if ($bullet === true) {
523
+ $newLine .= "* ";
524
+ } elseif (is_string($bullet)) {
525
+ $newLine .= $bullet . " ";
526
+ }
527
+ $newLine .= $line;
528
+
529
+ // Display memory and datetime/timer.
530
+ /*
531
+ $nbSpaces = 75 - strlen($newLine);
532
+ if ($nbSpaces > 0) {
533
+ $newLine .= str_repeat(" ", $nbSpaces);
534
+ }
535
+ $newLine .= sprintf(" `%s - %s`", $this->_getMemory(), $this->_getTimerAsString());
536
+ //*/
537
+
538
+ if ($this->_transactionTrace !== null) {
539
+ $this->_transactionTrace .= $newLine . "\n";
540
+ } else {
541
+ $this->_trace .= $newLine . "\n";
542
+ }
543
+ }
544
+
545
+ /**
546
+ * Set the depth
547
+ * @param int $depth
548
+ * @return Neteven_NetevenSync_Helper_Logger
549
+ */
550
+ protected function _setDepth($depth)
551
+ {
552
+ if ($this->_transactionTrace !== null) {
553
+ $this->_transactionDepth = $depth;
554
+ } else {
555
+ $this->_depth = $depth;
556
+ }
557
+ return $this;
558
+ }
559
+
560
+ /**
561
+ * Clean up the current trace
562
+ * <p>Keep the current trace in memory if it exists.</p>
563
+ */
564
+ protected function _cleanup()
565
+ {
566
+ if (!empty($this->_trace)) {
567
+ $this->_traces[] = $this->_trace;
568
+ }
569
+ $this->reset();
570
+ }
571
+
572
+ /**
573
+ * Retrieve the current memory usage readable by human
574
+ * @return string
575
+ */
576
+ protected function _getMemory()
577
+ {
578
+ $size = memory_get_usage(true);
579
+ $unit = array('b','Kb','Mb','Gb','Tb','Pb');
580
+ return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 6) . ' ' . $unit[$i];
581
+ }
582
+
583
+ /**
584
+ * Retrieve the timer
585
+ * <p>If it's the first time it returns the datetime</p>
586
+ * @return string
587
+ */
588
+ protected function _getTimerAsString()
589
+ {
590
+ if (is_null($this->_timer)) {
591
+ $this->_timer = microtime(true);
592
+ return date('c');
593
+ }
594
+ $time = microtime(true);
595
+ $diff = $time - $this->_timer;
596
+ return (string) '+' . round($diff, 4) . 's';
597
+ }
598
+
599
+ /**
600
+ * Retrieve a "var_dump" of the variable
601
+ * @param mixed $var
602
+ * @return string
603
+ */
604
+ protected function _getVarDump($var)
605
+ {
606
+ if (is_object($var)) {
607
+ return sprintf("object(%s)", get_class($var));
608
+ } elseif (is_array($var)) {
609
+ return sprintf("array(count=%d)", count($var));
610
+ }
611
+
612
+ ob_start();
613
+ var_dump($var);
614
+ $dump = trim(ob_get_contents());
615
+ ob_end_clean();
616
+
617
+ return $dump;
618
+ }
619
+
620
+ /**
621
+ * Magic method: To string
622
+ * @return string
623
+ */
624
+ public function __toString()
625
+ {
626
+ return $this->_trace;
627
+ }
628
+
629
+ /**
630
+ * Destructor
631
+ * <p>Don't loose a trace :)</p>
632
+ */
633
+ public function __destruct()
634
+ {
635
+ $this->_cleanup();
636
+ foreach ($this->_traces as $trace) {
637
+ $this->_trace = "[!!!] LOGGER DESTRUCTION\n" . $trace;
638
+ $this->log();
639
+ }
640
+ }
641
+
642
+ }
app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Backend/Datetime.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ /**
13
+ * Adminhtml_System_Config_Backend_Datetime Model
14
+ * @package Neteven_NetevenSync
15
+ */
16
+ class Neteven_NetevenSync_Model_Adminhtml_System_Config_Backend_Datetime extends Mage_Core_Model_Config_Data
17
+ {
18
+
19
+ /**
20
+ * We convert the MySQL datetime (in UTC)
21
+ * to an array (of the corresponding date using the configured timezone).
22
+ */
23
+ protected function _afterLoad()
24
+ {
25
+ if (!is_array($this->getValue())) {
26
+ $gmtDate = (string) $this->getValue(); // From UTC
27
+
28
+ if (empty($gmtDate)) {
29
+ $gmtDate = 1; // Default to 1970-01-01 00:00:01
30
+ }
31
+
32
+ $date = Mage::app()->getLocale()->date($gmtDate); // To Timezone
33
+ $value = explode('-', $date->toString('y-MM-dd-HH-mm-ss'));
34
+ $this->setValue($value);
35
+ }
36
+ }
37
+
38
+ /**
39
+ * We transform the array with date and time (configured timezone)
40
+ * to MySQL date (in UTC).
41
+ *
42
+ * @throws Zend_Date_Exception
43
+ */
44
+ protected function _beforeSave()
45
+ {
46
+ if (is_array($this->getValue())) {
47
+ $value = $this->getValue();
48
+
49
+ if (strlen($value[0])) {
50
+ $filterInput = new Zend_Filter_LocalizedToNormalized(array(
51
+ 'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
52
+ ));
53
+ $filterInternal = new Zend_Filter_NormalizedToLocalized(array(
54
+ 'date_format' => Varien_Date::DATE_INTERNAL_FORMAT,
55
+ ));
56
+ $normalizedDate = $filterInternal->filter($filterInput->filter($value[0]));
57
+ } else {
58
+ $normalizedDate = '1970-01-01';
59
+ }
60
+
61
+ $date = Mage::app()->getLocale()->date(); // From timezone
62
+ $date
63
+ ->setDate($normalizedDate, Varien_Date::DATE_INTERNAL_FORMAT)
64
+ ->setHour($value[1])
65
+ ->setMinute($value[2])
66
+ ->setSecond($value[3])
67
+ ->setTimezone('UTC') // To UTC
68
+ ;
69
+
70
+ $this->setValue($date->toString('y-MM-dd HH:mm:ss'));
71
+ }
72
+ }
73
+ }
app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Order/Mapping.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ /**
13
+ * Adminhtml_System_Config_Order_Mapping Model
14
+ * @package Neteven_NetevenSync
15
+ */
16
+ class Neteven_NetevenSync_Model_Adminhtml_System_Config_Order_Mapping extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
17
+ {
18
+ protected $_eventPrefix = 'neteven_netevensync_config_backend_order_mapping';
19
+ }
app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/Logs.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ /**
13
+ * Adminhtml_System_Config_Source_Logs Model
14
+ * @package Neteven_NetevenSync
15
+ */
16
+ class Neteven_NetevenSync_Model_Adminhtml_System_Config_Source_Logs
17
+ {
18
+
19
+ /**
20
+ * Retrieve logs as option array
21
+ * <p>Format [label, value]</p>
22
+ * @return array
23
+ */
24
+ public function toOptionArray()
25
+ {
26
+ $options = array();
27
+ foreach ($this->toArray() as $value => $label) {
28
+ $options[] = compact('value', 'label');
29
+ }
30
+ return $options;
31
+ }
32
+
33
+ /**
34
+ * Retrieve list of log files
35
+ * <p>Format value => label</p>
36
+ * @param bool $withSize Append file size at the end of the name
37
+ * @return array
38
+ */
39
+ public function toArray($withSize = false)
40
+ {
41
+ $options = array();
42
+ $logDir = Mage::getBaseDir('log');
43
+ $files = glob($logDir . DS . '*neteven*');
44
+ foreach ($files as $file) {
45
+ if (filesize($file)) {
46
+ $filename = basename($file);
47
+ $options[hash('md5', $filename)] = $filename;
48
+ if ($withSize) {
49
+ $options[hash('md5', $filename)] .= ' - ' . $this->_getHumanFilesize($file);
50
+ }
51
+ }
52
+ }
53
+ return $options;
54
+ }
55
+
56
+ /**
57
+ * Retrieve readable file size
58
+ * @param string $filename
59
+ * @param int $decimals
60
+ * @return string
61
+ */
62
+ protected function _getHumanFilesize($filename, $decimals = 2)
63
+ {
64
+ $sz = array('b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb');
65
+ $bytes = filesize($filename);
66
+ $factor = floor((strlen($bytes) - 1) / 3);
67
+ return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor];
68
+ }
69
+
70
+ }
app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/MagentoOrderStatus.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Orders state source options
4
  *
@@ -8,54 +9,64 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Model_Adminhtml_System_Config_Source_MagentoOrderStatus extends Mage_Adminhtml_Model_System_Config_Source_Order_Status{
12
-
13
- public function getAvailableStatuses($state) {
14
- $this->_stateStatuses = array($state);
15
- $options = array();
16
- $srcOptions = $this->toOptionArray();
17
- foreach($srcOptions as $srcOption) {
18
- $options[$srcOption['value']] = $srcOption['label'];
19
- }
20
- return $options;
21
- }
22
-
 
 
23
  public function toOptionArray()
24
  {
25
  if ($this->_stateStatuses) {
26
  $statuses = Mage::getModel('sales/order_config')->getStateStatuses($this->_stateStatuses);
27
- }
28
- else {
29
  $statuses = Mage::getModel('sales/order_config')->getStatuses();
30
  }
31
- $options = array();
32
  $options[] = array(
33
- 'value' => '',
34
- 'label' => Mage::helper('adminhtml')->__('-- Please Select --')
35
- );
36
- foreach ($statuses as $code=>$label) {
37
  $options[] = array(
38
- 'value' => $code,
39
- 'label' => $label
40
  );
41
  }
42
  return $options;
43
  }
44
-
45
- public function getNewStatuses() {
46
- return $this->getAvailableStatuses(Mage_Sales_Model_Order::STATE_NEW);
47
- }
48
-
49
- public function getProcessingStatuses() {
50
- return $this->getAvailableStatuses(Mage_Sales_Model_Order::STATE_PROCESSING);
51
-
52
- }
53
-
54
- public function getCanceledStatuses() {
55
- return $this->getAvailableStatuses(Mage_Sales_Model_Order::STATE_CANCELED);
56
- }
57
-
58
- public function getClosedStatuses() {
59
- return $this->getAvailableStatuses(Mage_Sales_Model_Order::STATE_CLOSED);
60
- }
 
 
 
 
 
 
 
 
 
61
  }
1
  <?php
2
+
3
  /**
4
  * Orders state source options
5
  *
9
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
11
  */
12
+ class Neteven_NetevenSync_Model_Adminhtml_System_Config_Source_MagentoOrderStatus extends Mage_Adminhtml_Model_System_Config_Source_Order_Status
13
+ {
14
+
15
+ public function getAvailableStatuses($state)
16
+ {
17
+ $this->_stateStatuses = array($state);
18
+ $options = array();
19
+ $srcOptions = $this->toOptionArray();
20
+ foreach ($srcOptions as $srcOption) {
21
+ $options[$srcOption['value']] = $srcOption['label'];
22
+ }
23
+ return $options;
24
+ }
25
+
26
  public function toOptionArray()
27
  {
28
  if ($this->_stateStatuses) {
29
  $statuses = Mage::getModel('sales/order_config')->getStateStatuses($this->_stateStatuses);
30
+ } else {
 
31
  $statuses = Mage::getModel('sales/order_config')->getStatuses();
32
  }
33
+ $options = array();
34
  $options[] = array(
35
+ 'value' => '',
36
+ 'label' => Mage::helper('adminhtml')->__('-- Please Select --')
37
+ );
38
+ foreach ($statuses as $code => $label) {
39
  $options[] = array(
40
+ 'value' => $code,
41
+ 'label' => $label
42
  );
43
  }
44
  return $options;
45
  }
46
+
47
+ public function getNewStatuses()
48
+ {
49
+ return $this->getAvailableStatuses(Mage_Sales_Model_Order::STATE_NEW);
50
+ }
51
+
52
+ public function getProcessingStatuses()
53
+ {
54
+ return $this->getAvailableStatuses(Mage_Sales_Model_Order::STATE_PROCESSING);
55
+ }
56
+
57
+ public function getCanceledStatuses()
58
+ {
59
+ return $this->getAvailableStatuses(Mage_Sales_Model_Order::STATE_CANCELED);
60
+ }
61
+
62
+ public function getClosedStatuses()
63
+ {
64
+ return $this->getAvailableStatuses(Mage_Sales_Model_Order::STATE_CLOSED);
65
+ }
66
+
67
+ public function getCompleteStatuses()
68
+ {
69
+ return $this->getAvailableStatuses(Mage_Sales_Model_Order::STATE_COMPLETE);
70
+ }
71
+
72
  }
app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/NetevenOrderStatus.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Orders state source options
4
  *
@@ -8,36 +9,40 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Model_Adminhtml_System_Config_Source_NetevenOrderStatus {
12
-
13
- /**
14
- * Options getter
15
- *
16
- * @return array $options
17
- */
18
- public function toOptionArray() {
19
- $srcOptions = Mage::getSingleton('netevensync/config')->getNetevenOrderStatuses();
20
- $options = array();
21
- foreach($srcOptions as $code => $label) {
22
- $options[] = array('value' => $code, 'label' => $label);
23
- }
24
-
25
- return $options;
26
- }
27
-
28
- /**
29
- * Get options with empty
30
- *
31
- * @return array $options
32
- */
33
- public function toSelect() {
34
- $options[''] = Mage::helper('adminhtml')->__('--Please Select--');
35
- $optionsSrc = $this->toOptionArray();
36
-
37
- foreach($optionsSrc as $option) {
38
- $options[$option['value']] = $option['label'];
39
- }
40
-
41
- return $options;
42
- }
43
- }
 
 
 
 
1
  <?php
2
+
3
  /**
4
  * Orders state source options
5
  *
9
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
11
  */
12
+ class Neteven_NetevenSync_Model_Adminhtml_System_Config_Source_NetevenOrderStatus
13
+ {
14
+
15
+ /**
16
+ * Options getter
17
+ *
18
+ * @return array $options
19
+ */
20
+ public function toOptionArray()
21
+ {
22
+ $srcOptions = Mage::getSingleton('netevensync/config')->getNetevenOrderStatuses();
23
+ $options = array();
24
+ foreach ($srcOptions as $code => $label) {
25
+ $options[] = array('value' => $code, 'label' => $label);
26
+ }
27
+
28
+ return $options;
29
+ }
30
+
31
+ /**
32
+ * Get options with empty
33
+ *
34
+ * @return array $options
35
+ */
36
+ public function toSelect()
37
+ {
38
+ $options[''] = Mage::helper('adminhtml')->__('--Please Select--');
39
+ $optionsSrc = $this->toOptionArray();
40
+
41
+ foreach ($optionsSrc as $option) {
42
+ $options[$option['value']] = $option['label'];
43
+ }
44
+
45
+ return $options;
46
+ }
47
+
48
+ }
app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/Order/Pdm.php CHANGED
@@ -8,25 +8,32 @@
8
  * @package Neteven_NetevenSync
9
  * @copyright Copyright (c) 2013 Agence Soon (http://www.agence-soon.fr)
10
  */
11
- class Neteven_NetevenSync_Model_Adminhtml_System_Config_Source_Order_Pdm {
 
 
12
 
13
  /**
14
  * Options getter
15
  *
16
  * @return array $options
17
  */
18
- public function toOptionArray() {
19
- $options[] = array('value' => '', 'label' => Mage::helper('adminhtml')->__('-- Please Select --'));
 
 
 
 
20
 
21
  $marketplacesCountries = array_unique(Mage::getSingleton('netevensync/config')->getMarketplacesCountries());
22
- $countries = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false);
23
 
24
- foreach($countries as $country) {
25
- if(in_array(strtolower($country['value']), $marketplacesCountries)) {
26
  $options[] = array('value' => strtolower($country['value']), 'label' => $country['label']);
27
  }
28
  }
29
 
30
  return $options;
31
  }
32
- }
 
8
  * @package Neteven_NetevenSync
9
  * @copyright Copyright (c) 2013 Agence Soon (http://www.agence-soon.fr)
10
  */
11
+
12
+ class Neteven_NetevenSync_Model_Adminhtml_System_Config_Source_Order_Pdm
13
+ {
14
 
15
  /**
16
  * Options getter
17
  *
18
  * @return array $options
19
  */
20
+ public function toOptionArray()
21
+ {
22
+ $options[] = array(
23
+ 'value' => '',
24
+ 'label' => Mage::helper('adminhtml')->__('-- Please Select --'),
25
+ );
26
 
27
  $marketplacesCountries = array_unique(Mage::getSingleton('netevensync/config')->getMarketplacesCountries());
28
+ $countries = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false);
29
 
30
+ foreach ($countries as $country) {
31
+ if (in_array(strtolower($country['value']), $marketplacesCountries)) {
32
  $options[] = array('value' => strtolower($country['value']), 'label' => $country['label']);
33
  }
34
  }
35
 
36
  return $options;
37
  }
38
+
39
+ }
app/code/community/Neteven/NetevenSync/Model/Adminhtml/System/Config/Source/Start.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- /**
3
- * Start Hour source options
4
- *
5
- * @category Neteven
6
- * @package Neteven_NetevenSync
7
- * @copyright Copyright (c) 2013 Agence Soon. (http://www.agence-soon.fr)
8
- * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
- * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
- */
11
- class Neteven_NetevenSync_Model_Adminhtml_System_Config_Source_Start {
12
-
13
- /**
14
- * Options getter
15
- *
16
- * @return array $options
17
- */
18
- public function toOptionArray() {
19
- $options = array();
20
-
21
- for($i = 0; $i < 24; $i++) {
22
- $options[] = array('value' => $i, 'label' => sprintf("%02s", $i) . 'h');
23
- }
24
-
25
- return $options;
26
- }
27
-
28
- /**
29
- * Get optins in "key-value" format
30
- *
31
- * @return array $optionsArray
32
- */
33
- public function toArray() {
34
- $options = array();
35
- $optionsSrc = $this->toOptionArray();
36
-
37
- foreach($optionsSrc as $option) {
38
- $options[$option['value']] = $option['label'];
39
- }
40
-
41
- return $options;
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Neteven/NetevenSync/Model/Config.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Config model
4
  *
@@ -8,19 +9,20 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Model_Config {
 
12
 
13
  /**
14
  * Process types codes
15
  */
16
  const NETEVENSYNC_PROCESS_INVENTORY_CODE = 'inventory';
17
- const NETEVENSYNC_PROCESS_ORDER_CODE = 'order';
18
- const NETEVENSYNC_PROCESS_STOCK_CODE = 'stock';
19
 
20
  /**
21
  * Export modes codes
22
  */
23
- const NETEVENSYNC_EXPORT_FULL = 'full';
24
  const NETEVENSYNC_EXPORT_INCREMENTAL = 'incremental';
25
 
26
  /**
@@ -32,7 +34,7 @@ class Neteven_NetevenSync_Model_Config {
32
  /**
33
  * Page Size for chunks in Neteven API calls
34
  */
35
- const NETEVENSYNC_CHUNK_SIZE = 150;
36
  const NETEVENSYNC_CHUNK_SIZE_AJAX = 20;
37
 
38
  /**
@@ -40,16 +42,15 @@ class Neteven_NetevenSync_Model_Config {
40
  */
41
  const NETEVENSYNC_ORDER_STATUS_TOCONFIRM = 'toConfirm';
42
  const NETEVENSYNC_ORDER_STATUS_CONFIRMED = 'Confirmed';
43
- const NETEVENSYNC_ORDER_STATUS_SHIPPED = 'Shipped';
44
- const NETEVENSYNC_ORDER_STATUS_CANCELED = 'Canceled';
45
- const NETEVENSYNC_ORDER_STATUS_REFUNDED = 'Refunded';
46
 
47
  /**
48
  * Neteven Sandbox marketplace ID for orders
49
  */
50
  const SANDBOX_MARKETPLACE_ID = '19';
51
-
52
- const INVENTORY_SKUFAMILY_CODE = 'sku_family';
53
  const INVENTORY_SKUFAMILY_AUTOMATIC_KEY = '_automatic';
54
 
55
  /**
@@ -64,7 +65,8 @@ class Neteven_NetevenSync_Model_Config {
64
  *
65
  * @return array
66
  */
67
- public function getProcessCodes() {
 
68
  return array(
69
  self::NETEVENSYNC_PROCESS_INVENTORY_CODE,
70
  self::NETEVENSYNC_PROCESS_ORDER_CODE,
@@ -77,7 +79,8 @@ class Neteven_NetevenSync_Model_Config {
77
  *
78
  * @return array
79
  */
80
- public function getDirs() {
 
81
  return array(
82
  self::NETEVENSYNC_DIR_IMPORT,
83
  self::NETEVENSYNC_DIR_EXPORT,
@@ -89,14 +92,15 @@ class Neteven_NetevenSync_Model_Config {
89
  *
90
  * @return array || string $errors
91
  */
92
- public function getErrorLabels($errorCode = null) {
 
93
  $errorCodes = array(
94
- self::NETEVENSYNC_PROCESS_INVENTORY_CODE => Mage::helper('netevensync')->__('Inventory'),
95
- self::NETEVENSYNC_PROCESS_ORDER_CODE => Mage::helper('netevensync')->__('Orders'),
96
- self::NETEVENSYNC_PROCESS_STOCK_CODE => Mage::helper('netevensync')->__('Stocks'),
97
  );
98
 
99
- if($errorCode && isset($errorCodes[$errorCode])) {
100
  return $errorCodes[$errorCode];
101
  }
102
 
@@ -108,7 +112,8 @@ class Neteven_NetevenSync_Model_Config {
108
  *
109
  * @return array
110
  */
111
- public function getDisallowedAttributes() {
 
112
  return array_keys(Mage::getConfig()->getNode('netevensync/disallowed_attributes')->asArray());
113
  }
114
 
@@ -116,17 +121,18 @@ class Neteven_NetevenSync_Model_Config {
116
  * Append dynamic fields to system config
117
  * @param Varien_Event_Observer $observer
118
  */
119
- public function appendConfigNodes(Varien_Event_Observer $observer) {
 
120
 
121
  $config = $observer->getConfig();
122
 
123
  // Specific Fields Mapping
124
  $specificFields = Mage::getConfig()->getNode('netevensync/specific_fields')->asArray();
125
- $xml = array();
126
- $sortOrder = 100;
127
- foreach($specificFields as $code => $label) {
128
 
129
- switch($code) {
130
  case 'ean':
131
  $comment = '<comment>' . Mage::helper('netevensync')->__('EAN code is highly recommended') . '</comment>';
132
  break;
@@ -142,7 +148,7 @@ class Neteven_NetevenSync_Model_Config {
142
 
143
  $sourceModel = 'netevensync/adminhtml_system_config_source_attribute';
144
 
145
- if(strstr($code, 'price_')) { // If field is if type 'price'
146
  $sourceModel = 'netevensync/adminhtml_system_config_source_attribute_price';
147
  }
148
 
@@ -151,12 +157,11 @@ class Neteven_NetevenSync_Model_Config {
151
  }
152
 
153
  $xml[] = sprintf(
154
- '<%s translate="label"><label>%s</label><frontend_type>select</frontend_type><source_model>%s::toSelect</source_model><sort_order>%s</sort_order><show_in_default>1</show_in_default><show_in_website>0</show_in_website><show_in_store>0</show_in_store>%s<depends><enable>1</enable></depends></%s>',
155
- $code, $label, $sourceModel, $sortOrder, $comment, $code
156
  );
157
  $sortOrder++;
158
  }
159
- foreach($xml as $field) {
160
  $node = new Mage_Core_Model_Config_Element($field);
161
  $config->getNode('sections/netevensync/groups/inventory/fields')->appendChild($node);
162
  }
@@ -164,34 +169,32 @@ class Neteven_NetevenSync_Model_Config {
164
 
165
  // Neteven <=> Magento Order Statuses Mapping
166
  $netevenStatuses = $this->getNetevenOrderStatuses();
167
- $xml = array();
168
- $sortOrder = 100;
169
- foreach($netevenStatuses as $code => $label) {
170
- $state = $this->getMappedOrderState($code);
171
  $method = 'get' . ucfirst($state) . 'Statuses';
172
- $xml[] = sprintf(
173
- '<%s translate="label"><label>%s</label><frontend_type>select</frontend_type><source_model>netevensync/adminhtml_system_config_source_magentoOrderStatus::%s</source_model><sort_order>%s</sort_order><show_in_default>1</show_in_default><show_in_website>0</show_in_website><show_in_store>0</show_in_store></%s>',
174
- $code, $label, $method, $sortOrder, $code
175
  );
176
  $sortOrder++;
177
  }
178
- foreach($xml as $field) {
179
  $node = new Mage_Core_Model_Config_Element($field);
180
  $config->getNode('sections/netevensync/groups/order_mapping_neteven/fields')->appendChild($node);
181
  }
182
 
183
  // Magento <=> Neteven Order Statuses Mapping
184
  $magentoStatuses = Mage::getSingleton('sales/order_config')->getStatuses();
185
- $xml = array();
186
- $sortOrder = 1000;
187
- foreach($magentoStatuses as $code => $label) {
188
  $xml[] = sprintf(
189
- '<%s translate="label"><label>%s</label><frontend_type>select</frontend_type><source_model>netevensync/adminhtml_system_config_source_netevenOrderStatus::toSelect</source_model><sort_order>%s</sort_order><show_in_default>1</show_in_default><show_in_website>0</show_in_website><show_in_store>0</show_in_store></%s>',
190
- $code, $label, $sortOrder, $code
191
  );
192
  $sortOrder++;
193
  }
194
- foreach($xml as $field) {
195
  $node = new Mage_Core_Model_Config_Element($field);
196
  $config->getNode('sections/netevensync/groups/order_mapping_magento/fields')->appendChild($node);
197
  }
@@ -203,15 +206,16 @@ class Neteven_NetevenSync_Model_Config {
203
  * @param bool $withLabel
204
  * @return array $availableProductTypes
205
  */
206
- public function getAvailableProductTypes($withLabel = false) {
 
207
  $availableProductTypes = array();
208
- $allProductTypes = Mage::getSingleton('catalog/product_type')->getOptionArray();
209
- $allowedProductTypes = array(
210
  Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
211
  Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
212
  );
213
- foreach($allProductTypes as $code => $label) {
214
- if(in_array($code, $allowedProductTypes)) {
215
  $availableProductTypes[$code] = ($withLabel) ? $label : $code;
216
  }
217
  }
@@ -223,10 +227,11 @@ class Neteven_NetevenSync_Model_Config {
223
  *
224
  * @return array
225
  */
226
- public function getNetevenOrderStatuses() {
 
227
  $confOptions = Mage::getConfig()->getNode('netevensync/order_statuses')->asArray();
228
- $options = array();
229
- foreach($confOptions as $code => $label) {
230
  $options[$code] = Mage::helper("netevensync")->__($label);
231
  }
232
  return $options;
@@ -237,7 +242,8 @@ class Neteven_NetevenSync_Model_Config {
237
  *
238
  * @return array
239
  */
240
- public function getSuccessStatusResponse() {
 
241
  return array(
242
  'Accepted',
243
  'Inserted',
@@ -252,23 +258,24 @@ class Neteven_NetevenSync_Model_Config {
252
  * @param string $attributeCode
253
  * @return mixed
254
  */
255
- public function getMappedAddressAttributeCode($attributeCode) {
 
256
  $attributeCodes = array(
257
- 'prefix' => 'na',
258
- 'firstname' => 'first_name',
259
  'middlename' => 'na',
260
- 'lastname' => 'last_name',
261
- 'suffix' => 'na',
262
- 'company' => 'company',
263
- 'street' => array('address1', 'address2'),
264
- 'city' => 'city_name',
265
  'country_id' => 'country_code',
266
- 'region' => 'na',
267
- 'region_id' => 'na',
268
- 'postcode' => 'postal_code',
269
- 'telephone' => 'phone',
270
- 'fax' => 'fax',
271
- 'vat_id' => 'na',
272
  );
273
  return $attributeCodes[$attributeCode];
274
  }
@@ -281,30 +288,28 @@ class Neteven_NetevenSync_Model_Config {
281
  */
282
  public function getCountryIdForMarketPlaceId($marketPlaceId)
283
  {
284
- $mappingCsv = Mage::getModuleDir('etc', 'Neteven_NetevenSync') . DS . 'marketplace_country.csv';
285
- $io = new Varien_File_Csv();
286
- $mapping = $io->getDataPairs($mappingCsv);
287
 
288
- if(isset($mapping[$marketPlaceId])) {
289
- return $mapping[$marketPlaceId];
290
  }
291
 
292
  return 'FR';
293
  }
294
 
295
-
296
  /**
297
  * Retrieve Magento payment method based on Neteven payment code
298
  *
299
  * @param string $paymentCode
300
  * @return array
301
  */
302
- public function getMappedPaymentCode($paymentCode) {
 
303
  $confOptions = Mage::getConfig()->getNode('netevensync/payment_methods')->asArray();
304
- if(isset($confOptions[$paymentCode])) {
305
  return $confOptions[$paymentCode];
306
- }
307
- else return 'neteven';
308
  }
309
 
310
  /**
@@ -316,7 +321,8 @@ class Neteven_NetevenSync_Model_Config {
316
  * @param string $source
317
  * @return string
318
  */
319
- public function getMappedOrderStatus($statusCode, $source = 'neteven') {
 
320
  return Mage::getStoreConfig('netevensync/order_mapping_' . $source . '/' . $statusCode);
321
  }
322
 
@@ -326,16 +332,17 @@ class Neteven_NetevenSync_Model_Config {
326
  * @param string $statusCode
327
  * @return string
328
  */
329
- public function getMappedOrderState($statusCode) {
 
330
  $states = array(
331
- self::NETEVENSYNC_ORDER_STATUS_TOCONFIRM => Mage_Sales_Model_Order::STATE_NEW,
332
- self::NETEVENSYNC_ORDER_STATUS_CONFIRMED => Mage_Sales_Model_Order::STATE_PROCESSING,
333
- self::NETEVENSYNC_ORDER_STATUS_SHIPPED => Mage_Sales_Model_Order::STATE_PROCESSING,
334
- self::NETEVENSYNC_ORDER_STATUS_CANCELED => Mage_Sales_Model_Order::STATE_CANCELED,
335
- self::NETEVENSYNC_ORDER_STATUS_REFUNDED => Mage_Sales_Model_Order::STATE_CLOSED,
336
  );
337
 
338
- if(isset($states[$statusCode])) {
339
  return $states[$statusCode];
340
  }
341
 
@@ -347,7 +354,8 @@ class Neteven_NetevenSync_Model_Config {
347
  *
348
  * @return array
349
  */
350
- public function getAllowedNetevenOrderStatesForImport(){
 
351
  return array(
352
  self::NETEVENSYNC_ORDER_STATUS_CONFIRMED,
353
  self::NETEVENSYNC_ORDER_STATUS_SHIPPED,
@@ -363,12 +371,12 @@ class Neteven_NetevenSync_Model_Config {
363
  public function getInventoryPriceSpecificFields()
364
  {
365
  $priceSpecificFields = array();
366
- $specificFields = Mage::getConfig()->getNode('netevensync/specific_fields')->asArray();
367
 
368
- foreach($specificFields as $code => $label) {
369
- if(strstr($code, 'price_')) { // If field is if type 'price'
370
  $attributeCode = Mage::getStoreConfig('netevensync/inventory/' . $code);
371
- if($attributeCode && $attributeCode != '') {
372
  $priceSpecificFields[$label] = $attributeCode;
373
  }
374
  }
@@ -385,9 +393,9 @@ class Neteven_NetevenSync_Model_Config {
385
  public function getInventoryLanguages()
386
  {
387
  $inventoryLanguages = array();
388
- $languages = explode(',', Mage::getConfig()->getNode('netevensync/inventory_languages'));
389
 
390
- foreach($languages as $language) {
391
  $inventoryLanguages[trim($language)] = trim($language);
392
  }
393
 
@@ -402,11 +410,11 @@ class Neteven_NetevenSync_Model_Config {
402
  public function getConfiguredInventoryLanguages()
403
  {
404
  $configCollection = Mage::getResourceModel('core/config_data_collection')
405
- ->addFieldToFilter('path', 'netevensync/inventory/language');
406
 
407
  $configuredInventoryLanguages = array();
408
- foreach($configCollection as $configItem) {
409
- if(!is_null($configItem->getValue())) {
410
  $configuredInventoryLanguages[$configItem->getScopeId()] = $configItem->getValue();
411
  }
412
  }
@@ -421,24 +429,70 @@ class Neteven_NetevenSync_Model_Config {
421
  */
422
  public function getMarketplacesCountries()
423
  {
424
- $marketplacesCountries = array();
425
-
426
- // Load pdm_mapping.xml file, push it into config and retrieve its config array
427
- $config = Mage::getConfig();
428
- $config->loadModulesConfiguration('pdm_mapping.xml', $config);
429
- $mappingConfig = $config->getNode('netevensync/pdm_mapping')->asArray();
430
-
431
- // Populate $marketplacesCountries
432
- foreach($mappingConfig as $countryCode => $marketplaces) {
433
- $marketplaces = explode(',', $marketplaces);
434
- foreach($marketplaces as $marketplace) {
435
- $marketplacesCountries[trim($marketplace)] = strtolower($countryCode);
436
- }
437
- }
438
 
 
439
  return $marketplacesCountries;
440
  }
441
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
442
 
443
  /**
444
  * Retrieve configured store ID for a marketplace ID
@@ -448,29 +502,55 @@ class Neteven_NetevenSync_Model_Config {
448
  */
449
  public function getStoreIdForMarketplace($marketplace)
450
  {
451
- if(!isset($this->_storeIdsForMarketplaces[$marketplace])) {
 
 
 
 
 
452
  $countryForMarketplace = false;
453
- $marketplaceCountries = $this->getMarketplacesCountries();
454
 
455
- foreach($marketplaceCountries as $configMarketplace => $countryCode) {
456
- if($marketplace == $configMarketplace) {
 
457
  $countryForMarketplace = $countryCode;
458
  break;
459
  }
460
  }
461
 
462
- if($countryForMarketplace) {
463
- $configData = Mage::getResourceModel('core/config_data_collection')
464
- ->addFieldToFilter('path', 'netevensync/order/pdm_mapping')
465
- ->addFieldToFilter('value', $countryForMarketplace)
466
- ->getFirstItem();
467
-
468
- if($configData && $configData->getConfigId()) {
469
- $this->_storeIdsForMarketplaces[$marketplace] = $configData->getScopeId();
 
 
 
 
 
 
470
  }
 
 
471
  }
472
  }
473
 
474
- return (isset($this->_storeIdsForMarketplaces[$marketplace])) ? $this->_storeIdsForMarketplaces[$marketplace] : false;
 
 
475
  }
 
 
 
 
 
 
 
 
 
 
476
  }
1
  <?php
2
+
3
  /**
4
  * Config model
5
  *
9
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
11
  */
12
+ class Neteven_NetevenSync_Model_Config
13
+ {
14
 
15
  /**
16
  * Process types codes
17
  */
18
  const NETEVENSYNC_PROCESS_INVENTORY_CODE = 'inventory';
19
+ const NETEVENSYNC_PROCESS_ORDER_CODE = 'order';
20
+ const NETEVENSYNC_PROCESS_STOCK_CODE = 'stock';
21
 
22
  /**
23
  * Export modes codes
24
  */
25
+ const NETEVENSYNC_EXPORT_FULL = 'full';
26
  const NETEVENSYNC_EXPORT_INCREMENTAL = 'incremental';
27
 
28
  /**
34
  /**
35
  * Page Size for chunks in Neteven API calls
36
  */
37
+ const NETEVENSYNC_CHUNK_SIZE = 150;
38
  const NETEVENSYNC_CHUNK_SIZE_AJAX = 20;
39
 
40
  /**
42
  */
43
  const NETEVENSYNC_ORDER_STATUS_TOCONFIRM = 'toConfirm';
44
  const NETEVENSYNC_ORDER_STATUS_CONFIRMED = 'Confirmed';
45
+ const NETEVENSYNC_ORDER_STATUS_SHIPPED = 'Shipped';
46
+ const NETEVENSYNC_ORDER_STATUS_CANCELED = 'Canceled';
47
+ const NETEVENSYNC_ORDER_STATUS_REFUNDED = 'Refunded';
48
 
49
  /**
50
  * Neteven Sandbox marketplace ID for orders
51
  */
52
  const SANDBOX_MARKETPLACE_ID = '19';
53
+ const INVENTORY_SKUFAMILY_CODE = 'sku_family';
 
54
  const INVENTORY_SKUFAMILY_AUTOMATIC_KEY = '_automatic';
55
 
56
  /**
65
  *
66
  * @return array
67
  */
68
+ public function getProcessCodes()
69
+ {
70
  return array(
71
  self::NETEVENSYNC_PROCESS_INVENTORY_CODE,
72
  self::NETEVENSYNC_PROCESS_ORDER_CODE,
79
  *
80
  * @return array
81
  */
82
+ public function getDirs()
83
+ {
84
  return array(
85
  self::NETEVENSYNC_DIR_IMPORT,
86
  self::NETEVENSYNC_DIR_EXPORT,
92
  *
93
  * @return array || string $errors
94
  */
95
+ public function getErrorLabels($errorCode = null)
96
+ {
97
  $errorCodes = array(
98
+ self::NETEVENSYNC_PROCESS_INVENTORY_CODE => Mage::helper('netevensync')->__('Inventory'),
99
+ self::NETEVENSYNC_PROCESS_ORDER_CODE => Mage::helper('netevensync')->__('Orders'),
100
+ self::NETEVENSYNC_PROCESS_STOCK_CODE => Mage::helper('netevensync')->__('Stocks'),
101
  );
102
 
103
+ if ($errorCode && isset($errorCodes[$errorCode])) {
104
  return $errorCodes[$errorCode];
105
  }
106
 
112
  *
113
  * @return array
114
  */
115
+ public function getDisallowedAttributes()
116
+ {
117
  return array_keys(Mage::getConfig()->getNode('netevensync/disallowed_attributes')->asArray());
118
  }
119
 
121
  * Append dynamic fields to system config
122
  * @param Varien_Event_Observer $observer
123
  */
124
+ public function appendConfigNodes(Varien_Event_Observer $observer)
125
+ {
126
 
127
  $config = $observer->getConfig();
128
 
129
  // Specific Fields Mapping
130
  $specificFields = Mage::getConfig()->getNode('netevensync/specific_fields')->asArray();
131
+ $xml = array();
132
+ $sortOrder = 100;
133
+ foreach ($specificFields as $code => $label) {
134
 
135
+ switch ($code) {
136
  case 'ean':
137
  $comment = '<comment>' . Mage::helper('netevensync')->__('EAN code is highly recommended') . '</comment>';
138
  break;
148
 
149
  $sourceModel = 'netevensync/adminhtml_system_config_source_attribute';
150
 
151
+ if (strstr($code, 'price_')) { // If field is if type 'price'
152
  $sourceModel = 'netevensync/adminhtml_system_config_source_attribute_price';
153
  }
154
 
157
  }
158
 
159
  $xml[] = sprintf(
160
+ '<%s translate="label"><label>%s</label><frontend_type>select</frontend_type><source_model>%s::toSelect</source_model><sort_order>%s</sort_order><show_in_default>1</show_in_default><show_in_website>0</show_in_website><show_in_store>0</show_in_store>%s<depends><enable>1</enable></depends></%s>', $code, $label, $sourceModel, $sortOrder, $comment, $code
 
161
  );
162
  $sortOrder++;
163
  }
164
+ foreach ($xml as $field) {
165
  $node = new Mage_Core_Model_Config_Element($field);
166
  $config->getNode('sections/netevensync/groups/inventory/fields')->appendChild($node);
167
  }
169
 
170
  // Neteven <=> Magento Order Statuses Mapping
171
  $netevenStatuses = $this->getNetevenOrderStatuses();
172
+ $xml = array();
173
+ $sortOrder = 100;
174
+ foreach ($netevenStatuses as $code => $label) {
175
+ $state = $this->getMappedOrderState($code);
176
  $method = 'get' . ucfirst($state) . 'Statuses';
177
+ $xml[] = sprintf(
178
+ '<%s translate="label"><label>%s</label><frontend_type>select</frontend_type><source_model>netevensync/adminhtml_system_config_source_magentoOrderStatus::%s</source_model><sort_order>%s</sort_order><show_in_default>1</show_in_default><show_in_website>0</show_in_website><show_in_store>0</show_in_store></%s>', $code, $label, $method, $sortOrder, $code
 
179
  );
180
  $sortOrder++;
181
  }
182
+ foreach ($xml as $field) {
183
  $node = new Mage_Core_Model_Config_Element($field);
184
  $config->getNode('sections/netevensync/groups/order_mapping_neteven/fields')->appendChild($node);
185
  }
186
 
187
  // Magento <=> Neteven Order Statuses Mapping
188
  $magentoStatuses = Mage::getSingleton('sales/order_config')->getStatuses();
189
+ $xml = array();
190
+ $sortOrder = 1000;
191
+ foreach ($magentoStatuses as $code => $label) {
192
  $xml[] = sprintf(
193
+ '<%s translate="label"><label>%s</label><frontend_type>select</frontend_type><source_model>netevensync/adminhtml_system_config_source_netevenOrderStatus::toSelect</source_model><sort_order>%s</sort_order><show_in_default>1</show_in_default><show_in_website>0</show_in_website><show_in_store>0</show_in_store></%s>', $code, $label, $sortOrder, $code
 
194
  );
195
  $sortOrder++;
196
  }
197
+ foreach ($xml as $field) {
198
  $node = new Mage_Core_Model_Config_Element($field);
199
  $config->getNode('sections/netevensync/groups/order_mapping_magento/fields')->appendChild($node);
200
  }
206
  * @param bool $withLabel
207
  * @return array $availableProductTypes
208
  */
209
+ public function getAvailableProductTypes($withLabel = false)
210
+ {
211
  $availableProductTypes = array();
212
+ $allProductTypes = Mage::getSingleton('catalog/product_type')->getOptionArray();
213
+ $allowedProductTypes = array(
214
  Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
215
  Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
216
  );
217
+ foreach ($allProductTypes as $code => $label) {
218
+ if (in_array($code, $allowedProductTypes)) {
219
  $availableProductTypes[$code] = ($withLabel) ? $label : $code;
220
  }
221
  }
227
  *
228
  * @return array
229
  */
230
+ public function getNetevenOrderStatuses()
231
+ {
232
  $confOptions = Mage::getConfig()->getNode('netevensync/order_statuses')->asArray();
233
+ $options = array();
234
+ foreach ($confOptions as $code => $label) {
235
  $options[$code] = Mage::helper("netevensync")->__($label);
236
  }
237
  return $options;
242
  *
243
  * @return array
244
  */
245
+ public function getSuccessStatusResponse()
246
+ {
247
  return array(
248
  'Accepted',
249
  'Inserted',
258
  * @param string $attributeCode
259
  * @return mixed
260
  */
261
+ public function getMappedAddressAttributeCode($attributeCode)
262
+ {
263
  $attributeCodes = array(
264
+ 'prefix' => 'na',
265
+ 'firstname' => 'first_name',
266
  'middlename' => 'na',
267
+ 'lastname' => 'last_name',
268
+ 'suffix' => 'na',
269
+ 'company' => 'company',
270
+ 'street' => array('address1', 'address2'),
271
+ 'city' => 'city_name',
272
  'country_id' => 'country_code',
273
+ 'region' => 'na',
274
+ 'region_id' => 'na',
275
+ 'postcode' => 'postal_code',
276
+ 'telephone' => 'phone',
277
+ 'fax' => 'fax',
278
+ 'vat_id' => 'na',
279
  );
280
  return $attributeCodes[$attributeCode];
281
  }
288
  */
289
  public function getCountryIdForMarketPlaceId($marketPlaceId)
290
  {
291
+ $mapping = $this->getMarketplacesCountries();
 
 
292
 
293
+ if (isset($mapping[$marketPlaceId])) {
294
+ return strtoupper($mapping[$marketPlaceId]);
295
  }
296
 
297
  return 'FR';
298
  }
299
 
 
300
  /**
301
  * Retrieve Magento payment method based on Neteven payment code
302
  *
303
  * @param string $paymentCode
304
  * @return array
305
  */
306
+ public function getMappedPaymentCode($paymentCode)
307
+ {
308
  $confOptions = Mage::getConfig()->getNode('netevensync/payment_methods')->asArray();
309
+ if (isset($confOptions[$paymentCode])) {
310
  return $confOptions[$paymentCode];
311
+ } else
312
+ return 'neteven';
313
  }
314
 
315
  /**
321
  * @param string $source
322
  * @return string
323
  */
324
+ public function getMappedOrderStatus($statusCode, $source = 'neteven')
325
+ {
326
  return Mage::getStoreConfig('netevensync/order_mapping_' . $source . '/' . $statusCode);
327
  }
328
 
332
  * @param string $statusCode
333
  * @return string
334
  */
335
+ public function getMappedOrderState($statusCode)
336
+ {
337
  $states = array(
338
+ self::NETEVENSYNC_ORDER_STATUS_TOCONFIRM => Mage_Sales_Model_Order::STATE_NEW,
339
+ self::NETEVENSYNC_ORDER_STATUS_CONFIRMED => Mage_Sales_Model_Order::STATE_PROCESSING,
340
+ self::NETEVENSYNC_ORDER_STATUS_SHIPPED => Mage_Sales_Model_Order::STATE_COMPLETE,
341
+ self::NETEVENSYNC_ORDER_STATUS_CANCELED => Mage_Sales_Model_Order::STATE_CANCELED,
342
+ self::NETEVENSYNC_ORDER_STATUS_REFUNDED => Mage_Sales_Model_Order::STATE_CLOSED,
343
  );
344
 
345
+ if (isset($states[$statusCode])) {
346
  return $states[$statusCode];
347
  }
348
 
354
  *
355
  * @return array
356
  */
357
+ public function getAllowedNetevenOrderStatesForImport()
358
+ {
359
  return array(
360
  self::NETEVENSYNC_ORDER_STATUS_CONFIRMED,
361
  self::NETEVENSYNC_ORDER_STATUS_SHIPPED,
371
  public function getInventoryPriceSpecificFields()
372
  {
373
  $priceSpecificFields = array();
374
+ $specificFields = Mage::getConfig()->getNode('netevensync/specific_fields')->asArray();
375
 
376
+ foreach ($specificFields as $code => $label) {
377
+ if (strstr($code, 'price_')) { // If field is if type 'price'
378
  $attributeCode = Mage::getStoreConfig('netevensync/inventory/' . $code);
379
+ if ($attributeCode && $attributeCode != '') {
380
  $priceSpecificFields[$label] = $attributeCode;
381
  }
382
  }
393
  public function getInventoryLanguages()
394
  {
395
  $inventoryLanguages = array();
396
+ $languages = explode(',', Mage::getConfig()->getNode('netevensync/inventory_languages'));
397
 
398
+ foreach ($languages as $language) {
399
  $inventoryLanguages[trim($language)] = trim($language);
400
  }
401
 
410
  public function getConfiguredInventoryLanguages()
411
  {
412
  $configCollection = Mage::getResourceModel('core/config_data_collection')
413
+ ->addFieldToFilter('path', 'netevensync/inventory/language');
414
 
415
  $configuredInventoryLanguages = array();
416
+ foreach ($configCollection as $configItem) {
417
+ if (!is_null($configItem->getValue())) {
418
  $configuredInventoryLanguages[$configItem->getScopeId()] = $configItem->getValue();
419
  }
420
  }
429
  */
430
  public function getMarketplacesCountries()
431
  {
432
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
433
+ $logger = Mage::helper('netevensync/logger');
434
+ $logger->info("Read marketplaces / countries mapping from CSV");
435
+
436
+ // Mapping
437
+ $mappingCsv = Mage::getModuleDir('etc', 'Neteven_NetevenSync') . DS . 'marketplace_country.csv';
438
+ $io = new Varien_File_Csv();
439
+ $mapping = $io->getDataPairs($mappingCsv, 0, 2);
 
 
 
 
 
 
440
 
441
+ $marketplacesCountries = array_map('strtolower', $mapping);
442
  return $marketplacesCountries;
443
  }
444
 
445
+ /**
446
+ * Retrieve marketplaces as option array
447
+ * @return array
448
+ */
449
+ public function getMarketplacesAsOptionArray()
450
+ {
451
+ // CSV header:
452
+ // ID, Marketplace name, Country code
453
+ $mappingCsv = Mage::getModuleDir('etc', 'Neteven_NetevenSync') . DS . 'marketplace_country.csv';
454
+ $csv = new Varien_File_Csv;
455
+ $lines = $csv->getData($mappingCsv);
456
+ $options = array();
457
+
458
+ foreach ($lines as $line) {
459
+ $options[] = array(
460
+ 'value' => $line[0],
461
+ 'label' => sprintf("%s (%s / #%s)", $line[1], $line[2], $line[0]),
462
+ );
463
+ }
464
+
465
+ return $options;
466
+ }
467
+
468
+ /**
469
+ * Retrieve the country selected with the marketplace in configuration
470
+ * @param int $marketplaceId
471
+ * @return string
472
+ */
473
+ public function getAddressCountryForMarketPlaceId($marketplaceId)
474
+ {
475
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
476
+ $logger = Mage::helper('netevensync/logger');
477
+ $logger->info("Get the country selected in configuration for the marketplace.");
478
+
479
+ // Loop stores
480
+ $stores = Mage::app()->getStores(false);
481
+ foreach ($stores as $store) {
482
+ $config = Mage::getStoreConfig('netevensync/order/pdm_mapping', $store);
483
+ if (null !== $config) {
484
+ $mapping = unserialize($config);
485
+ // Loop mapping
486
+ foreach ($mapping as $map) {
487
+ if ((int) $map['pdm'] === (int) $marketplaceId) {
488
+ return strtoupper($map['country']);
489
+ }
490
+ }
491
+ }
492
+ }
493
+
494
+ return $this->getCountryIdForMarketPlaceId($marketplaceId);
495
+ }
496
 
497
  /**
498
  * Retrieve configured store ID for a marketplace ID
502
  */
503
  public function getStoreIdForMarketplace($marketplace)
504
  {
505
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
506
+ $logger = Mage::helper('netevensync/logger');
507
+ $logger->step("Find store ID according to marketplace ID")->up();
508
+ $logger->data("marketplace_id", $marketplace);
509
+
510
+ if (!$logger->condition("Store ID already found for this marketplace?", isset($this->_storeIdsForMarketplaces[$marketplace]))) {
511
  $countryForMarketplace = false;
512
+ $marketplaceCountries = $this->getMarketplacesCountries();
513
 
514
+ foreach ($marketplaceCountries as $configMarketplace => $countryCode) {
515
+ if ($marketplace == $configMarketplace) {
516
+ $logger->result($countryCode, "Country code");
517
  $countryForMarketplace = $countryCode;
518
  break;
519
  }
520
  }
521
 
522
+ if ($countryForMarketplace) {
523
+ $logger->info("Loop configuration to get the mapping store/marketplace");
524
+
525
+ // Loop stores
526
+ $stores = Mage::app()->getStores(false);
527
+ foreach ($stores as $store) {
528
+ $config = Mage::getStoreConfig('netevensync/order/pdm_mapping', $store);
529
+ if (null !== $config) {
530
+ $mapping = unserialize($config);
531
+ // Loop mapping
532
+ foreach ($mapping as $map) {
533
+ $this->_storeIdsForMarketplaces[$map['pdm']] = (int) $store->getId();
534
+ }
535
+ }
536
  }
537
+ } else {
538
+ $logger->err("Country code not found");
539
  }
540
  }
541
 
542
+ $storeId = (isset($this->_storeIdsForMarketplaces[$marketplace])) ? $this->_storeIdsForMarketplaces[$marketplace] : false;
543
+ $logger->result($storeId, "Store ID")->down();
544
+ return $storeId;
545
  }
546
+
547
+ /**
548
+ * Retrieve the status when we can invoice the order
549
+ * @return array
550
+ */
551
+ public function getInvoiceStatus()
552
+ {
553
+ return explode(',', Mage::getStoreConfig('netevensync/order/invoice_status'));
554
+ }
555
+
556
  }
app/code/community/Neteven/NetevenSync/Model/Config/Process.php CHANGED
@@ -29,7 +29,7 @@ class Neteven_NetevenSync_Model_Config_Process extends Mage_Core_Model_Abstract
29
  }
30
 
31
  /**
32
- * Retrieve next sync as timestamp
33
  *
34
  * @return int
35
  */
29
  }
30
 
31
  /**
32
+ * Retrieve next sync as timestamp (UTC)
33
  *
34
  * @return int
35
  */
app/code/community/Neteven/NetevenSync/Model/Cron.php CHANGED
@@ -9,9 +9,9 @@
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
  class Neteven_NetevenSync_Model_Cron {
12
-
13
  protected $_config;
14
-
15
  /**
16
  * Retrieve config singleton
17
  *
@@ -23,28 +23,28 @@ class Neteven_NetevenSync_Model_Cron {
23
  }
24
  return $this->_config;
25
  }
26
-
27
  /**
28
  * Run all processes
29
- *
30
  * @return bool
31
  */
32
  public function runAllProcesses() {
33
  $processTypes = $this->getConfig()->getProcessCodes();
34
  $dirs = $this->getConfig()->getDirs();
35
  $mode = Neteven_NetevenSync_Model_Config::NETEVENSYNC_EXPORT_INCREMENTAL;
36
-
37
  $success = true;
38
-
39
  foreach($processTypes as $processType) {
40
 
41
  if($this->canRunProcess($processType)) {
42
  $process = Mage::getModel('netevensync/config_process')->loadByProcessCode($processType);
43
- $process->setIsRunning(true)->save();
44
-
45
  foreach($dirs as $dir) {
46
  $model = Mage::getModel('netevensync/process_' . $processType);
47
- $processSuccess = $model->runProcess($mode, null, false, $dir);
48
  if(!$processSuccess) {
49
  $success = false;
50
  }
@@ -52,46 +52,80 @@ class Neteven_NetevenSync_Model_Cron {
52
  $this->_finishProcess($process);
53
  }
54
  }
55
-
56
  return $success;
57
  }
58
-
59
- /**
60
- * Check if process can be launched
61
- *
62
- * @param string $processType
63
- * @return bool
64
- */
65
- public function canRunProcess($processType) {
66
- if(!Mage::getStoreConfigFlag('netevensync/' . $processType . '/enable')) {
67
- return false;
68
- }
69
- $process = Mage::getModel('netevensync/config_process')->loadByProcessCode($processType);
70
- $nextSyncTimestamp = $process->getNextSyncTimestamp();
71
- $now = Mage::getModel('core/date')->timestamp(time());
72
- $isRunning = (bool) $process->getIsRunning();
73
-
74
- if($now >= $nextSyncTimestamp && !$isRunning) {
75
- return true;
76
- }
77
-
78
- return false;
79
- }
80
-
81
- /**
82
- * Run last operations when process is done
83
- *
84
- * @param Neteven_NetevenSync_Model_Config_Process
85
- */
86
- protected function _finishProcess($process) {
87
- $frequency = Mage::getStoreConfig('netevensync/' . $process->getProcessCode() . '/frequency'); // In hours
88
- $nextSyncTimestamp = Mage::getModel('core/date')->timestamp(time()) + $frequency * 3600;
89
- $nextSync = date('Y-m-d H:i:s', $nextSyncTimestamp);
90
- $lastSync = date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()));
91
-
92
- $process->setIsRunning(false)
93
- ->setNextSync($nextSync)
94
- ->setLastSync($lastSync)
95
- ->save();
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  }
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
  class Neteven_NetevenSync_Model_Cron {
12
+
13
  protected $_config;
14
+
15
  /**
16
  * Retrieve config singleton
17
  *
23
  }
24
  return $this->_config;
25
  }
26
+
27
  /**
28
  * Run all processes
29
+ *
30
  * @return bool
31
  */
32
  public function runAllProcesses() {
33
  $processTypes = $this->getConfig()->getProcessCodes();
34
  $dirs = $this->getConfig()->getDirs();
35
  $mode = Neteven_NetevenSync_Model_Config::NETEVENSYNC_EXPORT_INCREMENTAL;
36
+
37
  $success = true;
38
+
39
  foreach($processTypes as $processType) {
40
 
41
  if($this->canRunProcess($processType)) {
42
  $process = Mage::getModel('netevensync/config_process')->loadByProcessCode($processType);
43
+ $process->setIsRunning(true)->save();
44
+
45
  foreach($dirs as $dir) {
46
  $model = Mage::getModel('netevensync/process_' . $processType);
47
+ $processSuccess = $model->runProcess($mode, null, false, $dir);
48
  if(!$processSuccess) {
49
  $success = false;
50
  }
52
  $this->_finishProcess($process);
53
  }
54
  }
55
+
56
  return $success;
57
  }
58
+
59
+ /**
60
+ * Check if process can be launched
61
+ *
62
+ * @param string $processType
63
+ * @return bool
64
+ */
65
+ public function canRunProcess($processType)
66
+ {
67
+ if (!Mage::getStoreConfigFlag('netevensync/' . $processType . '/enable')) {
68
+ return false;
69
+ }
70
+
71
+ // The process
72
+ $process = Mage::getModel('netevensync/config_process')->loadByProcessCode($processType);
73
+
74
+ // Is running?
75
+ if ($process->getIsRunning()) {
76
+ return false;
77
+ }
78
+
79
+ /*
80
+ * Test dates in UTC only
81
+ */
82
+ $now = time(); // UTC because Magento forces this timezone
83
+ $startDatetime = strtotime(Mage::getStoreConfig('netevensync/' . $processType . '/start_datetime')); // UTC
84
+ $nextSyncTimestamp = $process->getNextSyncTimestamp(); // UTC
85
+
86
+ if ($now < $startDatetime || $now < $nextSyncTimestamp) {
87
+ return false;
88
+ }
89
+
90
+ /*
91
+ * Test CRON schedule
92
+ */
93
+ $frequency = Mage::getStoreConfig('netevensync/' . $processType . '/frequency');
94
+ switch ($frequency) {
95
+ case '0.25':
96
+ $expr = '*/15 * * * *';
97
+ break;
98
+ case '0.5':
99
+ $expr = '*/30 * * * *';
100
+ break;
101
+ case '1':
102
+ $expr = '0 * * * *';
103
+ break;
104
+ case '24':
105
+ $expr = '0 0 * * *';
106
+ break;
107
+ default: /* 2, 4, 12 */
108
+ $expr = sprintf('0 */%d * * *', $frequency);
109
+ break;
110
+ }
111
+ $cron = Mage::getModel('cron/schedule');
112
+ $cron->setCronExpr($expr);
113
+
114
+ return $cron->trySchedule(time());
115
+ }
116
+
117
+ /**
118
+ * Run last operations when process is done
119
+ *
120
+ * @param Neteven_NetevenSync_Model_Config_Process
121
+ */
122
+ protected function _finishProcess($process)
123
+ {
124
+ $process
125
+ ->setIsRunning(false)
126
+ ->setLastSync(Mage::getSingleton('core/date')->gmtDate())
127
+ ->save()
128
+ ;
129
+ }
130
+
131
  }
app/code/community/Neteven/NetevenSync/Model/Observer.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Observer
4
  *
@@ -8,125 +9,127 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Model_Observer {
12
-
13
- /**
14
- * Register increment based on its process type
15
- *
16
- * @param Varien_Event_Observer $observer
17
- */
18
- public function registerIncrement(Varien_Event_Observer $observer) {
19
- $args = Mage::helper('netevensync')->getObserverArgs($observer, get_class($this), __FUNCTION__);
20
- $object = $observer->getEvent()->getDataObject();
21
-
22
- /**
23
- * Manage events that lead to object deletion on Neteven platform
24
- */
25
- $deleteableEvents = array(
26
- 'catalog_product_delete_after',
27
- );
28
-
29
- if(in_array($observer->getEvent()->getName(), $deleteableEvents)) {
30
- $object->setToDelete(true);
31
- }
32
-
33
- Mage::getModel('netevensync/process_' . $args->getProcessType())->registerIncrement($object, true);
34
- }
35
-
36
- /**
37
- * Register increment for product attribute mass update
38
- *
39
- * @param Varien_Event_Observer $observer
40
- */
41
- public function registerMultiIncrement(Varien_Event_Observer $observer) {
42
- $attributes = $observer->getAttributesData();
43
- $productIds = $observer->getProductIds();
44
-
45
- foreach($productIds as $productId) {
46
- $object = new Varien_Object();
47
- $object->setId($productId);
48
-
49
- if(isset($attributes['status'])) {
50
- $object->setStatus($attributes['status']);
51
- }
52
-
53
- Mage::getModel('netevensync/process_inventory')->registerIncrement($object, true);
54
- }
55
- }
56
-
57
- /**
58
- * Add notice if export Neteven Selection has changed
59
- *
60
- * @param Varien_Event_Observer $observer
61
- */
62
- public function addNoticeConfigChange(Varien_Event_Observer $observer) {
63
- $config = $observer->getObject()->getData();
64
- $flagForceStock = false;
65
-
66
- if(isset($config['section']) && $config['section'] == 'netevensync') {
67
- $changedConfig = array();
68
- $groupsToCheck = array(
69
- 'inventory' => Mage::helper('netevensync')->__('Inventory Synchronization'),
70
- 'stock' => Mage::helper('netevensync')->__('Stocks Synchronization'),
71
- );
72
-
73
- foreach($groupsToCheck as $code => $label) {
74
- $currentConfig = Mage::getStoreConfig('netevensync/' . $code . '/selected');
75
- if(!isset($config['groups'][$code]['fields']['selected']['value'])) {
76
- continue;
77
- }
78
- $newConfig = $config['groups'][$code]['fields']['selected']['value'];
79
- if($currentConfig != $newConfig) {
80
- $changedConfig[$code] = $label;
81
- if($newConfig == 1) {
82
- $flagForceStock = true;
83
- }
84
- }
85
- }
86
-
87
- if(count($changedConfig) > 0) {
88
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('netevensync')->__('A full Neteven synchronization may be required for the following: %s.', implode(', ', $changedConfig)));
89
- }
90
-
91
- // Save config for forcing export of not-in-selection products as out-of-stock
92
- $path = 'netevensync/force_stock';
93
- $config = Mage::getModel('core/config_data')->getCollection()
94
- ->addFieldToFilter('path', $path)
95
- ->getFirstItem();
96
-
97
- $data = array(
98
- 'path' => $path,
99
- 'scope' => 'default',
100
- 'scope_id' => 0,
101
- 'value' => ($flagForceStock) ? 1 : 0,
102
- );
103
-
104
- $config->setData($data);
105
- $config->save();
106
- }
107
- }
108
-
109
-
110
- /**
111
- * Update next sync from each process
112
- *
113
- * @param Varien_Event_Observer $observer
114
- */
115
- public function updateNextSync(Varien_Event_Observer $observer) {
116
- $config = $observer->getObject()->getData();
117
-
118
- if(isset($config['section']) && $config['section'] == 'netevensync') {
119
- $processTypes = Mage::getModel('netevensync/config_process')->getCollection();
120
- foreach($processTypes as $processType) {
121
- $startTime = Mage::getStoreConfig('netevensync/' . $processType->getProcessCode() . '/start'); // In hours
122
- $todayStartTime = Mage::getModel('core/date')->timestamp(date('Y-m-d')) + $startTime * 3600;
123
- $now = Mage::getModel('core/date')->timestamp(time());
124
- $nextSyncTimestamp = ($todayStartTime <= $now) ? $todayStartTime + 86400 : $todayStartTime; // If today's start time has passed, next sync will be tomorrow at the same time
125
-
126
- $nextSync = date('Y-m-d H:i:s', $nextSyncTimestamp);
127
-
128
- $processType->setNextSync($nextSync)->save();
129
- }
130
- }
131
- }
132
- }
 
 
1
  <?php
2
+
3
  /**
4
  * Observer
5
  *
9
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
11
  */
12
+ class Neteven_NetevenSync_Model_Observer
13
+ {
14
+
15
+ /**
16
+ * Register increment based on its process type
17
+ *
18
+ * @param Varien_Event_Observer $observer
19
+ */
20
+ public function registerIncrement(Varien_Event_Observer $observer)
21
+ {
22
+ $args = Mage::helper('netevensync')->getObserverArgs($observer, get_class($this), __FUNCTION__);
23
+ $object = $observer->getEvent()->getDataObject();
24
+
25
+ /**
26
+ * Manage events that lead to object deletion on Neteven platform
27
+ */
28
+ $deleteableEvents = array(
29
+ 'catalog_product_delete_after',
30
+ );
31
+
32
+ if (in_array($observer->getEvent()->getName(), $deleteableEvents)) {
33
+ $object->setToDelete(true);
34
+ }
35
+
36
+ Mage::getModel('netevensync/process_' . $args->getProcessType())->registerIncrement($object, true);
37
+ }
38
+
39
+ /**
40
+ * Register increment for product attribute mass update
41
+ *
42
+ * @param Varien_Event_Observer $observer
43
+ */
44
+ public function registerMultiIncrement(Varien_Event_Observer $observer)
45
+ {
46
+ $attributes = $observer->getAttributesData();
47
+ $productIds = $observer->getProductIds();
48
+
49
+ foreach ($productIds as $productId) {
50
+ $object = new Varien_Object();
51
+ $object->setId($productId);
52
+
53
+ if (isset($attributes['status'])) {
54
+ $object->setStatus($attributes['status']);
55
+ }
56
+
57
+ Mage::getModel('netevensync/process_inventory')->registerIncrement($object, true);
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Add notice if export Neteven Selection has changed
63
+ *
64
+ * @param Varien_Event_Observer $observer
65
+ */
66
+ public function addNoticeConfigChange(Varien_Event_Observer $observer)
67
+ {
68
+ $config = $observer->getObject()->getData();
69
+ $flagForceStock = false;
70
+
71
+ if (isset($config['section']) && $config['section'] == 'netevensync') {
72
+ $changedConfig = array();
73
+ $groupsToCheck = array(
74
+ 'inventory' => Mage::helper('netevensync')->__('Inventory Synchronization'),
75
+ 'stock' => Mage::helper('netevensync')->__('Stocks Synchronization'),
76
+ );
77
+
78
+ foreach ($groupsToCheck as $code => $label) {
79
+ $currentConfig = Mage::getStoreConfig('netevensync/' . $code . '/selected');
80
+ if (!isset($config['groups'][$code]['fields']['selected']['value'])) {
81
+ continue;
82
+ }
83
+ $newConfig = $config['groups'][$code]['fields']['selected']['value'];
84
+ if ($currentConfig != $newConfig) {
85
+ $changedConfig[$code] = $label;
86
+ if ($newConfig == 1) {
87
+ $flagForceStock = true;
88
+ }
89
+ }
90
+ }
91
+
92
+ if (count($changedConfig) > 0) {
93
+ Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('netevensync')->__('A full Neteven synchronization may be required for the following: %s.', implode(', ', $changedConfig)));
94
+ }
95
+
96
+ // Save config for forcing export of not-in-selection products as out-of-stock
97
+ $path = 'netevensync/force_stock';
98
+ $config = Mage::getModel('core/config_data')->getCollection()
99
+ ->addFieldToFilter('path', $path)
100
+ ->getFirstItem();
101
+
102
+ $data = array(
103
+ 'path' => $path,
104
+ 'scope' => 'default',
105
+ 'scope_id' => 0,
106
+ 'value' => ($flagForceStock) ? 1 : 0,
107
+ );
108
+
109
+ $config->setData($data);
110
+ $config->save();
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Add Neteven specific info in payment info block
116
+ *
117
+ * @param Varien_Event_Observer $observer
118
+ */
119
+ public function enrichPaymentInfoBlock(Varien_Event_Observer $observer)
120
+ {
121
+ $paymentCode = $observer->getPayment()->getMethodInstance()->getCode();
122
+
123
+ // If we're not dealing with neteven payment type, get out.
124
+ if ($paymentCode != 'neteven') {
125
+ return;
126
+ }
127
+
128
+ $netevenOrderLink = Mage::getModel('netevensync/process_order_link')
129
+ ->loadByMagentoOrderId($observer->getPayment()->getParentId());
130
+
131
+ $transport = $observer->getTransport();
132
+ $transport->setData('Marketplace', $netevenOrderLink->getNetevenMarketPlaceName());
133
+ }
134
+
135
+ }
app/code/community/Neteven/NetevenSync/Model/Process/Abstract.php CHANGED
@@ -8,313 +8,332 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- abstract class Neteven_NetevenSync_Model_Process_Abstract extends Mage_Core_Model_Abstract {
12
-
13
- protected $_processType;
14
- protected $_config;
15
- protected $_itemsProcessed = 0;
16
-
17
- /**
18
- * Initialize resource model
19
- */
20
- protected function _construct() {
21
- $this->_init('netevensync/process_' . $this->_processType);
22
- }
23
-
24
- /**
25
- * Retrieve config singleton
26
- *
27
- * @return Neteven_NetevenSync_Model_Config
28
- */
29
- public function getConfig(){
30
- if(is_null($this->_config)) {
31
- $this->_config = Mage::getSingleton('netevensync/config');
32
- }
33
- return $this->_config;
34
- }
35
-
36
- /**
37
- * Run process
38
- *
39
- * @param string $mode
40
- * @param mixed $processedPage
41
- * @param mixed $fromAjax
42
- * @return bool $success
43
- */
44
- public function runProcess($mode, $processedPage = null, $fromAjax = false, $dir) {
45
-
46
- $success = true;
47
- $collection = $this->getProcessCollection($mode, $fromAjax, true, $dir);
48
-
49
- if($collection && $collection->count()) {
50
- for($page = 1; $page <= $collection->getLastPageNumber(); $page++) {
51
- if($processedPage && $page == $processedPage || !$processedPage) {
52
- $success = $this->processPage($page, $collection, $dir, $mode);
53
- }
54
- }
55
- }
56
-
57
- if($fromAjax) {
58
- return array('success' => $success, 'items_processed' => $this->_itemsProcessed);
59
- }
60
-
61
- // If we're not in AJAX context, we finish the process
62
- $success = $this->finishProcess($mode, $dir);
63
-
64
- if($success) {
65
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('netevensync')->__('Process "%s" has been successfully executed.', $this->_processType));
66
- }
67
-
68
- else {
69
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('netevensync')->__('Not all items have been processed for "%s" process.', $this->_processType));
70
- }
71
-
72
- return $success;
73
- }
74
-
75
- /**
76
- * Run process by page
77
- *
78
- * @param int $page
79
- * @param Mage_Core_Model_Resource_Db_Collection_Abstract
80
- * @param string $dir
81
- * @param string $mode
82
- * @return bool $success
83
- */
84
- public function processPage($page, $collection, $dir, $mode) {
85
- $success = true;
86
-
87
- $collection->clear();
88
- $collection->setCurPage($page);
89
-
90
- if($collection->count()) {
91
- $itemsToProcess = array();
92
- foreach($collection as $item) {
93
- if($preparedItem = $this->prepareItem($item, $dir)) {
94
- $itemsToProcess[] = $preparedItem;
95
- }
96
- }
97
- if(count($itemsToProcess) > 0) {
98
- try{
99
- $result = $this->processItems($itemsToProcess, $dir);
100
- $success = $result['success'];
101
- $this->_itemsProcessed = $this->_itemsProcessed + $result['success_items_count'];
102
- }
103
- catch(Exception $e) {
104
- $success = false;
105
- Mage::helper('netevensync')->log($e->__toString(), $this->_processType);
106
- }
107
- }
108
- }
109
-
110
- return $success;
111
- }
112
-
113
- /**
114
- * Finish process
115
- *
116
- * @param string $mode
117
- * @param string $dir
118
- * @param bool $fromAjax
119
- */
120
- public function finishProcess($mode, $dir, $fromAjax = false) {
121
- $success = true;
122
-
123
- switch($dir) {
124
- case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT:
125
- $success = $this->finishImportProcess($mode);
126
- break;
127
-
128
- case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT:
129
- $success = $this->finishExportProcess($mode);
130
- break;
131
- }
132
-
133
- // Update last sync date
134
- $lastSync = date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()));
135
- Mage::getModel('netevensync/config_process')->loadByProcessCode($this->_processType)
136
- ->setLastSync($lastSync)
137
- ->save();
138
-
139
- return $success;
140
- }
141
-
142
- /**
143
- * Retrieve process collection
144
- *
145
- * @param string $mode
146
- * @param bool $addChunk
147
- * @param bool $fromAjax
148
- * @param string $dir
149
- * @return Mage_Core_Model_Resource_Db_Collection_Abstract
150
- */
151
- public function getProcessCollection($mode, $fromAjax, $addChunk = true, $dir) {
152
-
153
- switch($dir) {
154
- case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT:
155
- $collection = $this->getImportCollection($mode);
156
- break;
157
-
158
- case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT:
159
- $collection = $this->getExportCollection($mode);
160
- break;
161
- }
162
-
163
- if($collection && $addChunk) {
164
- $collection = $this->addChunk($collection, $fromAjax, $dir);
165
- }
166
-
167
- return $collection;
168
- }
169
-
170
- /**
171
- * Retrieve collection for import
172
- *
173
- * @param string $mode
174
- * @return Varien_Data_Collection
175
- */
176
- public function getImportCollection($mode) {
177
- return new Varien_Data_Collection();
178
- }
179
-
180
- /**
181
- * Retrieve collection for export
182
- *
183
- * @param string $mode
184
- * @return Varien_Data_Collection
185
- */
186
- public function getExportCollection($mode) {
187
- return new Varien_Data_Collection();
188
- }
189
-
190
- /**
191
- * Add page limit to collection
192
- *
193
- * @param Mage_Core_Model_Resource_Db_Collection_Abstract
194
- * @param string $dir
195
- * @param bool $fromAjax
196
- * @return Mage_Core_Model_Resource_Db_Collection_Abstract
197
- */
198
- public function addChunk($collection, $fromAjax, $dir) {
199
- if($fromAjax) {
200
- $collection->setPageSize(Neteven_NetevenSync_Model_Config::NETEVENSYNC_CHUNK_SIZE_AJAX);
201
- }
202
- else {
203
- $collection->setPageSize(Neteven_NetevenSync_Model_Config::NETEVENSYNC_CHUNK_SIZE);
204
- }
205
- return $collection;
206
- }
207
-
208
- /**
209
- * Prepare item for process
210
- *
211
- * @param mixed $item
212
- * @param string $dir
213
- * @return mixed $preparedItem
214
- */
215
- public function prepareItem($item, $dir) {
216
- $preparedItem = false;
217
-
218
- switch($dir) {
219
- case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT:
220
- $preparedItem = $this->prepareImportItem($item);
221
- break;
222
-
223
- case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT:
224
- $preparedItem = $this->prepareExportItem($item);
225
- break;
226
- }
227
-
228
- return $preparedItem;
229
- }
230
-
231
- /**
232
- * Prepare item for import
233
- *
234
- * @param mixed $item
235
- * @param string $dir
236
- * @return mixed $preparedItem
237
- */
238
- public function prepareImportItem($item) {
239
- $preparedItem = false;
240
- return $preparedItem;
241
- }
242
-
243
- /**
244
- * Prepare item for export
245
- *
246
- * @param mixed $item
247
- * @param string $dir
248
- * @return mixed $preparedItem
249
- */
250
- public function prepareExportItem($item) {
251
- $preparedItem = false;
252
- return $preparedItem;
253
- }
254
-
255
- /**
256
- * Process items
257
- *
258
- * @param array $items
259
- * @return array $result
260
- */
261
- public function processItems($items, $dir) {
262
- $result = array('success' => true, 'success_items_count' => count($items));
263
-
264
- switch($dir) {
265
- case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT:
266
- $result = $this->processImportItems($items);
267
- break;
268
-
269
- case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT:
270
- $result = $this->processExportItems($items);
271
- break;
272
- }
273
-
274
- return $result;
275
- }
276
-
277
- /**
278
- * Process items for import
279
- *
280
- * @param array $items
281
- * @return array $result
282
- */
283
- public function processImportItems($items) {
284
- $result = array('success' => true, 'success_items_count' => count($items));
285
- return $result;
286
- }
287
-
288
- /**
289
- * Process items for import
290
- *
291
- * @param array $items
292
- * @return array $result
293
- */
294
- public function processExportItems($items) {
295
- $result = array('success' => true, 'success_items_count' => count($items));
296
- return $result;
297
- }
298
-
299
- /**
300
- * Finish import
301
- *
302
- * @param string $mode
303
- * @return bool $success
304
- */
305
- public function finishImportProcess($mode) {
306
- $success = true;
307
- return $success;
308
- }
309
-
310
- /**
311
- * Finish export
312
- *
313
- * @param string $mode
314
- * @return bool $success
315
- */
316
- public function finishExportProcess($mode) {
317
- $success = true;
318
- return $success;
319
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  }
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
+ abstract class Neteven_NetevenSync_Model_Process_Abstract extends Mage_Core_Model_Abstract
12
+ {
13
+
14
+ protected $_processType;
15
+ protected $_config;
16
+ protected $_itemsProcessed = 0;
17
+
18
+ /**
19
+ * Initialize resource model
20
+ */
21
+ protected function _construct()
22
+ {
23
+ $this->_init('netevensync/process_' . $this->_processType);
24
+ }
25
+
26
+ /**
27
+ * Retrieve config singleton
28
+ *
29
+ * @return Neteven_NetevenSync_Model_Config
30
+ */
31
+ public function getConfig()
32
+ {
33
+ if (is_null($this->_config)) {
34
+ $this->_config = Mage::getSingleton('netevensync/config');
35
+ }
36
+ return $this->_config;
37
+ }
38
+
39
+ /**
40
+ * Run process
41
+ *
42
+ * @param string $mode
43
+ * @param mixed $processedPage
44
+ * @param mixed $fromAjax
45
+ * @return bool $success
46
+ */
47
+ public function runProcess($mode, $processedPage = null, $fromAjax = false, $dir)
48
+ {
49
+
50
+ $success = true;
51
+ $collection = $this->getProcessCollection($mode, $fromAjax, true, $dir);
52
+
53
+ if ($collection && $collection->count()) {
54
+ for ($page = 1; $page <= $collection->getLastPageNumber(); $page++) {
55
+ if ($processedPage && $page == $processedPage || !$processedPage) {
56
+ $success = $this->processPage($page, $collection, $dir, $mode);
57
+ }
58
+ }
59
+ }
60
+
61
+ if ($fromAjax) {
62
+ return array('success' => $success, 'items_processed' => $this->_itemsProcessed);
63
+ }
64
+
65
+ // If we're not in AJAX context, we finish the process
66
+ $success = $this->finishProcess($mode, $dir);
67
+
68
+ if ($success) {
69
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('netevensync')->__('Process "%s" has been successfully executed.', $this->_processType));
70
+ } else {
71
+ Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('netevensync')->__('Not all items have been processed for "%s" process.', $this->_processType));
72
+ }
73
+
74
+ return $success;
75
+ }
76
+
77
+ /**
78
+ * Run process by page
79
+ *
80
+ * @param int $page
81
+ * @param Mage_Core_Model_Resource_Db_Collection_Abstract
82
+ * @param string $dir
83
+ * @param string $mode
84
+ * @return bool $success
85
+ */
86
+ public function processPage($page, $collection, $dir, $mode)
87
+ {
88
+ $success = true;
89
+
90
+ $collection->clear();
91
+ $collection->setCurPage($page);
92
+
93
+ if ($collection->count()) {
94
+ $itemsToProcess = array();
95
+ foreach ($collection as $item) {
96
+ if ($preparedItem = $this->prepareItem($item, $dir)) {
97
+ $itemsToProcess[] = $preparedItem;
98
+ }
99
+ }
100
+ if (count($itemsToProcess) > 0) {
101
+ try {
102
+ $result = $this->processItems($itemsToProcess, $dir);
103
+ $success = $result['success'];
104
+ $this->_itemsProcessed = $this->_itemsProcessed + $result['success_items_count'];
105
+ } catch (Exception $e) {
106
+ $success = false;
107
+ Mage::helper('netevensync')->log($e, $this->_processType);
108
+ }
109
+ }
110
+ }
111
+
112
+ return $success;
113
+ }
114
+
115
+ /**
116
+ * Finish process
117
+ *
118
+ * @param string $mode
119
+ * @param string $dir
120
+ * @param bool $fromAjax
121
+ * @return bool
122
+ */
123
+ public function finishProcess($mode, $dir, $fromAjax = false)
124
+ {
125
+ $success = true;
126
+
127
+ switch ($dir) {
128
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT:
129
+ $success = $this->finishImportProcess($mode);
130
+ break;
131
+
132
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT:
133
+ $success = $this->finishExportProcess($mode);
134
+ break;
135
+ }
136
+
137
+ // Update last sync date
138
+ $lastSync = date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()));
139
+ Mage::getModel('netevensync/config_process')->loadByProcessCode($this->_processType)
140
+ ->setLastSync($lastSync)
141
+ ->save();
142
+
143
+ return $success;
144
+ }
145
+
146
+ /**
147
+ * Retrieve process collection
148
+ *
149
+ * @param string $mode
150
+ * @param bool $addChunk
151
+ * @param bool $fromAjax
152
+ * @param string $dir
153
+ * @return Mage_Core_Model_Resource_Db_Collection_Abstract
154
+ */
155
+ public function getProcessCollection($mode, $fromAjax, $addChunk = true, $dir)
156
+ {
157
+
158
+ switch ($dir) {
159
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT:
160
+ $collection = $this->getImportCollection($mode);
161
+ break;
162
+
163
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT:
164
+ $collection = $this->getExportCollection($mode);
165
+ break;
166
+ }
167
+
168
+ if (!$collection instanceof Varien_Data_Collection && !$fromAjax) {
169
+ // In this case, $collection is a string
170
+ Mage::throwException($collection);
171
+ }
172
+
173
+ if ($collection && $addChunk) {
174
+ $collection = $this->addChunk($collection, $fromAjax, $dir);
175
+ }
176
+
177
+ return $collection;
178
+ }
179
+
180
+ /**
181
+ * Retrieve collection for import
182
+ *
183
+ * @param string $mode
184
+ * @return Varien_Data_Collection
185
+ */
186
+ public function getImportCollection($mode)
187
+ {
188
+ return new Varien_Data_Collection();
189
+ }
190
+
191
+ /**
192
+ * Retrieve collection for export
193
+ *
194
+ * @param string $mode
195
+ * @return Varien_Data_Collection
196
+ */
197
+ public function getExportCollection($mode)
198
+ {
199
+ return new Varien_Data_Collection();
200
+ }
201
+
202
+ /**
203
+ * Add page limit to collection
204
+ *
205
+ * @param Mage_Core_Model_Resource_Db_Collection_Abstract
206
+ * @param string $dir
207
+ * @param bool $fromAjax
208
+ * @return Mage_Core_Model_Resource_Db_Collection_Abstract
209
+ */
210
+ public function addChunk($collection, $fromAjax, $dir)
211
+ {
212
+ if ($fromAjax) {
213
+ $collection->setPageSize(Neteven_NetevenSync_Model_Config::NETEVENSYNC_CHUNK_SIZE_AJAX);
214
+ } else {
215
+ $collection->setPageSize(Neteven_NetevenSync_Model_Config::NETEVENSYNC_CHUNK_SIZE);
216
+ }
217
+ return $collection;
218
+ }
219
+
220
+ /**
221
+ * Prepare item for process
222
+ *
223
+ * @param mixed $item
224
+ * @param string $dir
225
+ * @return mixed $preparedItem
226
+ */
227
+ public function prepareItem($item, $dir)
228
+ {
229
+ $preparedItem = false;
230
+
231
+ switch ($dir) {
232
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT:
233
+ $preparedItem = $this->prepareImportItem($item);
234
+ break;
235
+
236
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT:
237
+ $preparedItem = $this->prepareExportItem($item);
238
+ break;
239
+ }
240
+
241
+ return $preparedItem;
242
+ }
243
+
244
+ /**
245
+ * Prepare item for import
246
+ *
247
+ * @param mixed $item
248
+ * @return mixed $preparedItem
249
+ */
250
+ public function prepareImportItem($item)
251
+ {
252
+ $preparedItem = false;
253
+ return $preparedItem;
254
+ }
255
+
256
+ /**
257
+ * Prepare item for export
258
+ *
259
+ * @param mixed $item
260
+ * @return mixed $preparedItem
261
+ */
262
+ public function prepareExportItem($item)
263
+ {
264
+ $preparedItem = false;
265
+ return $preparedItem;
266
+ }
267
+
268
+ /**
269
+ * Process items
270
+ *
271
+ * @param array $items
272
+ * @return array $result
273
+ */
274
+ public function processItems($items, $dir)
275
+ {
276
+ $result = array('success' => true, 'success_items_count' => count($items));
277
+
278
+ switch ($dir) {
279
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT:
280
+ $result = $this->processImportItems($items);
281
+ break;
282
+
283
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT:
284
+ $result = $this->processExportItems($items);
285
+ break;
286
+ }
287
+
288
+ return $result;
289
+ }
290
+
291
+ /**
292
+ * Process items for import
293
+ *
294
+ * @param array $items
295
+ * @return array $result
296
+ */
297
+ public function processImportItems($items)
298
+ {
299
+ $result = array('success' => true, 'success_items_count' => count($items));
300
+ return $result;
301
+ }
302
+
303
+ /**
304
+ * Process items for import
305
+ *
306
+ * @param array $items
307
+ * @return array $result
308
+ */
309
+ public function processExportItems($items)
310
+ {
311
+ $result = array('success' => true, 'success_items_count' => count($items));
312
+ return $result;
313
+ }
314
+
315
+ /**
316
+ * Finish import
317
+ *
318
+ * @param string $mode
319
+ * @return bool $success
320
+ */
321
+ public function finishImportProcess($mode)
322
+ {
323
+ $success = true;
324
+ return $success;
325
+ }
326
+
327
+ /**
328
+ * Finish export
329
+ *
330
+ * @param string $mode
331
+ * @return bool $success
332
+ */
333
+ public function finishExportProcess($mode)
334
+ {
335
+ $success = true;
336
+ return $success;
337
+ }
338
+
339
  }
app/code/community/Neteven/NetevenSync/Model/Process/Inventory.php CHANGED
@@ -18,24 +18,28 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
18
  * @var string
19
  */
20
  protected $_processType = Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_INVENTORY_CODE;
 
21
  /**
22
  * Attributes used for export
23
  *
24
  * @var array
25
  */
26
  protected $_attributes = array();
 
27
  /**
28
  * Category names of item
29
  *
30
  * @var array
31
  */
32
  protected $_categoryNames = array();
 
33
  /**
34
  * Current exported product
35
  *
36
  * @var Mage_Catalog_Model_Product
37
  */
38
  protected $_product;
 
39
  /**
40
  * Parent product of $_product
41
  * if $_product is simple with parent composite
@@ -43,6 +47,7 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
43
  * @var Mage_Catalog_Model_Product
44
  */
45
  protected $_parentProduct;
 
46
  /**
47
  * Mage_Catalog_Model_Product objects for
48
  * each mapped Neteven Language <--> Magento Store ID
@@ -50,6 +55,7 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
50
  * @var array
51
  */
52
  protected $_languagesProducts = array();
 
53
  /**
54
  * Specific fields needed to populate
55
  * ArrayOfSpecificFields in XML SOAP node
@@ -77,11 +83,10 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
77
  * Add product type filter
78
  */
79
  $collection->addFieldToFilter(
80
- 'type_id',
81
- array(
82
- array('in' => Mage::getSingleton('netevensync/config')->getAvailableProductTypes()),
83
- array('null' => 1)
84
- )
85
  );
86
 
87
  /**
@@ -89,9 +94,7 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
89
  */
90
  if (Mage::getStoreConfigFlag('netevensync/inventory/selected')) {
91
  $collection->getSelect()->joinRight(
92
- array('netevensync_product' => $collection->getTable('netevensync/product')),
93
- 'netevensync_product.product_id = e.entity_id',
94
- array()
95
  );
96
  }
97
 
@@ -100,9 +103,7 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
100
  */
101
  if ($mode == Neteven_NetevenSync_Model_Config::NETEVENSYNC_EXPORT_INCREMENTAL) {
102
  $collection->getSelect()->joinRight(
103
- array('netevensync_inventory' => $collection->getTable('netevensync/inventory')),
104
- 'netevensync_inventory.product_id = e.entity_id',
105
- array('product_id', 'sku', 'to_delete')
106
  );
107
 
108
  //$collection->getSelect()->where('e.entity_id IS NOT NULL AND netevensync_inventory.to_delete != 1 OR e.entity_id IS NULL AND netevensync_inventory.to_delete = 1');
@@ -113,24 +114,24 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
113
  * @TODO Optimize with union in order to avoid catalog collection load
114
  */
115
  if ($mode == Neteven_NetevenSync_Model_Config::NETEVENSYNC_EXPORT_FULL && Mage::getStoreConfigFlag(
116
- 'netevensync/inventory/selected'
117
- )
118
  ) {
119
  $inventoryCollection = $this->getCollection()->addFieldToFilter('to_delete', '1');
120
 
121
  if ($inventoryCollection->count()) {
122
- $inventoryCollection = $inventoryCollection->toArray(array('product_id'));
123
  $inventoryCollectionIds = array();
124
  foreach ($inventoryCollection['items'] as $item) {
125
  $inventoryCollectionIds[$item['product_id']] = $item['product_id'];
126
  }
127
 
128
  $collectionIds = $collection->getAllIds();
129
- $allIds = array_merge($inventoryCollectionIds, $collectionIds);
130
- $allIds = array_unique($allIds);
131
 
132
  $collection = Mage::getModel('catalog/product')->getCollection()
133
- ->addFieldToFilter('entity_id', array('in' => $allIds));
134
  }
135
  }
136
 
@@ -138,9 +139,7 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
138
  * Add stock information
139
  */
140
  $collection->getSelect()->joinLeft(
141
- array('stock' => $collection->getTable('cataloginventory/stock_item')),
142
- 'stock.product_id = e.entity_id',
143
- array('qty', 'use_config_min_qty', 'min_qty')
144
  );
145
 
146
  /**
@@ -150,11 +149,11 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
150
  */
151
  $configMinValue = Mage::getStoreConfig('cataloginventory/item_options/min_qty');
152
  $collection->getSelect()->columns(
153
- array(
154
- 'available_qty' => new Zend_Db_Expr(
155
- "IF(use_config_min_qty > 0, (qty) - {$configMinValue}, (qty) - (min_qty))"
 
156
  )
157
- )
158
  );
159
 
160
  return $collection;
@@ -168,25 +167,24 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
168
  public function forceOutOfStockItems()
169
  {
170
  $config = Mage::getModel('core/config_data')->getCollection()
171
- ->addFieldToFilter('path', 'netevensync/force_stock')
172
- ->getFirstItem();
173
 
174
  if ($config && $config->getValue() == 1) {
175
  $selectionCollection = Mage::getModel('netevensync/product')->getCollection()->toArray(array('product_id'));
176
- $selectionIds = array();
177
 
178
  foreach ($selectionCollection['items'] as $item) {
179
  $selectionIds[$item['product_id']] = $item['product_id'];
180
  }
181
 
182
  $itemsToForce = Mage::getModel('catalog/product')->getCollection()
183
- ->addFieldToFilter(
184
- 'type_id',
185
- array(
186
- array('in' => Mage::getSingleton('netevensync/config')->getAvailableProductTypes()),
187
- array('null' => 1)
188
  )
189
- );
190
 
191
  if (count($selectionIds) > 0) {
192
  $itemsToForce->addFieldToFilter('entity_id', array('nin' => $selectionIds));
@@ -196,9 +194,9 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
196
  $this->setId(null);
197
  $this->loadByProductId($product->getEntityId());
198
  $this->setProductId($product->getEntityId())
199
- ->setSku($product->getSku())
200
- ->setToDelete(true)
201
- ->save();
202
  }
203
 
204
  $config->setValue(0)->save();
@@ -227,33 +225,48 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
227
  */
228
  public function prepareExportItem($item)
229
  {
 
 
 
 
 
230
 
231
  // Do not export items with invalid SKU
 
232
  $sku = Mage::helper('netevensync')->checkSku($item->getData('sku'), $this->_processType);
 
233
  if (!$sku) {
 
234
  return false;
235
  }
236
 
237
  // Do not export items with available_qty to 0
238
- if (!Mage::getStoreConfigFlag('netevensync/inventory/stock') && $item->getData(
239
- 'available_qty'
240
- ) == 0 && !$item->getToDelete()
 
241
  ) {
 
242
  return false;
243
  }
244
 
245
- if (Mage::getStoreConfigFlag('netevensync/inventory/selected')) {
 
246
  if ($item->getEntityId()) {
247
  $productId = $item->getEntityId();
248
  } else {
249
  $productId = $item->getProductId();
250
  }
 
251
  $this->setId(null);
 
252
  $this->loadByProductId($productId);
253
 
254
- if ($this->getToDelete()) {
 
255
  $item->setToDelete(true);
256
  }
 
257
  }
258
 
259
  if ($item->getToDelete()) {
@@ -262,47 +275,43 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
262
  $quantity = ($item->getData('available_qty') > 0) ? $item->getData('available_qty') : '0.0000';
263
  }
264
 
 
 
265
  $preparedItem = array(
266
- 'SKU' => $sku,
267
  'Quantity' => $quantity,
268
  );
269
 
270
- if (!$item->getToDelete()) {
271
- $product = Mage::getModel('catalog/product')->load($item->getEntityId());
272
- $this->_product = $product;
 
 
 
273
 
274
- // If product is not visible and has parent configurable product(s), we set data to $_parentProduct variable
275
- if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE
276
- && $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
277
- ) {
278
- $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild(
279
- $product->getId()
280
- );
281
- if (is_array($parentIds) && isset($parentIds[0])) {
282
- $this->_parentProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
283
- }
284
- }
285
 
286
  // Load other store views data for $_product and $_parentProduct
287
  $this->_populateLanguagesProducts();
288
 
289
  // Inject data into item
290
- $preparedItem = $this->_getItemData($preparedItem, 'title', 'name');
291
- $preparedItem = $this->_getItemData($preparedItem, 'sub_title', 'short_description');
292
- $preparedItem = $this->_getItemData($preparedItem, 'description', 'description', null);
293
- $preparedItem = $this->_getItemData($preparedItem, 'comment', 'model');
294
- $preparedItem['Cost'] = round($this->_product->getCost(), 2);
295
  $preparedItem['Classification'] = $this->getCategoryPath();
296
- $preparedItem = $this->_getItemData($preparedItem, 'weight', 'weight', 'float');
297
- $preparedItem['Tva'] = $this->getTaxRate();
298
- $preparedItem['Ecotaxe'] = $this->getWeee();
299
- // @deprecated
300
- //$preparedItem['PriceFixed'] = $this->getFinalPrice();
301
- $preparedItem = $this->_getImages($preparedItem);
302
- $preparedItem = $this->_getMappedFieldsData($preparedItem);
303
- $preparedItem = $this->_getSpecificFieldsData($preparedItem);
304
  }
305
 
 
 
306
  return $preparedItem;
307
  }
308
 
@@ -313,26 +322,36 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
313
  */
314
  protected function _populateLanguagesProducts()
315
  {
 
 
 
 
 
 
316
  $languages = $this->_getLanguages();
317
 
 
 
318
  foreach ($languages as $storeId => $language) {
319
  if ($language) {
320
  $product = Mage::getModel('catalog/product')
321
- ->setStoreId($storeId)
322
- ->load($this->_product->getId());
323
 
324
  $this->_languagesProducts[$storeId][$product->getId()] = $product;
325
 
326
  if (!is_null($this->_parentProduct)) {
327
  $parentProduct = Mage::getModel('catalog/product')
328
- ->setStoreId($storeId)
329
- ->load($this->_parentProduct->getId());
330
 
331
  $this->_languagesProducts[$storeId][$parentProduct->getId()] = $parentProduct;
332
  }
333
  }
334
  }
335
 
 
 
336
  return $this;
337
  }
338
 
@@ -350,6 +369,37 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
350
  return $languages;
351
  }
352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  /**
354
  * Retrieve item data and add language data when necessary
355
  *
@@ -361,25 +411,127 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
361
  */
362
  protected function _getItemData($preparedItem, $netevenCode, $attributeCode, $type = 'string')
363
  {
364
- // If we are working on SKUfamily with _automatic value, use parent sku
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  $useParent = false;
366
  if (
367
  $netevenCode == Neteven_NetevenSync_Model_Config::INVENTORY_SKUFAMILY_CODE
368
  && $attributeCode == Neteven_NetevenSync_Model_Config::INVENTORY_SKUFAMILY_AUTOMATIC_KEY
369
  ) {
370
- $useParent = true;
 
 
 
 
 
 
 
 
 
 
 
 
371
  $attributeCode = 'sku';
372
  }
373
 
374
- // Patch - Neteven needs to receive "SKUFamily" case sensitive instead of "SkuFamily" value in WS
375
- $usedNetevenCode = uc_words($netevenCode, '');
376
- if ($netevenCode != 'sku_family') {
377
- $usedNetevenCode = 'SKUFamily';
 
 
 
378
  }
379
 
380
- $preparedItem[$usedNetevenCode] = $this->getFormattedValue($type, $attributeCode, false, $useParent);
 
 
 
 
 
 
 
 
 
 
 
381
 
382
- /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  * If export is configured for several languages (store IDs),
384
  * each localized data must be sent in the ArrayOfSpecificFields node to Neteven WS
385
  * We then add a specific field for each language / store ID
@@ -388,10 +540,12 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
388
  foreach ($languages as $storeId => $language) {
389
  if ($language && strpos($netevenCode, 'price') === false) { // If dealing with price attribute, do nothing
390
  $value = $this->getFormattedValue($type, $attributeCode, $storeId, $useParent);
 
391
  $this->_addSpecificField($netevenCode, $value, $language);
392
  }
393
  }
394
 
 
395
  return $preparedItem;
396
  }
397
 
@@ -411,9 +565,7 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
411
  $value = substr(
412
  Mage::helper('core')->stripTags(
413
  $this->_getAttributeValue($attributeCode, false, $storeId, $useParent)
414
- ),
415
- 0,
416
- 255
417
  );
418
  break;
419
  case 'float':
@@ -434,31 +586,40 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
434
  * @param string $attributeCode
435
  * @param int|bool $storeId
436
  * @param bool $useParent
437
- * @return string
438
  */
439
  protected function _getAttributeValue($attributeCode, $withLabel = false, $storeId = false, $useParent = false)
440
  {
441
- $value = $this->_product->getData($attributeCode);
 
 
 
 
 
442
  $usedProduct = $this->_product;
443
 
444
  // If there is no data for this product on this attribute, or if we force to $useParent, try with $_parentProduct
445
  if (
446
- !$value && $this->_parentProduct && Mage::getStoreConfigFlag('netevensync/inventory/parent_data')
447
- || $useParent && $this->_parentProduct
 
 
 
448
  ) {
449
- $value = $this->_parentProduct->getData($attributeCode);
450
  $usedProduct = $this->_parentProduct;
451
  }
452
 
453
  // But if there are several languages, we must be sure to use the right localized data
454
  if ($storeId !== false && count($this->_languagesProducts) > 0) {
455
  $usedProduct = $this->_languagesProducts[$storeId][$usedProduct->getId()];
456
- $value = $usedProduct->getData($attributeCode);
457
  }
458
 
459
  // No value? No value!
460
  if (!$value) {
461
- return '';
 
462
  }
463
 
464
  /**
@@ -469,24 +630,25 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
469
  $attribute = $this->getAttribute($attributeCode, $usedProduct);
470
 
471
  if (!$attribute) {
472
- return '';
 
473
  }
474
 
475
  if ($storeId) {
476
  $attribute->setStoreId($storeId);
477
  }
478
 
479
- $isArray = false;
480
  $setValue = $value;
481
- $label = false;
482
 
483
  if ($withLabel) {
484
  $label = $attribute->getFrontend()->getLabel();
485
  }
486
 
487
  if ($attribute->getFrontendInput() == 'multiselect') {
488
- $value = explode(trim(Mage_Catalog_Model_Convert_Parser_Product::MULTI_DELIMITER), $value);
489
- $isArray = true;
490
  $setValue = array();
491
  }
492
 
@@ -518,12 +680,25 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
518
  }
519
 
520
  if ($withLabel) {
 
521
  $attributeData = new Varien_Object;
522
  $attributeData->setLabel($label);
523
  $attributeData->setValue($setValue);
 
 
 
 
 
 
524
  return $attributeData;
525
  }
526
 
 
 
 
 
 
 
527
  return $setValue;
528
  }
529
 
@@ -580,8 +755,8 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
580
  $categoryIds = $this->_product->getCategoryIds();
581
 
582
  if ($this->_parentProduct && count($categoryIds) < 1 && Mage::getStoreConfigFlag(
583
- 'netevensync/inventory/parent_data'
584
- )
585
  ) {
586
  $categoryIds = $this->_parentProduct->getCategoryIds();
587
  }
@@ -592,13 +767,13 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
592
 
593
  // Loop thru categories and use the one with the deepest path
594
  $deepestPath = 0;
595
- $pathArr = array();
596
  foreach ($categoryIds as $categoryId) {
597
  $path = Mage::getModel('catalog/category')->load($categoryId)->getPath();
598
- $arr = explode('/', $path);
599
  if (count($arr) > $deepestPath) {
600
  $deepestPath = count($arr);
601
- $pathArr = $arr;
602
  }
603
  }
604
 
@@ -639,15 +814,15 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
639
  {
640
  $request = Mage::getSingleton('tax/calculation')->getRateOriginRequest();
641
  $percent = Mage::getSingleton('tax/calculation')->getRate(
642
- $request->setProductClassId($this->_product->getTaxClassId())
643
  );
644
 
645
  if ((!$percent || $percent == 0) && $this->_parentProduct && Mage::getStoreConfigFlag(
646
- 'netevensync/inventory/parent_data'
647
- )
648
  ) {
649
  $percent = Mage::getSingleton('tax/calculation')->getRate(
650
- $request->setProductClassId($this->_parentProduct->getTaxClassId())
651
  );
652
  }
653
 
@@ -664,48 +839,14 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
664
  $weee = Mage::getModel('weee/tax')->getWeeeAmount($this->_product, null, null, null, false, true);
665
 
666
  if ((!$weee || $weee == 0) && $this->_parentProduct && Mage::getStoreConfigFlag(
667
- 'netevensync/inventory/parent_data'
668
- )
669
  ) {
670
  $weee = Mage::getModel('weee/tax')->getWeeeAmount($this->_parentProduct, null, null, null, false, true);
671
  }
672
  return $weee;
673
  }
674
 
675
- /**
676
- * Retrieve Product Final Price including Catalog Price Rules
677
- *
678
- * @deprecated
679
- * @see Mage_CatalogRule_Model_Observer::processAdminFinalPrice for rule_data registry
680
- * @return float
681
- */
682
- public function getFinalPrice()
683
- {
684
- /*
685
- * Commented because unused by Neteven which needs only full price
686
- *
687
- if(!Mage::registry('rule_data')) {
688
- $ruleData = new Varien_Object;
689
- $ruleData->setWebsiteId(Mage::app()->getDefaultStoreView()->getWebsiteId());
690
- $ruleData->setCustomerGroupId(0); // 0 for NOT_LOGGED_IN
691
- Mage::register('rule_data', $ruleData);
692
- }
693
-
694
- return Mage::helper('tax')->getPrice($this->_product, $this->_product->getFinalPrice(), true);
695
- */
696
-
697
- $price = Mage::helper('tax')->getPrice($this->_product, $this->_product->getPrice(), true);
698
-
699
- if ((!$price || $price == 0) && $this->_parentProduct && Mage::getStoreConfigFlag(
700
- 'netevensync/inventory/parent_data'
701
- )
702
- ) {
703
- $price = Mage::helper('tax')->getPrice($this->_parentProduct, $this->_parentProduct->getPrice(), true);
704
- }
705
-
706
- return $price;
707
- }
708
-
709
  /**
710
  * Populate images
711
  *
@@ -714,24 +855,38 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
714
  */
715
  protected function _getImages($preparedItem)
716
  {
717
- $maxAdditionalImageCount = 5;
 
 
 
718
  $additionalImageCountIndex = 1;
719
- $imageIndex = 2;
 
 
720
 
721
  $product = $this->_product;
722
- if ((!$product->getImage() || $product->getImage() == '' || $product->getImage(
723
- ) === 'no_selection') && $this->_parentProduct && Mage::getStoreConfigFlag(
724
- 'netevensync/inventory/parent_data'
725
- )
726
  ) {
 
727
  $product = $this->_parentProduct;
728
  }
729
 
730
- $gallery = $product->getMediaGallery();
731
- $preparedItem['images'][1] = ($product->getImage() === 'no_selection') ? '' : $product->getImage();
 
 
 
732
 
 
733
  foreach ($gallery['images'] as $image) {
734
- if ($image['file'] == $preparedItem['images'][1] || $additionalImageCountIndex > $maxAdditionalImageCount) {
 
 
 
 
735
  continue;
736
  }
737
  $preparedItem['images'][$imageIndex] = $image['file'];
@@ -775,6 +930,8 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
775
  */
776
  protected function _getSpecificFieldsData($preparedItem)
777
  {
 
 
778
 
779
  // First, populate array with specific fields added earlier
780
  // @see _getItemData()
@@ -794,14 +951,14 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
794
  foreach ($attributesArr as $attributeCode) {
795
 
796
  /**
797
- * Loop thru languages array anyway.
798
  * If there is no Neteven Language <--> Magento Store ID mapping
799
  * the fist $languages item is "false"
800
  */
801
  $languages = $this->_getLanguages();
802
  foreach ($languages as $storeId => $language) {
803
  $storeId = ($language) ? $storeId : false;
804
- $data = $this->_getAttributeValue($attributeCode, true, $storeId);
805
  if ($data != '') {
806
  $value = $data->getValue();
807
  if (is_array($value)) {
@@ -812,14 +969,16 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
812
  }
813
  }
814
  if (!$language) {
815
- $specificFields[] = array('Name' => $data->getLabel(), 'Value' => $value);
816
  } else {
817
- $specificFields[] = array('Name' => $data->getLabel(), 'Value' => $value, 'lang' => $language);
818
  }
819
  }
820
  }
821
  }
822
 
 
 
823
  if (count($specificFields) > 0) {
824
  $preparedItem['ArrayOfSpecificFields'] = $specificFields;
825
  }
@@ -845,10 +1004,9 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
845
  */
846
  public function processExportItems($items)
847
  {
848
- $soapClient = Mage::getModel(
849
- 'netevensync/soap'
850
- ); // We must instantiate a new SOAP for each call because authentication must be renewed
851
- $result = $soapClient->processPostItems($items, $this->_processType);
852
  return $result;
853
  }
854
 
@@ -860,8 +1018,7 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
860
  */
861
  public function finishExportProcess($mode)
862
  {
863
- $this->getCollection()
864
- ->walk('delete');
865
  return true;
866
  }
867
 
@@ -888,18 +1045,18 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
888
 
889
  if (!$product->getSku()) {
890
  $model = Mage::getModel('catalog/product')->load(
891
- $product->getId()
892
  ); // This is needed for increments called by Neteven_NetevenSync_Model_Observer::registerMultiIncrement
893
  $product->setSku($model->getSku());
894
  }
895
 
896
  // If product is configurable and export of configurable parent data is enabled, register all children products
897
  if (Mage::getStoreConfigFlag('netevensync/inventory/parent_data') && $product->getTypeId(
898
- ) == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
899
  ) {
900
  $simpleProductIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
901
  foreach ($simpleProductIds[0] as $simpleProductId) {
902
- $this->registerIncrement((int)$simpleProductId, $fromProductSave);
903
  }
904
  }
905
 
@@ -925,4 +1082,33 @@ class Neteven_NetevenSync_Model_Process_Inventory extends Neteven_NetevenSync_Mo
925
 
926
  $this->save();
927
  }
928
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  * @var string
19
  */
20
  protected $_processType = Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_INVENTORY_CODE;
21
+
22
  /**
23
  * Attributes used for export
24
  *
25
  * @var array
26
  */
27
  protected $_attributes = array();
28
+
29
  /**
30
  * Category names of item
31
  *
32
  * @var array
33
  */
34
  protected $_categoryNames = array();
35
+
36
  /**
37
  * Current exported product
38
  *
39
  * @var Mage_Catalog_Model_Product
40
  */
41
  protected $_product;
42
+
43
  /**
44
  * Parent product of $_product
45
  * if $_product is simple with parent composite
47
  * @var Mage_Catalog_Model_Product
48
  */
49
  protected $_parentProduct;
50
+
51
  /**
52
  * Mage_Catalog_Model_Product objects for
53
  * each mapped Neteven Language <--> Magento Store ID
55
  * @var array
56
  */
57
  protected $_languagesProducts = array();
58
+
59
  /**
60
  * Specific fields needed to populate
61
  * ArrayOfSpecificFields in XML SOAP node
83
  * Add product type filter
84
  */
85
  $collection->addFieldToFilter(
86
+ 'type_id', array(
87
+ array('in' => Mage::getSingleton('netevensync/config')->getAvailableProductTypes()),
88
+ array('null' => 1)
89
+ )
 
90
  );
91
 
92
  /**
94
  */
95
  if (Mage::getStoreConfigFlag('netevensync/inventory/selected')) {
96
  $collection->getSelect()->joinRight(
97
+ array('netevensync_product' => $collection->getTable('netevensync/product')), 'netevensync_product.product_id = e.entity_id', array()
 
 
98
  );
99
  }
100
 
103
  */
104
  if ($mode == Neteven_NetevenSync_Model_Config::NETEVENSYNC_EXPORT_INCREMENTAL) {
105
  $collection->getSelect()->joinRight(
106
+ array('netevensync_inventory' => $collection->getTable('netevensync/inventory')), 'netevensync_inventory.product_id = e.entity_id', array('product_id', 'sku', 'to_delete')
 
 
107
  );
108
 
109
  //$collection->getSelect()->where('e.entity_id IS NOT NULL AND netevensync_inventory.to_delete != 1 OR e.entity_id IS NULL AND netevensync_inventory.to_delete = 1');
114
  * @TODO Optimize with union in order to avoid catalog collection load
115
  */
116
  if ($mode == Neteven_NetevenSync_Model_Config::NETEVENSYNC_EXPORT_FULL && Mage::getStoreConfigFlag(
117
+ 'netevensync/inventory/selected'
118
+ )
119
  ) {
120
  $inventoryCollection = $this->getCollection()->addFieldToFilter('to_delete', '1');
121
 
122
  if ($inventoryCollection->count()) {
123
+ $inventoryCollection = $inventoryCollection->toArray(array('product_id'));
124
  $inventoryCollectionIds = array();
125
  foreach ($inventoryCollection['items'] as $item) {
126
  $inventoryCollectionIds[$item['product_id']] = $item['product_id'];
127
  }
128
 
129
  $collectionIds = $collection->getAllIds();
130
+ $allIds = array_merge($inventoryCollectionIds, $collectionIds);
131
+ $allIds = array_unique($allIds);
132
 
133
  $collection = Mage::getModel('catalog/product')->getCollection()
134
+ ->addFieldToFilter('entity_id', array('in' => $allIds));
135
  }
136
  }
137
 
139
  * Add stock information
140
  */
141
  $collection->getSelect()->joinLeft(
142
+ array('stock' => $collection->getTable('cataloginventory/stock_item')), 'stock.product_id = e.entity_id', array('qty', 'use_config_min_qty', 'min_qty')
 
 
143
  );
144
 
145
  /**
149
  */
150
  $configMinValue = Mage::getStoreConfig('cataloginventory/item_options/min_qty');
151
  $collection->getSelect()->columns(
152
+ array(
153
+ 'available_qty' => new Zend_Db_Expr(
154
+ "IF(use_config_min_qty > 0, (qty) - {$configMinValue}, (qty) - (min_qty))"
155
+ )
156
  )
 
157
  );
158
 
159
  return $collection;
167
  public function forceOutOfStockItems()
168
  {
169
  $config = Mage::getModel('core/config_data')->getCollection()
170
+ ->addFieldToFilter('path', 'netevensync/force_stock')
171
+ ->getFirstItem();
172
 
173
  if ($config && $config->getValue() == 1) {
174
  $selectionCollection = Mage::getModel('netevensync/product')->getCollection()->toArray(array('product_id'));
175
+ $selectionIds = array();
176
 
177
  foreach ($selectionCollection['items'] as $item) {
178
  $selectionIds[$item['product_id']] = $item['product_id'];
179
  }
180
 
181
  $itemsToForce = Mage::getModel('catalog/product')->getCollection()
182
+ ->addFieldToFilter(
183
+ 'type_id', array(
184
+ array('in' => Mage::getSingleton('netevensync/config')->getAvailableProductTypes()),
185
+ array('null' => 1)
 
186
  )
187
+ );
188
 
189
  if (count($selectionIds) > 0) {
190
  $itemsToForce->addFieldToFilter('entity_id', array('nin' => $selectionIds));
194
  $this->setId(null);
195
  $this->loadByProductId($product->getEntityId());
196
  $this->setProductId($product->getEntityId())
197
+ ->setSku($product->getSku())
198
+ ->setToDelete(true)
199
+ ->save();
200
  }
201
 
202
  $config->setValue(0)->save();
225
  */
226
  public function prepareExportItem($item)
227
  {
228
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
229
+ $logger = Mage::helper('netevensync/logger');
230
+
231
+ $logger->init('Prepare export item [inventory]');
232
+ $logger->step("Item:", $item);
233
 
234
  // Do not export items with invalid SKU
235
+ $logger->info("Check SKU");
236
  $sku = Mage::helper('netevensync')->checkSku($item->getData('sku'), $this->_processType);
237
+ $logger->result($sku, "SKU");
238
  if (!$sku) {
239
+ $logger->info("Invalid SKU")->end();
240
  return false;
241
  }
242
 
243
  // Do not export items with available_qty to 0
244
+ if (
245
+ !Mage::getStoreConfigFlag('netevensync/inventory/stock')
246
+ && $item->getData('available_qty') == 0
247
+ && !$item->getToDelete()
248
  ) {
249
+ $logger->info("No qty")->end();
250
  return false;
251
  }
252
 
253
+ if ($logger->condition("Export only selected products?", Mage::getStoreConfigFlag('netevensync/inventory/selected'))) {
254
+ $logger->up();
255
  if ($item->getEntityId()) {
256
  $productId = $item->getEntityId();
257
  } else {
258
  $productId = $item->getProductId();
259
  }
260
+ $logger->data("product_id", $productId);
261
  $this->setId(null);
262
+ $logger->info("Load by product ID");
263
  $this->loadByProductId($productId);
264
 
265
+ if ($logger->condition("To delete?", $this->getToDelete())) {
266
+ $logger->up()->info("Set item to delete to TRUE")->down();
267
  $item->setToDelete(true);
268
  }
269
+ $logger->down();
270
  }
271
 
272
  if ($item->getToDelete()) {
275
  $quantity = ($item->getData('available_qty') > 0) ? $item->getData('available_qty') : '0.0000';
276
  }
277
 
278
+ $logger->data("quantity", $quantity);
279
+
280
  $preparedItem = array(
281
+ 'SKU' => $sku,
282
  'Quantity' => $quantity,
283
  );
284
 
285
+ if (!$logger->condition("Product to delete?", $item->getToDelete())) {
286
+ $logger->info("Load the product");
287
+ $logger->data("entity_id", $item->getEntityId());
288
+ $product = Mage::getModel('catalog/product')->load($item->getEntityId());
289
+ $this->_product = $product;
290
+ $this->_parentProduct = null;
291
 
292
+ // Set parent product if necessary
293
+ $this->_setParentProduct($product);
 
 
 
 
 
 
 
 
 
294
 
295
  // Load other store views data for $_product and $_parentProduct
296
  $this->_populateLanguagesProducts();
297
 
298
  // Inject data into item
299
+ $preparedItem = $this->_getItemData($preparedItem, 'title', 'name');
300
+ $preparedItem = $this->_getItemData($preparedItem, 'sub_title', 'short_description');
301
+ $preparedItem = $this->_getItemData($preparedItem, 'description', 'description', null);
302
+ $preparedItem = $this->_getItemData($preparedItem, 'comment', 'model');
303
+ $preparedItem['Cost'] = round($this->_product->getCost(), 2);
304
  $preparedItem['Classification'] = $this->getCategoryPath();
305
+ $preparedItem = $this->_getItemData($preparedItem, 'weight', 'weight', 'float');
306
+ $preparedItem['Tva'] = $this->getTaxRate();
307
+ $preparedItem['Ecotaxe'] = $this->getWeee();
308
+ $preparedItem = $this->_getImages($preparedItem);
309
+ $preparedItem = $this->_getMappedFieldsData($preparedItem);
310
+ $preparedItem = $this->_getSpecificFieldsData($preparedItem);
 
 
311
  }
312
 
313
+ $logger->end();
314
+
315
  return $preparedItem;
316
  }
317
 
322
  */
323
  protected function _populateLanguagesProducts()
324
  {
325
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
326
+ $logger = Mage::helper('netevensync/logger');
327
+
328
+ $logger->step("Populate languages products");
329
+ $logger->up();
330
+
331
  $languages = $this->_getLanguages();
332
 
333
+ $logger->data("languages [store_id => language]", $languages);
334
+
335
  foreach ($languages as $storeId => $language) {
336
  if ($language) {
337
  $product = Mage::getModel('catalog/product')
338
+ ->setStoreId($storeId)
339
+ ->load($this->_product->getId());
340
 
341
  $this->_languagesProducts[$storeId][$product->getId()] = $product;
342
 
343
  if (!is_null($this->_parentProduct)) {
344
  $parentProduct = Mage::getModel('catalog/product')
345
+ ->setStoreId($storeId)
346
+ ->load($this->_parentProduct->getId());
347
 
348
  $this->_languagesProducts[$storeId][$parentProduct->getId()] = $parentProduct;
349
  }
350
  }
351
  }
352
 
353
+ $logger->down();
354
+
355
  return $this;
356
  }
357
 
369
  return $languages;
370
  }
371
 
372
+ /**
373
+ * Retrieve item data and add language data when necessary.
374
+ * <p>This method is typically used by Stock process to get prices.</p>
375
+ *
376
+ * @param Mage_Catalog_Model_Product $product
377
+ * @param $preparedItem
378
+ * @param $netevenCode
379
+ * @param $attributeCode
380
+ * @param string $type
381
+ * @return mixed
382
+ */
383
+ public function getItemData($product, $preparedItem, $netevenCode, $attributeCode, $type = 'string')
384
+ {
385
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
386
+ $logger = Mage::helper('netevensync/logger');
387
+
388
+ // If the product is changing, then we update some data
389
+ if (!$this->_product || $product->getId() !== $this->_product->getId()) {
390
+ $this->_product = $product;
391
+ $this->_parentProduct = null;
392
+
393
+ // Set parent product if necessary
394
+ $this->_setParentProduct($product);
395
+
396
+ // Load other store views data for $_product and $_parentProduct
397
+ $this->_populateLanguagesProducts();
398
+ }
399
+
400
+ return $this->_getItemData($preparedItem, $netevenCode, $attributeCode, $type);
401
+ }
402
+
403
  /**
404
  * Retrieve item data and add language data when necessary
405
  *
411
  */
412
  protected function _getItemData($preparedItem, $netevenCode, $attributeCode, $type = 'string')
413
  {
414
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
415
+ $logger = Mage::helper('netevensync/logger');
416
+
417
+ $logger->step("Get item data using attribute", "`$attributeCode`");
418
+ $logger->up();
419
+
420
+ // Patch - Neteven needs to receive "SKUFamily" case sensitive instead of "SkuFamily" value in WS
421
+ $usedNetevenCode = uc_words($netevenCode, '');
422
+ if ($netevenCode == Neteven_NetevenSync_Model_Config::INVENTORY_SKUFAMILY_CODE) {
423
+ $usedNetevenCode = 'SKUFamily';
424
+ }
425
+
426
+ $logger->data('Used Neteven Code', $usedNetevenCode);
427
+
428
+ // If we are working on SKUfamily with _automatic value, use parent sku if parent exists
429
  $useParent = false;
430
  if (
431
  $netevenCode == Neteven_NetevenSync_Model_Config::INVENTORY_SKUFAMILY_CODE
432
  && $attributeCode == Neteven_NetevenSync_Model_Config::INVENTORY_SKUFAMILY_AUTOMATIC_KEY
433
  ) {
434
+ $logger->info("Use parent?");
435
+
436
+ // If parent is not set, return empty value for SKUFamily
437
+ if (!$this->_parentProduct) {
438
+ $preparedItem[$usedNetevenCode] = '';
439
+ $logger->info("Parent not set");
440
+ $logger->result('', $usedNetevenCode);
441
+ $logger->down();
442
+ return $preparedItem;
443
+ }
444
+
445
+ $logger->info("Use parent, skip current");
446
+ $useParent = true;
447
  $attributeCode = 'sku';
448
  }
449
 
450
+ $logger->data("type", $type);
451
+
452
+ /*
453
+ * Standard case: it's not a price attribute
454
+ */
455
+ if (stripos($attributeCode, 'price') === false) {
456
+ $preparedItem[$usedNetevenCode] = $this->getFormattedValue($type, $attributeCode, false, $useParent);
457
  }
458
 
459
+ /*
460
+ * It's a price attribute. We have two cases:
461
+ * 1. the price is global: that's easy ;)
462
+ * 2. the price isn't global, it's per website: we have to loop on each store to find the price and the currency
463
+ */
464
+ else {
465
+ $logger->info("/!\\ Price attribute");
466
+
467
+ // We use an array for prices, because we can have multiple currencies
468
+ if (!isset($preparedItem[$usedNetevenCode])) {
469
+ $preparedItem[$usedNetevenCode] = array();
470
+ }
471
 
472
+ /*
473
+ * No matter if the price is global or not, we want the global price too
474
+ * Note that the global price, if given in first position, will be
475
+ * override by another price with the same currency via the price per website.
476
+ */
477
+ // Only if we have a value
478
+ $logger->result($this->_getAttributeValue($attributeCode, false, false, $useParent), "get attribute $attributeCode for store admin");
479
+ if (null !== $this->_getAttributeValue($attributeCode, false, false, $useParent)) {
480
+ $preparedItem[$usedNetevenCode][] = new SoapVar(
481
+ sprintf(
482
+ '<ns1:%1$s currency_id="%2$s">%3$.2F</ns1:%1$s>',
483
+ $usedNetevenCode,
484
+ $currency = Mage::app()->getStore()->getBaseCurrencyCode(),
485
+ $value = $this->getFormattedValue($type, $attributeCode, false, $useParent)
486
+ ),
487
+ XSD_ANYXML
488
+ );
489
+ $logger->result(sprintf('%.2F in %s', $value, $currency), $usedNetevenCode);
490
+ }
491
+
492
+ // Price is per website
493
+ // We add each store currency
494
+ $processedWebsites = array();
495
+ if (!Mage::helper('catalog')->isPriceGlobal()) {
496
+ $languages = $this->_getLanguages();
497
+ foreach ($languages as $storeId => $language) {
498
+ // No value? skip.
499
+ $logger->result($this->_getAttributeValue($attributeCode, false, $storeId, $useParent), "get attribute $attributeCode for store $storeId");
500
+ if (null === $this->_getAttributeValue($attributeCode, false, $storeId, $useParent)) {
501
+ continue;
502
+ }
503
+
504
+ $store = Mage::app()->getStore($storeId);
505
+
506
+ // Website already processed? useless to perform other stores.
507
+ if (in_array($store->getWebsiteId(), $processedWebsites)) {
508
+ continue;
509
+ } else {
510
+ $processedWebsites[] = $store->getWebsiteId();
511
+ }
512
+
513
+ $value = $this->getFormattedValue($type, $attributeCode, $storeId, $useParent);
514
+ $currency = $store->getBaseCurrencyCode();
515
+ $logger->data("Price found", array(
516
+ "used_neteven_code" => $usedNetevenCode,
517
+ "currency" => $currency,
518
+ "value" => $value,
519
+ ));
520
+ $preparedItem[$usedNetevenCode][] = new SoapVar(
521
+ sprintf(
522
+ '<ns1:%1$s currency_id="%2$s">%3$.2F</ns1:%1$s>',
523
+ $usedNetevenCode,
524
+ $currency,
525
+ $value
526
+ ),
527
+ XSD_ANYXML
528
+ );
529
+ $logger->result(sprintf('%.2F in %s', $value, $currency), $usedNetevenCode);
530
+ }
531
+ }
532
+ }
533
+
534
+ /*
535
  * If export is configured for several languages (store IDs),
536
  * each localized data must be sent in the ArrayOfSpecificFields node to Neteven WS
537
  * We then add a specific field for each language / store ID
540
  foreach ($languages as $storeId => $language) {
541
  if ($language && strpos($netevenCode, 'price') === false) { // If dealing with price attribute, do nothing
542
  $value = $this->getFormattedValue($type, $attributeCode, $storeId, $useParent);
543
+ $logger->result($value, "store $storeId / $language");
544
  $this->_addSpecificField($netevenCode, $value, $language);
545
  }
546
  }
547
 
548
+ $logger->down();
549
  return $preparedItem;
550
  }
551
 
565
  $value = substr(
566
  Mage::helper('core')->stripTags(
567
  $this->_getAttributeValue($attributeCode, false, $storeId, $useParent)
568
+ ), 0, 255
 
 
569
  );
570
  break;
571
  case 'float':
586
  * @param string $attributeCode
587
  * @param int|bool $storeId
588
  * @param bool $useParent
589
+ * @return string|null
590
  */
591
  protected function _getAttributeValue($attributeCode, $withLabel = false, $storeId = false, $useParent = false)
592
  {
593
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
594
+ $logger = Mage::helper('netevensync/logger');
595
+ $logger->transaction();
596
+ $logger->step("Get attribute value", $attributeCode)->up();
597
+
598
+ $value = $this->_product->getData($attributeCode);
599
  $usedProduct = $this->_product;
600
 
601
  // If there is no data for this product on this attribute, or if we force to $useParent, try with $_parentProduct
602
  if (
603
+ !$value
604
+ && $this->_parentProduct
605
+ && Mage::getStoreConfigFlag('netevensync/inventory/parent_data')
606
+ || $useParent
607
+ && $this->_parentProduct
608
  ) {
609
+ $value = $this->_parentProduct->getData($attributeCode);
610
  $usedProduct = $this->_parentProduct;
611
  }
612
 
613
  // But if there are several languages, we must be sure to use the right localized data
614
  if ($storeId !== false && count($this->_languagesProducts) > 0) {
615
  $usedProduct = $this->_languagesProducts[$storeId][$usedProduct->getId()];
616
+ $value = $usedProduct->getData($attributeCode);
617
  }
618
 
619
  // No value? No value!
620
  if (!$value) {
621
+ $logger->rollback();
622
+ return null;
623
  }
624
 
625
  /**
630
  $attribute = $this->getAttribute($attributeCode, $usedProduct);
631
 
632
  if (!$attribute) {
633
+ $logger->rollback();
634
+ return null;
635
  }
636
 
637
  if ($storeId) {
638
  $attribute->setStoreId($storeId);
639
  }
640
 
641
+ $isArray = false;
642
  $setValue = $value;
643
+ $label = false;
644
 
645
  if ($withLabel) {
646
  $label = $attribute->getFrontend()->getLabel();
647
  }
648
 
649
  if ($attribute->getFrontendInput() == 'multiselect') {
650
+ $value = explode(trim(Mage_Catalog_Model_Convert_Parser_Product::MULTI_DELIMITER), $value);
651
+ $isArray = true;
652
  $setValue = array();
653
  }
654
 
680
  }
681
 
682
  if ($withLabel) {
683
+ $logger->info("Use label ($label)");
684
  $attributeData = new Varien_Object;
685
  $attributeData->setLabel($label);
686
  $attributeData->setValue($setValue);
687
+ $logger->down();
688
+ if ($storeId) { // no log
689
+ $logger->rollback();
690
+ } else {
691
+ $logger->commit();
692
+ }
693
  return $attributeData;
694
  }
695
 
696
+ $logger->down();
697
+ if ($storeId) { // no log
698
+ $logger->rollback();
699
+ } else {
700
+ $logger->commit();
701
+ }
702
  return $setValue;
703
  }
704
 
755
  $categoryIds = $this->_product->getCategoryIds();
756
 
757
  if ($this->_parentProduct && count($categoryIds) < 1 && Mage::getStoreConfigFlag(
758
+ 'netevensync/inventory/parent_data'
759
+ )
760
  ) {
761
  $categoryIds = $this->_parentProduct->getCategoryIds();
762
  }
767
 
768
  // Loop thru categories and use the one with the deepest path
769
  $deepestPath = 0;
770
+ $pathArr = array();
771
  foreach ($categoryIds as $categoryId) {
772
  $path = Mage::getModel('catalog/category')->load($categoryId)->getPath();
773
+ $arr = explode('/', $path);
774
  if (count($arr) > $deepestPath) {
775
  $deepestPath = count($arr);
776
+ $pathArr = $arr;
777
  }
778
  }
779
 
814
  {
815
  $request = Mage::getSingleton('tax/calculation')->getRateOriginRequest();
816
  $percent = Mage::getSingleton('tax/calculation')->getRate(
817
+ $request->setProductClassId($this->_product->getTaxClassId())
818
  );
819
 
820
  if ((!$percent || $percent == 0) && $this->_parentProduct && Mage::getStoreConfigFlag(
821
+ 'netevensync/inventory/parent_data'
822
+ )
823
  ) {
824
  $percent = Mage::getSingleton('tax/calculation')->getRate(
825
+ $request->setProductClassId($this->_parentProduct->getTaxClassId())
826
  );
827
  }
828
 
839
  $weee = Mage::getModel('weee/tax')->getWeeeAmount($this->_product, null, null, null, false, true);
840
 
841
  if ((!$weee || $weee == 0) && $this->_parentProduct && Mage::getStoreConfigFlag(
842
+ 'netevensync/inventory/parent_data'
843
+ )
844
  ) {
845
  $weee = Mage::getModel('weee/tax')->getWeeeAmount($this->_parentProduct, null, null, null, false, true);
846
  }
847
  return $weee;
848
  }
849
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
850
  /**
851
  * Populate images
852
  *
855
  */
856
  protected function _getImages($preparedItem)
857
  {
858
+ // Init images
859
+ $preparedItem['images'] = array();
860
+
861
+ $maxAdditionalImageCount = 5;
862
  $additionalImageCountIndex = 1;
863
+ $firstImageIndex = 1;
864
+ $imageIndex = $firstImageIndex;
865
+
866
 
867
  $product = $this->_product;
868
+ if (
869
+ (!$product->getImage() || $product->getImage() === 'no_selection')
870
+ && $this->_parentProduct
871
+ && Mage::getStoreConfigFlag('netevensync/inventory/parent_data')
872
  ) {
873
+ // Use parent !
874
  $product = $this->_parentProduct;
875
  }
876
 
877
+ // First "main" image
878
+ if ($product->getImage() && $product->getImage() !== 'no_selection') {
879
+ $preparedItem['images'][$firstImageIndex] = $product->getImage();
880
+ }
881
+ $imageIndex++;
882
 
883
+ $gallery = $product->getMediaGallery();
884
  foreach ($gallery['images'] as $image) {
885
+ if (
886
+ !$image['file']
887
+ || (isset($preparedItem['images'][$firstImageIndex]) && $image['file'] === $preparedItem['images'][$firstImageIndex])
888
+ || $additionalImageCountIndex > $maxAdditionalImageCount
889
+ ) {
890
  continue;
891
  }
892
  $preparedItem['images'][$imageIndex] = $image['file'];
930
  */
931
  protected function _getSpecificFieldsData($preparedItem)
932
  {
933
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
934
+ $logger = Mage::helper('netevensync/logger');
935
 
936
  // First, populate array with specific fields added earlier
937
  // @see _getItemData()
951
  foreach ($attributesArr as $attributeCode) {
952
 
953
  /**
954
+ * Loop through languages array anyway.
955
  * If there is no Neteven Language <--> Magento Store ID mapping
956
  * the fist $languages item is "false"
957
  */
958
  $languages = $this->_getLanguages();
959
  foreach ($languages as $storeId => $language) {
960
  $storeId = ($language) ? $storeId : false;
961
+ $data = $this->_getAttributeValue($attributeCode, true, $storeId);
962
  if ($data != '') {
963
  $value = $data->getValue();
964
  if (is_array($value)) {
969
  }
970
  }
971
  if (!$language) {
972
+ $specificFields[] = array('Name' => $attributeCode, 'Value' => $value);
973
  } else {
974
+ $specificFields[] = array('Name' => $attributeCode, 'Value' => $value, 'lang' => $language);
975
  }
976
  }
977
  }
978
  }
979
 
980
+ $logger->step("Retrieve specific fields data", $specificFields);
981
+
982
  if (count($specificFields) > 0) {
983
  $preparedItem['ArrayOfSpecificFields'] = $specificFields;
984
  }
1004
  */
1005
  public function processExportItems($items)
1006
  {
1007
+ // We must instantiate a new SOAP for each call because authentication must be renewed
1008
+ $soapClient = Mage::getModel('netevensync/soap');
1009
+ $result = $soapClient->processPostItems($items, $this->_processType);
 
1010
  return $result;
1011
  }
1012
 
1018
  */
1019
  public function finishExportProcess($mode)
1020
  {
1021
+ $this->getCollection()->walk('delete');
 
1022
  return true;
1023
  }
1024
 
1045
 
1046
  if (!$product->getSku()) {
1047
  $model = Mage::getModel('catalog/product')->load(
1048
+ $product->getId()
1049
  ); // This is needed for increments called by Neteven_NetevenSync_Model_Observer::registerMultiIncrement
1050
  $product->setSku($model->getSku());
1051
  }
1052
 
1053
  // If product is configurable and export of configurable parent data is enabled, register all children products
1054
  if (Mage::getStoreConfigFlag('netevensync/inventory/parent_data') && $product->getTypeId(
1055
+ ) == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
1056
  ) {
1057
  $simpleProductIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
1058
  foreach ($simpleProductIds[0] as $simpleProductId) {
1059
+ $this->registerIncrement((int) $simpleProductId, $fromProductSave);
1060
  }
1061
  }
1062
 
1082
 
1083
  $this->save();
1084
  }
1085
+
1086
+ /**
1087
+ * Set parent product
1088
+ * <em>of $product.</em>
1089
+ * @param Mage_Catalog_Model_Product $product
1090
+ */
1091
+ protected function _setParentProduct(Mage_Catalog_Model_Product $product)
1092
+ {
1093
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
1094
+ $logger = Mage::helper('netevensync/logger');
1095
+
1096
+ // If product is not visible and has parent configurable product(s), we set data to $_parentProduct variable
1097
+ if (
1098
+ $product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE
1099
+ && $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
1100
+ ) {
1101
+ $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild(
1102
+ $product->getId()
1103
+ );
1104
+ if (is_array($parentIds) && isset($parentIds[0])) {
1105
+ $logger->info("Load the parent product");
1106
+ $this->_parentProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
1107
+ $logger->data("parent_product", array(
1108
+ 'sku' => $this->_parentProduct->getSku(),
1109
+ ));
1110
+ }
1111
+ }
1112
+ }
1113
+
1114
+ }
app/code/community/Neteven/NetevenSync/Model/Process/Order.php CHANGED
@@ -104,6 +104,13 @@ class Neteven_NetevenSync_Model_Process_Order extends Neteven_NetevenSync_Model_
104
 
105
  $preparedItem = $this->_prepareFromMarketPlace($preparedItem);
106
 
 
 
 
 
 
 
 
107
  return $preparedItem;
108
  }
109
 
@@ -142,26 +149,24 @@ class Neteven_NetevenSync_Model_Process_Order extends Neteven_NetevenSync_Model_
142
  */
143
  public function prepareExportItem($item)
144
  {
145
- $order = $item;
146
  $status = $this->getConfig()->getMappedOrderStatus($order->getStatus(), 'magento');
147
 
148
  $preparedItem = array(
149
  'OrderID' => $item->getNetevenOrderId(),
150
- 'Status' => $status,
151
  );
152
 
153
- if ($status == Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_SHIPPED && (bool)$order->hasShipments(
154
- )
155
- ) {
156
- $shipment = $order->getShipmentsCollection()->getFirstItem(
157
- ); // We use only first shipment as Neteven only accepts one shipment per order
158
  $dateShipping = date(DATE_ATOM, strtotime($shipment->getCreatedAt()));
159
 
160
  $preparedItem['DateShipping'] = $dateShipping;
161
 
162
  $tracks = $shipment->getAllTracks();
163
  if (count($tracks) > 0) {
164
- $track = reset($tracks); // We use only first track as Neteven only accepts one tracking per order
165
  $preparedItem['TrackingNumber'] = $track->getNumber();
166
  }
167
  }
@@ -177,25 +182,68 @@ class Neteven_NetevenSync_Model_Process_Order extends Neteven_NetevenSync_Model_
177
  */
178
  public function processImportItems($items)
179
  {
 
 
180
  $result = array('success' => true, 'success_items_count' => count($items));
181
  foreach ($items as $item) {
182
 
183
- if (!$this->_canImport($item)) {
 
 
 
 
 
 
 
 
184
  continue;
185
  }
186
 
 
187
  $orderLink = Mage::getModel('netevensync/process_order_link')->loadByNetevenOrderId($item->getOrderId());
 
188
 
189
  // If order has already been imported and its status has changed, we update it
190
  if ($orderLink->getMagentoOrderId()) {
191
- if ($orderLink->getOrderStatus() != $item->getStatus()) {
 
 
 
 
 
 
 
 
 
 
192
  $orderLink->setOrderStatus($item->getStatus());
193
  $orderLink->save();
 
194
  }
195
- } // If order has not been imported yet, we create or update quote
 
 
196
  else {
 
 
 
 
197
  $result = $this->processImportQuote($orderLink, $item);
 
198
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
200
 
201
  return $result;
@@ -209,36 +257,45 @@ class Neteven_NetevenSync_Model_Process_Order extends Neteven_NetevenSync_Model_
209
  */
210
  protected function _canImport($item)
211
  {
 
212
 
213
  // Get address data
214
  // Check if data is empty or equal to a dash because Neteven may sends whether an empty values or a dash...
215
  $shippingAddress = $item->getShippingAddress();
216
  $address1 = $shippingAddress->getAddress1();
217
  if ($address1 == '-') {
 
218
  $address1 = '';
219
  }
220
  $address2 = $shippingAddress->getAddress2();
221
  if ($address2 == '-') {
 
222
  $address2 = '';
223
  }
224
  $pseudo = $item->getShippingAddress()->getPseudo();
225
  if ($pseudo == '-') {
 
226
  $pseudo = '';
227
  }
228
 
229
  // Check if shipping address is valid
230
  if ($address1 == '' && $address2 == '') {
 
231
  return false;
232
  }
233
 
234
  // Check if "pseudo" exists for MarketPlaceId 5
235
  if ($item->getMarketPlaceId() == '5' && $pseudo == '') {
 
236
  return false;
237
  }
238
 
 
239
  // Check if order status is allowed
240
  $allowedStatuses = $this->getConfig()->getAllowedNetevenOrderStatesForImport();
241
- if (!in_array($item->getStatus(), $allowedStatuses)) {
 
 
242
  return false;
243
  }
244
 
@@ -268,6 +325,8 @@ class Neteven_NetevenSync_Model_Process_Order extends Neteven_NetevenSync_Model_
268
  */
269
  public function finishImportProcess($mode)
270
  {
 
 
271
  $success = true;
272
 
273
  $this->flushTempItems();
@@ -275,25 +334,45 @@ class Neteven_NetevenSync_Model_Process_Order extends Neteven_NetevenSync_Model_
275
  // Update already imported orders
276
  $ordersToUpdate = Mage::getModel('netevensync/process_order_link')
277
  ->getCollection()
278
- ->addFieldToFilter('magento_order_id', array('notnull' => true));
 
 
 
 
279
 
280
  if ($ordersToUpdate->count()) {
281
  foreach ($ordersToUpdate as $orderLink) {
 
 
 
 
282
  $order = Mage::getModel('sales/order')->load($orderLink->getMagentoOrderId());
283
- $this->getConvertor()->updateOrder($order, $orderLink->getOrderStatus());
 
 
284
  }
285
  }
286
 
 
 
287
  // Create not yet imported orders
288
  $ordersToCreate = Mage::getModel('netevensync/process_order_link')
289
  ->getCollection()
290
- ->addFieldToFilter('magento_order_id', array('null' => true));
 
 
291
 
292
- if ($ordersToCreate->count()) {
293
 
 
 
294
  foreach ($ordersToCreate as $orderLink) {
 
 
 
295
  $quote = Mage::getModel('sales/quote');
296
- $quote->setStore(Mage::app()->getDefaultStoreView())->load($orderLink->getMagentoQuoteId());
 
297
 
298
  // Retrieve payment from DB and assign it to quote
299
  $quotePayment = $quote->getPayment();
@@ -309,6 +388,12 @@ class Neteven_NetevenSync_Model_Process_Order extends Neteven_NetevenSync_Model_
309
  // Retrieve Neteven market place order id from DB and assign to quote
310
  $quote->setNetevenMarketPlaceOrderId($orderLink->getNetevenMarketPlaceOrderId());
311
 
 
 
 
 
 
 
312
  $order = $this->getConvertor()->createOrder($quote);
313
 
314
  if ($orderId = $order->getId()) {
@@ -320,6 +405,20 @@ class Neteven_NetevenSync_Model_Process_Order extends Neteven_NetevenSync_Model_
320
  }
321
  }
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  return $success;
324
  }
325
 
@@ -345,55 +444,121 @@ class Neteven_NetevenSync_Model_Process_Order extends Neteven_NetevenSync_Model_
345
  */
346
  public function processImportQuote($orderLink, $item)
347
  {
 
 
348
 
349
  $result = array('success' => true, 'success_items_count' => 1);
 
 
350
  $quote = Mage::getModel('sales/quote');
351
 
352
  if ($magentoQuoteId = $orderLink->getMagentoQuoteId()) {
353
- $quote->setStore(Mage::app()->getDefaultStoreView())->load($magentoQuoteId);
 
 
 
 
 
 
 
 
 
 
 
354
  }
355
 
356
  // If quote does not exist in Magento, we create it
357
- if (!$quote->getId()) {
358
-
359
  try {
 
360
  $quote = $this->getConvertor()->createQuote($item);
361
  } catch (Exception $e) {
362
- Mage::helper('netevensync')->log("\n" . $e->__toString());
 
363
  $result = array('success' => false, 'success_items_count' => 0);
364
  return $result;
365
  }
366
 
367
- if (!$quote instanceof Mage_Sales_Model_Quote) {
 
368
  $result = array('success' => false, 'success_items_count' => 0);
369
  } else {
 
 
370
  $orderLink
371
  ->setNetevenOrderId($item->getOrderId())
372
  // Store Neteven marketplace order id in DB for use in finishImportProcess()
373
  ->setNetevenMarketPlaceOrderId($item->getMarketPlaceOrderId())
 
 
374
  ->setNetevenCustomerId($item->getCustomerId())
375
  ->setMagentoQuoteId($quote->getId())
376
  // Store Neteven payment method in DB for use in finishImportProcess()
377
  ->setPaymentMethod($item->getPaymentMethod())
378
  // Store Neteven order status in DB for use in finishImportProcess()
379
  ->setOrderStatus($item->getStatus())
 
 
380
  ->save();
 
 
381
  }
382
- } // Otherwise, we add new item to quote
383
  else {
384
- $quote = $this->getConvertor()->addItemToQuote($item, $quote);
 
 
 
 
 
 
 
 
 
385
 
386
- if (!$quote instanceof Mage_Sales_Model_Quote) {
 
387
  $result = array('success' => false, 'success_items_count' => 0);
388
  } else {
 
 
389
  $quote->collectTotals();
390
  $quote->save();
 
391
  }
392
  }
393
 
394
  return $result;
395
  }
396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397
  /**
398
  * Convert field string to correct Varien_Object conventions
399
  *
104
 
105
  $preparedItem = $this->_prepareFromMarketPlace($preparedItem);
106
 
107
+ // Init checksum, based on SKU, price + currency
108
+ $preparedItem->setChecksum(hash('sha1', implode('|', array(
109
+ $preparedItem->getSku(),
110
+ $preparedItem->getPrice()->getValue() / $preparedItem->getQuantity(),
111
+ $preparedItem->getPrice()->getCurrencyId(),
112
+ ))));
113
+
114
  return $preparedItem;
115
  }
116
 
149
  */
150
  public function prepareExportItem($item)
151
  {
152
+ $order = $item;
153
  $status = $this->getConfig()->getMappedOrderStatus($order->getStatus(), 'magento');
154
 
155
  $preparedItem = array(
156
  'OrderID' => $item->getNetevenOrderId(),
157
+ 'Status' => $status,
158
  );
159
 
160
+ if ($status == Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_SHIPPED && (bool) $order->hasShipments()) {
161
+ // We use only first shipment as Neteven only accepts one shipment per order
162
+ $shipment = $order->getShipmentsCollection()->getFirstItem();
 
 
163
  $dateShipping = date(DATE_ATOM, strtotime($shipment->getCreatedAt()));
164
 
165
  $preparedItem['DateShipping'] = $dateShipping;
166
 
167
  $tracks = $shipment->getAllTracks();
168
  if (count($tracks) > 0) {
169
+ $track = reset($tracks); // We use only first track as Neteven only accepts one tracking per order
170
  $preparedItem['TrackingNumber'] = $track->getNumber();
171
  }
172
  }
182
  */
183
  public function processImportItems($items)
184
  {
185
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
186
+ $logger = Mage::helper('netevensync/logger');
187
  $result = array('success' => true, 'success_items_count' => count($items));
188
  foreach ($items as $item) {
189
 
190
+ // Init the logger
191
+ $logger
192
+ ->init(sprintf("Import order item [%s]", $item->getData('market_place_order_line_id')))
193
+ ->step("Initial information (item)", $item->getData())
194
+ ->part("Process")
195
+ ;
196
+
197
+ if (!$logger->condition("Can import?", $this->_canImport($item))) {
198
+ $logger->end();
199
  continue;
200
  }
201
 
202
+ $logger->info("Retrieve the process_order_link object using the order_id");
203
  $orderLink = Mage::getModel('netevensync/process_order_link')->loadByNetevenOrderId($item->getOrderId());
204
+ $logger->step("The order link", $orderLink);
205
 
206
  // If order has already been imported and its status has changed, we update it
207
  if ($orderLink->getMagentoOrderId()) {
208
+ $logger->info("Magento's order ID found");
209
+ $logger->data(array(
210
+ "order link order status" => $orderLink->getOrderStatus(),
211
+ "item status" => $item->getStatus(),
212
+ ));
213
+ if (!$logger->condition("Same order status between orderLink and item?", $orderLink->getOrderStatus() === $item->getStatus())) {
214
+ $logger
215
+ ->up()
216
+ ->step("Update the order status of the order link")
217
+ ->result($item->getStatus(), "Order status")
218
+ ;
219
  $orderLink->setOrderStatus($item->getStatus());
220
  $orderLink->save();
221
+ $logger->down();
222
  }
223
+ }
224
+
225
+ // If order has not been imported yet, we create or update quote
226
  else {
227
+ $logger
228
+ ->step("Process quote importing")
229
+ ->up()
230
+ ;
231
  $result = $this->processImportQuote($orderLink, $item);
232
+ $logger->down();
233
  }
234
+
235
+ // Can Invoice?
236
+ $canInvoice = (int) in_array($orderLink->getOrderStatus(), Mage::getSingleton('netevensync/config')->getInvoiceStatus());
237
+ $logger->step("can invoice?", $canInvoice);
238
+
239
+ // Update the link
240
+ $orderLink
241
+ ->setCanInvoice($canInvoice)
242
+ ->setHasBeenProcessed(1)
243
+ ->save()
244
+ ;
245
+
246
+ $logger->end();
247
  }
248
 
249
  return $result;
257
  */
258
  protected function _canImport($item)
259
  {
260
+ $logger = Mage::helper('netevensync/logger');
261
 
262
  // Get address data
263
  // Check if data is empty or equal to a dash because Neteven may sends whether an empty values or a dash...
264
  $shippingAddress = $item->getShippingAddress();
265
  $address1 = $shippingAddress->getAddress1();
266
  if ($address1 == '-') {
267
+ $logger->info("Set address1 to empty string");
268
  $address1 = '';
269
  }
270
  $address2 = $shippingAddress->getAddress2();
271
  if ($address2 == '-') {
272
+ $logger->info("Set address2 to empty string");
273
  $address2 = '';
274
  }
275
  $pseudo = $item->getShippingAddress()->getPseudo();
276
  if ($pseudo == '-') {
277
+ $logger->info("Set pseudo to empty string");
278
  $pseudo = '';
279
  }
280
 
281
  // Check if shipping address is valid
282
  if ($address1 == '' && $address2 == '') {
283
+ $logger->info("Address1 and adress2 are empty");
284
  return false;
285
  }
286
 
287
  // Check if "pseudo" exists for MarketPlaceId 5
288
  if ($item->getMarketPlaceId() == '5' && $pseudo == '') {
289
+ $logger->info("Marketplace is 5 and pseudo is empty");
290
  return false;
291
  }
292
 
293
+ // Last check
294
  // Check if order status is allowed
295
  $allowedStatuses = $this->getConfig()->getAllowedNetevenOrderStatesForImport();
296
+ $goodStatus = in_array($item->getStatus(), $allowedStatuses);
297
+ $logger->step("Status allowed", $goodStatus);
298
+ if (!$goodStatus) {
299
  return false;
300
  }
301
 
325
  */
326
  public function finishImportProcess($mode)
327
  {
328
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
329
+ $logger = Mage::helper('netevensync/logger');
330
  $success = true;
331
 
332
  $this->flushTempItems();
334
  // Update already imported orders
335
  $ordersToUpdate = Mage::getModel('netevensync/process_order_link')
336
  ->getCollection()
337
+ ->addFieldToFilter('magento_order_id', array('notnull' => true))
338
+ ->addFieldToFilter('has_been_processed', 1)
339
+ ;
340
+
341
+ $logger->init("Update order [finish import process]");
342
 
343
  if ($ordersToUpdate->count()) {
344
  foreach ($ordersToUpdate as $orderLink) {
345
+ $logger
346
+ ->part(sprintf("Update order %d", $orderLink->getMagentoOrderId()))
347
+ ;
348
+ $logger->data("link", $orderLink);
349
  $order = Mage::getModel('sales/order')->load($orderLink->getMagentoOrderId());
350
+ $logger->step("Load order", $order->getData());
351
+ $logger->up();
352
+ $this->getConvertor()->updateOrder($order, $orderLink->getOrderStatus(), (bool) $orderLink->getCanInvoice());
353
  }
354
  }
355
 
356
+ $logger->end();
357
+
358
  // Create not yet imported orders
359
  $ordersToCreate = Mage::getModel('netevensync/process_order_link')
360
  ->getCollection()
361
+ ->addFieldToFilter('magento_order_id', array('null' => true))
362
+ ->addFieldToFilter('has_been_processed', 1)
363
+ ;
364
 
365
+ $logger->init("Create orders");
366
 
367
+ if ($logger->condition("How many orders to create?", $ordersToCreate->count())) {
368
+ $logger->info("Loop on orders to create");
369
  foreach ($ordersToCreate as $orderLink) {
370
+ $logger->part("Create order");
371
+ $logger->data('order link', $orderLink);
372
+
373
  $quote = Mage::getModel('sales/quote');
374
+ $store = Mage::app()->getStore($orderLink->getStoreId());
375
+ $quote->setStore($store)->load($orderLink->getMagentoQuoteId());
376
 
377
  // Retrieve payment from DB and assign it to quote
378
  $quotePayment = $quote->getPayment();
388
  // Retrieve Neteven market place order id from DB and assign to quote
389
  $quote->setNetevenMarketPlaceOrderId($orderLink->getNetevenMarketPlaceOrderId());
390
 
391
+ // Retrieve Neteven market place name from DB and assign to quote
392
+ $quote->setNetevenMarketPlaceName($orderLink->getNetevenMarketPlaceName());
393
+
394
+ // Can invoice the order?
395
+ $quote->setCanInvoiceOrder((bool) $orderLink->getCanInvoice());
396
+
397
  $order = $this->getConvertor()->createOrder($quote);
398
 
399
  if ($orderId = $order->getId()) {
405
  }
406
  }
407
 
408
+ $logger->end();
409
+
410
+ // Bulk update
411
+ $links = Mage::getModel('netevensync/process_order_link')
412
+ ->getCollection()
413
+ ->addFieldToFilter('has_been_processed', 1)
414
+ ;
415
+ foreach ($links as $link) {
416
+ $link
417
+ ->setHasBeenProcessed(null)
418
+ ->save()
419
+ ;
420
+ }
421
+
422
  return $success;
423
  }
424
 
444
  */
445
  public function processImportQuote($orderLink, $item)
446
  {
447
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
448
+ $logger = Mage::helper('netevensync/logger');
449
 
450
  $result = array('success' => true, 'success_items_count' => 1);
451
+
452
+ $logger->info("Instanciate new quote");
453
  $quote = Mage::getModel('sales/quote');
454
 
455
  if ($magentoQuoteId = $orderLink->getMagentoQuoteId()) {
456
+ $logger->info("Set the quote store in purpose to load the quote");
457
+
458
+ $store = $orderLink->getStoreId() ? Mage::app()->getStore($orderLink->getStoreId()) : Mage::app()->getDefaultStoreView();
459
+
460
+ $logger->logStore($store);
461
+ Mage::helper('netevensync')->updateStoreConfiguration($store);
462
+
463
+ $logger->info("Load the quote");
464
+ $quote
465
+ ->setStore($store)
466
+ ->load($magentoQuoteId)
467
+ ;
468
  }
469
 
470
  // If quote does not exist in Magento, we create it
471
+ if ($logger->condition("Is the quote a new one?", !$quote->getId())) {
 
472
  try {
473
+ $logger->info("Create the quote");
474
  $quote = $this->getConvertor()->createQuote($item);
475
  } catch (Exception $e) {
476
+ $logger->exception($e);
477
+ Mage::helper('netevensync')->log($e);
478
  $result = array('success' => false, 'success_items_count' => 0);
479
  return $result;
480
  }
481
 
482
+ if (!$logger->condition("Is the quote a real quote?", $quote instanceof Mage_Sales_Model_Quote)) {
483
+ $logger->up()->err("What?")->down();
484
  $result = array('success' => false, 'success_items_count' => 0);
485
  } else {
486
+ $logger->startComparison("Update the order link", $orderLink->getData());
487
+
488
  $orderLink
489
  ->setNetevenOrderId($item->getOrderId())
490
  // Store Neteven marketplace order id in DB for use in finishImportProcess()
491
  ->setNetevenMarketPlaceOrderId($item->getMarketPlaceOrderId())
492
+ // Store Neteven marketplace name in DB for use in finishImportProcess()
493
+ ->setNetevenMarketPlaceName($item->getMarketPlaceName())
494
  ->setNetevenCustomerId($item->getCustomerId())
495
  ->setMagentoQuoteId($quote->getId())
496
  // Store Neteven payment method in DB for use in finishImportProcess()
497
  ->setPaymentMethod($item->getPaymentMethod())
498
  // Store Neteven order status in DB for use in finishImportProcess()
499
  ->setOrderStatus($item->getStatus())
500
+ // Store ID Magento
501
+ ->setStoreId($quote->getStoreId())
502
  ->save();
503
+
504
+ $logger->endComparison($orderLink->getData());
505
  }
506
+ } // Otherwise, we try to add new item to quote
507
  else {
508
+ $logger->info("The quote exists, update it");
509
+ $logger->step("The existing quote", $quote->getData());
510
+ $logger->info("We try to add new item to existing quote");
511
+ if ($logger->condition("Do the quote already have the item?", $this->_quoteHasItem($quote, $item))) {
512
+ $logger->info("Update item qty");
513
+ $this->getConvertor()->updateQuoteItem($item, $quote);
514
+ } else {
515
+ $logger->info("Add item to quote");
516
+ $quote = $this->getConvertor()->addItemToQuote($item, $quote);
517
+ }
518
 
519
+ if (!$logger->condition("Is the quote a real one?", $quote instanceof Mage_Sales_Model_Quote)) {
520
+ $logger->up()->err("What?")->down();
521
  $result = array('success' => false, 'success_items_count' => 0);
522
  } else {
523
+ $logger->info("Collect quote totals and save");
524
+ $logger->startComparison("Quote", $quote->getData());
525
  $quote->collectTotals();
526
  $quote->save();
527
+ $logger->endComparison($quote->getData());
528
  }
529
  }
530
 
531
  return $result;
532
  }
533
 
534
+ /**
535
+ * Check if quote already has item
536
+ *
537
+ * @param Mage_Sales_Model_Quote $quote
538
+ * @param Varien_Object $netevenItem
539
+ * @return bool
540
+ */
541
+ protected function _quoteHasItem($quote, $netevenItem)
542
+ {
543
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
544
+ $logger = Mage::helper('netevensync/logger');
545
+
546
+ $logger->up();
547
+ $logger->data("Neteven item checksum", $netevenItem->getChecksum());
548
+
549
+ $quoteItems = $quote->getAllItems();
550
+ foreach ($quoteItems as $quoteItem) {
551
+ $logger->info(sprintf("Compare to %s", $quoteItem->getNetevenChecksum()));
552
+ if ($quoteItem->getNetevenChecksum() === $netevenItem->getChecksum()) {
553
+ $logger->down();
554
+ return true;
555
+ }
556
+ }
557
+
558
+ $logger->down();
559
+ return false;
560
+ }
561
+
562
  /**
563
  * Convert field string to correct Varien_Object conventions
564
  *
app/code/community/Neteven/NetevenSync/Model/Process/Order/Convertor.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Order / quote converter model
4
  *
@@ -8,7 +9,8 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Model_Process_Order_Convertor {
 
12
 
13
  /**
14
  * Countries collection
@@ -85,8 +87,9 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
85
  *
86
  * @return Neteven_NetevenSync_Model_Config
87
  */
88
- public function getConfig(){
89
- if(is_null($this->_config)) {
 
90
  $this->_config = Mage::getSingleton('netevensync/config');
91
  }
92
  return $this->_config;
@@ -98,57 +101,75 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
98
  * @param Varien_Object $netevenItem
99
  * @return Mage_Sales_Model_Quote
100
  */
101
- public function createQuote($netevenItem) {
 
 
 
 
102
 
103
- $billingAddress = $netevenItem->getBillingAddress();
104
  $shippingAddress = $netevenItem->getShippingAddress();
105
- $addresses = array('billingAddress' => $billingAddress, 'shippingAddress' => $shippingAddress);
106
 
107
  // Find store for quote
108
  $storeId = $this->getConfig()->getStoreIdForMarketplace($netevenItem->getMarketPlaceId());
109
- if($storeId) {
 
 
 
 
110
  $store = Mage::getModel('core/store')->load($storeId);
111
- }
112
- else {
113
  $store = Mage::app()->getDefaultStoreView();
114
  }
 
 
 
 
115
 
116
  // Create quote and add item
117
  $quote = Mage::getModel('sales/quote');
118
  $quote->setIsMultiShipping(false)
119
- ->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST)
120
- ->setCustomerId(null)
121
- ->setCustomerEmail($billingAddress->getEmail())
122
- ->setCustomerIsGuest(true)
123
- ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)
124
- ->setStore($store)
125
  ;
126
 
127
  $quote = $this->addItemToQuote($netevenItem, $quote);
128
 
129
- if(!$quote) {
 
 
130
  return false;
131
  }
132
 
133
  // Retrieve Neteven address fields and concatenate for addresses objects
134
  $addressForm = Mage::getModel('customer/form');
135
  $addressForm->setFormCode('customer_address_edit')
136
- ->setEntityType('customer_address')
137
  ;
138
 
139
- foreach($addresses as $name => $address) {
140
- foreach($addressForm->getAttributes() as $attribute) {
 
 
 
 
 
141
  $mappedAttributeCode = $this->getConfig()->getMappedAddressAttributeCode($attribute->getAttributeCode());
142
- $value = array();
143
- if(is_array($mappedAttributeCode)) {
144
- foreach($mappedAttributeCode as $attributeCode) {
145
- if($shippingAddress->getData($attributeCode)) {
146
  $value[] = $address->getData($attributeCode);
147
  }
148
  }
149
- }
150
- else {
151
- if($shippingAddress->getData($mappedAttributeCode)) {
152
  $value[] = $address->getData($mappedAttributeCode);
153
  }
154
  }
@@ -159,42 +180,88 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
159
  }
160
 
161
  // Manage country based on MarketPlaceId
162
- if(empty($value) && $attribute->getAttributeCode() == 'country_id') {
163
- $value[] = $this->getConfig()->getCountryIdForMarketPlaceId($netevenItem->getMarketPlaceId());
164
  }
165
 
166
- if(count($value) > 0) {
167
- $value = implode(' ', $value);
 
168
 
169
  // Retrieve country code
170
- if($attribute->getAttributeCode() == 'country_id') {
171
  $value = $this->_getCountryId($value);
172
  }
173
 
 
174
  $method = 'get' . ucfirst($name);
175
  $quote->$method()->setData($attribute->getAttributeCode(), $value);
176
  }
177
  }
 
178
  }
179
 
180
  // Force shipping price and method
181
  Mage::getSingleton('checkout/session')
182
- ->setNetevenShippingPrice($netevenItem->getOrderShippingCost()->getValue())
183
- ->setIsFromNeteven(true)
184
  ;
185
 
186
  $quote->getShippingAddress()
187
- ->setShippingMethod('neteven_dynamic')
188
- ->setCollectShippingRates(true)
189
- ->collectShippingRates();
190
 
191
  // Update quote with new data
 
192
  $quote->collectTotals();
193
  $quote->save();
194
 
 
 
 
 
 
195
  return $quote;
196
  }
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  /**
199
  * Add item to quote
200
  *
@@ -202,43 +269,64 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
202
  * @param Mage_Sales_Mode_Quote
203
  * @return Mage_Sales_Mode_Quote
204
  */
205
- public function addItemToQuote($netevenItem, $quote) {
 
 
 
 
206
 
207
  $quote->setIsSuperMode(true); // to avoid qty check
208
 
 
 
209
  $productModel = Mage::getModel('catalog/product');
210
- $product = $productModel->load($productModel->getIdBySku($netevenItem->getSku()));
211
 
212
  // Check that product exists in catalog
213
- if(!$product->getId()) {
 
 
214
  $message = Mage::helper('netevensync')->__('Imported order item does not exist in catalog. Item ID: %s, Order ID: %s, Sku: %s', $netevenItem->getId(), $netevenItem->getOrderId(), $netevenItem->getSku());
215
  Mage::helper('netevensync')->log($message, Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE);
216
  return false;
217
  }
218
 
219
  // Check that product can be added to quote based on its type
220
- if(!in_array($product->getTypeId(), $this->getConfig()->getAvailableProductTypes())) {
 
 
 
221
  $message = Mage::helper('netevensync')->__('Imported order item is of type "%s" which is not allowed for orders import. Item ID: %s, Order ID: %s, Sku: %s', $product->getTypeId(), $netevenItem->getId(), $netevenItem->getOrderId(), $netevenItem->getSku());
222
  Mage::helper('netevensync')->log($message, Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE);
223
  return false;
224
  }
225
 
226
  // Create quote item
 
227
  $quoteItem = Mage::getModel('sales/quote_item');
228
 
229
  // Force price to Neteven price (price incl VAT)
 
230
  $price = $netevenItem->getPrice()->getValue() / $netevenItem->getQuantity();
231
 
 
232
  $quoteItem
233
  ->setProduct($product)
234
  ->setCustomPrice($price)
235
  ->setOriginalCustomPrice($price)
236
  ->setQuote($quote)
237
  ->setQty($netevenItem->getQuantity())
 
238
  ;
 
239
 
 
240
  $quote->addItem($quoteItem);
241
 
 
 
 
 
242
  return $quote;
243
  }
244
 
@@ -248,15 +336,23 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
248
  * @param Mage_Sales_Model_Quote
249
  * @return Mage_Sales_Model_Order
250
  */
251
- public function createOrder($quote) {
 
 
 
 
 
252
 
253
  try {
254
  // Convert quote to order...
255
  $items = $quote->getAllItems();
256
  $quote->reserveOrderId();
 
257
 
258
  $convertQuote = Mage::getSingleton('sales/convert_quote');
259
- $order = $convertQuote->addressToOrder($quote->getShippingAddress());
 
 
260
 
261
  $order->setBillingAddress($convertQuote->addressToOrderAddress($quote->getBillingAddress()));
262
  $order->setShippingAddress($convertQuote->addressToOrderAddress($quote->getShippingAddress()));
@@ -274,16 +370,31 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
274
  $order->place();
275
 
276
  // Update order state and status, add a comment to order history
277
- $status = $this->getConfig()->getMappedOrderStatus($quote->getOrderStatus());
278
- $state = $this->getConfig()->getMappedOrderState($quote->getOrderStatus());
 
 
 
 
279
  $comment = Mage::helper('netevensync')->__('Order %s imported from Neteven', $quote->getNetevenMarketPlaceOrderId());
280
 
281
- if($state == Mage_Sales_Model_Order::STATE_CLOSED) {
282
  // If imported new order is refunded / closed, we cancel it straight away
 
283
  $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, $status, $comment);
284
- }
285
- else {
286
- $order->setState($state, $status, $comment);
 
 
 
 
 
 
 
 
 
 
287
  }
288
 
289
  // Save order in order for save to be observed and order to be registered for incremental export
@@ -295,12 +406,14 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
295
  $this->_updateCatalogInventory($order);
296
 
297
  // Create invoice, shipment, cancelation, creditmemo when needed
298
- $this->_runAdditionalOperations($order, $quote->getOrderStatus());
299
 
300
- return $order;
301
 
302
- } catch (Exception $e){
303
- Mage::helper('netevensync')->log($e->getMessage(), Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE);
 
 
304
  return false;
305
  }
306
  }
@@ -310,10 +423,17 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
310
  *
311
  * @param Mage_Sales_Mode_Order $order
312
  * @param string $status
 
313
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
314
  */
315
- public function updateOrder($order, $status) {
316
- return $this->_runAdditionalOperations($order, $status);
 
 
 
 
 
 
317
  }
318
 
319
  /**
@@ -322,19 +442,36 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
322
  * @param Mage_Sales_Mode_Order $order
323
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
324
  */
325
- protected function _updateCatalogInventory($order) {
 
 
 
 
 
 
326
  $items = $order->getAllItems();
327
- foreach($items as $item) {
328
- $product = $item->getProduct();
329
  $stockItem = $product->getStockItem();
330
- $qty = $stockItem->getQty() - $item->getQtyOrdered();
331
- if($qty < 0) {
 
 
 
 
332
  $qty = 0;
333
  }
334
  $stockItem->setQty($qty)->save();
 
 
 
335
  Mage::getModel('netevensync/process_inventory')->registerIncrement($product);
 
 
336
  }
337
 
 
 
338
  return $this;
339
  }
340
 
@@ -343,45 +480,55 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
343
  *
344
  * @param Mage_Sales_Mode_Order $order
345
  * @param string $status
 
346
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
347
  */
348
- protected function _runAdditionalOperations($order, $status) {
349
- $this->_hasInvoices = (bool) $order->hasInvoices();
350
- $this->_hasShipments = (bool) $order->hasShipments();
351
- $this->_isCanceled = (bool) $order->isCanceled();
352
- $this->_isRefunded = (bool) $order->hasCreditmemos();
353
-
354
- if(!$this->_hasInvoices && !$this->_isCanceled && !$this->_isRefunded) {
355
- $this->_canInvoice = true;
356
- }
357
 
358
- if(!$this->_hasShipments && !$this->_isCanceled && !$this->_isRefunded) {
359
- $this->_canShip = true;
360
- }
361
-
362
- if(!$this->_isCanceled && !$this->_hasInvoices) {
363
- $this->_canCancel = true;
364
- }
365
-
366
- if(!$this->_isRefunded && $this->_hasInvoices) {
367
- $this->_canRefund = true;
368
- }
369
-
370
- switch($status) {
 
 
 
 
 
 
371
  case Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_CONFIRMED:
 
372
  $this->invoice($order);
373
  break;
374
  case Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_SHIPPED:
 
375
  $this->ship($order);
 
376
  break;
377
  case Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_CANCELED:
 
 
378
  $this->cancel($order);
379
  break;
380
  case Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_REFUNDED:
 
 
381
  $this->refund($order);
382
  break;
383
  }
384
 
 
385
  $order
386
  ->setIsFromImport(true) // @see Neteven_NetevenSync_Model_Process_Order::registerIncrement()
387
  ->save();
@@ -395,18 +542,26 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
395
  * @param Mage_Sales_Model_Order
396
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
397
  */
398
- public function invoice($order) {
399
- if($this->_canInvoice && $order->canInvoice()) {
 
 
 
 
 
400
  $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
401
- if($invoice) {
 
 
402
  $invoice->register();
403
  $invoice->getOrder()->setIsInProcess(true);
404
  $transactionSave = Mage::getModel('core/resource_transaction')
405
- ->addObject($invoice)
406
- ->addObject($invoice->getOrder());
407
  $transactionSave->save();
408
 
409
  $this->_hasInvoices = true;
 
410
  }
411
  }
412
 
@@ -419,15 +574,16 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
419
  * @param Mage_Sales_Model_Order
420
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
421
  */
422
- public function ship($order) {
423
- if($this->_canShip && $order->canShip()) {
 
424
  $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment();
425
- if($shipment) {
426
  $shipment->register();
427
  $shipment->getOrder()->setIsInProcess(true);
428
  $transactionSave = Mage::getModel('core/resource_transaction')
429
- ->addObject($shipment)
430
- ->addObject($shipment->getOrder());
431
  $transactionSave->save();
432
 
433
  $this->_hasShipments = true;
@@ -445,8 +601,9 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
445
  * @param Mage_Sales_Model_Order
446
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
447
  */
448
- public function cancel($order) {
449
- if($this->_canCancel) {
 
450
  $order->cancel();
451
  $this->_isCanceled = true;
452
  }
@@ -460,20 +617,21 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
460
  * @param Mage_Sales_Model_Order
461
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
462
  */
463
- public function refund($order) {
464
- if($this->_canRefund && $order->canCreditmemo()) {
 
465
  $invoiceId = $order->getInvoiceCollection()->getFirstItem()->getId();
466
 
467
- if(!$invoiceId) {
468
  return $this;
469
  }
470
 
471
- $invoice = Mage::getModel('sales/order_invoice')->load($invoiceId)->setOrder($order);
472
- $service = Mage::getModel('sales/service_order', $order);
473
  $creditmemo = $service->prepareInvoiceCreditmemo($invoice);
474
 
475
  $backToStock = array();
476
- foreach($order->getAllItems() as $item) {
477
  $backToStock[$item->getId()] = true;
478
  }
479
 
@@ -489,8 +647,8 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
489
  $creditmemo->register();
490
 
491
  $transactionSave = Mage::getModel('core/resource_transaction')
492
- ->addObject($creditmemo)
493
- ->addObject($creditmemo->getOrder());
494
  if ($creditmemo->getInvoice()) {
495
  $transactionSave->addObject($creditmemo->getInvoice());
496
  }
@@ -508,15 +666,17 @@ class Neteven_NetevenSync_Model_Process_Order_Convertor {
508
  * @param string $countryName
509
  * @return string
510
  */
511
- protected function _getCountryId($countryName) {
512
- if(is_null($this->_countryCollection)) {
 
513
  $this->_countryCollection = Mage::getResourceModel('directory/country_collection')->toOptionArray();
514
  }
515
- foreach($this->_countryCollection as $country) {
516
- if(strtolower($country['label']) == strtolower($countryName)) {
517
  return $country['value'];
518
  }
519
  }
520
  return $countryName;
521
  }
522
- }
 
1
  <?php
2
+
3
  /**
4
  * Order / quote converter model
5
  *
9
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
11
  */
12
+ class Neteven_NetevenSync_Model_Process_Order_Convertor
13
+ {
14
 
15
  /**
16
  * Countries collection
87
  *
88
  * @return Neteven_NetevenSync_Model_Config
89
  */
90
+ public function getConfig()
91
+ {
92
+ if (is_null($this->_config)) {
93
  $this->_config = Mage::getSingleton('netevensync/config');
94
  }
95
  return $this->_config;
101
  * @param Varien_Object $netevenItem
102
  * @return Mage_Sales_Model_Quote
103
  */
104
+ public function createQuote($netevenItem)
105
+ {
106
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
107
+ $logger = Mage::helper('netevensync/logger');
108
+ $logger->step("Create quote using the convertor")->up();
109
 
110
+ $billingAddress = $netevenItem->getBillingAddress();
111
  $shippingAddress = $netevenItem->getShippingAddress();
112
+ $addresses = array('billingAddress' => $billingAddress, 'shippingAddress' => $shippingAddress);
113
 
114
  // Find store for quote
115
  $storeId = $this->getConfig()->getStoreIdForMarketplace($netevenItem->getMarketPlaceId());
116
+ $logger->data(array(
117
+ "marketplace_id" => $netevenItem->getMarketPlaceId(),
118
+ "store_id" => $storeId,
119
+ ));
120
+ if ($logger->condition("Has store ID", (bool) $storeId)) {
121
  $store = Mage::getModel('core/store')->load($storeId);
122
+ } else {
123
+ $logger->info("Use default store view");
124
  $store = Mage::app()->getDefaultStoreView();
125
  }
126
+ $logger->logStore($store);
127
+
128
+ // Update store configuration
129
+ Mage::helper('netevensync')->updateStoreConfiguration($store);
130
 
131
  // Create quote and add item
132
  $quote = Mage::getModel('sales/quote');
133
  $quote->setIsMultiShipping(false)
134
+ ->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST)
135
+ ->setCustomerId(null)
136
+ ->setCustomerEmail($billingAddress->getEmail())
137
+ ->setCustomerIsGuest(true)
138
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)
139
+ ->setStore($store)
140
  ;
141
 
142
  $quote = $this->addItemToQuote($netevenItem, $quote);
143
 
144
+ if (!$quote) {
145
+ $logger->err("Quote not returned by the addItemToQuote call");
146
+ $logger->up()->data("Returned instead", $quote)->down();
147
  return false;
148
  }
149
 
150
  // Retrieve Neteven address fields and concatenate for addresses objects
151
  $addressForm = Mage::getModel('customer/form');
152
  $addressForm->setFormCode('customer_address_edit')
153
+ ->setEntityType('customer_address')
154
  ;
155
 
156
+ $logger->info("Process the addresses");
157
+ foreach ($addresses as $name => $address) {
158
+ $logger
159
+ ->step("Process $name address")
160
+ ->up()
161
+ ;
162
+ foreach ($addressForm->getAttributes() as $attribute) {
163
  $mappedAttributeCode = $this->getConfig()->getMappedAddressAttributeCode($attribute->getAttributeCode());
164
+ $value = array();
165
+ if (is_array($mappedAttributeCode)) {
166
+ foreach ($mappedAttributeCode as $attributeCode) {
167
+ if ($shippingAddress->getData($attributeCode)) {
168
  $value[] = $address->getData($attributeCode);
169
  }
170
  }
171
+ } else {
172
+ if ($shippingAddress->getData($mappedAttributeCode)) {
 
173
  $value[] = $address->getData($mappedAttributeCode);
174
  }
175
  }
180
  }
181
 
182
  // Manage country based on MarketPlaceId
183
+ if (empty($value) && $attribute->getAttributeCode() == 'country_id') {
184
+ $value[] = $this->getConfig()->getAddressCountryForMarketPlaceId($netevenItem->getMarketPlaceId());
185
  }
186
 
187
+ if (count($value) > 0) {
188
+
189
+ $value = ($attribute->getAttributeCode() == 'street') ? implode("\n", $value) : implode(' ', $value);
190
 
191
  // Retrieve country code
192
+ if ($attribute->getAttributeCode() == 'country_id') {
193
  $value = $this->_getCountryId($value);
194
  }
195
 
196
+ $logger->data($attribute->getAttributeCode(), $value);
197
  $method = 'get' . ucfirst($name);
198
  $quote->$method()->setData($attribute->getAttributeCode(), $value);
199
  }
200
  }
201
+ $logger->down();
202
  }
203
 
204
  // Force shipping price and method
205
  Mage::getSingleton('checkout/session')
206
+ ->setNetevenShippingPrice($netevenItem->getOrderShippingCost()->getValue())
207
+ ->setIsFromNeteven(true)
208
  ;
209
 
210
  $quote->getShippingAddress()
211
+ ->setShippingMethod('neteven_dynamic')
212
+ ->setCollectShippingRates(true)
213
+ ->collectShippingRates();
214
 
215
  // Update quote with new data
216
+ $logger->info("Collect quote totals and save");
217
  $quote->collectTotals();
218
  $quote->save();
219
 
220
+ $logger
221
+ ->info("Returns the quote")
222
+ ->down()
223
+ ;
224
+
225
  return $quote;
226
  }
227
 
228
+ /**
229
+ * Update item in quote
230
+ * @param Varien_Object $netevenItem
231
+ * @param Mage_Sales_Mode_Quote
232
+ * @return Neteven_NetevenSync_Model_Process_Order_Convertor
233
+ */
234
+ public function updateQuoteItem($netevenItem, $quote)
235
+ {
236
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
237
+ $logger = Mage::helper('netevensync/logger');
238
+ $logger->step("Update quote item");
239
+
240
+ // Find quote item
241
+ $quoteItems = $quote->getAllItems();
242
+ $found = false;
243
+ foreach ($quoteItems as $quoteItem) {
244
+ if ($quoteItem->getNetevenChecksum() == $netevenItem->getChecksum()) {
245
+ $logger->info("Quote item found using checksum");
246
+ $found = $quoteItem;
247
+ break;
248
+ }
249
+ }
250
+
251
+ // Item found
252
+ if ($found !== false) {
253
+ $logger->data("old quantity", $found->getQty());
254
+ $found->setQty($found->getQty() + $netevenItem->getQuantity());
255
+ $logger->data("new quantity", $found->getQty());
256
+ } else {
257
+ $logger->err("Quote item not found");
258
+ }
259
+
260
+ $logger->down();
261
+
262
+ return $this;
263
+ }
264
+
265
  /**
266
  * Add item to quote
267
  *
269
  * @param Mage_Sales_Mode_Quote
270
  * @return Mage_Sales_Mode_Quote
271
  */
272
+ public function addItemToQuote($netevenItem, $quote)
273
+ {
274
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
275
+ $logger = Mage::helper('netevensync/logger');
276
+ $logger->step("Add item to quote")->up();
277
 
278
  $quote->setIsSuperMode(true); // to avoid qty check
279
 
280
+ $logger->info("Load the product");
281
+ $logger->up()->data("SKU", $netevenItem->getSku())->down();
282
  $productModel = Mage::getModel('catalog/product');
283
+ $product = $productModel->load($productModel->getIdBySku($netevenItem->getSku()));
284
 
285
  // Check that product exists in catalog
286
+ if (!$product->getId()) {
287
+ $logger->err("Product not found?");
288
+ $logger->step("Neteven item", $netevenItem->getData());
289
  $message = Mage::helper('netevensync')->__('Imported order item does not exist in catalog. Item ID: %s, Order ID: %s, Sku: %s', $netevenItem->getId(), $netevenItem->getOrderId(), $netevenItem->getSku());
290
  Mage::helper('netevensync')->log($message, Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE);
291
  return false;
292
  }
293
 
294
  // Check that product can be added to quote based on its type
295
+ $logger->data("Product type ID", $product->getTypeId());
296
+ $logger->data("Available types in config", $this->getConfig()->getAvailableProductTypes());
297
+ if (!$logger->condition("Is the product type available?", in_array($product->getTypeId(), $this->getConfig()->getAvailableProductTypes()))) {
298
+ $logger->err("Type unavailable, see values above");
299
  $message = Mage::helper('netevensync')->__('Imported order item is of type "%s" which is not allowed for orders import. Item ID: %s, Order ID: %s, Sku: %s', $product->getTypeId(), $netevenItem->getId(), $netevenItem->getOrderId(), $netevenItem->getSku());
300
  Mage::helper('netevensync')->log($message, Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE);
301
  return false;
302
  }
303
 
304
  // Create quote item
305
+ $logger->info("Create the quote item");
306
  $quoteItem = Mage::getModel('sales/quote_item');
307
 
308
  // Force price to Neteven price (price incl VAT)
309
+ $logger->info("Divide neteven price by neteven quantity");
310
  $price = $netevenItem->getPrice()->getValue() / $netevenItem->getQuantity();
311
 
312
+ $logger->startComparison("Fill the quote item", $quoteItem->getData());
313
  $quoteItem
314
  ->setProduct($product)
315
  ->setCustomPrice($price)
316
  ->setOriginalCustomPrice($price)
317
  ->setQuote($quote)
318
  ->setQty($netevenItem->getQuantity())
319
+ ->setNetevenChecksum($netevenItem->getChecksum())
320
  ;
321
+ $logger->endComparison($quoteItem->getData());
322
 
323
+ $logger->info("Call addItem on the quote");
324
  $quote->addItem($quoteItem);
325
 
326
+ $logger
327
+ ->info("Returns the quote")
328
+ ->down()
329
+ ;
330
  return $quote;
331
  }
332
 
336
  * @param Mage_Sales_Model_Quote
337
  * @return Mage_Sales_Model_Order
338
  */
339
+ public function createOrder($quote)
340
+ {
341
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
342
+ $logger = Mage::helper('netevensync/logger');
343
+ $logger->step("Create order using quote");
344
+ $logger->up();
345
 
346
  try {
347
  // Convert quote to order...
348
  $items = $quote->getAllItems();
349
  $quote->reserveOrderId();
350
+ $logger->result($quote->getReservedOrderId(), "Reserved order ID");
351
 
352
  $convertQuote = Mage::getSingleton('sales/convert_quote');
353
+
354
+ /* @var $order Mage_Sales_Model_Order */
355
+ $order = $convertQuote->addressToOrder($quote->getShippingAddress());
356
 
357
  $order->setBillingAddress($convertQuote->addressToOrderAddress($quote->getBillingAddress()));
358
  $order->setShippingAddress($convertQuote->addressToOrderAddress($quote->getShippingAddress()));
370
  $order->place();
371
 
372
  // Update order state and status, add a comment to order history
373
+ $status = $this->getConfig()->getMappedOrderStatus($quote->getOrderStatus());
374
+ $state = $this->getConfig()->getMappedOrderState($quote->getOrderStatus());
375
+ $logger->step("Statuses", array(
376
+ 'status' => $status,
377
+ 'state' => $state,
378
+ ));
379
  $comment = Mage::helper('netevensync')->__('Order %s imported from Neteven', $quote->getNetevenMarketPlaceOrderId());
380
 
381
+ if ($state == Mage_Sales_Model_Order::STATE_CLOSED) {
382
  // If imported new order is refunded / closed, we cancel it straight away
383
+ $logger->info("State is closed, cancel the order");
384
  $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, $status, $comment);
385
+ } else {
386
+
387
+ // State protected
388
+ if ($order->isStateProtected($state)) {
389
+ // State is complete, because other protected state (closed) is processed above
390
+ $logger->info(sprintf("State (%s) is protected", $state));
391
+
392
+ // Just comment
393
+ $history = $order->addStatusHistoryComment($comment, false); // no sense to set $status again
394
+ $history->setIsCustomerNotified(false); // for backwards compatibility
395
+ } else {
396
+ $order->setState($state, $status, $comment);
397
+ }
398
  }
399
 
400
  // Save order in order for save to be observed and order to be registered for incremental export
406
  $this->_updateCatalogInventory($order);
407
 
408
  // Create invoice, shipment, cancelation, creditmemo when needed
409
+ $this->_runAdditionalOperations($order, $quote->getOrderStatus(), $quote->getCanInvoiceOrder());
410
 
411
+ $logger->down();
412
 
413
+ return $order;
414
+ } catch (Exception $e) {
415
+ $logger->exception($e);
416
+ Mage::helper('netevensync')->log($e, Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE);
417
  return false;
418
  }
419
  }
423
  *
424
  * @param Mage_Sales_Mode_Order $order
425
  * @param string $status
426
+ * @param bool $isPaid
427
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
428
  */
429
+ public function updateOrder($order, $status, $isPaid)
430
+ {
431
+ $logger = Mage::helper('netevensync/logger');
432
+ $logger->info(sprintf("Update order %d with status %s and run additional operations", $order->getId(), $status));
433
+ $logger->up();
434
+ $ret = $this->_runAdditionalOperations($order, $status, $isPaid);
435
+ $logger->down();
436
+ return $ret;
437
  }
438
 
439
  /**
442
  * @param Mage_Sales_Mode_Order $order
443
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
444
  */
445
+ protected function _updateCatalogInventory($order)
446
+ {
447
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
448
+ $logger = Mage::helper('netevensync/logger');
449
+ $logger->info("Update catalog inventory");
450
+ $logger->up();
451
+
452
  $items = $order->getAllItems();
453
+ foreach ($items as $item) {
454
+ $product = $item->getProduct();
455
  $stockItem = $product->getStockItem();
456
+
457
+ $logger->step(sprintf("Product %s", $product->getSku()))->up();
458
+ $logger->startComparison("Stock item", $stockItem->getData());
459
+
460
+ $qty = $stockItem->getQty() - $item->getQtyOrdered();
461
+ if ($qty < 0) {
462
  $qty = 0;
463
  }
464
  $stockItem->setQty($qty)->save();
465
+
466
+ $logger->endComparison($stockItem->getData());
467
+
468
  Mage::getModel('netevensync/process_inventory')->registerIncrement($product);
469
+
470
+ $logger->down();
471
  }
472
 
473
+ $logger->down();
474
+
475
  return $this;
476
  }
477
 
480
  *
481
  * @param Mage_Sales_Mode_Order $order
482
  * @param string $status
483
+ * @param bool|int $canInvoice
484
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
485
  */
486
+ protected function _runAdditionalOperations($order, $status, $canInvoice)
487
+ {
488
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
489
+ $logger = Mage::helper('netevensync/logger');
 
 
 
 
 
490
 
491
+ $this->_hasInvoices = (bool) $order->hasInvoices();
492
+ $this->_hasShipments = (bool) $order->hasShipments();
493
+ $this->_isCanceled = (bool) $order->isCanceled();
494
+ $this->_isRefunded = (bool) $order->hasCreditmemos();
495
+
496
+ $this->_canInvoice = (!$this->_hasInvoices && !$this->_isCanceled && !$this->_isRefunded && (bool) $canInvoice);
497
+ $this->_canShip = (!$this->_hasShipments && !$this->_isCanceled && !$this->_isRefunded);
498
+ $this->_canCancel = (!$this->_isCanceled && !$this->_hasInvoices);
499
+ $this->_canRefund = (!$this->_isRefunded && $this->_hasInvoices);
500
+
501
+ $logger->step("Order flags", array(
502
+ "can invoice" => $this->_canInvoice,
503
+ "can ship" => $this->_canShip,
504
+ "can cancel" => $this->_canCancel,
505
+ "can refund" => $this->_canRefund,
506
+ ));
507
+
508
+ $logger->data("order status [neteven]", $status);
509
+ switch ($status) {
510
  case Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_CONFIRMED:
511
+ $logger->info("Process invoice");
512
  $this->invoice($order);
513
  break;
514
  case Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_SHIPPED:
515
+ $logger->info("Process ship");
516
  $this->ship($order);
517
+ $this->invoice($order);
518
  break;
519
  case Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_CANCELED:
520
+ $logger->info("Process cancel");
521
+ $this->invoice($order);
522
  $this->cancel($order);
523
  break;
524
  case Neteven_NetevenSync_Model_Config::NETEVENSYNC_ORDER_STATUS_REFUNDED:
525
+ $logger->info("Process refund");
526
+ $this->invoice($order);
527
  $this->refund($order);
528
  break;
529
  }
530
 
531
+ $logger->info("Save the order");
532
  $order
533
  ->setIsFromImport(true) // @see Neteven_NetevenSync_Model_Process_Order::registerIncrement()
534
  ->save();
542
  * @param Mage_Sales_Model_Order
543
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
544
  */
545
+ public function invoice($order)
546
+ {
547
+ /* @var $logger Neteven_NetevenSync_Helper_Logger */
548
+ $logger = Mage::helper('netevensync/logger');
549
+
550
+ if ($this->_canInvoice && $order->canInvoice()) {
551
+ $logger->info("Prepare invoice");
552
  $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
553
+ if ($invoice) {
554
+ $logger->up();
555
+ $logger->info("Register invoice");
556
  $invoice->register();
557
  $invoice->getOrder()->setIsInProcess(true);
558
  $transactionSave = Mage::getModel('core/resource_transaction')
559
+ ->addObject($invoice)
560
+ ->addObject($invoice->getOrder());
561
  $transactionSave->save();
562
 
563
  $this->_hasInvoices = true;
564
+ $logger->down();
565
  }
566
  }
567
 
574
  * @param Mage_Sales_Model_Order
575
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
576
  */
577
+ public function ship($order)
578
+ {
579
+ if ($this->_canShip && $order->canShip()) {
580
  $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment();
581
+ if ($shipment) {
582
  $shipment->register();
583
  $shipment->getOrder()->setIsInProcess(true);
584
  $transactionSave = Mage::getModel('core/resource_transaction')
585
+ ->addObject($shipment)
586
+ ->addObject($shipment->getOrder());
587
  $transactionSave->save();
588
 
589
  $this->_hasShipments = true;
601
  * @param Mage_Sales_Model_Order
602
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
603
  */
604
+ public function cancel($order)
605
+ {
606
+ if ($this->_canCancel) {
607
  $order->cancel();
608
  $this->_isCanceled = true;
609
  }
617
  * @param Mage_Sales_Model_Order
618
  * @return Neteven_NetevenSync_Model_Process_Order_Convertor
619
  */
620
+ public function refund($order)
621
+ {
622
+ if ($this->_canRefund && $order->canCreditmemo()) {
623
  $invoiceId = $order->getInvoiceCollection()->getFirstItem()->getId();
624
 
625
+ if (!$invoiceId) {
626
  return $this;
627
  }
628
 
629
+ $invoice = Mage::getModel('sales/order_invoice')->load($invoiceId)->setOrder($order);
630
+ $service = Mage::getModel('sales/service_order', $order);
631
  $creditmemo = $service->prepareInvoiceCreditmemo($invoice);
632
 
633
  $backToStock = array();
634
+ foreach ($order->getAllItems() as $item) {
635
  $backToStock[$item->getId()] = true;
636
  }
637
 
647
  $creditmemo->register();
648
 
649
  $transactionSave = Mage::getModel('core/resource_transaction')
650
+ ->addObject($creditmemo)
651
+ ->addObject($creditmemo->getOrder());
652
  if ($creditmemo->getInvoice()) {
653
  $transactionSave->addObject($creditmemo->getInvoice());
654
  }
666
  * @param string $countryName
667
  * @return string
668
  */
669
+ protected function _getCountryId($countryName)
670
+ {
671
+ if (is_null($this->_countryCollection)) {
672
  $this->_countryCollection = Mage::getResourceModel('directory/country_collection')->toOptionArray();
673
  }
674
+ foreach ($this->_countryCollection as $country) {
675
+ if (strtolower($country['label']) == strtolower($countryName)) {
676
  return $country['value'];
677
  }
678
  }
679
  return $countryName;
680
  }
681
+
682
+ }
app/code/community/Neteven/NetevenSync/Model/Process/Stock.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Stock process model
4
  *
@@ -8,154 +9,157 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Model_Process_Stock extends Neteven_NetevenSync_Model_Process_Abstract {
12
-
13
- protected $_processType = Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_STOCK_CODE;
14
-
15
- /**
16
- * Retrieve collection for export
17
- *
18
- * @param string $mode
19
- * @return Mage_Core_Model_Resource_Db_Collection_Abstract
20
- */
21
- public function getExportCollection($mode) {
22
-
23
- if(Mage::getStoreConfigFlag('netevensync/stock/selected')) {
24
- Mage::getModel('netevensync/process_inventory')->forceOutOfStockItems();
25
- }
26
-
27
- $collection = Mage::getModel('cataloginventory/stock')->getItemCollection();
28
-
29
- /**
30
- * Add product type filter
31
- */
32
- $collection->addFieldToFilter('type_id', array(array('in' => Mage::getSingleton('netevensync/config')->getAvailableProductTypes()), array('null' => 1)));
33
-
34
- /**
35
- * Filter by Neteven Selection depending on config
36
- */
37
- if(Mage::getStoreConfigFlag('netevensync/stock/selected')) {
38
- $collection->getSelect()->joinRight(
39
- array('netevensync_product' => $collection->getTable('netevensync/product')),
40
- 'netevensync_product.product_id = main_table.product_id',
41
- array()
42
- );
43
- }
44
-
45
- /**
46
- * Add items to force as out of stock
47
- *
48
- * @TODO Optimize with union in order to avoid catalog collection load
49
- */
50
- if(Mage::getStoreConfigFlag('netevensync/stock/selected')) {
51
- $inventoryCollection = Mage::getModel('netevensync/process_inventory')->getCollection()->addFieldToFilter('to_delete', '1');
52
-
53
- if($inventoryCollection->count()) {
54
- $inventoryCollection = $inventoryCollection->toArray(array('product_id'));
55
- $inventoryCollectionIds = array();
56
- foreach($inventoryCollection['items'] as $item) {
57
- $inventoryCollectionIds[$item['product_id']] = $item['product_id'];
58
- }
59
-
60
- $stockCollection = $collection->toArray(array('product_id'));
61
- $stockCollectionIds = array();
62
- foreach($stockCollection['items'] as $item) {
63
- $stockCollectionIds[$item['product_id']] = $item['product_id'];
64
- }
65
- $allIds = array_merge($inventoryCollectionIds, $stockCollectionIds);
66
- $allIds = array_unique($allIds);
67
-
68
- $collection = Mage::getModel('cataloginventory/stock')->getItemCollection()
69
- ->addFieldToFilter('product_id', array('in' => $allIds));
70
- }
71
- }
72
-
73
- /**
74
- * Add SKU field
75
- */
76
- $collection->getSelect()->columns('sku', 'cp_table'); // 'cp_table' alias is already present in $collection->getSelect()
77
-
78
- /**
79
- * Add "real" 'available_qty' column with value depending on product config:
80
- * - if use config for min qty is checked => available_qty = product qty - config min qty
81
- * - if use config for min qty is *not* checked => available_qty = product qty - product min qty
82
- */
83
- $configMinValue = Mage::getStoreConfig('cataloginventory/item_options/min_qty');
84
- $collection->getSelect()->columns(array('available_qty' => new Zend_Db_Expr("IF(main_table.use_config_min_qty > 0, (main_table.qty) - {$configMinValue}, (main_table.qty) - (main_table.min_qty))")));
85
-
86
- return $collection;
87
- }
88
-
89
- /**
90
- * Prepare item for export
91
- *
92
- * @param mixed $item
93
- * @return mixed $preparedItem
94
- */
95
- public function prepareExportItem($item) {
96
- $preparedItem = false;
97
-
98
- // Do not export items with available_qty to 0
99
- if(!Mage::getStoreConfigFlag('netevensync/stock/stock') && $item->getData('available_qty') == 0 && !$item->getToDelete()) {
100
- return false;
101
- }
102
-
103
- if($sku = Mage::helper('netevensync')->checkSku($item->getData('sku'), $this->_processType)) {
104
-
105
- if(Mage::getStoreConfigFlag('netevensync/stock/selected')) {
106
- $productId = $item->getProductId();
107
- $inventoryItem = Mage::getModel('netevensync/process_inventory')->loadByProductId($productId);
108
-
109
- if($inventoryItem->getToDelete()) {
110
- $item->setToDelete(true);
111
- }
112
- }
113
-
114
- if($item->getToDelete()) {
115
- $quantity = '0.0000';
116
- }
117
- else {
118
- $quantity = $item->getData('available_qty');
119
- }
120
-
121
- $preparedItem = array(
122
- 'SKU' => $sku,
123
- 'Quantity' => $quantity,
124
- );
125
 
126
  // Add fields that are price related
127
- if(Mage::getStoreConfig('netevensync/stock/sync_prices')) {
128
  $priceSpecificFields = Mage::getSingleton('netevensync/config')->getInventoryPriceSpecificFields();
129
- if(is_array($priceSpecificFields) && count($priceSpecificFields) > 0) {
130
- foreach($priceSpecificFields as $netevenField => $attributeCode) {
131
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
132
- $preparedItem[$netevenField] = round($product->getData($attributeCode), 2);
133
  }
134
  }
135
  }
136
- }
137
- return $preparedItem;
138
- }
139
-
140
- /**
141
- * Process items for export
142
- *
143
- * @param array $items
144
- * @return array $result
145
- */
146
- public function processExportItems($items) {
147
- $soapClient = Mage::getModel('netevensync/soap'); // We must instantiate a new SOAP for each call because authentication must be renewed
148
- $result = $soapClient->processPostItems($items, $this->_processType);
149
- return $result;
150
- }
151
-
152
- /**
153
- * Finish export
154
- *
155
- * @param string $mode
156
- * @return bool $success
157
- */
158
- public function finishExportProcess($mode) {
159
- return Mage::getModel('netevensync/process_inventory')->finishExportProcess($mode);
160
- }
161
- }
 
 
 
1
  <?php
2
+
3
  /**
4
  * Stock process model
5
  *
9
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
11
  */
12
+ class Neteven_NetevenSync_Model_Process_Stock extends Neteven_NetevenSync_Model_Process_Abstract
13
+ {
14
+
15
+ protected $_processType = Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_STOCK_CODE;
16
+
17
+ /**
18
+ * Retrieve collection for export
19
+ *
20
+ * @param string $mode
21
+ * @return Mage_Core_Model_Resource_Db_Collection_Abstract
22
+ */
23
+ public function getExportCollection($mode)
24
+ {
25
+
26
+ if (Mage::getStoreConfigFlag('netevensync/stock/selected')) {
27
+ Mage::getModel('netevensync/process_inventory')->forceOutOfStockItems();
28
+ }
29
+
30
+ $collection = Mage::getModel('cataloginventory/stock')->getItemCollection();
31
+
32
+ /**
33
+ * Add product type filter
34
+ */
35
+ $collection->addFieldToFilter('type_id', array(array('in' => Mage::getSingleton('netevensync/config')->getAvailableProductTypes()), array('null' => 1)));
36
+
37
+ /**
38
+ * Filter by Neteven Selection depending on config
39
+ */
40
+ if (Mage::getStoreConfigFlag('netevensync/stock/selected')) {
41
+ $collection->getSelect()->joinRight(
42
+ array('netevensync_product' => $collection->getTable('netevensync/product')), 'netevensync_product.product_id = main_table.product_id', array()
43
+ );
44
+ }
45
+
46
+ /**
47
+ * Add items to force as out of stock
48
+ *
49
+ * @TODO Optimize with union in order to avoid catalog collection load
50
+ */
51
+ if (Mage::getStoreConfigFlag('netevensync/stock/selected')) {
52
+ $inventoryCollection = Mage::getModel('netevensync/process_inventory')->getCollection()->addFieldToFilter('to_delete', '1');
53
+
54
+ if ($inventoryCollection->count()) {
55
+ $inventoryCollection = $inventoryCollection->toArray(array('product_id'));
56
+ $inventoryCollectionIds = array();
57
+ foreach ($inventoryCollection['items'] as $item) {
58
+ $inventoryCollectionIds[$item['product_id']] = $item['product_id'];
59
+ }
60
+
61
+ $stockCollection = $collection->toArray(array('product_id'));
62
+ $stockCollectionIds = array();
63
+ foreach ($stockCollection['items'] as $item) {
64
+ $stockCollectionIds[$item['product_id']] = $item['product_id'];
65
+ }
66
+ $allIds = array_merge($inventoryCollectionIds, $stockCollectionIds);
67
+ $allIds = array_unique($allIds);
68
+
69
+ $collection = Mage::getModel('cataloginventory/stock')->getItemCollection()
70
+ ->addFieldToFilter('product_id', array('in' => $allIds));
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Add SKU field
76
+ */
77
+ $collection->getSelect()->columns('sku', 'cp_table'); // 'cp_table' alias is already present in $collection->getSelect()
78
+
79
+ /**
80
+ * Add "real" 'available_qty' column with value depending on product config:
81
+ * - if use config for min qty is checked => available_qty = product qty - config min qty
82
+ * - if use config for min qty is *not* checked => available_qty = product qty - product min qty
83
+ */
84
+ $configMinValue = Mage::getStoreConfig('cataloginventory/item_options/min_qty');
85
+ $collection->getSelect()->columns(array('available_qty' => new Zend_Db_Expr("IF(main_table.use_config_min_qty > 0, (main_table.qty) - {$configMinValue}, (main_table.qty) - (main_table.min_qty))")));
86
+
87
+ return $collection;
88
+ }
89
+
90
+ /**
91
+ * Prepare item for export
92
+ *
93
+ * @param mixed $item
94
+ * @return mixed $preparedItem
95
+ */
96
+ public function prepareExportItem($item)
97
+ {
98
+ $preparedItem = false;
99
+
100
+ // Do not export items with available_qty to 0
101
+ if (!Mage::getStoreConfigFlag('netevensync/stock/stock') && $item->getData('available_qty') == 0 && !$item->getToDelete()) {
102
+ return false;
103
+ }
104
+
105
+ if ($sku = Mage::helper('netevensync')->checkSku($item->getData('sku'), $this->_processType)) {
106
+
107
+ if (Mage::getStoreConfigFlag('netevensync/stock/selected')) {
108
+ $productId = $item->getProductId();
109
+ $inventoryItem = Mage::getModel('netevensync/process_inventory')->loadByProductId($productId);
110
+
111
+ if ($inventoryItem->getToDelete()) {
112
+ $item->setToDelete(true);
113
+ }
114
+ }
115
+
116
+ if ($item->getToDelete()) {
117
+ $quantity = '0.0000';
118
+ } else {
119
+ $quantity = $item->getData('available_qty');
120
+ }
121
+
122
+ $preparedItem = array(
123
+ 'SKU' => $sku,
124
+ 'Quantity' => $quantity,
125
+ );
126
 
127
  // Add fields that are price related
128
+ if (Mage::getStoreConfig('netevensync/stock/sync_prices')) {
129
  $priceSpecificFields = Mage::getSingleton('netevensync/config')->getInventoryPriceSpecificFields();
130
+ if (is_array($priceSpecificFields) && count($priceSpecificFields) > 0) {
131
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
132
+ foreach ($priceSpecificFields as $netevenField => $attributeCode) {
133
+ $preparedItem = Mage::getSingleton('netevensync/process_inventory')->getItemData($product, $preparedItem, $netevenField, $attributeCode);
134
  }
135
  }
136
  }
137
+ }
138
+ return $preparedItem;
139
+ }
140
+
141
+ /**
142
+ * Process items for export
143
+ *
144
+ * @param array $items
145
+ * @return array $result
146
+ */
147
+ public function processExportItems($items)
148
+ {
149
+ $soapClient = Mage::getModel('netevensync/soap'); // We must instantiate a new SOAP for each call because authentication must be renewed
150
+ $result = $soapClient->processPostItems($items, $this->_processType);
151
+ return $result;
152
+ }
153
+
154
+ /**
155
+ * Finish export
156
+ *
157
+ * @param string $mode
158
+ * @return bool $success
159
+ */
160
+ public function finishExportProcess($mode)
161
+ {
162
+ return Mage::getModel('netevensync/process_inventory')->finishExportProcess($mode);
163
+ }
164
+
165
+ }
app/code/community/Neteven/NetevenSync/Model/Soap.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Soap connector
4
  *
@@ -8,316 +9,321 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Model_Soap extends Zend_Soap_Client {
12
-
13
- protected $_successStatusResponse;
14
- protected $_successItems = array();
15
- protected $_postedItems = array();
16
-
17
- /**
18
- * Constructor that defines WSDL and automatically connects to WS on model instanciation
19
- */
20
- public function __construct() {
 
 
21
  ini_set('default_socket_timeout', 120);
22
- parent::__construct(Mage::getStoreConfig('netevensync/soap/wsdl'));
23
- $this->_connect();
24
- }
25
-
26
- /**
27
- * Connect to Neteven WS
28
- *
29
- * @return Neteven_NetevenSync_Model_Soap
30
- */
31
- protected function _connect() {
32
- $login = Mage::getStoreConfig('netevensync/general/email');
33
- $seed = Mage::helper('core')->getRandomString(32);
34
- $stamp = date('Y-m-d\TH:i:s', Mage::getModel('core/date')->timestamp(time()));
35
- $password = Mage::getStoreConfig('netevensync/general/password');
36
- $signature = base64_encode(md5(implode("/", array($login, $stamp, $seed, $password)), true));
37
-
38
- $auth = array(
39
- 'Method' => '*',
40
- 'Login' => $login,
41
- 'Seed' => $seed,
42
- 'Stamp' => $stamp,
43
- 'Signature' => $signature
44
- );
45
-
46
- $this->addSoapInputHeader(new SoapHeader('urn:NWS:examples', "AuthenticationHeader", $auth));
47
-
48
- return $this;
49
- }
50
-
51
- /**
52
- * Test connection
53
- *
54
- * @return bool || Exception
55
- */
56
- public function testWsConnection() {
57
- $this->TestConnection();
58
- }
59
-
60
- /**
61
- * Process Post Items
62
- *
63
- * @param array $items
64
- * @param string $processType
65
- * @return bool
66
- */
67
- public function processPostItems($items, $processType) {
68
-
69
- $success = true;
70
-
71
- Mage::helper('netevensync')->logDebug('processPostItems posted items data:');
72
- Mage::helper('netevensync')->logDebug($items);
73
-
74
- try {
75
- foreach($items as $k => $item) {
76
- if(isset($item['ArrayOfSpecificFields'])) {
77
- foreach($item['ArrayOfSpecificFields'] as $j => $specificField) {
 
 
 
78
  // If there is some language-related data, we must update <SpecificField> SOAP XML node
79
- if(isset($specificField['lang'])) {
80
- $items[$k]['ArrayOfSpecificFields'][$j] = new SoapVar('<ns1:SpecificField lang="' . $specificField['lang'] .'"><ns1:Name>' . $specificField['Name'] . '</ns1:Name><ns1:Value><![CDATA[' . $specificField['Value'] . ']]></ns1:Value></ns1:SpecificField>', XSD_ANYXML);
81
  }
82
  }
83
  }
84
  }
85
 
86
- $response = $this->PostItems(array('items' => $items));
87
- }
88
- catch(Exception $e) {
89
- Mage::helper('netevensync')->log($e->__toString());
90
- Mage::helper('netevensync')->logDebug($this->GetLastRequest());
91
- return array('success' => false, 'success_items_count' => count($this->_successItems));
92
- }
93
-
94
- Mage::helper('netevensync')->logDebug($this->GetLastRequest());
95
- Mage::helper('netevensync')->logDebug('processPostItems response:');
96
- Mage::helper('netevensync')->logDebug($response);
97
- Mage::helper('netevensync')->logDebug($this->GetLastResponse());
98
-
99
- $itemsStatus = $response->PostItemsResult->InventoryItemStatusResponse;
100
-
101
- $success = $this->_checkResponse($itemsStatus, $processType);
102
-
103
- return array('success' => $success, 'success_items_count' => count($this->_successItems));
104
- }
105
-
106
- /**
107
- * Get orders
108
- *
109
- * @param array $params
110
- * @return Neteven_NetevenSync_Model_Soap
111
- */
112
- public function requestOrders($params = array()) {
113
- $date = false;
114
-
115
- $from = Mage::getSingleton('adminhtml/session')->getNetevenSyncFrom();
116
- if($from && $from != '') {
117
- $date = date(DATE_ATOM, $from);
118
- Mage::getSingleton('adminhtml/session')->setNetevenSyncFrom(null);
119
- }
120
-
121
- if(!$date) {
122
- $lastSync = Mage::getModel('netevensync/config_process')
123
- ->loadByProcessCode(Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE)
124
- ->getLastSync();
125
- $zendDate = new Zend_Date($lastSync, 'y-MM-d HH:mm:ss', Mage::app()->getLocale()->getLocaleCode());
126
- $date = date(DATE_ATOM, $zendDate->getTimestamp());
127
- }
128
-
129
- $params['DateModificationFrom'] = $date;
130
-
131
- // Get orders from sandbox marketplace when in sandbox mode
132
- if(Mage::getStoreConfigFlag('netevensync/general/sandbox')) {
133
- $params['MarketPlaceId'] = Neteven_NetevenSync_Model_Config::SANDBOX_MARKETPLACE_ID;
134
- }
135
-
136
- $this->processOrdersRequest($params);
137
-
138
- return $this;
139
- }
140
-
141
- /**
142
- * Request orders to SOAP
143
- *
144
- * @param array $params
145
- * @return Neteven_NetevenSync_Model_Soap
146
- */
147
- public function processOrdersRequest($params) {
148
-
149
- // Process first results page
150
- $response = $this->requestOrdersPage($params);
151
- $this->_processRequestedOrdersPage($response);
152
-
153
- // Process next result pages
154
- $pagesTotal = $response->PagesTotal;
155
- if($pagesTotal > 1) {
156
- for($page = 2; $page <= $pagesTotal; $page++) {
157
- $this->_processRequestedOrdersPage($this->requestOrdersPage($params, $page));
158
- }
159
- }
160
-
161
- return $this;
162
- }
163
-
164
- /**
165
- * Get orders by page
166
- *
167
- * @param array $params
168
- * @param int $page
169
- */
170
- public function requestOrdersPage($params, $page = 1) {
171
- $soapClient = new self(); // We must re-instanciate self to re-auth
172
- $params['PageNumber'] = $page;
173
-
174
- Mage::helper('netevensync')->logDebug('requestOrdersPage posted params for page ' . $page);
175
- Mage::helper('netevensync')->logDebug($params);
176
-
177
- $response = $soapClient->GetOrders($params);
178
-
179
- Mage::helper('netevensync')->logDebug($this->GetLastRequest());
180
- Mage::helper('netevensync')->logDebug('requestOrdersPage response for page ' . $page);
181
- Mage::helper('netevensync')->logDebug($response);
182
- Mage::helper('netevensync')->logDebug($this->GetLastResponse());
183
-
184
- return $response;
185
- }
186
-
187
- /**
188
- * Prepare order response
189
- *
190
- * @param object $response
191
- * @return Neteven_NetevenSync_Model_Soap
192
- */
193
- protected function _processRequestedOrdersPage($data) {
194
- Mage::getSingleton('netevensync/process_order')->saveSoapOrdersPage($data);
195
- return $this;
196
- }
197
-
198
- /**
199
- * Process Post Orders
200
- *
201
- * @param array $items
202
- * @param string $processType
203
- * @return bool
204
- */
205
- public function processPostOrders($items, $processType) {
206
- foreach($items as $k => $data) {
207
- $this->_postedItems[$k] = reset($data);
208
- }
209
-
210
- Mage::helper('netevensync')->logDebug('processPostOrders posted items:');
211
- Mage::helper('netevensync')->logDebug($items);
212
-
213
- try {
214
- $response = $this->PostOrders(array('orders' => $items));
215
- }
216
- catch(Exception $e) {
217
- Mage::helper('netevensync')->log($e->__toString());
218
- Mage::helper('netevensync')->logDebug($this->GetLastRequest());
219
- return array('success' => false, 'success_items_count' => count($this->_successItems));
220
- }
221
-
222
- Mage::helper('netevensync')->logDebug($this->GetLastRequest());
223
- Mage::helper('netevensync')->logDebug('processPostOrders response:');
224
- Mage::helper('netevensync')->logDebug($response);
225
- Mage::helper('netevensync')->logDebug($this->GetLastResponse());
226
-
227
- $postOrdersResult = $response->PostOrdersResult;
228
-
229
- if(is_array($postOrdersResult)) {
230
- foreach($postOrdersResult as $result) {
231
- $itemsStatus[] = $result->MarketPlaceOrderStatusResponse;
232
- }
233
- }
234
- else {
235
- $itemsStatus = $postOrdersResult->MarketPlaceOrderStatusResponse;
236
- }
237
-
238
- $success = $this->_checkResponse($itemsStatus, $processType);
239
-
240
- if(count($this->_successItems) > 0) {
241
- $collection = Mage::getModel('netevensync/process_order')->getCollection();
242
-
243
- // Add order link data
244
- $collection->getSelect()->joinLeft(
245
- array('link' => $collection->getTable('netevensync/order_link')),
246
- 'link.magento_order_id = main_table.order_id',
247
- array('neteven_order_id')
248
- );
249
-
250
- $collection->addFieldToFilter('link.neteven_order_id', array('in' => $this->_successItems));
251
- $collection->walk('delete');
252
- }
253
-
254
- return array('success' => $success, 'success_items_count' => count($this->_successItems));
255
- }
256
-
257
- /**
258
- * Check SOAP response
259
- *
260
- * @param object $items
261
- * @param string $processType
262
- * @return bool $success
263
- */
264
- protected function _checkResponse($items, $processType) {
265
- $success = true;
266
-
267
- if(is_array($items)) { // $itemStatus can be an array when several items are returned by WS
268
- foreach($items as $index => $item) {
269
- $statusSuccess = $this->_checkStatusResponse($item, $processType, $index);
270
- if($statusSuccess) {
271
- $itemId = (isset($this->_postedItems[$index])) ? $this->_postedItems[$index] : $item->ItemCode;
272
- $this->_successItems[] = $itemId;
273
- }
274
- else {
275
- $success = false;
276
- }
277
- }
278
- }
279
- else {
280
- $statusSuccess = $this->_checkStatusResponse($items, $processType);
281
- if($statusSuccess) {
282
- $itemId = (count($this->_postedItems) > 0) ? reset($this->_postedItems) : $items->ItemCode;
283
- $this->_successItems[] = $itemId;
284
- }
285
- else {
286
- $success = false;
287
- }
288
- }
289
-
290
- return $success;
291
- }
292
-
293
- /**
294
- * Check status response and log error when needed
295
- *
296
- * @param object $item
297
- * @param string $processType
298
- * @param int $index
299
- * @return bool
300
- */
301
- protected function _checkStatusResponse($item, $processType, $index = null) {
302
-
303
- if(!in_array($item->StatusResponse, $this->getSuccessStatusResponse())) {
304
- $itemId = (isset($this->_postedItems[$index])) ? $this->_postedItems[$index] : $item->ItemCode;
305
- Mage::helper('netevensync')->log($processType . ' ' . $itemId . ': ' . $item->StatusResponse, $processType);
306
- Mage::helper('netevensync')->log($processType . ' ' . $itemId . ': ' . $item->StatusResponse, $processType . ' . ' . $item->StatusResponseDetail);
307
- return false;
308
- }
309
- return true;
310
- }
311
-
312
- /**
313
- * Retrieve StatusResponse labels that are considered as success
314
- *
315
- * @return array
316
- */
317
- public function getSuccessStatusResponse() {
318
- if(is_null($this->_successStatusResponse)) {
319
- $this->_successStatusResponse = Mage::getSingleton('netevensync/config')->getSuccessStatusResponse();
320
- }
321
- return $this->_successStatusResponse;
322
- }
323
- }
1
  <?php
2
+
3
  /**
4
  * Soap connector
5
  *
9
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
11
  */
12
+ class Neteven_NetevenSync_Model_Soap extends Zend_Soap_Client
13
+ {
14
+
15
+ protected $_successStatusResponse;
16
+ protected $_successItems = array();
17
+ protected $_postedItems = array();
18
+
19
+ /**
20
+ * Constructor that defines WSDL and automatically connects to WS on model instanciation
21
+ */
22
+ public function __construct()
23
+ {
24
  ini_set('default_socket_timeout', 120);
25
+ parent::__construct(Mage::getStoreConfig('netevensync/soap/wsdl'));
26
+ $this->_connect();
27
+ }
28
+
29
+ /**
30
+ * Connect to Neteven WS
31
+ *
32
+ * @return Neteven_NetevenSync_Model_Soap
33
+ */
34
+ protected function _connect()
35
+ {
36
+ $login = Mage::getStoreConfig('netevensync/general/email');
37
+ $seed = Mage::helper('core')->getRandomString(32);
38
+ $stamp = date('Y-m-d\TH:i:s', Mage::getModel('core/date')->timestamp(time()));
39
+ $password = Mage::getStoreConfig('netevensync/general/password');
40
+ $signature = base64_encode(md5(implode("/", array($login, $stamp, $seed, $password)), true));
41
+
42
+ $auth = array(
43
+ 'Method' => '*',
44
+ 'Login' => $login,
45
+ 'Seed' => $seed,
46
+ 'Stamp' => $stamp,
47
+ 'Signature' => $signature
48
+ );
49
+
50
+ $this->addSoapInputHeader(new SoapHeader('urn:NWS:examples', "AuthenticationHeader", $auth));
51
+
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Test connection
57
+ *
58
+ * @return bool || Exception
59
+ */
60
+ public function testWsConnection()
61
+ {
62
+ $this->TestConnection();
63
+ }
64
+
65
+ /**
66
+ * Process Post Items
67
+ *
68
+ * @param array $items
69
+ * @param string $processType
70
+ * @return bool
71
+ */
72
+ public function processPostItems($items, $processType)
73
+ {
74
+
75
+ $success = true;
76
+
77
+ Mage::helper('netevensync')->logDebug('processPostItems posted items data:');
78
+ Mage::helper('netevensync')->logDebug($items);
79
+
80
+ try {
81
+ foreach ($items as $k => $item) {
82
+ if (isset($item['ArrayOfSpecificFields'])) {
83
+ foreach ($item['ArrayOfSpecificFields'] as $j => $specificField) {
84
  // If there is some language-related data, we must update <SpecificField> SOAP XML node
85
+ if (isset($specificField['lang'])) {
86
+ $items[$k]['ArrayOfSpecificFields'][$j] = new SoapVar('<ns1:SpecificField lang="' . $specificField['lang'] . '"><ns1:Name>' . $specificField['Name'] . '</ns1:Name><ns1:Value><![CDATA[' . $specificField['Value'] . ']]></ns1:Value></ns1:SpecificField>', XSD_ANYXML);
87
  }
88
  }
89
  }
90
  }
91
 
92
+ $response = $this->PostItems(array('items' => $items));
93
+ } catch (Exception $e) {
94
+ Mage::helper('netevensync')->log($e);
95
+ Mage::helper('netevensync')->logDebug($this->GetLastRequest());
96
+ return array('success' => false, 'success_items_count' => count($this->_successItems));
97
+ }
98
+
99
+ Mage::helper('netevensync')->logDebug($this->GetLastRequest());
100
+ Mage::helper('netevensync')->logDebug('processPostItems response:');
101
+ Mage::helper('netevensync')->logDebug($response);
102
+ Mage::helper('netevensync')->logDebug($this->GetLastResponse());
103
+
104
+ $itemsStatus = $response->PostItemsResult->InventoryItemStatusResponse;
105
+
106
+ $success = $this->_checkResponse($itemsStatus, $processType);
107
+
108
+ return array('success' => $success, 'success_items_count' => count($this->_successItems));
109
+ }
110
+
111
+ /**
112
+ * Get orders
113
+ *
114
+ * @param array $params
115
+ * @return Neteven_NetevenSync_Model_Soap
116
+ */
117
+ public function requestOrders($params = array())
118
+ {
119
+ $date = false;
120
+
121
+ $from = Mage::getSingleton('adminhtml/session')->getNetevenSyncFrom();
122
+ if ($from && $from != '') {
123
+ $date = date(DATE_ATOM, $from);
124
+ Mage::getSingleton('adminhtml/session')->setNetevenSyncFrom(null);
125
+ }
126
+
127
+ if (!$date) {
128
+ $lastSync = Mage::getModel('netevensync/config_process')
129
+ ->loadByProcessCode(Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE)
130
+ ->getLastSync();
131
+ $zendDate = new Zend_Date($lastSync, 'y-MM-d HH:mm:ss', Mage::app()->getLocale()->getLocaleCode());
132
+ $date = date(DATE_ATOM, $zendDate->getTimestamp());
133
+ }
134
+
135
+ $params['DateModificationFrom'] = $date;
136
+
137
+ // Get orders from sandbox marketplace when in sandbox mode
138
+ if (Mage::getStoreConfigFlag('netevensync/general/sandbox')) {
139
+ $params['MarketPlaceId'] = Neteven_NetevenSync_Model_Config::SANDBOX_MARKETPLACE_ID;
140
+ }
141
+
142
+ $this->processOrdersRequest($params);
143
+
144
+ return $this;
145
+ }
146
+
147
+ /**
148
+ * Request orders to SOAP
149
+ *
150
+ * @param array $params
151
+ * @return Neteven_NetevenSync_Model_Soap
152
+ */
153
+ public function processOrdersRequest($params)
154
+ {
155
+
156
+ // Process first results page
157
+ $response = $this->requestOrdersPage($params);
158
+ $this->_processRequestedOrdersPage($response);
159
+
160
+ // Process next result pages
161
+ $pagesTotal = $response->PagesTotal;
162
+ if ($pagesTotal > 1) {
163
+ for ($page = 2; $page <= $pagesTotal; $page++) {
164
+ $this->_processRequestedOrdersPage($this->requestOrdersPage($params, $page));
165
+ }
166
+ }
167
+
168
+ return $this;
169
+ }
170
+
171
+ /**
172
+ * Get orders by page
173
+ *
174
+ * @param array $params
175
+ * @param int $page
176
+ */
177
+ public function requestOrdersPage($params, $page = 1)
178
+ {
179
+ $soapClient = new self(); // We must re-instanciate self to re-auth
180
+ $params['PageNumber'] = $page;
181
+
182
+ Mage::helper('netevensync')->logDebug('requestOrdersPage posted params for page ' . $page);
183
+ Mage::helper('netevensync')->logDebug($params);
184
+
185
+ $response = $soapClient->GetOrders($params);
186
+
187
+ Mage::helper('netevensync')->logDebug($this->GetLastRequest());
188
+ Mage::helper('netevensync')->logDebug('requestOrdersPage response for page ' . $page);
189
+ Mage::helper('netevensync')->logDebug($response);
190
+ Mage::helper('netevensync')->logDebug($this->GetLastResponse());
191
+
192
+ return $response;
193
+ }
194
+
195
+ /**
196
+ * Prepare order response
197
+ *
198
+ * @param object $response
199
+ * @return Neteven_NetevenSync_Model_Soap
200
+ */
201
+ protected function _processRequestedOrdersPage($data)
202
+ {
203
+ Mage::getSingleton('netevensync/process_order')->saveSoapOrdersPage($data);
204
+ return $this;
205
+ }
206
+
207
+ /**
208
+ * Process Post Orders
209
+ *
210
+ * @param array $items
211
+ * @param string $processType
212
+ * @return bool
213
+ */
214
+ public function processPostOrders($items, $processType)
215
+ {
216
+ foreach ($items as $k => $data) {
217
+ $this->_postedItems[$k] = reset($data);
218
+ }
219
+
220
+ Mage::helper('netevensync')->logDebug('processPostOrders posted items:');
221
+ Mage::helper('netevensync')->logDebug($items);
222
+
223
+ try {
224
+ $response = $this->PostOrders(array('orders' => $items));
225
+ } catch (Exception $e) {
226
+ Mage::helper('netevensync')->log($e);
227
+ Mage::helper('netevensync')->logDebug($this->GetLastRequest());
228
+ return array('success' => false, 'success_items_count' => count($this->_successItems));
229
+ }
230
+
231
+ Mage::helper('netevensync')->logDebug($this->GetLastRequest());
232
+ Mage::helper('netevensync')->logDebug('processPostOrders response:');
233
+ Mage::helper('netevensync')->logDebug($response);
234
+ Mage::helper('netevensync')->logDebug($this->GetLastResponse());
235
+
236
+ $postOrdersResult = $response->PostOrdersResult;
237
+
238
+ if (is_array($postOrdersResult)) {
239
+ foreach ($postOrdersResult as $result) {
240
+ $itemsStatus[] = $result->MarketPlaceOrderStatusResponse;
241
+ }
242
+ } else {
243
+ $itemsStatus = $postOrdersResult->MarketPlaceOrderStatusResponse;
244
+ }
245
+
246
+ $success = $this->_checkResponse($itemsStatus, $processType);
247
+
248
+ if (count($this->_successItems) > 0) {
249
+ $collection = Mage::getModel('netevensync/process_order')->getCollection();
250
+
251
+ // Add order link data
252
+ $collection->getSelect()->joinLeft(
253
+ array('link' => $collection->getTable('netevensync/order_link')), 'link.magento_order_id = main_table.order_id', array('neteven_order_id')
254
+ );
255
+
256
+ $collection->addFieldToFilter('link.neteven_order_id', array('in' => $this->_successItems));
257
+ $collection->walk('delete');
258
+ }
259
+
260
+ return array('success' => $success, 'success_items_count' => count($this->_successItems));
261
+ }
262
+
263
+ /**
264
+ * Check SOAP response
265
+ *
266
+ * @param object $items
267
+ * @param string $processType
268
+ * @return bool $success
269
+ */
270
+ protected function _checkResponse($items, $processType)
271
+ {
272
+ $success = true;
273
+
274
+ if (is_array($items)) { // $itemStatus can be an array when several items are returned by WS
275
+ foreach ($items as $index => $item) {
276
+ $statusSuccess = $this->_checkStatusResponse($item, $processType, $index);
277
+ if ($statusSuccess) {
278
+ $itemId = (isset($this->_postedItems[$index])) ? $this->_postedItems[$index] : $item->ItemCode;
279
+ $this->_successItems[] = $itemId;
280
+ } else {
281
+ $success = false;
282
+ }
283
+ }
284
+ } else {
285
+ $statusSuccess = $this->_checkStatusResponse($items, $processType);
286
+ if ($statusSuccess) {
287
+ $itemId = (count($this->_postedItems) > 0) ? reset($this->_postedItems) : $items->ItemCode;
288
+ $this->_successItems[] = $itemId;
289
+ } else {
290
+ $success = false;
291
+ }
292
+ }
293
+
294
+ return $success;
295
+ }
296
+
297
+ /**
298
+ * Check status response and log error when needed
299
+ *
300
+ * @param object $item
301
+ * @param string $processType
302
+ * @param int $index
303
+ * @return bool
304
+ */
305
+ protected function _checkStatusResponse($item, $processType, $index = null)
306
+ {
307
+
308
+ if (!in_array($item->StatusResponse, $this->getSuccessStatusResponse())) {
309
+ $itemId = isset($this->_postedItems[$index]) ? $this->_postedItems[$index] : (isset($item->ItemCode) ? $item->ItemCode : '0');
310
+ Mage::helper('netevensync')->log($processType . ' ' . $itemId . ': ' . $item->StatusResponse . ' . ' . $item->StatusResponseDetail, $processType);
311
+ return false;
312
+ }
313
+ return true;
314
+ }
315
+
316
+ /**
317
+ * Retrieve StatusResponse labels that are considered as success
318
+ *
319
+ * @return array
320
+ */
321
+ public function getSuccessStatusResponse()
322
+ {
323
+ if (is_null($this->_successStatusResponse)) {
324
+ $this->_successStatusResponse = Mage::getSingleton('netevensync/config')->getSuccessStatusResponse();
325
+ }
326
+ return $this->_successStatusResponse;
327
+ }
328
+
329
+ }
app/code/community/Neteven/NetevenSync/controllers/Adminhtml/NetevensyncController.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Admin controller
4
  *
@@ -8,364 +9,416 @@
8
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
  */
11
- class Neteven_NetevenSync_Adminhtml_NetevensyncController extends Mage_Adminhtml_Controller_Action {
12
-
13
- //////////////
14
- ////////////// System Config
15
- //////////////
16
-
17
- /**
18
- * Test general configuration
19
- */
20
- public function testConfigurationAction() {
21
-
22
- $soapClient = Mage::getSingleton('netevensync/soap');
23
-
24
- try {
25
- $soapClient->testWsConnection();
26
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('netevensync')->__('Setup has been successfully validated.'));
27
- }
28
- catch(Exception $e) {
29
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('netevensync')->__('Setup has failed. Neteven WS sent the following message: "%s".', $e->getMessage()));
30
- }
31
-
32
- $this->_redirect('*/system_config/edit/section/netevensync');
33
- }
34
-
35
- //////////////
36
- ////////////// Logging
37
- //////////////
38
-
39
- /**
40
- * Clean errors log
41
- */
42
- public function cleanLogAction() {
43
- $collection = Mage::getModel('netevensync/log')->getCollection()->addErrorFilter();
44
- foreach($collection as $logType) {
45
- $logType->setHasError(false);
46
- $logType->save();
47
- }
48
- $this->_redirectReferer();
49
- }
50
-
51
- //////////////
52
- ////////////// Neteven Console
53
- //////////////
54
-
55
- /**
56
- * Display console in an iframe
57
- */
58
- public function consoleAction() {
59
- $this->_title(Mage::helper('netevensync')->__('Neteven Console'))->_title($this->__('Catalog'));
60
- $this->loadLayout();
61
-
62
- $html = '<iframe src="' . Mage::getStoreConfig('netevensync/console/url') . '" frameborder="0" style="display: block; width: 100%; height: 1000px; margin: auto auto"></iframe>';
63
- $this->_addContent(
64
- $this->getLayout()->createBlock('core/text', 'neteven_console', array('text' => $html))
65
- );
66
-
67
- $this->renderLayout();
68
- }
69
-
70
- //////////////
71
- ////////////// Processes
72
- //////////////
73
-
74
- protected $_type;
75
- protected $_mode;
76
- protected $_processCollections = array();
77
-
78
- /**
79
- * Run process from Admin
80
- */
81
- public function runProcessAction() {
82
- $this->loadLayout();
83
- $exportBlock = $this->getLayout()->getBlock('netevensync.process.run');
84
- $exportBlock->setType($this->getRequest()->getParam('type'));
85
- $exportBlock->setMode($this->getRequest()->getParam('mode'));
86
-
87
- $from = $this->getRequest()->getParam('from');
88
- if($from) {
89
- Mage::getSingleton('adminhtml/session')->setNetevenSyncFrom($from);
90
- }
91
-
92
- $this->renderLayout();
93
- }
94
-
95
- /**
96
- * Launch AJAX processes and count items and pages for each process type
97
- */
98
- public function launchProcessesAction() {
99
- $response = array();
100
-
101
- // Check credentials
102
- $soapClient = Mage::getModel('netevensync/soap');
103
- try {
104
- $soapClient->testWsConnection();
105
- }
106
- catch(Exception $e) {
107
- $response['error'] = Mage::helper('netevensync')->__('Unable to connect to Neteven WS. Please check your credentials.');
108
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
109
- return;
110
- }
111
-
112
- $this->_type = $this->getRequest()->getParam('type');
113
- $this->_mode = $this->getRequest()->getParam('mode');
114
-
115
- $importItemCount = $this->getItemsCount(Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT);
116
- $exportItemCount = $this->getItemsCount(Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT);
117
- $importPageCount = $this->getLastPageNumber(Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT);
118
- $exportPageCount = $this->getLastPageNumber(Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT);
119
-
120
- if(
121
- !is_int($importItemCount)
122
- || !is_int($exportItemCount)
123
- ) {
124
- if(is_string($importItemCount)) {
125
- $response['error'] = $importItemCount;
126
- }
127
- else {
128
- $response['error'] = Mage::helper('netevensync')->__('Error while getting collection.');
129
- }
130
- }
131
-
132
- else {
133
- $response = array(
134
- 'importItemCount' => $importItemCount,
135
- 'exportItemCount' => $exportItemCount,
136
- 'importPageCount' => $importPageCount,
137
- 'exportPageCount' => $exportPageCount,
138
- 'message' => Mage::helper('netevensync')->__('%s item(s) to process...', $importItemCount+$exportItemCount),
139
- );
140
- }
141
-
142
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
143
- }
144
-
145
- /**
146
- * Run single page from AJAX
147
- */
148
- public function runProcessPageAction() {
149
- $mode = $this->getRequest()->getParam('mode');
150
- $type = $this->getRequest()->getParam('type');
151
- $page = $this->getRequest()->getParam('page');
152
- $dir = $this->getRequest()->getParam('dir');
153
-
154
- $error = '';
155
-
156
- $model = Mage::getModel('netevensync/process_' . strtolower($type));
157
- $result = $model->runProcess($mode, $page, true, $dir);
158
-
159
- if(!$result['success']) {
160
- $error = Mage::helper('netevensync')->__('Errors while processing page %s. Please see var/log/neteven.log for details.', $page);
161
- }
162
-
163
- $result = array(
164
- 'savedRows' => $result['items_processed'],
165
- 'error' => $error,
166
- );
167
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
168
- }
169
-
170
- /**
171
- * Finish AJAX processes
172
- */
173
- public function finishProcessesAction() {
174
- $response = array();
175
-
176
- $this->_type = $this->getRequest()->getParam('type');
177
- $this->_mode = $this->getRequest()->getParam('mode');
178
- $this->_dir = $this->getRequest()->getParam('dir');
179
-
180
- $success = $this->getProcessClass()->finishProcess($this->_mode, $this->_dir, true);
181
-
182
- if(!$success) {
183
- $response['error'] = Mage::helper('netevensync')->__('Errors while processing last operations. Please see var/log/neteven.log for details.');
184
- }
185
-
186
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
187
- }
188
-
189
- /**
190
- * Retrieve process class model
191
- *
192
- * @return object
193
- */
194
- public function getProcessClass() {
195
- return Mage::getModel('Neteven_NetevenSync_Model_Process_' . ucfirst($this->_type));
196
- }
197
-
198
- /**
199
- * Retrieve process collection
200
- *
201
- * @param string dir
202
- * @return object
203
- */
204
- public function getProcessCollection($dir) {
205
- if(!isset($this->_processCollections[$dir])) {
206
- $this->_processCollections[$dir] = $this->getProcessClass()->getProcessCollection($this->_mode, true, false, $dir);
207
- }
208
- return $this->_processCollections[$dir];
209
- }
210
-
211
- /**
212
- * Retrieve items to process count
213
- *
214
- * @param string $dir
215
- * @return int
216
- */
217
- public function getItemsCount($dir) {
218
- $collection = $this->getProcessCollection($dir);
219
-
220
- if(is_object($collection)) {
221
- return (int) $collection->count();
222
- }
223
- if(is_string($collection)) {
224
- return $collection;
225
- }
226
- return Mage::helper('netevensync')->__('Error while getting collection.');
227
- }
228
-
229
- /**
230
- * Retrieve total pages number
231
- *
232
- * @param string $dir
233
- * @return int
234
- */
235
- public function getLastPageNumber($dir) {
236
- $lastPageNumber = 0;
237
-
238
- if($this->getItemsCount($dir)) {
239
- $collection = $this->getProcessCollection($dir);
240
-
241
- if(!is_object($collection)) {
242
- return $collection;
243
- }
244
-
245
- if($this->_type == Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE
246
- && $dir == Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT)
247
- {
248
- $lastPageNumber = $collection->count();
249
- }
250
-
251
- else {
252
- $collection->setPageSize(Neteven_NetevenSync_Model_Config::NETEVENSYNC_CHUNK_SIZE_AJAX);
253
- $lastPageNumber = ceil($collection->count() / Neteven_NetevenSync_Model_Config::NETEVENSYNC_CHUNK_SIZE_AJAX);
254
- }
255
- }
256
-
257
- return $lastPageNumber;
258
- }
259
-
260
- //////////////
261
- ////////////// Neteven Selection
262
- //////////////
263
-
264
- /**
265
- * Product selection main page
266
- */
267
- public function productAction() {
268
- $this->_title(Mage::helper('netevensync')->__('Neteven Selection'))->_title($this->__('Catalog'));
269
- $this->loadLayout()
270
- ->_setActiveMenu('catalog/netevensync/product')
271
- ->_addBreadcrumb(Mage::helper('netevensync')->__('Neteven Selection'), Mage::helper('netevensync')->__('Neteven Selection'))
272
- ;
273
- $this->renderLayout();
274
- }
275
-
276
- /**
277
- * Product selection Exported Products AJAX init
278
- */
279
- public function productExportedAction() {
280
- $this->loadLayout();
281
- $this->getLayout()
282
- ->getBlock('netevensync.product.view.exported')
283
- ->setCheckedProducts($this->getRequest()->getPost('netevensync_exported', null));
284
- $this->renderLayout();
285
- }
286
-
287
- /**
288
- * Product selection Exported Products AJAX grid
289
- */
290
- public function productExportedGridAction() {
291
- $this->loadLayout();
292
- $this->getLayout()
293
- ->getBlock('netevensync.product.view.exported')
294
- ->setCheckedProducts($this->getRequest()->getPost('netevensync_exported', null));
295
- $this->renderLayout();
296
- }
297
-
298
- /**
299
- * Product selection Available Products AJAX init
300
- */
301
- public function productAvailableAction() {
302
- $this->loadLayout();
303
- $this->getLayout()
304
- ->getBlock('netevensync.product.view.available')
305
- ->setCheckedProducts($this->getRequest()->getPost('netevensync_available', null));
306
- $this->renderLayout();
307
- }
308
-
309
- /**
310
- * Product selection Available Products AJAX grid
311
- */
312
- public function productAvailableGridAction() {
313
- $this->loadLayout();
314
- $this->getLayout()
315
- ->getBlock('netevensync.product.view.available')
316
- ->setCheckedProducts($this->getRequest()->getPost('netevensync_available', null));
317
- $this->renderLayout();
318
- }
319
-
320
- /**
321
- * Remove products from selection
322
- */
323
- public function removeProductsAction() {
324
- $post = $this->getRequest()->getPost('netevensync');
325
- $productIds = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post['exported']);
326
-
327
- try {
328
- foreach($productIds as $productId) {
329
- $product = Mage::getModel('catalog/product')->load($productId);
330
- $product->setToDelete(true);
331
- Mage::getModel('netevensync/process_inventory')->registerIncrement($product);
332
- }
333
-
334
- Mage::getModel('netevensync/product')->getCollection()
335
- ->addFieldToFilter('product_id', array('in' => $productIds))
336
- ->walk('delete');
337
-
338
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('netevensync')->__('Products have been removed from Neteven selection.'));
339
- }
340
- catch(Exception $e) {
341
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
342
- }
343
-
344
- $this->_redirect('*/*/product');
345
- }
346
-
347
- /**
348
- * Add products to selection
349
- */
350
- public function addProductsAction() {
351
- $post = $this->getRequest()->getPost('netevensync');
352
- $productIds = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post['available']);
353
-
354
- try {
355
- foreach($productIds as $productId) {
356
- Mage::getModel('netevensync/product')
357
- ->setProductId($productId)
358
- ->save();
359
-
360
- Mage::getModel('netevensync/process_inventory')->registerIncrement($productId);
361
- }
362
-
363
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('netevensync')->__('Products have been added to Neteven selection.'));
364
- }
365
- catch(Exception $e) {
366
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
367
- }
368
-
369
- $this->_redirect('*/*/product');
370
- }
371
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+
3
  /**
4
  * Admin controller
5
  *
9
  * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
11
  */
12
+ class Neteven_NetevenSync_Adminhtml_NetevensyncController extends Mage_Adminhtml_Controller_Action
13
+ {
14
+ //////////////
15
+ ////////////// System Config
16
+ //////////////
17
+
18
+ /**
19
+ * Test general configuration
20
+ */
21
+ public function testConfigurationAction()
22
+ {
23
+
24
+ $soapClient = Mage::getSingleton('netevensync/soap');
25
+
26
+ try {
27
+ $soapClient->testWsConnection();
28
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('netevensync')->__('Setup has been successfully validated.'));
29
+ } catch (Exception $e) {
30
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('netevensync')->__('Setup has failed. Neteven WS sent the following message: "%s".', $e->getMessage()));
31
+ }
32
+
33
+ $this->_redirect('*/system_config/edit/section/netevensync');
34
+ }
35
+
36
+ /**
37
+ * Delete a log file
38
+ */
39
+ public function deletelogAction()
40
+ {
41
+ // Get given log
42
+ $logToDelete = $this->getRequest()->getParam('log');
43
+ $logs = Mage::getSingleton('netevensync/adminhtml_system_config_source_logs')->toArray();
44
+
45
+ // Delete if log is found
46
+ if (isset($logs[$logToDelete])) {
47
+ $logDir = Mage::getBaseDir('log');
48
+ @unlink($logDir . DS . $logs[$logToDelete]);
49
+ $this->_getSession()->addSuccess(Mage::helper('netevensync')->__('Log file deleted.'));
50
+ } else {
51
+ $this->_getSession()->addError(Mage::helper('netevensync')->__('Log file not found.'));
52
+ }
53
+
54
+ $this->_redirectReferer();
55
+ }
56
+
57
+ /**
58
+ * Download a log file
59
+ */
60
+ public function downloadlogAction()
61
+ {
62
+ // Get given log
63
+ $logToDownload = $this->getRequest()->getParam('log');
64
+ $logs = Mage::getSingleton('netevensync/adminhtml_system_config_source_logs')->toArray();
65
+
66
+ if (isset($logs[$logToDownload])) {
67
+ $filename = $logs[$logToDownload];
68
+ $this->_prepareDownloadResponse(
69
+ $filename,
70
+ array(
71
+ 'type' => 'filename',
72
+ 'value' => Mage::getBaseDir('log') . DS . $filename,
73
+ )
74
+ );
75
+ } else {
76
+ $this->_getSession()->addError(Mage::helper('netevensync')->__('Log file not found.'));
77
+ $this->_redirectReferer();
78
+ }
79
+ }
80
+
81
+ //////////////
82
+ ////////////// Logging
83
+ //////////////
84
+
85
+ /**
86
+ * Clean errors log
87
+ */
88
+ public function cleanLogAction()
89
+ {
90
+ $collection = Mage::getModel('netevensync/log')->getCollection()->addErrorFilter();
91
+ foreach ($collection as $logType) {
92
+ $logType->setHasError(false);
93
+ $logType->save();
94
+ }
95
+ $this->_redirectReferer();
96
+ }
97
+
98
+ //////////////
99
+ ////////////// Neteven Console
100
+ //////////////
101
+
102
+ /**
103
+ * Display console in an iframe
104
+ */
105
+ public function consoleAction()
106
+ {
107
+ $this->_title(Mage::helper('netevensync')->__('Neteven Console'))->_title($this->__('Catalog'));
108
+ $this->loadLayout();
109
+
110
+ $html = '<iframe src="' . Mage::getStoreConfig('netevensync/console/url') . '" frameborder="0" style="display: block; width: 100%; height: 1000px; margin: auto auto"></iframe>';
111
+ $this->_addContent(
112
+ $this->getLayout()->createBlock('core/text', 'neteven_console', array('text' => $html))
113
+ );
114
+
115
+ $this->renderLayout();
116
+ }
117
+
118
+ //////////////
119
+ ////////////// Processes
120
+ //////////////
121
+
122
+ protected $_type;
123
+ protected $_mode;
124
+ protected $_processCollections = array();
125
+
126
+ /**
127
+ * Run process from Admin
128
+ */
129
+ public function runProcessAction()
130
+ {
131
+ $this->loadLayout();
132
+ $exportBlock = $this->getLayout()->getBlock('netevensync.process.run');
133
+ $exportBlock->setType($this->getRequest()->getParam('type'));
134
+ $exportBlock->setMode($this->getRequest()->getParam('mode'));
135
+
136
+ $from = $this->getRequest()->getParam('from');
137
+ if ($from) {
138
+ Mage::getSingleton('adminhtml/session')->setNetevenSyncFrom($from);
139
+ }
140
+
141
+ $this->renderLayout();
142
+ }
143
+
144
+ /**
145
+ * Launch AJAX processes and count items and pages for each process type
146
+ */
147
+ public function launchProcessesAction()
148
+ {
149
+ $response = array();
150
+
151
+ // Check credentials
152
+ $soapClient = Mage::getModel('netevensync/soap');
153
+ try {
154
+ $soapClient->testWsConnection();
155
+ } catch (Exception $e) {
156
+ $response['error'] = Mage::helper('netevensync')->__('Unable to connect to Neteven WS. Please check your credentials.');
157
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
158
+ return;
159
+ }
160
+
161
+ $this->_type = $this->getRequest()->getParam('type');
162
+ $this->_mode = $this->getRequest()->getParam('mode');
163
+
164
+ $importItemCount = $this->getItemsCount(Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT);
165
+ $exportItemCount = $this->getItemsCount(Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT);
166
+ $importPageCount = $this->getLastPageNumber(Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT);
167
+ $exportPageCount = $this->getLastPageNumber(Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_EXPORT);
168
+
169
+ if (
170
+ !is_int($importItemCount) || !is_int($exportItemCount)
171
+ ) {
172
+ if (is_string($importItemCount)) {
173
+ $response['error'] = $importItemCount;
174
+ } else {
175
+ $response['error'] = Mage::helper('netevensync')->__('Error while getting collection.');
176
+ }
177
+ } else {
178
+ $response = array(
179
+ 'importItemCount' => $importItemCount,
180
+ 'exportItemCount' => $exportItemCount,
181
+ 'importPageCount' => $importPageCount,
182
+ 'exportPageCount' => $exportPageCount,
183
+ 'message' => Mage::helper('netevensync')->__('%s item(s) to process...', $importItemCount + $exportItemCount),
184
+ );
185
+ }
186
+
187
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
188
+ }
189
+
190
+ /**
191
+ * Run single page from AJAX
192
+ */
193
+ public function runProcessPageAction()
194
+ {
195
+ $mode = $this->getRequest()->getParam('mode');
196
+ $type = $this->getRequest()->getParam('type');
197
+ $page = $this->getRequest()->getParam('page');
198
+ $dir = $this->getRequest()->getParam('dir');
199
+
200
+ $error = '';
201
+
202
+ $model = Mage::getModel('netevensync/process_' . strtolower($type));
203
+ $result = $model->runProcess($mode, $page, true, $dir);
204
+
205
+ if (!$result['success']) {
206
+ $error = Mage::helper('netevensync')->__('Errors while processing page %s. Please see var/log/neteven.log for details.', $page);
207
+ }
208
+
209
+ $result = array(
210
+ 'savedRows' => $result['items_processed'],
211
+ 'error' => $error,
212
+ );
213
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
214
+ }
215
+
216
+ /**
217
+ * Finish AJAX processes
218
+ */
219
+ public function finishProcessesAction()
220
+ {
221
+ $response = array();
222
+
223
+ $this->_type = $this->getRequest()->getParam('type');
224
+ $this->_mode = $this->getRequest()->getParam('mode');
225
+ $this->_dir = $this->getRequest()->getParam('dir');
226
+
227
+ $success = $this->getProcessClass()->finishProcess($this->_mode, $this->_dir, true);
228
+
229
+ if (!$success) {
230
+ $response['error'] = Mage::helper('netevensync')->__('Errors while processing last operations. Please see var/log/neteven.log for details.');
231
+ }
232
+
233
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
234
+ }
235
+
236
+ /**
237
+ * Retrieve process class model
238
+ *
239
+ * @return object
240
+ */
241
+ public function getProcessClass()
242
+ {
243
+ return Mage::getModel('Neteven_NetevenSync_Model_Process_' . ucfirst($this->_type));
244
+ }
245
+
246
+ /**
247
+ * Retrieve process collection
248
+ *
249
+ * @param string dir
250
+ * @return object
251
+ */
252
+ public function getProcessCollection($dir)
253
+ {
254
+ if (!isset($this->_processCollections[$dir])) {
255
+ $this->_processCollections[$dir] = $this->getProcessClass()->getProcessCollection($this->_mode, true, false, $dir);
256
+ }
257
+ return $this->_processCollections[$dir];
258
+ }
259
+
260
+ /**
261
+ * Retrieve items to process count
262
+ *
263
+ * @param string $dir
264
+ * @return int
265
+ */
266
+ public function getItemsCount($dir)
267
+ {
268
+ $collection = $this->getProcessCollection($dir);
269
+
270
+ if (is_object($collection)) {
271
+ return (int) $collection->count();
272
+ }
273
+ if (is_string($collection)) {
274
+ return $collection;
275
+ }
276
+ return Mage::helper('netevensync')->__('Error while getting collection.');
277
+ }
278
+
279
+ /**
280
+ * Retrieve total pages number
281
+ *
282
+ * @param string $dir
283
+ * @return int
284
+ */
285
+ public function getLastPageNumber($dir)
286
+ {
287
+ $lastPageNumber = 0;
288
+
289
+ if ($this->getItemsCount($dir)) {
290
+ $collection = $this->getProcessCollection($dir);
291
+
292
+ if (!is_object($collection)) {
293
+ return $collection;
294
+ }
295
+
296
+ if ($this->_type == Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE && $dir == Neteven_NetevenSync_Model_Config::NETEVENSYNC_DIR_IMPORT) {
297
+ $lastPageNumber = $collection->count();
298
+ } else {
299
+ $collection->setPageSize(Neteven_NetevenSync_Model_Config::NETEVENSYNC_CHUNK_SIZE_AJAX);
300
+ $lastPageNumber = ceil($collection->count() / Neteven_NetevenSync_Model_Config::NETEVENSYNC_CHUNK_SIZE_AJAX);
301
+ }
302
+ }
303
+
304
+ return $lastPageNumber;
305
+ }
306
+
307
+ //////////////
308
+ ////////////// Neteven Selection
309
+ //////////////
310
+
311
+ /**
312
+ * Product selection main page
313
+ */
314
+ public function productAction()
315
+ {
316
+ $this->_title(Mage::helper('netevensync')->__('Neteven Selection'))->_title($this->__('Catalog'));
317
+ $this->loadLayout()
318
+ ->_setActiveMenu('catalog/netevensync/product')
319
+ ->_addBreadcrumb(Mage::helper('netevensync')->__('Neteven Selection'), Mage::helper('netevensync')->__('Neteven Selection'))
320
+ ;
321
+ $this->renderLayout();
322
+ }
323
+
324
+ /**
325
+ * Product selection Exported Products AJAX init
326
+ */
327
+ public function productExportedAction()
328
+ {
329
+ $this->loadLayout();
330
+ $this->getLayout()
331
+ ->getBlock('netevensync.product.view.exported')
332
+ ->setCheckedProducts($this->getRequest()->getPost('netevensync_exported', null));
333
+ $this->renderLayout();
334
+ }
335
+
336
+ /**
337
+ * Product selection Exported Products AJAX grid
338
+ */
339
+ public function productExportedGridAction()
340
+ {
341
+ $this->loadLayout();
342
+ $this->getLayout()
343
+ ->getBlock('netevensync.product.view.exported')
344
+ ->setCheckedProducts($this->getRequest()->getPost('netevensync_exported', null));
345
+ $this->renderLayout();
346
+ }
347
+
348
+ /**
349
+ * Product selection Available Products AJAX init
350
+ */
351
+ public function productAvailableAction()
352
+ {
353
+ $this->loadLayout();
354
+ $this->getLayout()
355
+ ->getBlock('netevensync.product.view.available')
356
+ ->setCheckedProducts($this->getRequest()->getPost('netevensync_available', null));
357
+ $this->renderLayout();
358
+ }
359
+
360
+ /**
361
+ * Product selection Available Products AJAX grid
362
+ */
363
+ public function productAvailableGridAction()
364
+ {
365
+ $this->loadLayout();
366
+ $this->getLayout()
367
+ ->getBlock('netevensync.product.view.available')
368
+ ->setCheckedProducts($this->getRequest()->getPost('netevensync_available', null));
369
+ $this->renderLayout();
370
+ }
371
+
372
+ /**
373
+ * Remove products from selection
374
+ */
375
+ public function removeProductsAction()
376
+ {
377
+ $post = $this->getRequest()->getPost('netevensync');
378
+ $productIds = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post['exported']);
379
+
380
+ try {
381
+ foreach ($productIds as $productId) {
382
+ $product = Mage::getModel('catalog/product')->load($productId);
383
+ $product->setToDelete(true);
384
+ Mage::getModel('netevensync/process_inventory')->registerIncrement($product);
385
+ }
386
+
387
+ Mage::getModel('netevensync/product')->getCollection()
388
+ ->addFieldToFilter('product_id', array('in' => $productIds))
389
+ ->walk('delete');
390
+
391
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('netevensync')->__('Products have been removed from Neteven selection.'));
392
+ } catch (Exception $e) {
393
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
394
+ }
395
+
396
+ $this->_redirect('*/*/product');
397
+ }
398
+
399
+ /**
400
+ * Add products to selection
401
+ */
402
+ public function addProductsAction()
403
+ {
404
+ $post = $this->getRequest()->getPost('netevensync');
405
+ $productIds = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post['available']);
406
+
407
+ try {
408
+ foreach ($productIds as $productId) {
409
+ Mage::getModel('netevensync/product')
410
+ ->setProductId($productId)
411
+ ->save();
412
+
413
+ Mage::getModel('netevensync/process_inventory')->registerIncrement($productId);
414
+ }
415
+
416
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('netevensync')->__('Products have been added to Neteven selection.'));
417
+ } catch (Exception $e) {
418
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
419
+ }
420
+
421
+ $this->_redirect('*/*/product');
422
+ }
423
+
424
+ }
app/code/community/Neteven/NetevenSync/etc/config.xml CHANGED
@@ -1,7 +1,8 @@
 
1
  <!--
2
  /**
3
  * This module manages data synchronisation from and to Neteven platform
4
- *
5
  * @category Neteven
6
  * @package Neteven_NetevenSync
7
  * @copyright Copyright (c) 2013 Agence Soon. (http://www.agence-soon.fr)
@@ -10,18 +11,18 @@
10
  */
11
  -->
12
  <!--
13
- @EVO Flag Neteven Orders in admin Orders Grid
14
- @EVO "Empty Neteven Selection" button in Neteven Selection
15
- @EVO "Remove from Neteven Selection" in admin Products Grid
16
- @EVO Customer account creation on orders import
17
  -->
18
  <config>
19
  <modules>
20
  <Neteven_NetevenSync>
21
- <version>2.0.0.2</version>
 
22
  </Neteven_NetevenSync>
23
  </modules>
24
-
25
  <global>
26
  <events>
27
  <catalog_product_save_after>
@@ -75,11 +76,11 @@
75
  </netevensync>
76
  </helpers>
77
  <models>
78
- <adminhtml>
79
- <rewrite>
80
- <config>Neteven_NetevenSync_Model_Adminhtml_Config</config>
81
- </rewrite>
82
- </adminhtml>
83
  <netevensync>
84
  <class>Neteven_NetevenSync_Model</class>
85
  <resourceModel>netevensync_resource</resourceModel>
@@ -116,10 +117,12 @@
116
  <setup>
117
  <module>Neteven_NetevenSync</module>
118
  </setup>
 
 
 
119
  </netevensync_setup>
120
  </resources>
121
  </global>
122
-
123
  <admin>
124
  <routers>
125
  <adminhtml>
@@ -131,7 +134,6 @@
131
  </adminhtml>
132
  </routers>
133
  </admin>
134
-
135
  <adminhtml>
136
  <events>
137
  <adminhtml_init_system_config>
@@ -152,12 +154,6 @@
152
  <class>Neteven_NetevenSync_Model_Observer</class>
153
  <method>addNoticeConfigChange</method>
154
  </netevensync_config_neteven_selection_changed>
155
- <!-- Update next sync dates -->
156
- <netevensync_config_neteven_update_nextsync>
157
- <type>singleton</type>
158
- <class>Neteven_NetevenSync_Model_Observer</class>
159
- <method>updateNextSync</method>
160
- </netevensync_config_neteven_update_nextsync>
161
  </observers>
162
  </model_config_data_save_before>
163
  <catalog_product_attribute_update_before>
@@ -170,6 +166,15 @@
170
  </netevensync_register_increment_mass_update>
171
  </observers>
172
  </catalog_product_attribute_update_before>
 
 
 
 
 
 
 
 
 
173
  </events>
174
  <translate>
175
  <modules>
@@ -230,16 +235,16 @@
230
  <netevensync translate="title" module="netevensync">
231
  <title>Neteven</title>
232
  <sort_order>1000</sort_order>
233
- <children>
234
- <product translate="title" module="netevensync">
235
- <title>Neteven Selection</title>
236
- <sort_order>10</sort_order>
237
- </product>
238
- <console translate="title" module="netevensync">
239
- <title>Neteven Console</title>
240
- <sort_order>20</sort_order>
241
- </console>
242
- </children>
243
  </netevensync>
244
  </children>
245
  </catalog>
@@ -248,13 +253,15 @@
248
  </resources>
249
  </acl>
250
  </adminhtml>
251
-
252
  <default>
253
  <netevensync>
 
 
 
254
  <inventory>
255
  <enable>0</enable>
256
  <frequency>1</frequency>
257
- <start>0</start>
258
  <selected>1</selected>
259
  <stock>0</stock>
260
  <parent_data>0</parent_data>
@@ -262,7 +269,7 @@
262
  <stock>
263
  <enable>0</enable>
264
  <frequency>1</frequency>
265
- <start>0</start>
266
  <selected>1</selected>
267
  <stock>0</stock>
268
  <sync_prices>0</sync_prices>
@@ -270,7 +277,7 @@
270
  <order>
271
  <enable>0</enable>
272
  <frequency>1</frequency>
273
- <start>0</start>
274
  </order>
275
  <console>
276
  <url>https://evenmarketplaces.neteven.com</url>
@@ -279,7 +286,6 @@
279
  <wsdl>http://ws.neteven.com/NWS</wsdl>
280
  </soap>
281
  </netevensync>
282
-
283
  <carriers>
284
  <neteven>
285
  <active>1</active>
@@ -291,7 +297,6 @@
291
  <handling_type>F</handling_type>
292
  </neteven>
293
  </carriers>
294
-
295
  <payment>
296
  <neteven translate="title" module="netevensync">
297
  <active>1</active>
@@ -303,7 +308,6 @@
303
  </neteven>
304
  </payment>
305
  </default>
306
-
307
  <crontab>
308
  <jobs>
309
  <netevensync_process_all>
@@ -316,48 +320,45 @@
316
  </netevensync_process_all>
317
  </jobs>
318
  </crontab>
319
-
320
  <netevensync>
321
  <disallowed_attributes>
322
  <!--
323
- Those are attributes (attribute codes) that must be excluded from additional attributes to be synchronized.
324
- They are excluded because whether because it is a non-sense to export them or because there are
325
- always exported.
326
-
327
- @see Neteven_NetevenSync_Model_Config::getDisallowedAttributes
328
  -->
329
- <cost/>
330
- <custom_design/>
331
- <custom_design_from/>
332
- <custom_design_to/>
333
- <custom_layout_update/>
334
- <description/>
335
- <gallery/>
336
- <image/>
337
- <manufacturer/>
338
- <media_gallery/>
339
- <name/>
340
- <options_container/>
341
- <page_layout/>
342
- <price/>
343
- <price_view/>
344
- <short_description/>
345
- <sku/>
346
- <small_image/>
347
- <special_price/>
348
- <status/>
349
- <tax_class_id/>
350
- <thumbnail/>
351
- <tier_price/>
352
- <visibility/>
353
  </disallowed_attributes>
354
-
355
  <specific_fields>
356
  <!--
357
- Those are Neteven specific fields that may require mapping
358
- Format: <code>Neteven Code</code>
359
-
360
- @see Neteven_NetevenSync_Model_Config::appendConfigNodes
361
  -->
362
  <ean>EAN</ean>
363
  <upc>UPC</upc>
@@ -383,11 +384,10 @@
383
  <shipping_delay>ShippingDelay</shipping_delay>
384
  <sku_family>SKUFamily</sku_family>
385
  </specific_fields>
386
-
387
  <order_statuses>
388
  <!--
389
- Those are Neteven order statuses that require mapping
390
- Format: <neteven_code>Admin Label</neteven_code>
391
  -->
392
  <toConfirm>To Confirm</toConfirm>
393
  <Confirmed>Confirmed</Confirmed>
@@ -395,13 +395,12 @@
395
  <Refunded>Refunded</Refunded>
396
  <Shipped>Shipped</Shipped>
397
  </order_statuses>
398
-
399
  <payment_methods>
400
  <!--
401
- Those are Neteven payment codes that require mapping
402
- Format: <neteven_code>magento_code</neteven_code>
403
-
404
- "neteven" payment payment is created is this module
405
  -->
406
  <CreditCard>ccsave</CreditCard>
407
  <Check>checkmo</Check>
@@ -409,8 +408,6 @@
409
  <Other>neteven</Other>
410
  <Unknown>neteven</Unknown>
411
  </payment_methods>
412
-
413
  <inventory_languages>fr,en,de,es,it</inventory_languages>
414
-
415
  </netevensync>
416
  </config>
1
+ <?xml version="1.0"?>
2
  <!--
3
  /**
4
  * This module manages data synchronisation from and to Neteven platform
5
+ *
6
  * @category Neteven
7
  * @package Neteven_NetevenSync
8
  * @copyright Copyright (c) 2013 Agence Soon. (http://www.agence-soon.fr)
11
  */
12
  -->
13
  <!--
14
+ @EVO Flag Neteven Orders in admin Orders Grid
15
+ @EVO "Empty Neteven Selection" button in Neteven Selection
16
+ @EVO "Remove from Neteven Selection" in admin Products Grid
17
+ @EVO Customer account creation on orders import
18
  -->
19
  <config>
20
  <modules>
21
  <Neteven_NetevenSync>
22
+ <version>2.2.4</version>
23
+ <!--<version_name></version_name>-->
24
  </Neteven_NetevenSync>
25
  </modules>
 
26
  <global>
27
  <events>
28
  <catalog_product_save_after>
76
  </netevensync>
77
  </helpers>
78
  <models>
79
+ <adminhtml>
80
+ <rewrite>
81
+ <config>Neteven_NetevenSync_Model_Adminhtml_Config</config>
82
+ </rewrite>
83
+ </adminhtml>
84
  <netevensync>
85
  <class>Neteven_NetevenSync_Model</class>
86
  <resourceModel>netevensync_resource</resourceModel>
117
  <setup>
118
  <module>Neteven_NetevenSync</module>
119
  </setup>
120
+ <connection>
121
+ <use>core_setup</use>
122
+ </connection>
123
  </netevensync_setup>
124
  </resources>
125
  </global>
 
126
  <admin>
127
  <routers>
128
  <adminhtml>
134
  </adminhtml>
135
  </routers>
136
  </admin>
 
137
  <adminhtml>
138
  <events>
139
  <adminhtml_init_system_config>
154
  <class>Neteven_NetevenSync_Model_Observer</class>
155
  <method>addNoticeConfigChange</method>
156
  </netevensync_config_neteven_selection_changed>
 
 
 
 
 
 
157
  </observers>
158
  </model_config_data_save_before>
159
  <catalog_product_attribute_update_before>
166
  </netevensync_register_increment_mass_update>
167
  </observers>
168
  </catalog_product_attribute_update_before>
169
+ <payment_info_block_prepare_specific_information>
170
+ <observers>
171
+ <!-- Add custom payment info to info block in admin -->
172
+ <netevensync_enrich_payment_info_block>
173
+ <class>netevensync/observer</class>
174
+ <method>enrichPaymentInfoBlock</method>
175
+ </netevensync_enrich_payment_info_block>
176
+ </observers>
177
+ </payment_info_block_prepare_specific_information>
178
  </events>
179
  <translate>
180
  <modules>
235
  <netevensync translate="title" module="netevensync">
236
  <title>Neteven</title>
237
  <sort_order>1000</sort_order>
238
+ <children>
239
+ <product translate="title" module="netevensync">
240
+ <title>Neteven Selection</title>
241
+ <sort_order>10</sort_order>
242
+ </product>
243
+ <console translate="title" module="netevensync">
244
+ <title>Neteven Console</title>
245
+ <sort_order>20</sort_order>
246
+ </console>
247
+ </children>
248
  </netevensync>
249
  </children>
250
  </catalog>
253
  </resources>
254
  </acl>
255
  </adminhtml>
 
256
  <default>
257
  <netevensync>
258
+ <general>
259
+ <debug_advanced>0</debug_advanced>
260
+ </general>
261
  <inventory>
262
  <enable>0</enable>
263
  <frequency>1</frequency>
264
+ <start_datetime>2000-01-01 00:00:00</start_datetime>
265
  <selected>1</selected>
266
  <stock>0</stock>
267
  <parent_data>0</parent_data>
269
  <stock>
270
  <enable>0</enable>
271
  <frequency>1</frequency>
272
+ <start_datetime>2000-01-01 00:00:00</start_datetime>
273
  <selected>1</selected>
274
  <stock>0</stock>
275
  <sync_prices>0</sync_prices>
277
  <order>
278
  <enable>0</enable>
279
  <frequency>1</frequency>
280
+ <start_datetime>2000-01-01 00:00:00</start_datetime>
281
  </order>
282
  <console>
283
  <url>https://evenmarketplaces.neteven.com</url>
286
  <wsdl>http://ws.neteven.com/NWS</wsdl>
287
  </soap>
288
  </netevensync>
 
289
  <carriers>
290
  <neteven>
291
  <active>1</active>
297
  <handling_type>F</handling_type>
298
  </neteven>
299
  </carriers>
 
300
  <payment>
301
  <neteven translate="title" module="netevensync">
302
  <active>1</active>
308
  </neteven>
309
  </payment>
310
  </default>
 
311
  <crontab>
312
  <jobs>
313
  <netevensync_process_all>
320
  </netevensync_process_all>
321
  </jobs>
322
  </crontab>
 
323
  <netevensync>
324
  <disallowed_attributes>
325
  <!--
326
+ Those are attributes (attribute codes) that must be excluded from additional attributes to be synchronized.
327
+ They are excluded because whether because it is a non-sense to export them or because there are
328
+ always exported.
329
+
330
+ @see Neteven_NetevenSync_Model_Config::getDisallowedAttributes
331
  -->
332
+ <cost />
333
+ <custom_design />
334
+ <custom_design_from />
335
+ <custom_design_to />
336
+ <custom_layout_update />
337
+ <description />
338
+ <gallery />
339
+ <image />
340
+ <media_gallery />
341
+ <name />
342
+ <options_container />
343
+ <page_layout />
344
+ <price />
345
+ <price_view />
346
+ <short_description />
347
+ <sku />
348
+ <small_image />
349
+ <special_price />
350
+ <status />
351
+ <tax_class_id />
352
+ <thumbnail />
353
+ <tier_price />
354
+ <visibility />
 
355
  </disallowed_attributes>
 
356
  <specific_fields>
357
  <!--
358
+ Those are Neteven specific fields that may require mapping
359
+ Format: <code>Neteven Code</code>
360
+
361
+ @see Neteven_NetevenSync_Model_Config::appendConfigNodes
362
  -->
363
  <ean>EAN</ean>
364
  <upc>UPC</upc>
384
  <shipping_delay>ShippingDelay</shipping_delay>
385
  <sku_family>SKUFamily</sku_family>
386
  </specific_fields>
 
387
  <order_statuses>
388
  <!--
389
+ Those are Neteven order statuses that require mapping
390
+ Format: <neteven_code>Admin Label</neteven_code>
391
  -->
392
  <toConfirm>To Confirm</toConfirm>
393
  <Confirmed>Confirmed</Confirmed>
395
  <Refunded>Refunded</Refunded>
396
  <Shipped>Shipped</Shipped>
397
  </order_statuses>
 
398
  <payment_methods>
399
  <!--
400
+ Those are Neteven payment codes that require mapping
401
+ Format: <neteven_code>magento_code</neteven_code>
402
+
403
+ "neteven" payment payment is created is this module
404
  -->
405
  <CreditCard>ccsave</CreditCard>
406
  <Check>checkmo</Check>
408
  <Other>neteven</Other>
409
  <Unknown>neteven</Unknown>
410
  </payment_methods>
 
411
  <inventory_languages>fr,en,de,es,it</inventory_languages>
 
412
  </netevensync>
413
  </config>
app/code/community/Neteven/NetevenSync/etc/marketplace_country.csv CHANGED
@@ -1,67 +1,69 @@
1
- 1,"FR"
2
- 2,"FR"
3
- 3,"FR"
4
- 4,"FR"
5
- 5,"FR"
6
- 6,"FR"
7
- 7,"FR"
8
- 8,"FR"
9
- 9,"FR"
10
- 10,"FR"
11
- 11,"FR"
12
- 12,"FR"
13
- 13,"FR"
14
- 14,"FR"
15
- 15,"FR"
16
- 16,"FR"
17
- 17,"FR"
18
- 18,"DE"
19
- 19,"FR"
20
- 20,"DE"
21
- 21,"FR"
22
- 22,"GB"
23
- 23,"GB"
24
- 24,"FR"
25
- 25,"FR"
26
- 26,"FR"
27
- 27,"FR"
28
- 28,"FR"
29
- 29,"ES"
30
- 30,"IT"
31
- 31,"ES"
32
- 32,"IT"
33
- 33,"FR"
34
- 34,"FR"
35
- 35,"GB"
36
- 36,"FR"
37
- 37,"FR"
38
- 38,"FR"
39
- 39,"AU"
40
- 40,"CA"
41
- 41,"US"
42
- 42,"CA"
43
- 43,"IT"
44
- 44,"FR"
45
- 45,"ES"
46
- 46,"DE"
47
- 47,"DE"
48
- 48,"IT"
49
- 49,"FR"
50
- 50,"NL"
51
- 51,"FR"
52
- 52,"ES"
53
- 53,"GB"
54
- 54,"FR"
55
- 55,"DE"
56
- 56,"FR"
57
- 57,"GB"
58
- 58,"US"
59
- 59,"FR"
60
- 60,"JP"
61
- 61,"GB"
62
- 62,"FR"
63
- 63,"FR"
64
- 64,"GB"
65
- 1000,"FR"
66
- 1001,"FR"
67
- 1002,"FR"
 
 
1
+ 14,2x Moins Cher,FR
2
+ 9,AbeBooks,FR
3
+ 6,Alapage,FR
4
+ 20,Amazon Allemagne,DE
5
+ 22,Amazon Angleterre,GB
6
+ 7,Amazon France,FR
7
+ 30,Amazon Italy,IT
8
+ 2,Amazon Marketplace,FR
9
+ 29,Amazon Spain,ES
10
+ 58,Amazon USA,US
11
+ 36,Atosho,FR
12
+ 63,Back Market,FR
13
+ 67,Boulanger,FR
14
+ 3,Boutique eBay,FR
15
+ 26,BrandAlley,FR
16
+ 62,Carrefour OnLine,FR
17
+ 25,cdiscount,FR
18
+ 13,Clicanddeal,FR
19
+ 68,Darty,FR
20
+ 18,eBay Allemagne,DE
21
+ 39,eBay Australia,AU
22
+ 54,eBay Belgique FR,BE
23
+ 40,eBay Canada,CA
24
+ 42,eBay Canada Français,CA
25
+ 4,eBay France,FR
26
+ 32,eBay Italy,IT
27
+ 31,eBay Spain,ES
28
+ 23,eBay UK,GB
29
+ 41,eBay USA,US
30
+ 15,Fnac,FR
31
+ 45,Fnac Espagne,ES
32
+ 49,Galeries Lafayette,FR
33
+ 17,Games,FR
34
+ 60,Ichiba,JP
35
+ 24,La Redoute,FR
36
+ 72,Lazada Malaisie,MY
37
+ 66,Menlook,FR
38
+ 44,Mister Good Deal,FR
39
+ 51,MyMarketplace,FR
40
+ 69,Oclio,FR
41
+ 34,one world avenue,FR
42
+ 46,Otto,DE
43
+ 11,Oxatis,FR
44
+ 12,Pixmania,FR
45
+ 35,Play,GB
46
+ 5,PriceMinister,FR
47
+ 52,Privalia,ES
48
+ 16,Rue du commerce,FR
49
+ 19,Sandbox,FR
50
+ 59,Sandboxv2,FR
51
+ 1000,Scopeo,FR
52
+ 27,SFR,FR
53
+ 55,Spartoo Allemagne,DE
54
+ 57,Spartoo Angleterre,GB
55
+ 56,Spartoo France,FR
56
+ 43,Spartoo Italie,IT
57
+ 53,Tesco,GB
58
+ 73,TMALL Global,CN
59
+ 10,Top Annonces,FR
60
+ 21,Vente du Diable,FR
61
+ 1001,Villatech,FR
62
+ 1002,Villatech,FR
63
+ 64,Wehkamp,NL
64
+ 47,Zalando Allemagne,DE
65
+ 61,Zalando Angleterre,GB
66
+ 37,Zalando France,FR
67
+ 48,Zalando Italie,IT
68
+ 50,Zalando Pays-Bas,NL
69
+ 38,ZekidStore,FR
app/code/community/Neteven/NetevenSync/etc/neteven_wsdl.xml CHANGED
@@ -1,424 +1,427 @@
1
- <!--
2
-
3
-
4
 
5
  This is a copy of online WSDL file, copied here for easy of development purpose.
6
-
7
-
8
-
9
 
10
  -->
11
-
12
- <?xml version="1.0" encoding="UTF-8"?>
13
  <definitions
14
- xmlns="http://schemas.xmlsoap.org/wsdl/"
15
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
16
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
17
- xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
18
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
19
- xmlns:tns="urn:NWS:examples"
20
- targetNamespace="urn:NWS:examples"
21
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
22
 
23
  <types>
24
  <xsd:schema elementFormDefault="qualified" targetNamespace="urn:NWS:examples">
25
- <xsd:element name="EchoRequestType">
26
- <xsd:complexType>
27
- <xsd:sequence>
28
- <xsd:element minOccurs="0" maxOccurs="1" name="EchoInput" type="xsd:string" />
29
- </xsd:sequence>
30
- </xsd:complexType>
31
- </xsd:element>
32
- <xsd:element name="EchoResponseType">
33
- <xsd:complexType>
34
- <xsd:sequence>
35
- <xsd:element minOccurs="0" maxOccurs="1" name="EchoOutput" type="xsd:string" />
36
- </xsd:sequence>
37
- </xsd:complexType>
38
- </xsd:element>
39
- <xsd:element name="GetItemsRequestType">
40
- <xsd:complexType>
41
- <xsd:sequence>
42
- <xsd:element minOccurs="0" maxOccurs="1" name="GetItemsInput" type="xsd:string" /><!-- USELESS -->
43
- <xsd:element minOccurs="0" maxOccurs="1" name="PageNumber" type="xsd:integer" />
44
- <xsd:element minOccurs="0" maxOccurs="1" name="DateModificationFrom" type="xsd:dateTime" />
45
- <xsd:element minOccurs="0" maxOccurs="1" name="SKU" type="xsd:string"/>
46
- <!-- GetItems returns only 200 items by request, you should specify
47
- a page number in order to get other element than 200 firsts. -->
48
- </xsd:sequence>
49
- </xsd:complexType>
50
- </xsd:element>
51
- <xsd:element name="TestConnectionRequest">
52
- <xsd:complexType />
53
- </xsd:element>
54
- <xsd:element name="TestConnectionResponse">
55
- <xsd:complexType>
56
- <xsd:sequence>
57
- <xsd:element minOccurs="1" maxOccurs="1" name="TestConnectionResult" type="tns:StatusEnum" />
58
- </xsd:sequence>
59
- </xsd:complexType>
60
- </xsd:element>
61
- <xsd:simpleType name="StatusEnum">
62
- <xsd:restriction base="xsd:string">
63
- <xsd:enumeration value="Accepted" />
64
- <xsd:enumeration value="Canceled" />
65
- <xsd:enumeration value="NonConformantAuthorization" />
66
- <xsd:enumeration value="NonConformantFormat" />
67
- <xsd:enumeration value="Rejected" />
68
- <xsd:enumeration value="UnexpectedInformation" />
69
- <xsd:enumeration value="Inserted" />
70
- <xsd:enumeration value="Updated" />
71
- <xsd:enumeration value="Deleted" />
72
- <!--<xsd:enumeration value="Unmodified" />-->
73
- <xsd:enumeration value="Error" />
74
- </xsd:restriction>
75
- </xsd:simpleType>
76
- <xsd:simpleType name="LangEnum">
77
- <xsd:restriction base="xsd:string">
78
- <xsd:enumeration value="fr" />
79
- <xsd:enumeration value="en" />
80
- <xsd:enumeration value="de" />
81
- </xsd:restriction>
82
- </xsd:simpleType>
83
- <xsd:complexType name="lstring">
84
- <xsd:simpleContent>
85
- <xsd:extension base="xsd:string">
86
- <xsd:attribute name="language_id" type="tns:LangEnum" default="fr"/>
87
- </xsd:extension>
88
- </xsd:simpleContent>
89
- </xsd:complexType>
90
- <xsd:simpleType name="CurrencyEnum">
91
- <xsd:restriction base="xsd:string">
92
- <xsd:enumeration value="EUR" />
93
- <xsd:enumeration value="GBP" />
94
- </xsd:restriction>
95
- </xsd:simpleType>
96
- <xsd:complexType name="price">
97
- <xsd:simpleContent>
98
- <xsd:extension base="xsd:double">
99
- <xsd:attribute name="currency_id" type="tns:CurrencyEnum" default="EUR"/>
100
- </xsd:extension>
101
- </xsd:simpleContent>
102
- </xsd:complexType>
103
- <xsd:element name="AuthenticationHeader" type="tns:AuthenticationHeader" />
104
- <xsd:complexType name="AuthenticationHeader">
105
  <xsd:sequence>
106
- <xsd:element minOccurs="1" maxOccurs="1" name="Method" type="xsd:string" /> <!-- AuthenticationMethod -->
107
- <xsd:element minOccurs="1" maxOccurs="1" name="Login" type="xsd:string" />
108
- <xsd:element minOccurs="1" maxOccurs="1" name="Seed" type="xsd:string" />
109
- <xsd:element minOccurs="1" maxOccurs="1" name="Stamp" type="xsd:string" /> <!-- dateTime -->
110
- <xsd:element minOccurs="1" maxOccurs="1" name="Signature" type="xsd:string" />
111
  </xsd:sequence>
112
- <xsd:anyAttribute />
113
  </xsd:complexType>
114
- <xsd:simpleType name="AuthenticationMethod">
115
- <xsd:restriction base="xsd:string">
116
- <xsd:enumeration value="xxxxMD5V1" />
117
- </xsd:restriction>
118
- </xsd:simpleType>
119
- <xsd:simpleType name="EtatEnum">
120
- <xsd:restriction base="xsd:integer">
121
- <xsd:enumeration value="1" />
122
- <xsd:enumeration value="2" />
123
- <xsd:enumeration value="3" />
124
- <xsd:enumeration value="4" />
125
- <xsd:enumeration value="5" />
126
- <xsd:enumeration value="6" />
127
- <xsd:enumeration value="7" />
128
- <xsd:enumeration value="8" />
129
- <xsd:enumeration value="9" />
130
- <xsd:enumeration value="10" />
131
- <xsd:enumeration value="11" />
132
- <xsd:enumeration value="12" />
133
- <xsd:enumeration value="13" />
134
- <xsd:enumeration value="15" />
135
- </xsd:restriction>
136
- </xsd:simpleType>
137
-
138
- <xsd:element name="InventoryItemsType">
139
- <xsd:complexType>
140
- <xsd:sequence>
141
- <xsd:element minOccurs="1" maxOccurs="1" name="nb_pages" type="xsd:integer" />
142
- <xsd:element minOccurs="1" maxOccurs="1" name="nb_items" type="xsd:integer" />
143
- <xsd:element minOccurs="1" maxOccurs="1" name="cur_page" type="xsd:integer" />
144
- <xsd:element minOccurs="0" maxOccurs="1" name="items" type="tns:ArrayOfInventoryItem" />
145
- </xsd:sequence>
146
- </xsd:complexType>
147
- </xsd:element>
148
-
149
- <xsd:element name="PostItems">
150
- <xsd:complexType>
151
- <xsd:sequence>
152
- <xsd:element minOccurs="0" maxOccurs="1" name="items" type="tns:ArrayOfInventoryItem" />
153
- </xsd:sequence>
154
- </xsd:complexType>
155
- </xsd:element>
156
-
157
- <xsd:complexType name="ArrayOfSpecificFields">
158
  <xsd:sequence>
159
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="SpecificField" nillable="true" type="tns:SpecificField" />
160
  </xsd:sequence>
161
  </xsd:complexType>
162
-
163
- <xsd:complexType name="SpecificField">
 
164
  <xsd:sequence>
165
- <xsd:element minOccurs="1" maxOccurs="1" name="Name" type="xsd:string" />
166
- <xsd:element minOccurs="1" maxOccurs="1" name="Value" type="xsd:string" />
 
 
 
 
167
  </xsd:sequence>
168
- <xsd:attribute name="lang" type="tns:LangEnum" />
169
  </xsd:complexType>
170
-
171
- <!--
172
- <xsd:complexType name="ArrayOfWarehouses">
 
 
 
173
  <xsd:sequence>
174
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="Warehouse" nillable="true" type="tns:SpecificField" />
175
  </xsd:sequence>
176
  </xsd:complexType>
177
-
178
- <xsd:complexType name="Warehouse">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  <xsd:sequence>
180
- <xsd:element minOccurs="1" maxOccurs="1" name="WarehouseId" type="xsd:double" />
181
- <xsd:element minOccurs="1" maxOccurs="1" name="WarehouseStock" type="xsd:double" />
182
- <xsd:element minOccurs="1" maxOccurs="1" name="WarehouseShipped" type="xsd:double" />
 
183
  </xsd:sequence>
184
- <xsd:attribute name="lang" type="tns:LangEnum" />
185
  </xsd:complexType>
186
- -->
187
 
188
- <xsd:complexType name="ArrayOfInventoryItem">
 
189
  <xsd:sequence>
190
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="InventoryItem" nillable="true" type="tns:InventoryItem" />
191
  </xsd:sequence>
192
  </xsd:complexType>
193
- <xsd:complexType name="InventoryItem">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  <xsd:sequence>
195
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="Title" type="xsd:string" />
196
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="SubTitle" type="xsd:string" />
197
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="Description" type="xsd:string" />
198
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="Comment" type="xsd:string" />
199
- <xsd:element minOccurs="1" maxOccurs="1" name="SKU" type="xsd:string" />
200
- <xsd:element minOccurs="0" maxOccurs="1" name="SKUFamily" type="xsd:string" />
201
- <xsd:element minOccurs="0" maxOccurs="1" name="Brand" type="xsd:string" />
202
- <xsd:element minOccurs="0" maxOccurs="1" name="CodeProduit" type="xsd:string" /> <!--deprecated-->
203
- <xsd:element minOccurs="0" maxOccurs="1" name="TypeCodeProduit" type="xsd:string" /> <!--deprecated-->
204
- <xsd:element minOccurs="0" maxOccurs="1" name="EAN" type="xsd:string" />
205
- <xsd:element minOccurs="0" maxOccurs="1" name="UPC" type="xsd:string" />
206
- <xsd:element minOccurs="0" maxOccurs="1" name="ISBN" type="xsd:string" />
207
- <xsd:element minOccurs="0" maxOccurs="1" name="ASIN" type="xsd:string" />
208
- <xsd:element minOccurs="0" maxOccurs="1" name="PartNumber" type="xsd:string" />
209
- <xsd:element minOccurs="0" maxOccurs="1" name="Quantity" type="xsd:integer" />
210
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="Cost" type="tns:price" />
211
- <xsd:element minOccurs="0" maxOccurs="1" name="Tva" type="xsd:double" />
212
- <xsd:element minOccurs="0" maxOccurs="1" name="Ecotaxe" type="xsd:double" />
213
- <xsd:element minOccurs="0" maxOccurs="1" name="Keywords" type="xsd:string" />
214
- <xsd:element minOccurs="0" maxOccurs="1" name="DateAvailability" type="xsd:dateTime" />
215
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceFixed" type="tns:price" />
216
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceStarting" type="tns:price" />
217
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceReserved" type="tns:price" />
218
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceRetail" type="tns:price" />
219
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceSecondChance" type="tns:price" />
220
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceBestOffer" type="tns:price" />
221
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional1" type="tns:price" />
222
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional2" type="tns:price" />
223
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional3" type="tns:price" />
224
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional4" type="tns:price" />
225
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional5" type="tns:price" />
226
- <xsd:element minOccurs="0" maxOccurs="1" name="Etat" type="tns:EtatEnum" />
227
- <xsd:element minOccurs="0" maxOccurs="1" name="LotSize" type="xsd:integer" />
228
- <xsd:element minOccurs="0" maxOccurs="1" name="SupplierName" type="xsd:string" /> <!--deprecated-->
229
- <xsd:element minOccurs="0" maxOccurs="1" name="Classification" type="xsd:string" />
230
- <xsd:element minOccurs="0" maxOccurs="1" name="Weight" type="xsd:double" />
231
- <xsd:element minOccurs="0" maxOccurs="1" name="Height" type="xsd:double" />
232
- <xsd:element minOccurs="0" maxOccurs="1" name="Width" type="xsd:double" />
233
- <xsd:element minOccurs="0" maxOccurs="1" name="Depth" type="xsd:double" />
234
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingLocal1" type="tns:price" />
235
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppLocal1" type="tns:price" />
236
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingLocal2" type="tns:price" />
237
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppLocal2" type="tns:price" />
238
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingLocal3" type="tns:price" />
239
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppLocal3" type="tns:price" />
240
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingInt1" type="tns:price" />
241
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppInt1" type="tns:price" />
242
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingInt2" type="tns:price" />
243
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppInt2" type="tns:price" />
244
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingInt3" type="tns:price" />
245
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppInt3" type="tns:price" />
246
- <xsd:element minOccurs="0" maxOccurs="1" name="ShippingDelay" type="xsd:integer" />
247
- <xsd:element minOccurs="0" maxOccurs="1" name="Image1" type="xsd:string" />
248
- <xsd:element minOccurs="0" maxOccurs="1" name="Image2" type="xsd:string" />
249
- <xsd:element minOccurs="0" maxOccurs="1" name="Image3" type="xsd:string" />
250
- <xsd:element minOccurs="0" maxOccurs="1" name="Image4" type="xsd:string" />
251
- <xsd:element minOccurs="0" maxOccurs="1" name="Image5" type="xsd:string" />
252
- <xsd:element minOccurs="0" maxOccurs="1" name="Image6" type="xsd:string" />
253
- <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseId" type="xsd:double" />
254
- <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseStock" type="xsd:double" />
255
- <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseShipped" type="xsd:double" />
256
- <xsd:element minOccurs="0" maxOccurs="1" name="ArrayOfSpecificFields" type="tns:ArrayOfSpecificFields" />
257
- <!--<xsd:element minOccurs="0" maxOccurs="1" name="ArrayOfWarehouses" type="tns:ArrayOfWarehouses" />-->
258
  </xsd:sequence>
259
  </xsd:complexType>
260
- <xsd:element name="PostItemsResponse">
261
- <xsd:complexType>
262
- <xsd:sequence>
263
- <xsd:element minOccurs="0" maxOccurs="1" name="PostItemsResult" type="tns:ArrayOfInventoryItemStatusResponse" />
264
- </xsd:sequence>
265
- </xsd:complexType>
266
- </xsd:element>
267
- <xsd:complexType name="ArrayOfInventoryItemStatusResponse">
 
 
 
 
 
 
 
268
  <xsd:sequence>
269
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="InventoryItemStatusResponse" nillable="true" type="tns:InventoryItemStatusResponse" />
270
- </xsd:sequence>
271
- </xsd:complexType>
272
- <xsd:complexType name="InventoryItemStatusResponse">
273
- <xsd:sequence>
274
- <xsd:element minOccurs="0" maxOccurs="1" name="ItemCode" type="xsd:string" />
275
- <xsd:element minOccurs="1" maxOccurs="1" name="StatusResponse" type="tns:StatusEnum" />
 
 
 
 
 
 
276
  </xsd:sequence>
277
  </xsd:complexType>
 
278
 
279
- <xsd:element name="GetOrders">
280
- <xsd:complexType>
281
- <xsd:sequence>
282
- <xsd:element minOccurs="0" maxOccurs="1" name="PageNumber" type="xsd:string" />
283
- <xsd:element minOccurs="0" maxOccurs="1" name="DateSaleFrom" type="xsd:dateTime" />
284
- <xsd:element minOccurs="0" maxOccurs="1" name="DateSaleTo" type="xsd:dateTime" />
285
- <xsd:element minOccurs="0" maxOccurs="1" name="DatePaymentFrom" type="xsd:dateTime" />
286
- <xsd:element minOccurs="0" maxOccurs="1" name="DatePaymentTo" type="xsd:dateTime" />
287
- <xsd:element minOccurs="0" maxOccurs="1" name="DateCreationFrom" type="xsd:dateTime" />
288
- <xsd:element minOccurs="0" maxOccurs="1" name="DateCreationTo" type="xsd:dateTime" />
289
- <xsd:element minOccurs="0" maxOccurs="1" name="DateModificationFrom" type="xsd:dateTime" />
290
- <xsd:element minOccurs="0" maxOccurs="1" name="DateModificationTo" type="xsd:dateTime" />
291
- <xsd:element minOccurs="0" maxOccurs="1" name="DateAvailabilityFrom" type="xsd:dateTime" />
292
- <xsd:element minOccurs="0" maxOccurs="1" name="DateAvailabilityTo" type="xsd:dateTime" />
293
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceId" type="xsd:string" />
294
- <xsd:element minOccurs="0" maxOccurs="1" name="OrderID" type="xsd:string" />
295
- </xsd:sequence>
296
- </xsd:complexType>
297
- </xsd:element>
298
-
299
-
300
- <xsd:element name="GetOrdersResponse">
301
- <xsd:complexType>
302
- <xsd:sequence>
303
- <xsd:element minOccurs="1" maxOccurs="1" name="PageNumber" type="xsd:string" />
304
- <xsd:element minOccurs="1" maxOccurs="1" name="PagesTotal" type="xsd:string" />
305
- <xsd:element minOccurs="0" maxOccurs="1" name="GetOrdersResult" type="tns:ArrayOfMarketPlaceOrder" />
306
- </xsd:sequence>
307
- </xsd:complexType>
308
- </xsd:element>
309
-
310
- <xsd:complexType name="ArrayOfMarketPlaceOrder">
311
- <xsd:sequence>
312
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="MarketPlaceOrder" nillable="true" type="tns:MarketPlaceOrder" />
313
- </xsd:sequence>
314
- </xsd:complexType>
315
- <xsd:complexType name="MarketPlaceOrder">
316
- <xsd:sequence>
317
- <xsd:element minOccurs="0" maxOccurs="1" name="ID" type="xsd:string" />
318
- <xsd:element minOccurs="0" maxOccurs="1" name="OrderID" type="xsd:string" />
319
- <xsd:element minOccurs="0" maxOccurs="1" name="OrderLineID" type="xsd:string" />
320
- <xsd:element minOccurs="0" maxOccurs="1" name="Status" type="tns:OrderStatusEnum" />
321
- <xsd:element minOccurs="0" maxOccurs="1" name="CustomerId" type="xsd:string" />
322
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceId" type="xsd:string" />
323
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceOrderId" type="xsd:string" />
324
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceOrderLineId" type="xsd:string" />
325
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceName" type="xsd:string" />
326
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceListingId" type="xsd:string" />
327
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceSaleId" type="xsd:string" />
328
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceInvoiceId" type="xsd:string" />
329
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceTransactionId" type="xsd:string" />
330
- <xsd:element minOccurs="0" maxOccurs="1" name="SKU" type="xsd:string" />
331
- <xsd:element minOccurs="0" maxOccurs="1" name="DateSale" type="xsd:dateTime" />
332
- <xsd:element minOccurs="0" maxOccurs="1" name="DatePayment" type="xsd:dateTime" />
333
- <xsd:element minOccurs="0" maxOccurs="1" name="DateShipping" type="xsd:dateTime" />
334
- <xsd:element minOccurs="0" maxOccurs="1" name="DateAvailability" type="xsd:dateTime" />
335
- <xsd:element minOccurs="0" maxOccurs="1" name="TrackingNumber" type="xsd:string" />
336
- <xsd:element minOccurs="0" maxOccurs="1" name="AmountPaid" type="tns:price" />
337
- <xsd:element minOccurs="0" maxOccurs="1" name="PaymentMethod" type="tns:PaymentMethodEnum" />
338
- <xsd:element minOccurs="0" maxOccurs="1" name="PaymentTransactionId" type="xsd:string" />
339
- <xsd:element minOccurs="0" maxOccurs="1" name="Quantity" type="xsd:double" />
340
- <xsd:element minOccurs="0" maxOccurs="1" name="Price" type="tns:price" />
341
- <xsd:element minOccurs="0" maxOccurs="1" name="InsuranceId" type="xsd:string" />
342
- <xsd:element minOccurs="0" maxOccurs="1" name="InsuranceCost" type="tns:price" />
343
- <xsd:element minOccurs="0" maxOccurs="1" name="ShippingCost" type="tns:price" />
344
- <xsd:element minOccurs="0" maxOccurs="1" name="FinalShippingCost" type="tns:price" />
345
- <xsd:element minOccurs="0" maxOccurs="1" name="OrderShippingCost" type="tns:price" />
346
- <xsd:element minOccurs="0" maxOccurs="1" name="ShipperId" type="xsd:string" />
347
- <xsd:element minOccurs="0" maxOccurs="1" name="VAT" type="tns:price" />
348
- <xsd:element minOccurs="0" maxOccurs="1" name="TotalCostWithVAT" type="tns:price" />
349
- <xsd:element minOccurs="0" maxOccurs="1" name="MarketplaceFee" type="tns:price" />
350
- <xsd:element minOccurs="0" maxOccurs="1" name="ProcessingFee" type="xsd:double" />
351
- <xsd:element minOccurs="0" maxOccurs="1" name="AmountToRefund" type="xsd:double" />
352
- <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseId" type="xsd:double" />
353
- <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseShippable" type="xsd:Boolean" />
354
- <xsd:element minOccurs="0" maxOccurs="1" name="BillingAddress" type="tns:MarketPlaceAddress" />
355
- <xsd:element minOccurs="0" maxOccurs="1" name="ShippingAddress" type="tns:MarketPlaceAddress" />
356
 
357
- </xsd:sequence>
358
- </xsd:complexType>
359
- <xsd:simpleType name="OrderStatusEnum">
360
- <xsd:restriction base="xsd:string">
361
- <xsd:enumeration value="toConfirm" />
362
- <xsd:enumeration value="Confirmed" />
363
- <xsd:enumeration value="Canceled" />
364
- <xsd:enumeration value="Refunded" />
365
- <xsd:enumeration value="Shipped" />
366
- </xsd:restriction>
367
- </xsd:simpleType>
368
- <xsd:simpleType name="PaymentMethodEnum">
369
- <xsd:restriction base="xsd:string">
370
- <xsd:enumeration value="CreditCard" />
371
- <xsd:enumeration value="Check" />
372
- <xsd:enumeration value="PayPal" />
373
- <xsd:enumeration value="Other" />
374
- <xsd:enumeration value="Unknown" />
375
- </xsd:restriction>
376
- </xsd:simpleType>
377
- <xsd:complexType name="MarketPlaceAddress">
378
  <xsd:sequence>
379
- <xsd:element minOccurs="0" maxOccurs="1" name="FirstName" type="xsd:string" />
380
- <xsd:element minOccurs="0" maxOccurs="1" name="LastName" type="xsd:string" />
381
- <xsd:element minOccurs="0" maxOccurs="1" name="Address1" type="xsd:string" />
382
- <xsd:element minOccurs="0" maxOccurs="1" name="Address2" type="xsd:string" />
383
- <xsd:element minOccurs="0" maxOccurs="1" name="CityName" type="xsd:string" />
384
- <xsd:element minOccurs="0" maxOccurs="1" name="PostalCode" type="xsd:string" />
385
- <xsd:element minOccurs="0" maxOccurs="1" name="Country" type="xsd:string" />
386
- <xsd:element minOccurs="0" maxOccurs="1" name="Phone" type="xsd:string" />
387
- <xsd:element minOccurs="0" maxOccurs="1" name="Mobile" type="xsd:string" />
388
- <xsd:element minOccurs="0" maxOccurs="1" name="Fax" type="xsd:string" />
389
- <xsd:element minOccurs="0" maxOccurs="1" name="Email" type="xsd:string" />
390
- <xsd:element minOccurs="0" maxOccurs="1" name="Company" type="xsd:string" />
391
- <xsd:element minOccurs="0" maxOccurs="1" name="Pseudo" type="xsd:string" />
392
  </xsd:sequence>
393
  </xsd:complexType>
394
- <xsd:element name="PostOrders">
395
- <xsd:complexType>
396
- <xsd:sequence>
397
- <xsd:element minOccurs="0" maxOccurs="1" name="orders" type="tns:ArrayOfMarketPlaceOrder" />
398
- </xsd:sequence>
399
- </xsd:complexType>
400
- </xsd:element>
401
- <xsd:element name="PostOrdersResponse">
402
- <xsd:complexType>
403
- <xsd:sequence>
404
- <xsd:element minOccurs="0" maxOccurs="1" name="PostOrdersResult" type="tns:ArrayOfMarketPlaceOrderStatusResponse" />
405
- </xsd:sequence>
406
- </xsd:complexType>
407
- </xsd:element>
408
- <xsd:complexType name="ArrayOfMarketPlaceOrderStatusResponse">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  <xsd:sequence>
410
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="MarketPlaceOrderStatusResponse" nillable="true" type="tns:MarketPlaceOrderStatusResponse" />
411
  </xsd:sequence>
412
  </xsd:complexType>
413
- <xsd:complexType name="MarketPlaceOrderStatusResponse">
 
 
414
  <xsd:sequence>
415
- <xsd:element minOccurs="0" maxOccurs="1" name="OrderLineID" type="xsd:string" />
416
- <xsd:element minOccurs="0" maxOccurs="1" name="OrderID" type="xsd:string" />
417
- <xsd:element minOccurs="1" maxOccurs="1" name="StatusResponse" type="tns:StatusEnum" />
418
- <!--deprecated : -->
419
- <xsd:element minOccurs="0" maxOccurs="1" name="OrderId" type="xsd:string" />
420
  </xsd:sequence>
421
  </xsd:complexType>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  </xsd:schema>
423
  </types>
424
 
@@ -514,73 +517,73 @@ This is a copy of online WSDL file, copied here for easy of development purpose.
514
  <wsdl:operation name="Echo">
515
  <wsdl:documentation>Echo service available for testing purposes</wsdl:documentation>
516
  <soap:operation soapAction="Echo" style="document" />
517
- <wsdl:input>
518
- <soap:body use="literal"/>
519
- </wsdl:input>
520
- <wsdl:output>
521
- <soap:body use="literal"/>
522
- </wsdl:output>
523
  </wsdl:operation>
524
 
525
  <wsdl:operation name="GetItems">
526
  <wsdl:documentation>Retrieve inventory items</wsdl:documentation>
527
  <soap:operation soapAction="GetItems" style="document" />
528
- <wsdl:input>
529
- <soap:body use="literal"/>
530
- <soap:header message="tns:TestConnectionAuthenticationHeader" part="AuthenticationHeader" use="literal" />
531
- </wsdl:input>
532
- <wsdl:output>
533
- <soap:body use="literal"/>
534
- </wsdl:output>
535
  </wsdl:operation>
536
 
537
  <wsdl:operation name="TestConnection">
538
  <wsdl:documentation>Authentication</wsdl:documentation>
539
  <soap:operation soapAction="TestConnection" style="document" />
540
- <wsdl:input>
541
- <soap:body use="literal" />
542
- <soap:header message="tns:TestConnectionAuthenticationHeader" part="AuthenticationHeader" use="literal" />
543
- </wsdl:input>
544
- <wsdl:output>
545
- <soap:body use="literal" />
546
- </wsdl:output>
547
  </wsdl:operation>
548
 
549
  <wsdl:operation name="PostItems">
550
  <wsdl:documentation>Upload inventory items</wsdl:documentation>
551
  <soap:operation soapAction="PostItems" style="document" />
552
- <wsdl:input>
553
- <soap:body use="literal" />
554
- <soap:header message="tns:PostItemsAuthenticationHeader" part="AuthenticationHeader" use="literal" />
555
- </wsdl:input>
556
- <wsdl:output>
557
- <soap:body use="literal" />
558
- </wsdl:output>
559
  </wsdl:operation>
560
 
561
 
562
  <wsdl:operation name="GetOrders">
563
  <wsdl:documentation>Retrieve orders</wsdl:documentation>
564
  <soap:operation soapAction="GetOrders" style="document" />
565
- <wsdl:input>
566
- <soap:body use="literal" />
567
- <soap:header message="tns:GetOrdersAuthenticationHeader" part="AuthenticationHeader" use="literal" />
568
- </wsdl:input>
569
- <wsdl:output>
570
- <soap:body use="literal" />
571
- </wsdl:output>
572
  </wsdl:operation>
573
 
574
  <wsdl:operation name="PostOrders">
575
  <wsdl:documentation>Upload orders</wsdl:documentation>
576
  <soap:operation soapAction="PostOrders" style="document" />
577
- <wsdl:input>
578
- <soap:body use="literal" />
579
- <soap:header message="tns:PostOrdersAuthenticationHeader" part="AuthenticationHeader" use="literal" />
580
- </wsdl:input>
581
- <wsdl:output>
582
- <soap:body use="literal" />
583
- </wsdl:output>
584
  </wsdl:operation>
585
  </wsdl:binding>
586
 
@@ -588,10 +591,10 @@ This is a copy of online WSDL file, copied here for easy of development purpose.
588
 
589
 
590
  <service name="NWS">
591
- <wsdl:documentation>Neteven service, please send your comments/remarks to technique@neteven.com.
592
- PDF Documentation : http://images.neteven.com/tmp/NWS.pdf</wsdl:documentation>
593
  <port name="NWSServerPortType" binding="tns:NWSServerBinding">
594
- <soap:address location="http://ws.neteven.com/NWS"/>
595
  </port>
596
  </service>
597
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!--
 
3
 
4
  This is a copy of online WSDL file, copied here for easy of development purpose.
5
+ Online version: http://ws.neteven.com/NWS
 
 
6
 
7
  -->
 
 
8
  <definitions
9
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
10
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
11
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
12
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
13
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
14
+ xmlns:tns="urn:NWS:examples"
15
+ targetNamespace="urn:NWS:examples"
16
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
17
 
18
  <types>
19
  <xsd:schema elementFormDefault="qualified" targetNamespace="urn:NWS:examples">
20
+ <xsd:element name="EchoRequestType">
21
+ <xsd:complexType>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  <xsd:sequence>
23
+ <xsd:element minOccurs="0" maxOccurs="1" name="EchoInput" type="xsd:string" />
 
 
 
 
24
  </xsd:sequence>
 
25
  </xsd:complexType>
26
+ </xsd:element>
27
+ <xsd:element name="EchoResponseType">
28
+ <xsd:complexType>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  <xsd:sequence>
30
+ <xsd:element minOccurs="0" maxOccurs="1" name="EchoOutput" type="xsd:string" />
31
  </xsd:sequence>
32
  </xsd:complexType>
33
+ </xsd:element>
34
+ <xsd:element name="GetItemsRequestType">
35
+ <xsd:complexType>
36
  <xsd:sequence>
37
+ <xsd:element minOccurs="0" maxOccurs="1" name="GetItemsInput" type="xsd:string" /><!-- USELESS -->
38
+ <xsd:element minOccurs="0" maxOccurs="1" name="PageNumber" type="xsd:integer" />
39
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateModificationFrom" type="xsd:dateTime" />
40
+ <xsd:element minOccurs="0" maxOccurs="1" name="SKU" type="xsd:string"/>
41
+ <!-- GetItems returns only 200 items by request, you should specify
42
+ a page number in order to get other element than 200 firsts. -->
43
  </xsd:sequence>
 
44
  </xsd:complexType>
45
+ </xsd:element>
46
+ <xsd:element name="TestConnectionRequest">
47
+ <xsd:complexType />
48
+ </xsd:element>
49
+ <xsd:element name="TestConnectionResponse">
50
+ <xsd:complexType>
51
  <xsd:sequence>
52
+ <xsd:element minOccurs="1" maxOccurs="1" name="TestConnectionResult" type="tns:StatusEnum" />
53
  </xsd:sequence>
54
  </xsd:complexType>
55
+ </xsd:element>
56
+ <xsd:simpleType name="StatusEnum">
57
+ <xsd:restriction base="xsd:string">
58
+ <xsd:enumeration value="Accepted" />
59
+ <xsd:enumeration value="Canceled" />
60
+ <xsd:enumeration value="NonConformantAuthorization" />
61
+ <xsd:enumeration value="NonConformantFormat" />
62
+ <xsd:enumeration value="Rejected" />
63
+ <xsd:enumeration value="UnexpectedInformation" />
64
+ <xsd:enumeration value="Inserted" />
65
+ <xsd:enumeration value="Updated" />
66
+ <xsd:enumeration value="Deleted" />
67
+ <!--<xsd:enumeration value="Unmodified" />-->
68
+ <xsd:enumeration value="Error" />
69
+ </xsd:restriction>
70
+ </xsd:simpleType>
71
+ <xsd:simpleType name="LangEnum">
72
+ <xsd:restriction base="xsd:string">
73
+ <xsd:enumeration value="fr" />
74
+ <xsd:enumeration value="en" />
75
+ <xsd:enumeration value="de" />
76
+ <xsd:enumeration value="es" />
77
+ <xsd:enumeration value="it" />
78
+ </xsd:restriction>
79
+ </xsd:simpleType>
80
+ <xsd:complexType name="lstring">
81
+ <xsd:simpleContent>
82
+ <xsd:extension base="xsd:string">
83
+ <xsd:attribute name="language_id" type="tns:LangEnum" default="fr"/>
84
+ </xsd:extension>
85
+ </xsd:simpleContent>
86
+ </xsd:complexType>
87
+ <xsd:simpleType name="CurrencyEnum">
88
+ <xsd:restriction base="xsd:string">
89
+ <xsd:enumeration value="EUR" />
90
+ <xsd:enumeration value="GBP" />
91
+ <xsd:enumeration value="USD" />
92
+ <xsd:enumeration value="CNY" />
93
+ </xsd:restriction>
94
+ </xsd:simpleType>
95
+ <xsd:complexType name="price">
96
+ <xsd:simpleContent>
97
+ <xsd:extension base="xsd:double">
98
+ <xsd:attribute name="currency_id" type="tns:CurrencyEnum" default="EUR"/>
99
+ </xsd:extension>
100
+ </xsd:simpleContent>
101
+ </xsd:complexType>
102
+ <xsd:element name="AuthenticationHeader" type="tns:AuthenticationHeader" />
103
+ <xsd:complexType name="AuthenticationHeader">
104
+ <xsd:sequence>
105
+ <xsd:element minOccurs="1" maxOccurs="1" name="Method" type="xsd:string" /> <!-- AuthenticationMethod -->
106
+ <xsd:element minOccurs="1" maxOccurs="1" name="Login" type="xsd:string" />
107
+ <xsd:element minOccurs="1" maxOccurs="1" name="Seed" type="xsd:string" />
108
+ <xsd:element minOccurs="1" maxOccurs="1" name="Stamp" type="xsd:string" /> <!-- dateTime -->
109
+ <xsd:element minOccurs="1" maxOccurs="1" name="Signature" type="xsd:string" />
110
+ </xsd:sequence>
111
+ <xsd:anyAttribute />
112
+ </xsd:complexType>
113
+ <xsd:simpleType name="AuthenticationMethod">
114
+ <xsd:restriction base="xsd:string">
115
+ <xsd:enumeration value="xxxxMD5V1" />
116
+ </xsd:restriction>
117
+ </xsd:simpleType>
118
+ <xsd:simpleType name="EtatEnum">
119
+ <xsd:restriction base="xsd:integer">
120
+ <xsd:enumeration value="1" />
121
+ <xsd:enumeration value="2" />
122
+ <xsd:enumeration value="3" />
123
+ <xsd:enumeration value="4" />
124
+ <xsd:enumeration value="5" />
125
+ <xsd:enumeration value="6" />
126
+ <xsd:enumeration value="7" />
127
+ <xsd:enumeration value="8" />
128
+ <xsd:enumeration value="9" />
129
+ <xsd:enumeration value="10" />
130
+ <xsd:enumeration value="11" />
131
+ <xsd:enumeration value="12" />
132
+ <xsd:enumeration value="13" />
133
+ <xsd:enumeration value="15" />
134
+ </xsd:restriction>
135
+ </xsd:simpleType>
136
+
137
+ <xsd:element name="InventoryItemsType">
138
+ <xsd:complexType>
139
  <xsd:sequence>
140
+ <xsd:element minOccurs="1" maxOccurs="1" name="nb_pages" type="xsd:integer" />
141
+ <xsd:element minOccurs="1" maxOccurs="1" name="nb_items" type="xsd:integer" />
142
+ <xsd:element minOccurs="1" maxOccurs="1" name="cur_page" type="xsd:integer" />
143
+ <xsd:element minOccurs="0" maxOccurs="1" name="items" type="tns:ArrayOfInventoryItem" />
144
  </xsd:sequence>
 
145
  </xsd:complexType>
146
+ </xsd:element>
147
 
148
+ <xsd:element name="PostItems">
149
+ <xsd:complexType>
150
  <xsd:sequence>
151
+ <xsd:element minOccurs="0" maxOccurs="1" name="items" type="tns:ArrayOfInventoryItem" />
152
  </xsd:sequence>
153
  </xsd:complexType>
154
+ </xsd:element>
155
+
156
+ <xsd:complexType name="ArrayOfSpecificFields">
157
+ <xsd:sequence>
158
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="SpecificField" nillable="true" type="tns:SpecificField" />
159
+ </xsd:sequence>
160
+ </xsd:complexType>
161
+
162
+ <xsd:complexType name="SpecificField">
163
+ <xsd:sequence>
164
+ <xsd:element minOccurs="1" maxOccurs="1" name="Name" type="xsd:string" />
165
+ <xsd:element minOccurs="1" maxOccurs="1" name="Value" type="xsd:string" />
166
+ </xsd:sequence>
167
+ <xsd:attribute name="lang" type="tns:LangEnum" />
168
+ </xsd:complexType>
169
+
170
+ <!--
171
+ <xsd:complexType name="ArrayOfWarehouses">
172
+ <xsd:sequence>
173
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="Warehouse" nillable="true" type="tns:SpecificField" />
174
+ </xsd:sequence>
175
+ </xsd:complexType>
176
+
177
+ <xsd:complexType name="Warehouse">
178
+ <xsd:sequence>
179
+ <xsd:element minOccurs="1" maxOccurs="1" name="WarehouseId" type="xsd:double" />
180
+ <xsd:element minOccurs="1" maxOccurs="1" name="WarehouseStock" type="xsd:double" />
181
+ <xsd:element minOccurs="1" maxOccurs="1" name="WarehouseShipped" type="xsd:double" />
182
+ </xsd:sequence>
183
+ <xsd:attribute name="lang" type="tns:LangEnum" />
184
+ </xsd:complexType>
185
+ -->
186
+
187
+ <xsd:complexType name="ArrayOfInventoryItem">
188
+ <xsd:sequence>
189
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="InventoryItem" nillable="true" type="tns:InventoryItem" />
190
+ </xsd:sequence>
191
+ </xsd:complexType>
192
+ <xsd:complexType name="InventoryItem">
193
+ <xsd:sequence>
194
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="Title" type="xsd:string" />
195
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="SubTitle" type="xsd:string" />
196
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="Description" type="xsd:string" />
197
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="Comment" type="xsd:string" />
198
+ <xsd:element minOccurs="1" maxOccurs="1" name="SKU" type="xsd:string" />
199
+ <xsd:element minOccurs="0" maxOccurs="1" name="SKUFamily" type="xsd:string" />
200
+ <xsd:element minOccurs="0" maxOccurs="1" name="Brand" type="xsd:string" />
201
+ <xsd:element minOccurs="0" maxOccurs="1" name="CodeProduit" type="xsd:string" /> <!--deprecated-->
202
+ <xsd:element minOccurs="0" maxOccurs="1" name="TypeCodeProduit" type="xsd:string" /> <!--deprecated-->
203
+ <xsd:element minOccurs="0" maxOccurs="1" name="EAN" type="xsd:string" />
204
+ <xsd:element minOccurs="0" maxOccurs="1" name="UPC" type="xsd:string" />
205
+ <xsd:element minOccurs="0" maxOccurs="1" name="ISBN" type="xsd:string" />
206
+ <xsd:element minOccurs="0" maxOccurs="1" name="ASIN" type="xsd:string" />
207
+ <xsd:element minOccurs="0" maxOccurs="1" name="PartNumber" type="xsd:string" />
208
+ <xsd:element minOccurs="0" maxOccurs="1" name="Quantity" type="xsd:integer" />
209
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="Cost" type="tns:price" />
210
+ <xsd:element minOccurs="0" maxOccurs="1" name="Tva" type="xsd:double" />
211
+ <xsd:element minOccurs="0" maxOccurs="1" name="Ecotax" type="xsd:double" />
212
+ <xsd:element minOccurs="0" maxOccurs="1" name="Keywords" type="xsd:string" />
213
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateAvailability" type="xsd:dateTime" />
214
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceFixed" type="tns:price" />
215
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceStarting" type="tns:price" />
216
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceReserved" type="tns:price" />
217
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceRetail" type="tns:price" />
218
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceSecondChance" type="tns:price" />
219
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceBestOffer" type="tns:price" />
220
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional1" type="tns:price" />
221
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional2" type="tns:price" />
222
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional3" type="tns:price" />
223
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional4" type="tns:price" />
224
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceAdditional5" type="tns:price" />
225
+ <xsd:element minOccurs="0" maxOccurs="1" name="Etat" type="tns:EtatEnum" />
226
+ <xsd:element minOccurs="0" maxOccurs="1" name="LotSize" type="xsd:integer" />
227
+ <xsd:element minOccurs="0" maxOccurs="1" name="SupplierName" type="xsd:string" /> <!--deprecated-->
228
+ <xsd:element minOccurs="0" maxOccurs="1" name="Classification" type="xsd:string" />
229
+ <xsd:element minOccurs="0" maxOccurs="1" name="Weight" type="xsd:double" />
230
+ <xsd:element minOccurs="0" maxOccurs="1" name="Height" type="xsd:double" />
231
+ <xsd:element minOccurs="0" maxOccurs="1" name="Width" type="xsd:double" />
232
+ <xsd:element minOccurs="0" maxOccurs="1" name="Depth" type="xsd:double" />
233
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingLocal1" type="tns:price" />
234
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppLocal1" type="tns:price" />
235
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingLocal2" type="tns:price" />
236
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppLocal2" type="tns:price" />
237
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingLocal3" type="tns:price" />
238
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppLocal3" type="tns:price" />
239
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingInt1" type="tns:price" />
240
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppInt1" type="tns:price" />
241
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingInt2" type="tns:price" />
242
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppInt2" type="tns:price" />
243
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingInt3" type="tns:price" />
244
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="PriceShippingSuppInt3" type="tns:price" />
245
+ <xsd:element minOccurs="0" maxOccurs="1" name="ShippingDelay" type="xsd:integer" />
246
+ <xsd:element minOccurs="0" maxOccurs="1" name="Image1" type="xsd:string" />
247
+ <xsd:element minOccurs="0" maxOccurs="1" name="Image2" type="xsd:string" />
248
+ <xsd:element minOccurs="0" maxOccurs="1" name="Image3" type="xsd:string" />
249
+ <xsd:element minOccurs="0" maxOccurs="1" name="Image4" type="xsd:string" />
250
+ <xsd:element minOccurs="0" maxOccurs="1" name="Image5" type="xsd:string" />
251
+ <xsd:element minOccurs="0" maxOccurs="1" name="Image6" type="xsd:string" />
252
+ <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseId" type="xsd:double" />
253
+ <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseStock" type="xsd:double" />
254
+ <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseShipped" type="xsd:double" />
255
+ <xsd:element minOccurs="0" maxOccurs="1" name="ArrayOfSpecificFields" type="tns:ArrayOfSpecificFields" />
256
+ <!--<xsd:element minOccurs="0" maxOccurs="1" name="ArrayOfWarehouses" type="tns:ArrayOfWarehouses" />-->
257
+ </xsd:sequence>
258
+ </xsd:complexType>
259
+ <xsd:element name="PostItemsResponse">
260
+ <xsd:complexType>
261
  <xsd:sequence>
262
+ <xsd:element minOccurs="0" maxOccurs="1" name="PostItemsResult" type="tns:ArrayOfInventoryItemStatusResponse" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  </xsd:sequence>
264
  </xsd:complexType>
265
+ </xsd:element>
266
+ <xsd:complexType name="ArrayOfInventoryItemStatusResponse">
267
+ <xsd:sequence>
268
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="InventoryItemStatusResponse" nillable="true" type="tns:InventoryItemStatusResponse" />
269
+ </xsd:sequence>
270
+ </xsd:complexType>
271
+ <xsd:complexType name="InventoryItemStatusResponse">
272
+ <xsd:sequence>
273
+ <xsd:element minOccurs="0" maxOccurs="1" name="ItemCode" type="xsd:string" />
274
+ <xsd:element minOccurs="1" maxOccurs="1" name="StatusResponse" type="tns:StatusEnum" />
275
+ </xsd:sequence>
276
+ </xsd:complexType>
277
+
278
+ <xsd:element name="GetOrders">
279
+ <xsd:complexType>
280
  <xsd:sequence>
281
+ <xsd:element minOccurs="0" maxOccurs="1" name="PageNumber" type="xsd:string" />
282
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateSaleFrom" type="xsd:dateTime" />
283
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateSaleTo" type="xsd:dateTime" />
284
+ <xsd:element minOccurs="0" maxOccurs="1" name="DatePaymentFrom" type="xsd:dateTime" />
285
+ <xsd:element minOccurs="0" maxOccurs="1" name="DatePaymentTo" type="xsd:dateTime" />
286
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateCreationFrom" type="xsd:dateTime" />
287
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateCreationTo" type="xsd:dateTime" />
288
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateModificationFrom" type="xsd:dateTime" />
289
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateModificationTo" type="xsd:dateTime" />
290
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateAvailabilityFrom" type="xsd:dateTime" />
291
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateAvailabilityTo" type="xsd:dateTime" />
292
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceId" type="xsd:string" />
293
+ <xsd:element minOccurs="0" maxOccurs="1" name="OrderID" type="xsd:string" />
294
  </xsd:sequence>
295
  </xsd:complexType>
296
+ </xsd:element>
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
 
299
+ <xsd:element name="GetOrdersResponse">
300
+ <xsd:complexType>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  <xsd:sequence>
302
+ <xsd:element minOccurs="1" maxOccurs="1" name="PageNumber" type="xsd:string" />
303
+ <xsd:element minOccurs="1" maxOccurs="1" name="PagesTotal" type="xsd:string" />
304
+ <xsd:element minOccurs="0" maxOccurs="1" name="GetOrdersResult" type="tns:ArrayOfMarketPlaceOrder" />
 
 
 
 
 
 
 
 
 
 
305
  </xsd:sequence>
306
  </xsd:complexType>
307
+ </xsd:element>
308
+
309
+ <xsd:complexType name="ArrayOfMarketPlaceOrder">
310
+ <xsd:sequence>
311
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="MarketPlaceOrder" nillable="true" type="tns:MarketPlaceOrder" />
312
+ </xsd:sequence>
313
+ </xsd:complexType>
314
+ <xsd:complexType name="MarketPlaceOrder">
315
+ <xsd:sequence>
316
+ <xsd:element minOccurs="0" maxOccurs="1" name="ID" type="xsd:string" />
317
+ <xsd:element minOccurs="0" maxOccurs="1" name="OrderID" type="xsd:string" />
318
+ <xsd:element minOccurs="0" maxOccurs="1" name="OrderLineID" type="xsd:string" />
319
+ <xsd:element minOccurs="0" maxOccurs="1" name="Status" type="tns:OrderStatusEnum" />
320
+ <xsd:element minOccurs="0" maxOccurs="1" name="CustomerId" type="xsd:string" />
321
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceId" type="xsd:string" />
322
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceOrderId" type="xsd:string" />
323
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceOrderLineId" type="xsd:string" />
324
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceName" type="xsd:string" />
325
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceListingId" type="xsd:string" />
326
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceSaleId" type="xsd:string" />
327
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceInvoiceId" type="xsd:string" />
328
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketPlaceTransactionId" type="xsd:string" />
329
+ <xsd:element minOccurs="0" maxOccurs="1" name="SKU" type="xsd:string" />
330
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateSale" type="xsd:dateTime" />
331
+ <xsd:element minOccurs="0" maxOccurs="1" name="DatePayment" type="xsd:dateTime" />
332
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateShipping" type="xsd:dateTime" />
333
+ <xsd:element minOccurs="0" maxOccurs="1" name="DateAvailability" type="xsd:dateTime" />
334
+ <xsd:element minOccurs="0" maxOccurs="1" name="TrackingNumber" type="xsd:string" />
335
+ <xsd:element minOccurs="0" maxOccurs="1" name="TrackingInfo" type="xsd:string" />
336
+ <xsd:element minOccurs="0" maxOccurs="1" name="AmountPaid" type="tns:price" />
337
+ <xsd:element minOccurs="0" maxOccurs="1" name="PaymentMethod" type="tns:PaymentMethodEnum" />
338
+ <xsd:element minOccurs="0" maxOccurs="1" name="PaymentTransactionId" type="xsd:string" />
339
+ <xsd:element minOccurs="0" maxOccurs="1" name="Quantity" type="xsd:double" />
340
+ <xsd:element minOccurs="0" maxOccurs="1" name="Price" type="tns:price" />
341
+ <xsd:element minOccurs="0" maxOccurs="1" name="InsuranceId" type="xsd:string" />
342
+ <xsd:element minOccurs="0" maxOccurs="1" name="InsuranceCost" type="tns:price" />
343
+ <xsd:element minOccurs="0" maxOccurs="1" name="ShippingCost" type="tns:price" />
344
+ <xsd:element minOccurs="0" maxOccurs="1" name="FinalShippingCost" type="tns:price" />
345
+ <xsd:element minOccurs="0" maxOccurs="1" name="OrderShippingCost" type="tns:price" />
346
+ <xsd:element minOccurs="0" maxOccurs="1" name="ShipperId" type="xsd:string" />
347
+ <xsd:element minOccurs="0" maxOccurs="1" name="VAT" type="tns:price" />
348
+ <xsd:element minOccurs="0" maxOccurs="1" name="TotalCostWithVAT" type="tns:price" />
349
+ <xsd:element minOccurs="0" maxOccurs="1" name="MarketplaceFee" type="tns:price" />
350
+ <xsd:element minOccurs="0" maxOccurs="1" name="Ecotax" type="xsd:double" />
351
+ <xsd:element minOccurs="0" maxOccurs="1" name="ProcessingFee" type="xsd:double" />
352
+ <xsd:element minOccurs="0" maxOccurs="1" name="AmountToRefund" type="xsd:double" />
353
+ <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseId" type="xsd:double" />
354
+ <xsd:element minOccurs="0" maxOccurs="1" name="WarehouseShippable" type="xsd:boolean" />
355
+ <xsd:element minOccurs="0" maxOccurs="1" name="BillingAddress" type="tns:MarketPlaceAddress" />
356
+ <xsd:element minOccurs="0" maxOccurs="1" name="ShippingAddress" type="tns:MarketPlaceAddress" />
357
+ <xsd:element minOccurs="0" maxOccurs="1" name="DeliveryInstructions" type="xsd:string" />
358
+ </xsd:sequence>
359
+ </xsd:complexType>
360
+ <xsd:simpleType name="OrderStatusEnum">
361
+ <xsd:restriction base="xsd:string">
362
+ <xsd:enumeration value="toConfirm" />
363
+ <xsd:enumeration value="Confirmed" />
364
+ <xsd:enumeration value="Canceled" />
365
+ <xsd:enumeration value="Refunded" />
366
+ <xsd:enumeration value="Shipped" />
367
+ </xsd:restriction>
368
+ </xsd:simpleType>
369
+ <xsd:simpleType name="PaymentMethodEnum">
370
+ <xsd:restriction base="xsd:string">
371
+ <xsd:enumeration value="CreditCard" />
372
+ <xsd:enumeration value="Check" />
373
+ <xsd:enumeration value="PayPal" />
374
+ <xsd:enumeration value="Other" />
375
+ <xsd:enumeration value="Unknown" />
376
+ </xsd:restriction>
377
+ </xsd:simpleType>
378
+ <xsd:complexType name="MarketPlaceAddress">
379
+ <xsd:sequence>
380
+ <xsd:element minOccurs="0" maxOccurs="1" name="FirstName" type="xsd:string" />
381
+ <xsd:element minOccurs="0" maxOccurs="1" name="LastName" type="xsd:string" />
382
+ <xsd:element minOccurs="0" maxOccurs="1" name="Address1" type="xsd:string" />
383
+ <xsd:element minOccurs="0" maxOccurs="1" name="Address2" type="xsd:string" />
384
+ <xsd:element minOccurs="0" maxOccurs="1" name="CityName" type="xsd:string" />
385
+ <xsd:element minOccurs="0" maxOccurs="1" name="PostalCode" type="xsd:string" />
386
+ <xsd:element minOccurs="0" maxOccurs="1" name="StateProvince" type="xsd:string" />
387
+ <xsd:element minOccurs="0" maxOccurs="1" name="Country" type="xsd:string" />
388
+ <xsd:element minOccurs="0" maxOccurs="1" name="Phone" type="xsd:string" />
389
+ <xsd:element minOccurs="0" maxOccurs="1" name="Mobile" type="xsd:string" />
390
+ <xsd:element minOccurs="0" maxOccurs="1" name="Fax" type="xsd:string" />
391
+ <xsd:element minOccurs="0" maxOccurs="1" name="Email" type="xsd:string" />
392
+ <xsd:element minOccurs="0" maxOccurs="1" name="Company" type="xsd:string" />
393
+ <xsd:element minOccurs="0" maxOccurs="1" name="Pseudo" type="xsd:string" />
394
+ </xsd:sequence>
395
+ </xsd:complexType>
396
+ <xsd:element name="PostOrders">
397
+ <xsd:complexType>
398
  <xsd:sequence>
399
+ <xsd:element minOccurs="0" maxOccurs="1" name="orders" type="tns:ArrayOfMarketPlaceOrder" />
400
  </xsd:sequence>
401
  </xsd:complexType>
402
+ </xsd:element>
403
+ <xsd:element name="PostOrdersResponse">
404
+ <xsd:complexType>
405
  <xsd:sequence>
406
+ <xsd:element minOccurs="0" maxOccurs="1" name="PostOrdersResult" type="tns:ArrayOfMarketPlaceOrderStatusResponse" />
 
 
 
 
407
  </xsd:sequence>
408
  </xsd:complexType>
409
+ </xsd:element>
410
+ <xsd:complexType name="ArrayOfMarketPlaceOrderStatusResponse">
411
+ <xsd:sequence>
412
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="MarketPlaceOrderStatusResponse" nillable="true" type="tns:MarketPlaceOrderStatusResponse" />
413
+ </xsd:sequence>
414
+ </xsd:complexType>
415
+ <xsd:complexType name="MarketPlaceOrderStatusResponse">
416
+ <xsd:sequence>
417
+ <xsd:element minOccurs="0" maxOccurs="1" name="OrderLineID" type="xsd:string" />
418
+ <xsd:element minOccurs="0" maxOccurs="1" name="OrderID" type="xsd:string" />
419
+ <xsd:element minOccurs="1" maxOccurs="1" name="StatusResponse" type="tns:StatusEnum" />
420
+ <xsd:element minOccurs="0" maxOccurs="1" name="StatusResponseDetail" type="xsd:string" />
421
+ <!--deprecated : -->
422
+ <xsd:element minOccurs="0" maxOccurs="1" name="OrderId" type="xsd:string" />
423
+ </xsd:sequence>
424
+ </xsd:complexType>
425
  </xsd:schema>
426
  </types>
427
 
517
  <wsdl:operation name="Echo">
518
  <wsdl:documentation>Echo service available for testing purposes</wsdl:documentation>
519
  <soap:operation soapAction="Echo" style="document" />
520
+ <wsdl:input>
521
+ <soap:body use="literal"/>
522
+ </wsdl:input>
523
+ <wsdl:output>
524
+ <soap:body use="literal"/>
525
+ </wsdl:output>
526
  </wsdl:operation>
527
 
528
  <wsdl:operation name="GetItems">
529
  <wsdl:documentation>Retrieve inventory items</wsdl:documentation>
530
  <soap:operation soapAction="GetItems" style="document" />
531
+ <wsdl:input>
532
+ <soap:body use="literal"/>
533
+ <soap:header message="tns:TestConnectionAuthenticationHeader" part="AuthenticationHeader" use="literal" />
534
+ </wsdl:input>
535
+ <wsdl:output>
536
+ <soap:body use="literal"/>
537
+ </wsdl:output>
538
  </wsdl:operation>
539
 
540
  <wsdl:operation name="TestConnection">
541
  <wsdl:documentation>Authentication</wsdl:documentation>
542
  <soap:operation soapAction="TestConnection" style="document" />
543
+ <wsdl:input>
544
+ <soap:body use="literal" />
545
+ <soap:header message="tns:TestConnectionAuthenticationHeader" part="AuthenticationHeader" use="literal" />
546
+ </wsdl:input>
547
+ <wsdl:output>
548
+ <soap:body use="literal" />
549
+ </wsdl:output>
550
  </wsdl:operation>
551
 
552
  <wsdl:operation name="PostItems">
553
  <wsdl:documentation>Upload inventory items</wsdl:documentation>
554
  <soap:operation soapAction="PostItems" style="document" />
555
+ <wsdl:input>
556
+ <soap:body use="literal" />
557
+ <soap:header message="tns:PostItemsAuthenticationHeader" part="AuthenticationHeader" use="literal" />
558
+ </wsdl:input>
559
+ <wsdl:output>
560
+ <soap:body use="literal" />
561
+ </wsdl:output>
562
  </wsdl:operation>
563
 
564
 
565
  <wsdl:operation name="GetOrders">
566
  <wsdl:documentation>Retrieve orders</wsdl:documentation>
567
  <soap:operation soapAction="GetOrders" style="document" />
568
+ <wsdl:input>
569
+ <soap:body use="literal" />
570
+ <soap:header message="tns:GetOrdersAuthenticationHeader" part="AuthenticationHeader" use="literal" />
571
+ </wsdl:input>
572
+ <wsdl:output>
573
+ <soap:body use="literal" />
574
+ </wsdl:output>
575
  </wsdl:operation>
576
 
577
  <wsdl:operation name="PostOrders">
578
  <wsdl:documentation>Upload orders</wsdl:documentation>
579
  <soap:operation soapAction="PostOrders" style="document" />
580
+ <wsdl:input>
581
+ <soap:body use="literal" />
582
+ <soap:header message="tns:PostOrdersAuthenticationHeader" part="AuthenticationHeader" use="literal" />
583
+ </wsdl:input>
584
+ <wsdl:output>
585
+ <soap:body use="literal" />
586
+ </wsdl:output>
587
  </wsdl:operation>
588
  </wsdl:binding>
589
 
591
 
592
 
593
  <service name="NWS">
594
+ <wsdl:documentation>Neteven service, please send your comments/remarks to support@neteven.com.
595
+ PDF Documentation : http://images.neteven.com/tmp/NWS.pdf</wsdl:documentation>
596
  <port name="NWSServerPortType" binding="tns:NWSServerBinding">
597
+ <soap:address location="https://ws.neteven.com/NWS"/>
598
  </port>
599
  </service>
600
 
app/code/community/Neteven/NetevenSync/etc/pdm_mapping.xml DELETED
@@ -1,23 +0,0 @@
1
- <!--
2
- /**
3
- * Mapping between Neteven marketplaces IDs and Neteven countries
4
- *
5
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
6
- * @author Hervé Guétin <@herveguetin> <herve.guetin@agence-soon.fr>
7
- * @category Soon
8
- * @package Soon_
9
- * @copyright Copyright (c) 2013 Agence Soon (http://www.agence-soon.fr)
10
- */
11
- -->
12
- <config>
13
- <netevensync>
14
- <pdm_mapping>
15
- <!-- <COUNTRY_CODE>marketplace id,marketplace id, ...</COUNTRY_CODE> -->
16
- <FR>2,4,5,7,12,15,16,19,21,24,25,26,27,34,36,37,44,49,56</FR>
17
- <DE>18,20,46,47,55</DE>
18
- <GB>22,23,35,57</GB>
19
- <IT>30,32,43,48</IT>
20
- <ES>29,31,45</ES>
21
- </pdm_mapping>
22
- </netevensync>
23
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Neteven/NetevenSync/etc/system.xml CHANGED
@@ -20,82 +20,109 @@
20
  <show_in_website>0</show_in_website>
21
  <show_in_store>1</show_in_store>
22
  <groups>
 
 
 
 
 
 
 
23
  <general translate="label">
24
  <label>General Configuration</label>
25
  <frontend_type>text</frontend_type>
26
  <sort_order>10</sort_order>
27
- <show_in_default>1</show_in_default>
28
- <show_in_website>0</show_in_website>
29
- <show_in_store>0</show_in_store>
30
- <expanded>1</expanded>
31
- <fields>
32
- <email translate="label, comment">
33
- <label>Email</label>
34
- <frontend_type>text</frontend_type>
35
- <comment>Example: email@domain.com</comment>
36
- <validate>validate-email</validate>
37
- <sort_order>10</sort_order>
38
- <show_in_default>1</show_in_default>
39
- <show_in_website>0</show_in_website>
40
- <show_in_store>0</show_in_store>
41
- </email>
42
- <password translate="label, comment">
43
- <label>Password</label>
44
- <frontend_type>password</frontend_type>
45
- <comment>Example: qwerty123</comment>
46
- <validate>validate-password</validate>
47
- <sort_order>20</sort_order>
48
- <show_in_default>1</show_in_default>
49
- <show_in_website>0</show_in_website>
50
- <show_in_store>0</show_in_store>
51
- </password>
52
- <test translate="label, comment">
53
- <label/>
54
- <frontend_type>button</frontend_type>
55
- <frontend_model>netevensync/adminhtml_system_config_test</frontend_model>
56
- <comment>Please save configuration before testing connection setup</comment>
57
- <sort_order>30</sort_order>
58
- <show_in_default>1</show_in_default>
59
- <show_in_website>0</show_in_website>
60
- <show_in_store>0</show_in_store>
61
- </test>
62
- <debug translate="label">
63
- <label>Enable debugging mode</label>
64
- <frontend_type>select</frontend_type>
65
- <source_model>adminhtml/system_config_source_yesno</source_model>
66
- <sort_order>40</sort_order>
67
- <show_in_default>1</show_in_default>
68
- <show_in_website>0</show_in_website>
69
- <show_in_store>0</show_in_store>
70
- </debug>
71
- <sandbox translate="label">
72
- <label>Enable sandbox mode</label>
73
- <frontend_type>select</frontend_type>
74
- <source_model>adminhtml/system_config_source_yesno</source_model>
75
- <sort_order>50</sort_order>
76
- <show_in_default>1</show_in_default>
77
- <show_in_website>0</show_in_website>
78
- <show_in_store>0</show_in_store>
79
- </sandbox>
80
- </fields>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  </general>
82
  <inventory translate="label">
83
  <label>Inventory Synchronization</label>
84
  <frontend_type>text</frontend_type>
85
  <sort_order>20</sort_order>
86
- <show_in_default>1</show_in_default>
87
- <show_in_website>0</show_in_website>
88
- <show_in_store>1</show_in_store>
89
- <fields>
90
- <enable translate="label">
91
- <label>Enable</label>
92
- <frontend_type>select</frontend_type>
93
- <source_model>adminhtml/system_config_source_yesno</source_model>
94
- <sort_order>10</sort_order>
95
- <show_in_default>1</show_in_default>
96
- <show_in_website>0</show_in_website>
97
- <show_in_store>0</show_in_store>
98
- </enable>
99
  <language translate="label">
100
  <label>Neteven Language</label>
101
  <frontend_type>select</frontend_type>
@@ -105,46 +132,58 @@
105
  <show_in_website>0</show_in_website>
106
  <show_in_store>1</show_in_store>
107
  </language>
108
- <frequency translate="label">
109
- <label>Synchronization Frequency</label>
110
- <frontend_type>select</frontend_type>
111
- <source_model>netevensync/adminhtml_system_config_source_frequency</source_model>
112
- <sort_order>20</sort_order>
113
- <show_in_default>1</show_in_default>
114
- <show_in_website>0</show_in_website>
115
- <show_in_store>0</show_in_store>
116
- <depends><enable>1</enable></depends>
117
- </frequency>
118
- <start translate="label">
119
- <label>Start Hour</label>
120
- <frontend_type>select</frontend_type>
121
- <source_model>netevensync/adminhtml_system_config_source_start</source_model>
122
- <sort_order>30</sort_order>
123
- <show_in_default>1</show_in_default>
124
- <show_in_website>0</show_in_website>
125
- <show_in_store>0</show_in_store>
126
- <depends><enable>1</enable></depends>
127
- </start>
128
- <selected translate="label">
129
- <label>Export Only Selected Products</label>
130
- <frontend_type>select</frontend_type>
131
- <source_model>adminhtml/system_config_source_yesno</source_model>
132
- <sort_order>40</sort_order>
133
- <show_in_default>1</show_in_default>
134
- <show_in_website>0</show_in_website>
135
- <show_in_store>0</show_in_store>
136
- <depends><enable>1</enable></depends>
137
- </selected>
138
- <stock translate="label">
139
- <label>Export Out-Of-Stock Products</label>
140
- <frontend_type>select</frontend_type>
141
- <source_model>adminhtml/system_config_source_yesno</source_model>
142
- <sort_order>50</sort_order>
143
- <show_in_default>1</show_in_default>
144
- <show_in_website>0</show_in_website>
145
- <show_in_store>0</show_in_store>
146
- <depends><enable>1</enable></depends>
147
- </stock>
 
 
 
 
 
 
 
 
 
 
 
 
148
  <parent_data>
149
  <label>Export Configurable Product</label>
150
  <frontend_type>select</frontend_type>
@@ -154,95 +193,115 @@
154
  <show_in_default>1</show_in_default>
155
  <show_in_website>0</show_in_website>
156
  <show_in_store>0</show_in_store>
157
- <depends><enable>1</enable></depends>
 
 
158
  </parent_data>
159
- <attribute translate="label">
160
- <label>Attributes To Synchronize</label>
161
- <frontend_type>multiselect</frontend_type>
162
- <source_model>netevensync/adminhtml_system_config_source_attribute</source_model>
163
- <sort_order>60</sort_order>
164
- <show_in_default>1</show_in_default>
165
- <show_in_website>0</show_in_website>
166
- <show_in_store>0</show_in_store>
167
- <depends><enable>1</enable></depends>
168
- </attribute>
169
- <incremental>
170
- <frontend_model>netevensync/adminhtml_system_config_incremental</frontend_model>
171
- <sort_order>1000</sort_order>
172
- <show_in_default>1</show_in_default>
173
- <show_in_website>0</show_in_website>
174
- <show_in_store>0</show_in_store>
175
- <depends><enable>1</enable></depends>
176
- <export_type>inventory</export_type>
177
- </incremental>
178
- <full>
179
- <frontend_model>netevensync/adminhtml_system_config_full</frontend_model>
180
- <sort_order>1010</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
- <depends><enable>1</enable></depends>
185
- <export_type>inventory</export_type>
186
- </full>
187
- </fields>
 
 
 
 
 
 
188
  </inventory>
189
  <stock translate="label">
190
  <label>Stocks Synchronization</label>
191
  <frontend_type>text</frontend_type>
192
  <sort_order>40</sort_order>
193
- <show_in_default>1</show_in_default>
194
- <show_in_website>0</show_in_website>
195
- <show_in_store>0</show_in_store>
196
- <fields>
197
- <enable translate="label">
198
- <label>Enable</label>
199
- <frontend_type>select</frontend_type>
200
- <source_model>adminhtml/system_config_source_yesno</source_model>
201
- <sort_order>10</sort_order>
202
- <show_in_default>1</show_in_default>
203
- <show_in_website>0</show_in_website>
204
- <show_in_store>0</show_in_store>
205
- </enable>
206
- <frequency translate="label">
207
- <label>Synchronization Frequency</label>
208
- <frontend_type>select</frontend_type>
209
- <source_model>netevensync/adminhtml_system_config_source_frequency</source_model>
210
- <sort_order>20</sort_order>
211
- <show_in_default>1</show_in_default>
212
- <show_in_website>0</show_in_website>
213
- <show_in_store>0</show_in_store>
214
- <depends><enable>1</enable></depends>
215
- </frequency>
216
- <start translate="label">
217
- <label>Start Hour</label>
218
- <frontend_type>select</frontend_type>
219
- <source_model>netevensync/adminhtml_system_config_source_start</source_model>
220
- <sort_order>30</sort_order>
221
- <show_in_default>1</show_in_default>
222
- <show_in_website>0</show_in_website>
223
- <show_in_store>0</show_in_store>
224
- <depends><enable>1</enable></depends>
225
- </start>
226
- <selected translate="label">
227
- <label>Export Only Selected Products</label>
228
- <frontend_type>select</frontend_type>
229
- <source_model>adminhtml/system_config_source_yesno</source_model>
230
- <sort_order>40</sort_order>
231
- <show_in_default>1</show_in_default>
232
- <show_in_website>0</show_in_website>
233
- <show_in_store>0</show_in_store>
234
- <depends><enable>1</enable></depends>
235
- </selected>
236
- <stock translate="label">
237
- <label>Export Out-Of-Stock Products</label>
238
- <frontend_type>select</frontend_type>
239
- <source_model>adminhtml/system_config_source_yesno</source_model>
240
- <sort_order>50</sort_order>
241
- <show_in_default>1</show_in_default>
242
- <show_in_website>0</show_in_website>
243
- <show_in_store>0</show_in_store>
244
- <depends><enable>1</enable></depends>
245
- </stock>
 
 
 
 
 
 
 
 
 
 
 
 
246
  <sync_prices translate="label, comment">
247
  <label>Synchronize Prices Attributes</label>
248
  <comment>Heavier for server</comment>
@@ -252,111 +311,137 @@
252
  <show_in_default>1</show_in_default>
253
  <show_in_website>0</show_in_website>
254
  <show_in_store>0</show_in_store>
255
- <depends><enable>1</enable></depends>
 
 
256
  </sync_prices>
257
- <incremental>
258
- <frontend_model>netevensync/adminhtml_system_config_full</frontend_model>
259
- <sort_order>1000</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
- <depends><enable>1</enable></depends>
264
- <export_type>stock</export_type>
265
- </incremental>
266
- </fields>
 
 
267
  </stock>
268
  <order translate="label">
269
  <label>Orders Synchronization</label>
270
  <frontend_type>text</frontend_type>
271
  <sort_order>50</sort_order>
272
- <show_in_default>1</show_in_default>
273
- <show_in_website>0</show_in_website>
274
- <show_in_store>1</show_in_store>
275
- <fields>
276
- <enable translate="label">
277
- <label>Enable</label>
278
- <frontend_type>select</frontend_type>
279
- <source_model>adminhtml/system_config_source_yesno</source_model>
280
- <sort_order>10</sort_order>
281
- <show_in_default>1</show_in_default>
282
- <show_in_website>0</show_in_website>
283
- <show_in_store>0</show_in_store>
284
- </enable>
 
 
 
 
 
 
 
 
 
 
285
  <pdm_mapping translate="label">
286
  <label>Orders Country</label>
287
- <frontend_type>select</frontend_type>
288
- <source_model>netevensync/adminhtml_system_config_source_order_pdm</source_model>
289
  <sort_order>15</sort_order>
290
  <show_in_default>0</show_in_default>
291
  <show_in_website>0</show_in_website>
292
  <show_in_store>1</show_in_store>
293
  </pdm_mapping>
294
- <frequency translate="label">
295
- <label>Synchronization Frequency</label>
296
- <frontend_type>select</frontend_type>
297
- <source_model>netevensync/adminhtml_system_config_source_frequency</source_model>
298
- <sort_order>20</sort_order>
299
- <show_in_default>1</show_in_default>
300
- <show_in_website>0</show_in_website>
301
- <show_in_store>0</show_in_store>
302
- <depends><enable>1</enable></depends>
303
- </frequency>
304
- <start translate="label">
305
- <label>Start Hour</label>
306
- <frontend_type>select</frontend_type>
307
- <source_model>netevensync/adminhtml_system_config_source_start</source_model>
308
- <sort_order>30</sort_order>
309
- <show_in_default>1</show_in_default>
310
- <show_in_website>0</show_in_website>
311
- <show_in_store>0</show_in_store>
312
- <depends><enable>1</enable></depends>
313
- </start>
314
- <incremental>
315
- <frontend_model>netevensync/adminhtml_system_config_incremental</frontend_model>
316
- <sort_order>3000</sort_order>
317
- <show_in_default>1</show_in_default>
318
- <show_in_website>0</show_in_website>
319
- <show_in_store>0</show_in_store>
320
- <depends><enable>1</enable></depends>
321
- <export_type>order</export_type>
322
- </incremental>
323
- <from>
324
- <frontend_model>netevensync/adminhtml_system_config_from</frontend_model>
325
- <sort_order>3010</sort_order>
326
- <show_in_default>1</show_in_default>
327
- <show_in_website>0</show_in_website>
328
- <show_in_store>0</show_in_store>
329
- <depends><enable>1</enable></depends>
330
- </from>
331
- </fields>
 
 
 
 
 
 
 
 
 
 
 
 
332
  </order>
333
  <order_mapping_neteven translate="label">
334
  <label>Neteven -> Magento Orders Mapping</label>
335
  <frontend_type>text</frontend_type>
336
  <sort_order>51</sort_order>
337
- <show_in_default>1</show_in_default>
338
- <show_in_website>0</show_in_website>
339
- <show_in_store>0</show_in_store>
340
- <fields/>
341
- </order_mapping_neteven>
342
  <order_mapping_magento translate="label">
343
  <label>Magento -> Neteven Orders Mapping</label>
344
  <frontend_type>text</frontend_type>
345
  <sort_order>52</sort_order>
346
- <show_in_default>1</show_in_default>
347
- <show_in_website>0</show_in_website>
348
- <show_in_store>0</show_in_store>
349
- <fields/>
350
- </order_mapping_magento>
351
  <shipping translate="label">
352
  <label>Shipping Information</label>
353
  <frontend_type>text</frontend_type>
354
  <sort_order>60</sort_order>
355
- <show_in_default>1</show_in_default>
356
- <show_in_website>0</show_in_website>
357
- <show_in_store>1</show_in_store>
358
- <expanded>1</expanded>
359
- <fields>
360
  <shipping_notice translate="label">
361
  <frontend_model>netevensync/adminhtml_system_config_hint</frontend_model>
362
  <hint_content>Orders Country in Orders Configuration must be set for this configuration to be used when importing orders.</hint_content>
@@ -365,17 +450,17 @@
365
  <show_in_website>0</show_in_website>
366
  <show_in_store>1</show_in_store>
367
  </shipping_notice>
368
- <carrier>
369
- <label>Carrier</label>
370
- <frontend_type>select</frontend_type>
371
- <source_model>netevensync/adminhtml_system_config_source_carrier</source_model>
372
- <validate>required-entry</validate>
373
- <sort_order>10</sort_order>
374
- <show_in_default>1</show_in_default>
375
- <show_in_website>0</show_in_website>
376
- <show_in_store>1</show_in_store>
377
- </carrier>
378
- </fields>
379
  </shipping>
380
  </groups>
381
  </netevensync>
20
  <show_in_website>0</show_in_website>
21
  <show_in_store>1</show_in_store>
22
  <groups>
23
+ <neteven_notice translate="label" module="paypal">
24
+ <frontend_model>netevensync/adminhtml_system_config_fieldset_hint</frontend_model>
25
+ <sort_order>0</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </neteven_notice>
30
  <general translate="label">
31
  <label>General Configuration</label>
32
  <frontend_type>text</frontend_type>
33
  <sort_order>10</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>0</show_in_website>
36
+ <show_in_store>0</show_in_store>
37
+ <expanded>1</expanded>
38
+ <fields>
39
+ <email translate="label, comment">
40
+ <label>Email</label>
41
+ <frontend_type>text</frontend_type>
42
+ <comment>Example: email@domain.com</comment>
43
+ <validate>validate-email</validate>
44
+ <sort_order>10</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>0</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ </email>
49
+ <password translate="label, comment">
50
+ <label>Password</label>
51
+ <frontend_type>password</frontend_type>
52
+ <comment>Example: qwerty123</comment>
53
+ <validate>validate-password</validate>
54
+ <sort_order>20</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>0</show_in_website>
57
+ <show_in_store>0</show_in_store>
58
+ </password>
59
+ <test translate="label, comment">
60
+ <label/>
61
+ <frontend_type>button</frontend_type>
62
+ <frontend_model>netevensync/adminhtml_system_config_test</frontend_model>
63
+ <comment>Please save configuration before testing connection setup</comment>
64
+ <sort_order>30</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>0</show_in_website>
67
+ <show_in_store>0</show_in_store>
68
+ </test>
69
+ <debug translate="label">
70
+ <label>Enable debugging mode</label>
71
+ <frontend_type>select</frontend_type>
72
+ <source_model>adminhtml/system_config_source_yesno</source_model>
73
+ <sort_order>40</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>0</show_in_website>
76
+ <show_in_store>0</show_in_store>
77
+ </debug>
78
+ <debug_advanced translate="label">
79
+ <label>Enable advanced debugging mode</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_yesno</source_model>
82
+ <sort_order>45</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>0</show_in_website>
85
+ <show_in_store>0</show_in_store>
86
+ <comment>This debug mode save full execution trace of the orders import and inventory export processes.</comment>
87
+ </debug_advanced>
88
+ <manage_logs translate="label">
89
+ <label>Manage logs</label>
90
+ <frontend_type>text</frontend_type>
91
+ <frontend_model>netevensync/adminhtml_system_config_logs</frontend_model>
92
+ <sort_order>45</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>0</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ <comment>This part allows you to download or remove the logs of Neteven.</comment>
97
+ </manage_logs>
98
+ <sandbox translate="label">
99
+ <label>Enable sandbox mode</label>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>50</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>0</show_in_website>
105
+ <show_in_store>0</show_in_store>
106
+ </sandbox>
107
+ </fields>
108
  </general>
109
  <inventory translate="label">
110
  <label>Inventory Synchronization</label>
111
  <frontend_type>text</frontend_type>
112
  <sort_order>20</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>0</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ <fields>
117
+ <enable translate="label">
118
+ <label>Enable</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>adminhtml/system_config_source_yesno</source_model>
121
+ <sort_order>10</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>0</show_in_website>
124
+ <show_in_store>0</show_in_store>
125
+ </enable>
126
  <language translate="label">
127
  <label>Neteven Language</label>
128
  <frontend_type>select</frontend_type>
132
  <show_in_website>0</show_in_website>
133
  <show_in_store>1</show_in_store>
134
  </language>
135
+ <frequency translate="label comment" module="netevensync">
136
+ <label>Synchronization Frequency</label>
137
+ <frontend_type>select</frontend_type>
138
+ <source_model>netevensync/adminhtml_system_config_source_frequency</source_model>
139
+ <sort_order>20</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>0</show_in_website>
142
+ <show_in_store>0</show_in_store>
143
+ <depends>
144
+ <enable>1</enable>
145
+ </depends>
146
+ <comment>We use the "crontab" notation here. By example, if you select "Every 2 hours" the process will be executed at 0am, 2am, 4am, etc.</comment>
147
+ </frequency>
148
+ <start_datetime translate="label comment" module="netevensync">
149
+ <label>After the</label>
150
+ <frontend_type>text</frontend_type>
151
+ <frontend_model>netevensync/adminhtml_system_config_form_field_datetime</frontend_model>
152
+ <backend_model>netevensync/adminhtml_system_config_backend_datetime</backend_model>
153
+ <validate>required-entry</validate>
154
+ <sort_order>30</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>0</show_in_website>
157
+ <show_in_store>0</show_in_store>
158
+ <depends>
159
+ <enable>1</enable>
160
+ </depends>
161
+ <comment>Please enter a date here. If the date is in the past there will be no effect. If the date is in the future then the next executions will be done after it.</comment>
162
+ </start_datetime>
163
+ <selected translate="label">
164
+ <label>Export Only Selected Products</label>
165
+ <frontend_type>select</frontend_type>
166
+ <source_model>adminhtml/system_config_source_yesno</source_model>
167
+ <sort_order>40</sort_order>
168
+ <show_in_default>1</show_in_default>
169
+ <show_in_website>0</show_in_website>
170
+ <show_in_store>0</show_in_store>
171
+ <depends>
172
+ <enable>1</enable>
173
+ </depends>
174
+ </selected>
175
+ <stock translate="label">
176
+ <label>Export Out-Of-Stock Products</label>
177
+ <frontend_type>select</frontend_type>
178
+ <source_model>adminhtml/system_config_source_yesno</source_model>
179
+ <sort_order>50</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>0</show_in_website>
182
+ <show_in_store>0</show_in_store>
183
+ <depends>
184
+ <enable>1</enable>
185
+ </depends>
186
+ </stock>
187
  <parent_data>
188
  <label>Export Configurable Product</label>
189
  <frontend_type>select</frontend_type>
193
  <show_in_default>1</show_in_default>
194
  <show_in_website>0</show_in_website>
195
  <show_in_store>0</show_in_store>
196
+ <depends>
197
+ <enable>1</enable>
198
+ </depends>
199
  </parent_data>
200
+ <attribute translate="label">
201
+ <label>Attributes To Synchronize</label>
202
+ <frontend_type>multiselect</frontend_type>
203
+ <source_model>netevensync/adminhtml_system_config_source_attribute</source_model>
204
+ <sort_order>60</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>0</show_in_website>
207
+ <show_in_store>0</show_in_store>
208
+ <depends>
209
+ <enable>1</enable>
210
+ </depends>
211
+ </attribute>
212
+ <incremental>
213
+ <frontend_model>netevensync/adminhtml_system_config_incremental</frontend_model>
214
+ <sort_order>1000</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>0</show_in_website>
217
+ <show_in_store>0</show_in_store>
218
+ <depends>
219
+ <enable>1</enable>
220
+ </depends>
221
+ <export_type>inventory</export_type>
222
+ </incremental>
223
+ <full>
224
+ <frontend_model>netevensync/adminhtml_system_config_full</frontend_model>
225
+ <sort_order>1010</sort_order>
226
+ <show_in_default>1</show_in_default>
227
+ <show_in_website>0</show_in_website>
228
+ <show_in_store>0</show_in_store>
229
+ <depends>
230
+ <enable>1</enable>
231
+ </depends>
232
+ <export_type>inventory</export_type>
233
+ </full>
234
+ </fields>
235
  </inventory>
236
  <stock translate="label">
237
  <label>Stocks Synchronization</label>
238
  <frontend_type>text</frontend_type>
239
  <sort_order>40</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
+ <fields>
244
+ <enable translate="label">
245
+ <label>Enable</label>
246
+ <frontend_type>select</frontend_type>
247
+ <source_model>adminhtml/system_config_source_yesno</source_model>
248
+ <sort_order>10</sort_order>
249
+ <show_in_default>1</show_in_default>
250
+ <show_in_website>0</show_in_website>
251
+ <show_in_store>0</show_in_store>
252
+ </enable>
253
+ <frequency translate="label comment" module="netevensync">
254
+ <label>Synchronization Frequency</label>
255
+ <frontend_type>select</frontend_type>
256
+ <source_model>netevensync/adminhtml_system_config_source_frequency</source_model>
257
+ <sort_order>20</sort_order>
258
+ <show_in_default>1</show_in_default>
259
+ <show_in_website>0</show_in_website>
260
+ <show_in_store>0</show_in_store>
261
+ <depends>
262
+ <enable>1</enable>
263
+ </depends>
264
+ <comment>We use the "crontab" notation here. By example, if you select "Every 2 hours" the process will be executed at 0am, 2am, 4am, etc.</comment>
265
+ </frequency>
266
+ <start_datetime translate="label comment" module="netevensync">
267
+ <label>After the</label>
268
+ <frontend_type>text</frontend_type>
269
+ <frontend_model>netevensync/adminhtml_system_config_form_field_datetime</frontend_model>
270
+ <backend_model>netevensync/adminhtml_system_config_backend_datetime</backend_model>
271
+ <validate>required-entry</validate>
272
+ <sort_order>30</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>0</show_in_website>
275
+ <show_in_store>0</show_in_store>
276
+ <depends>
277
+ <enable>1</enable>
278
+ </depends>
279
+ <comment>Please enter a date here. If the date is in the past there will be no effect. If the date is in the future then the next executions will be done after it.</comment>
280
+ </start_datetime>
281
+ <selected translate="label">
282
+ <label>Export Only Selected Products</label>
283
+ <frontend_type>select</frontend_type>
284
+ <source_model>adminhtml/system_config_source_yesno</source_model>
285
+ <sort_order>40</sort_order>
286
+ <show_in_default>1</show_in_default>
287
+ <show_in_website>0</show_in_website>
288
+ <show_in_store>0</show_in_store>
289
+ <depends>
290
+ <enable>1</enable>
291
+ </depends>
292
+ </selected>
293
+ <stock translate="label">
294
+ <label>Export Out-Of-Stock Products</label>
295
+ <frontend_type>select</frontend_type>
296
+ <source_model>adminhtml/system_config_source_yesno</source_model>
297
+ <sort_order>50</sort_order>
298
+ <show_in_default>1</show_in_default>
299
+ <show_in_website>0</show_in_website>
300
+ <show_in_store>0</show_in_store>
301
+ <depends>
302
+ <enable>1</enable>
303
+ </depends>
304
+ </stock>
305
  <sync_prices translate="label, comment">
306
  <label>Synchronize Prices Attributes</label>
307
  <comment>Heavier for server</comment>
311
  <show_in_default>1</show_in_default>
312
  <show_in_website>0</show_in_website>
313
  <show_in_store>0</show_in_store>
314
+ <depends>
315
+ <enable>1</enable>
316
+ </depends>
317
  </sync_prices>
318
+ <incremental>
319
+ <frontend_model>netevensync/adminhtml_system_config_full</frontend_model>
320
+ <sort_order>1000</sort_order>
321
+ <show_in_default>1</show_in_default>
322
+ <show_in_website>0</show_in_website>
323
+ <show_in_store>0</show_in_store>
324
+ <depends>
325
+ <enable>1</enable>
326
+ </depends>
327
+ <export_type>stock</export_type>
328
+ </incremental>
329
+ </fields>
330
  </stock>
331
  <order translate="label">
332
  <label>Orders Synchronization</label>
333
  <frontend_type>text</frontend_type>
334
  <sort_order>50</sort_order>
335
+ <show_in_default>1</show_in_default>
336
+ <show_in_website>0</show_in_website>
337
+ <show_in_store>1</show_in_store>
338
+ <fields>
339
+ <enable translate="label">
340
+ <label>Enable</label>
341
+ <frontend_type>select</frontend_type>
342
+ <source_model>adminhtml/system_config_source_yesno</source_model>
343
+ <sort_order>10</sort_order>
344
+ <show_in_default>1</show_in_default>
345
+ <show_in_website>0</show_in_website>
346
+ <show_in_store>0</show_in_store>
347
+ </enable>
348
+ <invoice_status translate="label comment" module="netevensync">
349
+ <label>Invoicing Status</label>
350
+ <frontend_type>multiselect</frontend_type>
351
+ <source_model>netevensync/adminhtml_system_config_source_netevenOrderStatus::toOptionArray</source_model>
352
+ <sort_order>15</sort_order>
353
+ <show_in_default>1</show_in_default>
354
+ <show_in_website>0</show_in_website>
355
+ <show_in_store>0</show_in_store>
356
+ <comment><![CDATA[Select one or more status, which will create an invoice when an order is imported from Neteven with a status in your selection.]]></comment>
357
+ </invoice_status>
358
  <pdm_mapping translate="label">
359
  <label>Orders Country</label>
360
+ <frontend_model>netevensync/adminhtml_system_config_form_field_order_mapping</frontend_model>
361
+ <backend_model>netevensync/adminhtml_system_config_order_mapping</backend_model>
362
  <sort_order>15</sort_order>
363
  <show_in_default>0</show_in_default>
364
  <show_in_website>0</show_in_website>
365
  <show_in_store>1</show_in_store>
366
  </pdm_mapping>
367
+ <frequency translate="label comment" module="netevensync">
368
+ <label>Synchronization Frequency</label>
369
+ <frontend_type>select</frontend_type>
370
+ <source_model>netevensync/adminhtml_system_config_source_frequency</source_model>
371
+ <sort_order>20</sort_order>
372
+ <show_in_default>1</show_in_default>
373
+ <show_in_website>0</show_in_website>
374
+ <show_in_store>0</show_in_store>
375
+ <depends>
376
+ <enable>1</enable>
377
+ </depends>
378
+ <comment>We use the "crontab" notation here. By example, if you select "Every 2 hours" the process will be executed at 0am, 2am, 4am, etc.</comment>
379
+ </frequency>
380
+ <start_datetime translate="label comment" module="netevensync">
381
+ <label>After the</label>
382
+ <frontend_type>text</frontend_type>
383
+ <frontend_model>netevensync/adminhtml_system_config_form_field_datetime</frontend_model>
384
+ <backend_model>netevensync/adminhtml_system_config_backend_datetime</backend_model>
385
+ <validate>required-entry</validate>
386
+ <sort_order>35</sort_order>
387
+ <show_in_default>1</show_in_default>
388
+ <show_in_website>0</show_in_website>
389
+ <show_in_store>0</show_in_store>
390
+ <depends>
391
+ <enable>1</enable>
392
+ </depends>
393
+ <comment>Please enter a date here. If the date is in the past there will be no effect. If the date is in the future then the next executions will be done after it.</comment>
394
+ </start_datetime>
395
+ <incremental>
396
+ <frontend_model>netevensync/adminhtml_system_config_incremental</frontend_model>
397
+ <sort_order>3000</sort_order>
398
+ <show_in_default>1</show_in_default>
399
+ <show_in_website>0</show_in_website>
400
+ <show_in_store>0</show_in_store>
401
+ <depends>
402
+ <enable>1</enable>
403
+ </depends>
404
+ <export_type>order</export_type>
405
+ </incremental>
406
+ <from>
407
+ <frontend_model>netevensync/adminhtml_system_config_from</frontend_model>
408
+ <sort_order>3010</sort_order>
409
+ <show_in_default>1</show_in_default>
410
+ <show_in_website>0</show_in_website>
411
+ <show_in_store>0</show_in_store>
412
+ <depends>
413
+ <enable>1</enable>
414
+ </depends>
415
+ </from>
416
+ </fields>
417
  </order>
418
  <order_mapping_neteven translate="label">
419
  <label>Neteven -> Magento Orders Mapping</label>
420
  <frontend_type>text</frontend_type>
421
  <sort_order>51</sort_order>
422
+ <show_in_default>1</show_in_default>
423
+ <show_in_website>0</show_in_website>
424
+ <show_in_store>0</show_in_store>
425
+ <fields/>
426
+ </order_mapping_neteven>
427
  <order_mapping_magento translate="label">
428
  <label>Magento -> Neteven Orders Mapping</label>
429
  <frontend_type>text</frontend_type>
430
  <sort_order>52</sort_order>
431
+ <show_in_default>1</show_in_default>
432
+ <show_in_website>0</show_in_website>
433
+ <show_in_store>0</show_in_store>
434
+ <fields/>
435
+ </order_mapping_magento>
436
  <shipping translate="label">
437
  <label>Shipping Information</label>
438
  <frontend_type>text</frontend_type>
439
  <sort_order>60</sort_order>
440
+ <show_in_default>1</show_in_default>
441
+ <show_in_website>0</show_in_website>
442
+ <show_in_store>1</show_in_store>
443
+ <expanded>1</expanded>
444
+ <fields>
445
  <shipping_notice translate="label">
446
  <frontend_model>netevensync/adminhtml_system_config_hint</frontend_model>
447
  <hint_content>Orders Country in Orders Configuration must be set for this configuration to be used when importing orders.</hint_content>
450
  <show_in_website>0</show_in_website>
451
  <show_in_store>1</show_in_store>
452
  </shipping_notice>
453
+ <carrier>
454
+ <label>Carrier</label>
455
+ <frontend_type>select</frontend_type>
456
+ <source_model>netevensync/adminhtml_system_config_source_carrier</source_model>
457
+ <validate>required-entry</validate>
458
+ <sort_order>10</sort_order>
459
+ <show_in_default>1</show_in_default>
460
+ <show_in_website>0</show_in_website>
461
+ <show_in_store>1</show_in_store>
462
+ </carrier>
463
+ </fields>
464
  </shipping>
465
  </groups>
466
  </netevensync>
app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.0.0.6-2.1.0.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SQL install script
4
+ *
5
+ * @category Neteven
6
+ * @package Neteven_NetevenSync
7
+ * @copyright Copyright (c) 2013 Agence Soon. (http://www.agence-soon.fr)
8
+ * @licence http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ * @author Hervé Guétin <herve.guetin@agence-soon.fr> <@herveguetin>
10
+ */
11
+
12
+ $installer = $this;
13
+ /* @var $installer Mage_Core_Model_Resource_Setup */
14
+
15
+ $installer->startSetup();
16
+
17
+ /**
18
+ * Add column to table 'netevensync/order_link'
19
+ */
20
+ $installer->getConnection()->addColumn(
21
+ $installer->getTable('netevensync/order_link'),
22
+ 'neteven_market_place_name',
23
+ array(
24
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
25
+ 'nullable' => false,
26
+ 'comment' => 'Neteven Market Place Name'
27
+ )
28
+ );
29
+
30
+ $installer->endSetup();
app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.1.0-2.1.1.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ try {
13
+
14
+ /* @var $installer Mage_Core_Model_Resource_Setup */
15
+ $installer = $this;
16
+ $installer->startSetup();
17
+
18
+ // Add column "store_id" on the order link table
19
+ $orderLinkTableName = $installer->getTable('netevensync/order_link');
20
+ $installer->getConnection()->addColumn(
21
+ $orderLinkTableName,
22
+ 'store_id',
23
+ array(
24
+ 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
25
+ 'length' => 5,
26
+ 'nullable' => true,
27
+ 'unsigned' => true,
28
+ 'comment' => 'Neteven Market Place Name'
29
+ )
30
+ );
31
+
32
+ // Add constraint
33
+ $installer->getConnection()->addForeignKey(
34
+ $installer->getFkName('netevensync/order_link', 'store_id', 'core/store', 'store_id'),
35
+ $orderLinkTableName,
36
+ 'store_id',
37
+ $installer->getTable('core/store'),
38
+ 'store_id',
39
+ Varien_Db_Ddl_Table::ACTION_SET_NULL,
40
+ Varien_Db_Ddl_Table::ACTION_SET_NULL
41
+ );
42
+
43
+ $installer->endSetup();
44
+
45
+ } catch (Exception $e) {
46
+ // Silence is golden
47
+ }
app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.1.1-2.1.3.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ try {
13
+
14
+ /* @var $installer Mage_Core_Model_Resource_Setup */
15
+ $installer = $this;
16
+ $installer->startSetup();
17
+
18
+ // Add column "has_been_processed" on the order link table
19
+ $orderLinkTableName = $installer->getTable('netevensync/order_link');
20
+ $installer->getConnection()->addColumn(
21
+ $orderLinkTableName,
22
+ 'has_been_processed',
23
+ array(
24
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
25
+ 'length' => 1,
26
+ 'nullable' => true,
27
+ 'unsigned' => true,
28
+ 'comment' => 'If the item has been processed recently'
29
+ )
30
+ );
31
+
32
+ $installer->endSetup();
33
+
34
+ } catch (Exception $e) {
35
+ // Silence is golden
36
+ }
app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.1.4-2.1.5.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ try {
13
+
14
+ /* @var $installer Mage_Sales_Model_Resource_Setup */
15
+ $installer = Mage::getResourceModel('sales/setup', 'core_setup');
16
+ $installer->startSetup();
17
+
18
+ // Add quote item column
19
+ $installer->addAttribute('quote_item', 'neteven_checksum', array(
20
+ 'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
21
+ ));
22
+
23
+ $installer->endSetup();
24
+
25
+ } catch (Exception $e) {
26
+ // Silence is golden
27
+ }
app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.1.5-2.1.6.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ try {
13
+
14
+ /* @var $installer Mage_Core_Model_Resource_Setup */
15
+ $installer = $this;
16
+ $installer->startSetup();
17
+
18
+ // Add column "can_invoice" on the order link table
19
+ $orderLinkTableName = $installer->getTable('netevensync/order_link');
20
+ $installer->getConnection()->addColumn(
21
+ $orderLinkTableName,
22
+ 'can_invoice',
23
+ array(
24
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
25
+ 'length' => 1,
26
+ 'nullable' => true,
27
+ 'unsigned' => true,
28
+ 'comment' => 'If the order can be invoiced'
29
+ )
30
+ );
31
+
32
+ $installer->endSetup();
33
+
34
+ } catch (Exception $e) {
35
+ // Silence is golden
36
+ }
app/code/community/Neteven/NetevenSync/sql/netevensync_setup/upgrade-2.2.2-2.2.3.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ try {
13
+
14
+ /* @var $installer Mage_Core_Model_Resource_Setup */
15
+ $installer = $this;
16
+ $installer->startSetup();
17
+
18
+ /*
19
+ * Add unique index on netevensync_product/product_id
20
+ * Note:
21
+ * In case some developers already added the constraint to avoid error,
22
+ * this will create a new one but it won't have any bad effect (except
23
+ * maybe some duplicated data on the server in case of multiple indexes…).
24
+ */
25
+ $tableName = $installer->getTable('netevensync/product');
26
+ $installer->getConnection()->addIndex(
27
+ $tableName,
28
+ $installer->getIdxName($tableName, 'product_id', Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
29
+ 'product_id',
30
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
31
+ );
32
+
33
+ $installer->endSetup();
34
+
35
+ } catch (Exception $e) {
36
+ // Silence is golden
37
+ }
app/design/adminhtml/default/default/layout/netevensync.xml CHANGED
@@ -15,6 +15,9 @@
15
  <reference name="notifications">
16
  <block type="netevensync/adminhtml_notifications" name="netevensync.notifications" template="netevensync/notifications.phtml"/>
17
  </reference>
 
 
 
18
  </default>
19
 
20
  <adminhtml_netevensync_runprocess>
15
  <reference name="notifications">
16
  <block type="netevensync/adminhtml_notifications" name="netevensync.notifications" template="netevensync/notifications.phtml"/>
17
  </reference>
18
+ <reference name="js">
19
+ <block type="netevensync/adminhtml_js_alert" name="netevensync.js.alert" template="netevensync/js/alert.phtml" />
20
+ </reference>
21
  </default>
22
 
23
  <adminhtml_netevensync_runprocess>
app/design/adminhtml/default/default/template/netevensync/js/alert.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+ /* @var $this Neteven_NetevenSync_Block_Adminhtml_Js_Alert */
12
+ ?>
13
+ <?php if ($this->isMarketplaceMappingMisconfigured()): ?>
14
+ <script>
15
+ $('messages').innerHTML = $('messages').innerHTML + '<ul class="messages"><li class="error-msg"><ul><li><?php echo $this->jsQuoteEscape($this->__("The mapping of the Neteven marketplaces is misconfigured. Please be sure that a marketplace is assigned to only one store!")); ?></li></ul></li></ul>';
16
+ </script>
17
+ <?php endif; ?>
app/locale/fr_FR/Neteven_NetevenSync.csv CHANGED
@@ -1,69 +1,83 @@
1
- "Orders Country in Orders Configuration must be set for this configuration to be used when importing orders.","Le Pays des commmandes dans la Synchronisation des commandes doit être spécifié pour que la configuration ci-dessous soit prise en compte lors de l'import des commandes."
2
  "%s item(s) to process...","%s éléments à mettre à jour..."
3
  "%s product(s) ready for synchronization<br/>(%s not in Neteven Selection)","%s produit(s) sont en attente de synchronisation<br/>(dont %s hors Selection Neteven)"
4
  "A full Neteven synchronization may be required for the following: %s.","Une synchronisation Neteven complète peut être nécessaire pour : %s."
5
- "Add Selected Products to Selection","Ajouter les produits sélectionnés à la sélection"
6
  "ASIN code is highly recommended for sales on Amazon","Code ASIN fortement recommandé pour les ventes sur Amazon"
 
 
 
7
  "Attributes To Synchronize","Attributs à synchroniser"
8
  "Available Products","Produits disponibles"
9
  "Canceled","Annulée"
10
  "Carrier","Transporteur"
11
  "Caution: server load can be heavy. Full synchronization my take several minutes and slow down your Magento system","Attention : le volume pouvant être important, la resynchronisation peut durer plusieurs minutes et ralentir Magento momentanément"
12
  "Confirmed","Confirmée"
 
 
 
13
  "EAN code is highly recommended","Code EAN Fortement recommandé"
 
14
  "Enable debugging mode","Activer mode debug"
15
  "Enable sandbox mode","Activer mode sandbox"
16
- "Errors while processing page %s. Please see var/log/neteven.log for details.","Erreur lors de l'exécution de la page %s. Consulter var/log/neteven.log pour les détails."
17
  "Errors while processing last operations. Please see var/log/neteven.log for details.","Erreurs lors de l'exécution des opérations finales. Merci de consulter le fichier var/log/neteven.log pour obtenir le détail des erreurs."
18
- "Every 15 minutes","Toutes les 15 minutes"
19
- "Every 30 minutes","Toutes les 30 minutes"
20
  "Every %s hour(s)","Toutes les %s heure(s)"
 
 
21
  "Example: email@domain.com","Exemple : vous@societe.com"
22
  "Example: qwerty123","Exemple : azerty123"
23
- "Export configurable parent product data if empty for simple product","Envoi des attributs du produit parent si vide sur le produit simple"
24
  "Export Configurable Product","Exporter produit configurable"
25
  "Export Only Selected Products","Exporter uniquement les produits sélectionnés"
26
  "Export Out-Of-Stock Products","Exporter les produits hors-stock"
 
27
  "Exported Products","Produits exportés"
28
  "Finished process execution","Exécution terminée"
29
  "General Configuration","Configuration générale"
30
  "Get orders created and updated since","Récupérer les commandes créées et mises à jour depuis le"
31
  "Heavier for server","Nécessite plus de ressources serveur"
 
32
  "Imported order item does not exist in catalog. Item ID: %s, Order ID: %s, Sku: %s","Le produit importé n'existe pas dans le catalogue Magento. Item ID: %s, Order ID: %s, Sku: %s"
33
  "Imported order item is of type ""%s"" which is not allowed for orders import. Item ID: %s, Order ID: %s, Sku: %s","Le produit importé est de type ""%s"" or ce type de produit ne peut pas être importé dans les commandes. Item ID: %s, Order ID: %s, Sku: %s"
34
- "Inventory","Inventaire"
35
  "Inventory Synchronization","Synchronisation de l'inventaire"
36
- "ISBN code is highly recommended for books","Code ISBN fortement recommandé pour les livres"
 
 
 
37
  "Magento Order Statuses Mapping","Mapping des statuts de commande Magento"
 
 
38
  "Minimum Order State","Etat minimum des commandes"
39
  "Neteven (Other or Unknown)","Neteven (Autre ou Inconnu)"
40
- "Neteven Order Statuses Mapping","Mapping des statuts de commande Neteven"
41
  "Neteven Console","Console Neteven"
42
  "Neteven Language","Langue Neteven"
 
43
  "Neteven Selection","Sélection Neteven"
44
  "Neteven Synchronization","Synchronisation Neteven"
 
45
  "Not all items have been processed for ""%s"" process.","Tous les éléments de la synchronisation ""%s"" n'ont pas été traités."
46
  "One or more errors occured during the following Neteven synchronization processes:","Une ou plusieurs erreurs sont survenues lors des échanges Neteven suivants :"
47
  "Order %s imported from Neteven","Commande %s importée de Neteven"
48
  "Order status changed by Neteven","Statut de commande modifié par Neteven"
49
- "Orders","Commandes"
50
  "Orders Country","Pays des commandes"
51
  "Orders Synchronization","Synchronisation des commandes"
 
52
  "Paid","Payée"
53
  "Password","Mot de passe"
54
- "Please map orders statuses and chose carrier. Process aborted.","Merci de mapper les statuts de commande et de choisir un transporteur. Process annulé."
55
  "Please map orders statuses and chose carrier. Order %s will not be included in next incremental order update.","Merci de mapper les statuts de commande et de choisir un transporteur. La commande %s ne sera pas incluse lors de la prochain synchronisation incrémentale des commandes."
 
56
  "Please save configuration before launching synchronization","Merci de sauvegarder la configuration avant de relancer la synchronisation"
57
  "Please save configuration before testing connection setup","Merci de sauvegarder la configuration avant de tester les paramètres de connexion"
58
  "Please see log file var/log/neteven.log for details. <a href=""%s"">Delete</a>","Merci de consulter le fichier var/log/neteven.log pour obtenir le détail des erreurs. <a href=""%s"">Supprimer</a>"
59
  "Process ""%s"" has been successfully executed.","La synchronisation ""%s"" a bien été effectuée."
60
  "Processed <strong>%s%% %s/%d</strong> records","<strong>%s%% %s/%d</strong> éléments exécutés"
61
  "Processing last operations, please wait...","Opérations finales en cours d'exécution, merci de patienter..."
62
- "Products have been removed from Neteven selection.","Les produits ont bien été supprimés de la sélection Neteven."
63
  "Products have been added to Neteven selection.","Les produits ont bien été ajoutés à la sélection Neteven."
 
64
  "Received","Reçue"
65
  "Refunded","Remboursée"
66
  "Remove Selected Products from Selection","Supprimer les produits sélectionnés de la sélection"
 
67
  "Setup has been successfully validated.","Vos identifiants ont été correctement validés."
68
  "Setup has failed. Neteven WS sent the following message: ""%s"".","Vos identifiants n'ont pas été validés. Neteven a renvoyé le message suivant : ""%s""."
69
  "Shipped","Expédiée"
@@ -73,11 +87,15 @@
73
  "Start Hour","Heure de départ"
74
  "Starting process execution, please wait...","Début de l'exécution, merci de patienter..."
75
  "Stocks Synchronization","Synchronisation des stocks"
76
- "Synchronization Frequency","Frequence de la synchronisation"
77
  "Synchronize Again","Relancer la synchronisation"
78
  "Synchronize Now","Synchroniser maintenant"
79
  "Synchronize Prices Attributes","Synchroniser attributs de prix"
80
  "Test connection setup","Tester les paramètres de connexion"
 
 
 
81
  "To Confirm","A confirmer"
82
- "Unable to connect to Neteven WS. Please check your credentials.","Impossible de se connecter au webservice Neteven. Merci de vérifier vos identifiants."
83
- "Warning: Please do not close the window during this process","Attention : ne pas fermer cette fenêtre pendant l'exécution"
 
 
1
  "%s item(s) to process...","%s éléments à mettre à jour..."
2
  "%s product(s) ready for synchronization<br/>(%s not in Neteven Selection)","%s produit(s) sont en attente de synchronisation<br/>(dont %s hors Selection Neteven)"
3
  "A full Neteven synchronization may be required for the following: %s.","Une synchronisation Neteven complète peut être nécessaire pour : %s."
 
4
  "ASIN code is highly recommended for sales on Amazon","Code ASIN fortement recommandé pour les ventes sur Amazon"
5
+ "Add Marketplace","Ajouter une place de marché"
6
+ "Add Selected Products to Selection","Ajouter les produits sélectionnés à la sélection"
7
+ "After the","Après le"
8
  "Attributes To Synchronize","Attributs à synchroniser"
9
  "Available Products","Produits disponibles"
10
  "Canceled","Annulée"
11
  "Carrier","Transporteur"
12
  "Caution: server load can be heavy. Full synchronization my take several minutes and slow down your Magento system","Attention : le volume pouvant être important, la resynchronisation peut durer plusieurs minutes et ralentir Magento momentanément"
13
  "Confirmed","Confirmée"
14
+ "Country","Pays"
15
+ "Delete this log","Supprimer ce log"
16
+ "Download this log","Télécharger ce log"
17
  "EAN code is highly recommended","Code EAN Fortement recommandé"
18
+ "Enable advanced debugging mode","Activer mode debug avancé"
19
  "Enable debugging mode","Activer mode debug"
20
  "Enable sandbox mode","Activer mode sandbox"
 
21
  "Errors while processing last operations. Please see var/log/neteven.log for details.","Erreurs lors de l'exécution des opérations finales. Merci de consulter le fichier var/log/neteven.log pour obtenir le détail des erreurs."
22
+ "Errors while processing page %s. Please see var/log/neteven.log for details.","Erreur lors de l'exécution de la page %s. Consulter var/log/neteven.log pour les détails."
 
23
  "Every %s hour(s)","Toutes les %s heure(s)"
24
+ "Every 15 minutes","Toutes les 15 minutes"
25
+ "Every 30 minutes","Toutes les 30 minutes"
26
  "Example: email@domain.com","Exemple : vous@societe.com"
27
  "Example: qwerty123","Exemple : azerty123"
 
28
  "Export Configurable Product","Exporter produit configurable"
29
  "Export Only Selected Products","Exporter uniquement les produits sélectionnés"
30
  "Export Out-Of-Stock Products","Exporter les produits hors-stock"
31
+ "Export configurable parent product data if empty for simple product","Envoi des attributs du produit parent si vide sur le produit simple"
32
  "Exported Products","Produits exportés"
33
  "Finished process execution","Exécution terminée"
34
  "General Configuration","Configuration générale"
35
  "Get orders created and updated since","Récupérer les commandes créées et mises à jour depuis le"
36
  "Heavier for server","Nécessite plus de ressources serveur"
37
+ "ISBN code is highly recommended for books","Code ISBN fortement recommandé pour les livres"
38
  "Imported order item does not exist in catalog. Item ID: %s, Order ID: %s, Sku: %s","Le produit importé n'existe pas dans le catalogue Magento. Item ID: %s, Order ID: %s, Sku: %s"
39
  "Imported order item is of type ""%s"" which is not allowed for orders import. Item ID: %s, Order ID: %s, Sku: %s","Le produit importé est de type ""%s"" or ce type de produit ne peut pas être importé dans les commandes. Item ID: %s, Order ID: %s, Sku: %s"
 
40
  "Inventory Synchronization","Synchronisation de l'inventaire"
41
+ "Inventory","Inventaire"
42
+ "Invoicing Status","Statut de facturation"
43
+ "Log file deleted.","Fichier de log supprimé."
44
+ "Log file not found.","Fichier de log introuvable."
45
  "Magento Order Statuses Mapping","Mapping des statuts de commande Magento"
46
+ "Manage logs","Gérer les logs"
47
+ "Marketplace","Place de marché"
48
  "Minimum Order State","Etat minimum des commandes"
49
  "Neteven (Other or Unknown)","Neteven (Autre ou Inconnu)"
 
50
  "Neteven Console","Console Neteven"
51
  "Neteven Language","Langue Neteven"
52
+ "Neteven Order Statuses Mapping","Mapping des statuts de commande Neteven"
53
  "Neteven Selection","Sélection Neteven"
54
  "Neteven Synchronization","Synchronisation Neteven"
55
+ "No log","Aucun log"
56
  "Not all items have been processed for ""%s"" process.","Tous les éléments de la synchronisation ""%s"" n'ont pas été traités."
57
  "One or more errors occured during the following Neteven synchronization processes:","Une ou plusieurs erreurs sont survenues lors des échanges Neteven suivants :"
58
  "Order %s imported from Neteven","Commande %s importée de Neteven"
59
  "Order status changed by Neteven","Statut de commande modifié par Neteven"
60
+ "Orders Country in Orders Configuration must be set for this configuration to be used when importing orders.","Le Pays des commmandes dans la Synchronisation des commandes doit être spécifié pour que la configuration ci-dessous soit prise en compte lors de l'import des commandes."
61
  "Orders Country","Pays des commandes"
62
  "Orders Synchronization","Synchronisation des commandes"
63
+ "Orders","Commandes"
64
  "Paid","Payée"
65
  "Password","Mot de passe"
66
+ "Please enter a date here. If the date is in the past there will be no effect. If the date is in the future then the next executions will be done after it.","Veuillez renseigner une date. Si la date est dans le passé alors cela n'aura aucun effet. Si la date est dans le futur alors la prochaine exécution se fera après celle-ci."
67
  "Please map orders statuses and chose carrier. Order %s will not be included in next incremental order update.","Merci de mapper les statuts de commande et de choisir un transporteur. La commande %s ne sera pas incluse lors de la prochain synchronisation incrémentale des commandes."
68
+ "Please map orders statuses and chose carrier. Process aborted.","Merci de mapper les statuts de commande et de choisir un transporteur. Process annulé."
69
  "Please save configuration before launching synchronization","Merci de sauvegarder la configuration avant de relancer la synchronisation"
70
  "Please save configuration before testing connection setup","Merci de sauvegarder la configuration avant de tester les paramètres de connexion"
71
  "Please see log file var/log/neteven.log for details. <a href=""%s"">Delete</a>","Merci de consulter le fichier var/log/neteven.log pour obtenir le détail des erreurs. <a href=""%s"">Supprimer</a>"
72
  "Process ""%s"" has been successfully executed.","La synchronisation ""%s"" a bien été effectuée."
73
  "Processed <strong>%s%% %s/%d</strong> records","<strong>%s%% %s/%d</strong> éléments exécutés"
74
  "Processing last operations, please wait...","Opérations finales en cours d'exécution, merci de patienter..."
 
75
  "Products have been added to Neteven selection.","Les produits ont bien été ajoutés à la sélection Neteven."
76
+ "Products have been removed from Neteven selection.","Les produits ont bien été supprimés de la sélection Neteven."
77
  "Received","Reçue"
78
  "Refunded","Remboursée"
79
  "Remove Selected Products from Selection","Supprimer les produits sélectionnés de la sélection"
80
+ "Select one or more status, which will create an invoice when an order is imported from Neteven with a status in your selection.","Sélectionnez un ou plusieurs statuts, qui créeront une facture dès qu'une commande sera récupérée de Neteven avec un statut faisant partie de votre sélection."
81
  "Setup has been successfully validated.","Vos identifiants ont été correctement validés."
82
  "Setup has failed. Neteven WS sent the following message: ""%s"".","Vos identifiants n'ont pas été validés. Neteven a renvoyé le message suivant : ""%s""."
83
  "Shipped","Expédiée"
87
  "Start Hour","Heure de départ"
88
  "Starting process execution, please wait...","Début de l'exécution, merci de patienter..."
89
  "Stocks Synchronization","Synchronisation des stocks"
90
+ "Synchronization Frequency","Fréquence de la synchronisation"
91
  "Synchronize Again","Relancer la synchronisation"
92
  "Synchronize Now","Synchroniser maintenant"
93
  "Synchronize Prices Attributes","Synchroniser attributs de prix"
94
  "Test connection setup","Tester les paramètres de connexion"
95
+ "The mapping of the Neteven marketplaces is misconfigured. Please be sure that a marketplace is assigned to only one store!","Le mapping des places de marché Neteven est incorrect. Merci de vérifier qu'une place de marché n'est associée qu'à une seule vue magasin."
96
+ "This debug mode save full execution trace of the orders import and inventory export processes.","Ce mode debug enregistre une trace d'exécution complète lors du traitement de l'import des commandes et de l'export de l'inventaire."
97
+ "This part allows you to download or remove the logs of Neteven.","Cette partie vous permet de télécharger ou supprimer les logs de Neteven."
98
  "To Confirm","A confirmer"
99
+ "Unable to connect to Neteven WS. Please check your credentials.","Impossible de se connecter au webservice Neteven. Merci de vérifier vos identifiants."
100
+ "Warning: Please do not close the window during this process","Attention : ne pas fermer cette fenêtre pendant l'exécution"
101
+ "We use the ""crontab"" notation here. By example, if you select ""Every 2 hours"" the process will be executed at 0am, 2am, 4am, etc.","Nous utilisons la notation ""crontab"" ici. Si vous sélectionnez par exemple ""Toutes les 2 heure(s)"" alors le traitement sera effectué à minuit, 2h, 4h, etc."
package.xml CHANGED
@@ -1,9 +1,9 @@
1
  <?xml version="1.0"?>
2
  <package>
3
- <name>neteven_netevensync</name>
4
- <version>1.0.8.7</version>
5
  <stability>stable</stability>
6
- <license uri="http://opensource.org/licenses/OSL-3.0">OSL-3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Official connector to Neteven marketplace solution.</summary>
@@ -44,23 +44,22 @@
44
  &#xD;
45
  &lt;ul&gt;&#xD;
46
  &lt;li&gt;English: &lt;a href="http://www.neteven.co.uk/magento/manual_addons_magento_neteven.html" title="Neteven Documentation"&gt;http://www.neteven.co.uk/magento/manual_addons_magento_neteven.html&lt;/a&gt;&lt;/li&gt;&#xD;
47
- &lt;li&gt;Fran&#xE7;ais: &lt;a href="http://www.neteven.com/magento/documentation_module_magento_neteven.html" title="Neteven Documentation"&gt;http://www.neteven.com/magento/documentation_module_magento_neteven.html&lt;/a&gt;&lt;/li&gt;&#xD;
48
  &lt;/ul&gt;&#xD;
49
  &#xD;
50
  &lt;h3&gt;About Neteven&lt;/h3&gt;&#xD;
51
  &lt;p&gt;&#xD;
52
- Founded in 2005 by former eBay employees and technologies experts, Neteven is the first distribution solution exclusively dedicated to marketplaces, leading websites in the global e-commerce market. Thanks to Neteven&#x2019;s human and technical accompaniment, companies can manage and optimise through one platform the full sale cycle of their catalog on marketplaces. The cloud based solution proposed by Neteven was conceived to fit any industry and is the only one available in 5 languages. It is based on one unique software, internally developed, in close collaboration with marketplaces partners&#x2019; technical teams. This software ensures merchants an unmatched level of performance. In addition to its software solution, Neteven offers its customers strategic and technical accompaniment services. A full or partial outsourcing of marketplaces distribution is possible thanks to an online sales expert team. Preferred provider of the largest actors in retail market, Neteven boosts the visibility of their products by exposing them directly towards final buyers. Among Neteven marketplaces partners are the largest generalist websites such as eBay, Amazon, Rakuten, Fnac as well as renowned specialised ones like Zalando, La Redoute, Spartoo or Brand Alley. These websites account more than 100 million buyers in Europe. Neteven frees its customer of the complex integration and marketplace management task. Neteven facilitates the distribution of many prestigious companies such as Sony Europe, Petit Bateau, Conrad or So Jeans. &#xD;
53
  &lt;/p&gt;&#xD;
54
  &lt;p&gt;&#xD;
55
  For more information: &lt;a href="http://www.neteven.co.uk" title="www.neteven.co.uk"&gt;www.neteven.co.uk&lt;/a&gt;&#xD;
56
- &lt;/p&gt;</description>
57
- <notes>Added check on "on_selection" for images export&#xD;
58
- Made available for Enterprise.&#xD;
59
- Is defined as stable.</notes>
60
- <authors><author><name>Herv&#xE9; Gu&#xE9;tin</name><user>vrnet</user><email>herve.guetin@agence-soon.fr</email></author></authors>
61
- <date>2014-11-21</date>
62
- <time>09:31:52</time>
63
- <contents><target name="magecommunity"><dir name="Neteven"><dir name="NetevenSync"><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="ee17e05056665117d011e0bc680d7b24"/><dir name="Process"><file name="Run.php" hash="8a3ba4bdc412774e86d8b6eb0fc56900"/></dir><dir name="Product"><dir name="View"><file name="Form.php" hash="138b28d53c299850b309deaa32181cdf"/><dir name="Tab"><file name="Available.php" hash="1d05dce934c9d615308271b0921ff5ee"/><file name="Exported.php" hash="2f997f7e2927045a7f581da49831ad79"/></dir><file name="Tabs.php" hash="2811fdbf27f79c0a44be40b77b930209"/></dir><file name="View.php" hash="220909cb8aa4116be4802ef63b10b659"/></dir><dir name="System"><dir name="Config"><file name="From.php" hash="9b1ddc2cc931d18bd59d5077b5b95cbb"/><file name="Full.php" hash="ffd3ab2c7e08ba1d45fb1922e8ff4635"/><file name="Hint.php" hash="518cf7613009a96ba67cc6e69e10efd8"/><file name="Incremental.php" hash="b457b5236f3a133aefbd5cea88390785"/><file name="Test.php" hash="65abb1d4525ff9ba169631b58f816158"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7d4794f573a311116df2e9daab37446f"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Config.php" hash="0788b5619ceb229f95db0e323fda476f"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Attribute"><file name="Price.php" hash="3d0251dc2b886e640826363a6274b07d"/><file name="Skufamily.php" hash="3257f4c20b3c6970f3a0519093e250a9"/></dir><file name="Attribute.php" hash="879e90c64d0cf85013651c6f06e7499c"/><file name="Carrier.php" hash="8e71759e33b7a8efc71c2ab141e69704"/><file name="Frequency.php" hash="c70199e7847fa8bb1bf5e9a21f589d28"/><dir name="Inventory"><file name="Language.php" hash="637e226b1d57bf02a1b8804fedad9b70"/></dir><file name="MagentoOrderStatus.php" hash="bff5c6a6e680231de0e582ef6836db09"/><file name="NetevenOrderStatus.php" hash="9e407b813218dd8d4db8ebe5c443acc3"/><dir name="Order"><file name="Pdm.php" hash="b940e63a10810ba283730e3d22c21496"/></dir><file name="Start.php" hash="866dd45713bba3f744a508838ca205c4"/></dir></dir></dir></dir><dir name="Config"><file name="Process.php" hash="7bfa06dab6a9fbfab94d06d7fe3b42e1"/></dir><file name="Config.php" hash="92a8082275fb637b5a4b4d07252670b2"/><file name="Cron.php" hash="8cd3cbd7263a1288bb37b611f3d658fe"/><file name="Log.php" hash="fc0f278db6f75d5dfad2fba6d0a042d6"/><file name="Observer.php" hash="14d9e6e3e932f81385405be9509966bc"/><dir name="Payment"><dir name="Method"><file name="Neteven.php" hash="ab5279ab83b7695ef1c5a95f6a302477"/></dir></dir><dir name="Process"><file name="Abstract.php" hash="5a8c4940dc530961074549853baf0726"/><file name="Inventory.php" hash="2e00bf91a6de73d8fb614444b421808d"/><dir name="Order"><file name="Convertor.php" hash="3bb2a33ac24edcdddd48b1c1af378a40"/><file name="Link.php" hash="5cc98489a6a0731f5e683ee2fee554bc"/></dir><file name="Order.php" hash="b4f8925ba8ee65524861eb8b318f7b25"/><file name="Stock.php" hash="19d9e551b6dea72657e89a411cdf4f3e"/></dir><file name="Product.php" hash="9bfedb2f9d63265a75e2605ff99bdfb9"/><dir name="Resource"><dir name="Config"><dir name="Process"><file name="Collection.php" hash="42d109d303960e32fc95836a6b11ec38"/></dir><file name="Process.php" hash="71ea71353e145f80a536d7e079c65fdb"/></dir><dir name="Log"><file name="Collection.php" hash="c4940516381bcd210cd7dd8822b15ad6"/></dir><file name="Log.php" hash="d7d8b946b42617ed94559d0be7fa100c"/><dir name="Process"><dir name="Inventory"><file name="Collection.php" hash="42e9a5f64d3b5f450ba94cfe283cf671"/></dir><file name="Inventory.php" hash="1b3aba93b3cb925c87ae337603a0f7c2"/><dir name="Order"><file name="Collection.php" hash="6174907ad3a84a68fb03f263bdcce44a"/><dir name="Link"><file name="Collection.php" hash="0673810fc34bad8fd1f6dc683497e79f"/></dir><file name="Link.php" hash="17c836be95cd9319a61da7068568c274"/><dir name="Temp"><file name="Collection.php" hash="fe7cdd58e63e33c66870a8a071f0e4b0"/></dir><file name="Temp.php" hash="d0e17a9524892d9865d34a1db5b2f5f8"/></dir><file name="Order.php" hash="1e981ba08ec546bf2dacd5792e397941"/><dir name="Stock"><file name="Collection.php" hash="dd7122802b16b05ad066f1758032a911"/></dir><file name="Stock.php" hash="233586c4601f25eed908e992a867c49e"/></dir><dir name="Product"><file name="Collection.php" hash="b03d830c57c25938350ea40cbfa08e82"/></dir><file name="Product.php" hash="159b9ceb673f7f32919f994024b50d3b"/></dir><dir name="Shipping"><file name="Dynamic.php" hash="04901409ad298619caf94adcb74cd4cb"/></dir><file name="Soap.php" hash="a6ed834f0fca611b0adb8b63a8425efa"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="NetevensyncController.php" hash="5582798dc5139a3c5fd87fc405c34be1"/></dir></dir><dir name="data"><dir name="netevensync_setup"><file name="data-install-1.0.0.0.php" hash="82c5b8b04d7372e25bfe6938bb6c76bb"/></dir></dir><dir name="docs"><dir name="en"><dir name="images"><file name="available.jpg" hash="7de30b2f713297b91d2b270fb2edb227"/><file name="config_item.jpg" hash="fe2e0a26d8163edb0dea738a578da637"/><file name="console.jpg" hash="6069ba0fc7358c8a747f0d25963add0b"/><file name="console_logged.jpg" hash="befda94fc103ca65365c6777ae3dc60c"/><file name="credentials.jpg" hash="5a9f2d6884712b5d221ca3c92781f731"/><file name="credentials_error.jpg" hash="f1f21f7746655e05983d54918fb233f3"/><file name="credentials_ok.jpg" hash="15c3a3b8cb2edffbe4a0f3961e34e622"/><file name="downloader.jpg" hash="c1971024cb7fdce238ac462d40ed73a6"/><file name="error_dash.jpg" hash="e047149ab50294f9cb22e7e76594f6f6"/><file name="error_manual.jpg" hash="3d73c9cc2cdfcd84a3726f35e31cc066"/><file name="export.jpg" hash="9a3b211f40f3d1f8c1ea7f616c8b5c21"/><file name="extension_key.jpg" hash="9858cc2b11e959c2506cb5e2b2545ac2"/><file name="installed.jpg" hash="8c41ebe50d94f2421fa3c51e561ab6b8"/><file name="inventory_config.jpg" hash="8c22f857458216e84e5a7cc0edff7392"/><file name="inventory_mapping.jpg" hash="f4787ad365c3ffe27fb02122ff5f2c89"/><file name="manual_sync.jpg" hash="e3fde48a9bd84de64063b915720f0e64"/><file name="multistore_inv_neteven.jpg" hash="5255b09529498c366c0cbd96a7d36699"/><file name="multistore_inv_setup.jpg" hash="174151c5fe2c22fa22559f0a8b3d6bca"/><file name="multistore_orders.jpg" hash="64dd459b5c39f43dd1b2ef3e78eea4e0"/><file name="multistore_orders_setup.jpg" hash="fdb87f029e5b004896680234c4465ee2"/><file name="orders.jpg" hash="4662e2f33a9b82a32b9d817b3a5a0623"/><file name="orders_date.jpg" hash="8f8be04e2e973e78550aa655ebc79645"/><file name="orders_mapping1.jpg" hash="c73dd9b3aba3bc7ac7eb9f29df856aed"/><file name="orders_mapping2.jpg" hash="97efc81df38edd02c08ce9939095c6ad"/><file name="product_incremental.jpg" hash="1fb2f82aa2891d12763dd0c0ddce2648"/><file name="shipping.jpg" hash="0634e62149163c24a5eccf6b230457b3"/><file name="stocks.jpg" hash="e06c29148e4e9f57182fc24d0b72407c"/></dir><file name="manual.html" hash="f6da92d45b500ea0e7a8ceade2d29a08"/><file name="manual.md" hash="28d0aa58edbb6207d229267830737478"/></dir><dir name="fr"><dir name="images"><file name="available.jpg" hash="c043142f613e1f0f010251199feb8714"/><file name="config_item.jpg" hash="fe2e0a26d8163edb0dea738a578da637"/><file name="console.jpg" hash="6069ba0fc7358c8a747f0d25963add0b"/><file name="console_logged.jpg" hash="befda94fc103ca65365c6777ae3dc60c"/><file name="credentials.jpg" hash="2de56e58d297a5e689bf9086eff18335"/><file name="credentials_error.jpg" hash="6a927dc2372cc12633782af00ea8640e"/><file name="credentials_ok.jpg" hash="5d94f2d861ff1a63d507d043473f42b2"/><file name="downloader.jpg" hash="c1971024cb7fdce238ac462d40ed73a6"/><file name="error_dash.jpg" hash="a5e1b6a825d30c11f9b8d512d47b52c6"/><file name="error_manual.jpg" hash="3d73c9cc2cdfcd84a3726f35e31cc066"/><file name="export.jpg" hash="5c8343ac88e9c632434c764751489c23"/><file name="extension_key.jpg" hash="9858cc2b11e959c2506cb5e2b2545ac2"/><file name="installed.jpg" hash="8c41ebe50d94f2421fa3c51e561ab6b8"/><file name="inventory_config.jpg" hash="ff0df5b850ee3ade1a2a76d34fd3504d"/><file name="inventory_mapping.jpg" hash="6a7cea4715a4d0d1d7427434c2108630"/><file name="manual_sync.jpg" hash="71d1ae34ef18be474a2453df1a4df066"/><file name="multistore_inv_neteven.jpg" hash="5255b09529498c366c0cbd96a7d36699"/><file name="multistore_inv_setup.jpg" hash="0a8b2788065ccccdfe58f17736c91230"/><file name="multistore_orders.jpg" hash="ff559d0c59c5d223ebd918bc970f1971"/><file name="multistore_orders_setup.jpg" hash="24758ef237e098cb208d711f0d3c5061"/><file name="orders.jpg" hash="073ef7aa1b8ada713967c7b4717c9aae"/><file name="orders_date.jpg" hash="c54762a8246ffac2e22d29fc4848d126"/><file name="orders_mapping1.jpg" hash="b3deaa8568db21fcb2993a2f3b4b6969"/><file name="orders_mapping2.jpg" hash="24b0a7efeabc0d0114ad6740fbf21fcc"/><file name="product_incremental.jpg" hash="d93695b597237f9bae503ed66cf7eaee"/><file name="shipping.jpg" hash="bbe3b5b9bc9a59cb259ab5fd039a9353"/><file name="stocks.jpg" hash="160dc9357d8ad2cf60d87c5cef504864"/></dir><file name="manual.html" hash="5ff58032c0a9614e45bbfbc050730618"/><file name="manual.md" hash="ef180ee4a721e22e3bf2943089fe7f1c"/></dir></dir><dir name="etc"><file name="config.xml" hash="32c281c2b9f199cd96493d619719cbd2"/><file name="marketplace_country.csv" hash="06204fe3b7fbf084557e5530d81a1ef4"/><file name="neteven_wsdl.xml" hash="336728cb61b80b49040d820ab1518c8e"/><file name="pdm_mapping.xml" hash="98ac299728fd63d147f9d5e55db54a3e"/><file name="system.xml" hash="66180e1156efc2ed44e5c981e4458c18"/></dir><dir name="sql"><dir name="netevensync_setup"><file name="install-1.0.7.0.php" hash="ba0aae1c9996ea2d49d32ae1cf631574"/><file name="upgrade-1.0.7.0-1.1.0.1.php" hash="f0fb40e49e775d0addd08e419e5c5bb9"/><file name="upgrade-1.1.0.0-1.1.0.1.php" hash="f0fb40e49e775d0addd08e419e5c5bb9"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="netevensync.xml" hash="7e853c1ceee6088ac2c64b2b990fe99b"/></dir><dir name="template"><dir name="netevensync"><file name="notifications.phtml" hash="879087425eaf3852fe06add6427b5fae"/><dir name="process"><file name="run.phtml" hash="c5f5b94c827c868fffbfcf083f163e6f"/></dir><dir name="product"><dir name="available"><file name="header.phtml" hash="02d0dd0018fff0f64f63b8c5f580c604"/></dir><dir name="exported"><file name="header.phtml" hash="5d36e676617bd6e9f4597e020592919c"/></dir></dir><dir name="system"><dir name="config"><dir name="shipping"><file name="hint.phtml" hash="f2cd02fab533b5c03667a1442961d05e"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Neteven_NetevenSync.xml" hash="bfb3cbff38fb326a925a09262cf80932"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Neteven_NetevenSync.csv" hash="217e98edd0f6bf8b900c1a9292158eab"/></dir></target><target name="mageweb"><dir name="js"><dir name="neteven"><file name="netevensync.js" hash="6c70a244d4e7a8ee2465502f763697a3"/></dir></dir></target></contents>
64
  <compatible/>
65
- <dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
66
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
+ <name>Neteven_NetevenSync</name>
4
+ <version>2.2.4</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/gpl-license.php">OSL-3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Official connector to Neteven marketplace solution.</summary>
44
  &#xD;
45
  &lt;ul&gt;&#xD;
46
  &lt;li&gt;English: &lt;a href="http://www.neteven.co.uk/magento/manual_addons_magento_neteven.html" title="Neteven Documentation"&gt;http://www.neteven.co.uk/magento/manual_addons_magento_neteven.html&lt;/a&gt;&lt;/li&gt;&#xD;
47
+ &lt;li&gt;Fran&amp;#xE7;ais: &lt;a href="http://www.neteven.com/magento/documentation_module_magento_neteven.html" title="Neteven Documentation"&gt;http://www.neteven.com/magento/documentation_module_magento_neteven.html&lt;/a&gt;&lt;/li&gt;&#xD;
48
  &lt;/ul&gt;&#xD;
49
  &#xD;
50
  &lt;h3&gt;About Neteven&lt;/h3&gt;&#xD;
51
  &lt;p&gt;&#xD;
52
+ Founded in 2005 by former eBay employees and technologies experts, Neteven is the first distribution solution exclusively dedicated to marketplaces, leading websites in the global e-commerce market. Thanks to Neteven&amp;#x2019;s human and technical accompaniment, companies can manage and optimise through one platform the full sale cycle of their catalog on marketplaces. The cloud based solution proposed by Neteven was conceived to fit any industry and is the only one available in 5 languages. It is based on one unique software, internally developed, in close collaboration with marketplaces partners&amp;#x2019; technical teams. This software ensures merchants an unmatched level of performance. In addition to its software solution, Neteven offers its customers strategic and technical accompaniment services. A full or partial outsourcing of marketplaces distribution is possible thanks to an online sales expert team. Preferred provider of the largest actors in retail market, Neteven boosts the visibility of their products by exposing them directly towards final buyers. Among Neteven marketplaces partners are the largest generalist websites such as eBay, Amazon, Rakuten, Fnac as well as renowned specialised ones like Zalando, La Redoute, Spartoo or Brand Alley. These websites account more than 100 million buyers in Europe. Neteven frees its customer of the complex integration and marketplace management task. Neteven facilitates the distribution of many prestigious companies such as Sony Europe, Petit Bateau, Conrad or So Jeans. &#xD;
53
  &lt;/p&gt;&#xD;
54
  &lt;p&gt;&#xD;
55
  For more information: &lt;a href="http://www.neteven.co.uk" title="www.neteven.co.uk"&gt;www.neteven.co.uk&lt;/a&gt;&#xD;
56
+ &lt;/p&gt;&#xD;
57
+ </description>
58
+ <notes>Fix images synchronization.</notes>
59
+ <authors><author><name>Jacques Bodin-Hullin</name><user>jacquesbh</user><email>j.bodinhullin@monsieurbiz.com</email></author></authors>
60
+ <date>2016-02-11</date>
61
+ <time>15:38:25</time>
62
+ <contents><target name="magecommunity"><dir name="Neteven"><dir name="NetevenSync"><dir name="Block"><dir name="Adminhtml"><dir name="Js"><file name="Alert.php" hash="c7110d8224ade2d0eaec2c8cd35e65a3"/></dir><file name="Notifications.php" hash="c68ee6334bd6c83e39fb67d29ed2c3ff"/><dir name="Process"><file name="Run.php" hash="8a3ba4bdc412774e86d8b6eb0fc56900"/></dir><dir name="Product"><dir name="View"><file name="Form.php" hash="138b28d53c299850b309deaa32181cdf"/><dir name="Tab"><file name="Available.php" hash="1d05dce934c9d615308271b0921ff5ee"/><file name="Exported.php" hash="2f997f7e2927045a7f581da49831ad79"/></dir><file name="Tabs.php" hash="2811fdbf27f79c0a44be40b77b930209"/></dir><file name="View.php" hash="220909cb8aa4116be4802ef63b10b659"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="7ffb9f34f7a0a51d1bf55ce5b3d56a64"/></dir><dir name="Form"><dir name="Field"><file name="Datetime.php" hash="906605a29f4b2841084123b0bb53966a"/><dir name="Order"><dir name="Mapping"><file name="Select.php" hash="0fd1e68b099f3df81f97faf51a18dbc2"/></dir><file name="Mapping.php" hash="a314f09f17c962ee5353dcc04ab087c8"/></dir></dir></dir><file name="From.php" hash="9b1ddc2cc931d18bd59d5077b5b95cbb"/><file name="Full.php" hash="ffd3ab2c7e08ba1d45fb1922e8ff4635"/><file name="Hint.php" hash="518cf7613009a96ba67cc6e69e10efd8"/><file name="Incremental.php" hash="b457b5236f3a133aefbd5cea88390785"/><file name="Logs.php" hash="5ea65ddfccafebb7c52938ad53675c25"/><file name="Test.php" hash="65abb1d4525ff9ba169631b58f816158"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7d24b3132ce210bd51b23f8664a1fc92"/><file name="Logger.php" hash="d815755da42679f19fe878476361b019"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Config.php" hash="0788b5619ceb229f95db0e323fda476f"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Datetime.php" hash="47d2a399e0c432e555ddeecdfd7a0fa9"/></dir><dir name="Order"><file name="Mapping.php" hash="a291a4345fb7918f69b6377ef4649786"/></dir><dir name="Source"><dir name="Attribute"><file name="Price.php" hash="3d0251dc2b886e640826363a6274b07d"/><file name="Skufamily.php" hash="3257f4c20b3c6970f3a0519093e250a9"/></dir><file name="Attribute.php" hash="879e90c64d0cf85013651c6f06e7499c"/><file name="Carrier.php" hash="8e71759e33b7a8efc71c2ab141e69704"/><file name="Frequency.php" hash="c70199e7847fa8bb1bf5e9a21f589d28"/><dir name="Inventory"><file name="Language.php" hash="637e226b1d57bf02a1b8804fedad9b70"/></dir><file name="Logs.php" hash="951a71c418762995a5a2cb17b9e49ee5"/><file name="MagentoOrderStatus.php" hash="47c5a1b3a1425cae5f17b160b4eb0bc9"/><file name="NetevenOrderStatus.php" hash="51b5828537372e5eb86e94213590eb32"/><dir name="Order"><file name="Pdm.php" hash="8032d4276cb0013eb651f2e011a232e5"/></dir></dir></dir></dir></dir><dir name="Config"><file name="Process.php" hash="0a443d1087c8ef471bdc4216e3f2153d"/></dir><file name="Config.php" hash="cce1376def46d4a49571ec657c048f9d"/><file name="Cron.php" hash="f7425b0550b800ad6cfe8cb281162571"/><file name="Log.php" hash="fc0f278db6f75d5dfad2fba6d0a042d6"/><file name="Observer.php" hash="9ad465e9ed4d2f23f04ee17e63c48110"/><dir name="Payment"><dir name="Method"><file name="Neteven.php" hash="ab5279ab83b7695ef1c5a95f6a302477"/></dir></dir><dir name="Process"><file name="Abstract.php" hash="6ca57e9a237c0bdeb9736aaa2f522903"/><file name="Inventory.php" hash="a8911972585adca6490b598a52d9c648"/><dir name="Order"><file name="Convertor.php" hash="ca36f9b38c0076bae3afdc368f85b78c"/><file name="Link.php" hash="5cc98489a6a0731f5e683ee2fee554bc"/></dir><file name="Order.php" hash="62b15857d9355c90156001b55b4eec8b"/><file name="Stock.php" hash="57e9582118532677886087f0f9008a1a"/></dir><file name="Product.php" hash="9bfedb2f9d63265a75e2605ff99bdfb9"/><dir name="Resource"><dir name="Config"><dir name="Process"><file name="Collection.php" hash="42d109d303960e32fc95836a6b11ec38"/></dir><file name="Process.php" hash="71ea71353e145f80a536d7e079c65fdb"/></dir><dir name="Log"><file name="Collection.php" hash="c4940516381bcd210cd7dd8822b15ad6"/></dir><file name="Log.php" hash="d7d8b946b42617ed94559d0be7fa100c"/><dir name="Process"><dir name="Inventory"><file name="Collection.php" hash="42e9a5f64d3b5f450ba94cfe283cf671"/></dir><file name="Inventory.php" hash="1b3aba93b3cb925c87ae337603a0f7c2"/><dir name="Order"><file name="Collection.php" hash="6174907ad3a84a68fb03f263bdcce44a"/><dir name="Link"><file name="Collection.php" hash="0673810fc34bad8fd1f6dc683497e79f"/></dir><file name="Link.php" hash="17c836be95cd9319a61da7068568c274"/><dir name="Temp"><file name="Collection.php" hash="fe7cdd58e63e33c66870a8a071f0e4b0"/></dir><file name="Temp.php" hash="d0e17a9524892d9865d34a1db5b2f5f8"/></dir><file name="Order.php" hash="1e981ba08ec546bf2dacd5792e397941"/><dir name="Stock"><file name="Collection.php" hash="dd7122802b16b05ad066f1758032a911"/></dir><file name="Stock.php" hash="233586c4601f25eed908e992a867c49e"/></dir><dir name="Product"><file name="Collection.php" hash="b03d830c57c25938350ea40cbfa08e82"/></dir><file name="Product.php" hash="159b9ceb673f7f32919f994024b50d3b"/></dir><dir name="Shipping"><file name="Dynamic.php" hash="04901409ad298619caf94adcb74cd4cb"/></dir><file name="Soap.php" hash="549be427df581b2c60fe6e16e89a9bd9"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="NetevensyncController.php" hash="00903546aba605178468f320251f5e6b"/></dir></dir><dir name="data"><dir name="netevensync_setup"><file name="data-install-1.0.0.0.php" hash="82c5b8b04d7372e25bfe6938bb6c76bb"/></dir></dir><dir name="docs"><dir name="en"><dir name="images"><file name="available.jpg" hash="7de30b2f713297b91d2b270fb2edb227"/><file name="config_item.jpg" hash="fe2e0a26d8163edb0dea738a578da637"/><file name="console.jpg" hash="6069ba0fc7358c8a747f0d25963add0b"/><file name="console_logged.jpg" hash="befda94fc103ca65365c6777ae3dc60c"/><file name="credentials.jpg" hash="5a9f2d6884712b5d221ca3c92781f731"/><file name="credentials_error.jpg" hash="f1f21f7746655e05983d54918fb233f3"/><file name="credentials_ok.jpg" hash="15c3a3b8cb2edffbe4a0f3961e34e622"/><file name="downloader.jpg" hash="c1971024cb7fdce238ac462d40ed73a6"/><file name="error_dash.jpg" hash="e047149ab50294f9cb22e7e76594f6f6"/><file name="error_manual.jpg" hash="3d73c9cc2cdfcd84a3726f35e31cc066"/><file name="export.jpg" hash="9a3b211f40f3d1f8c1ea7f616c8b5c21"/><file name="extension_key.jpg" hash="9858cc2b11e959c2506cb5e2b2545ac2"/><file name="installed.jpg" hash="8c41ebe50d94f2421fa3c51e561ab6b8"/><file name="inventory_config.jpg" hash="8c22f857458216e84e5a7cc0edff7392"/><file name="inventory_mapping.jpg" hash="f4787ad365c3ffe27fb02122ff5f2c89"/><file name="manual_sync.jpg" hash="e3fde48a9bd84de64063b915720f0e64"/><file name="multistore_inv_neteven.jpg" hash="5255b09529498c366c0cbd96a7d36699"/><file name="multistore_inv_setup.jpg" hash="174151c5fe2c22fa22559f0a8b3d6bca"/><file name="multistore_orders.jpg" hash="64dd459b5c39f43dd1b2ef3e78eea4e0"/><file name="multistore_orders_setup.jpg" hash="fdb87f029e5b004896680234c4465ee2"/><file name="orders.jpg" hash="4662e2f33a9b82a32b9d817b3a5a0623"/><file name="orders_date.jpg" hash="8f8be04e2e973e78550aa655ebc79645"/><file name="orders_mapping1.jpg" hash="c73dd9b3aba3bc7ac7eb9f29df856aed"/><file name="orders_mapping2.jpg" hash="97efc81df38edd02c08ce9939095c6ad"/><file name="product_incremental.jpg" hash="1fb2f82aa2891d12763dd0c0ddce2648"/><file name="shipping.jpg" hash="0634e62149163c24a5eccf6b230457b3"/><file name="stocks.jpg" hash="e06c29148e4e9f57182fc24d0b72407c"/></dir><file name="manual.html" hash="f6da92d45b500ea0e7a8ceade2d29a08"/><file name="manual.md" hash="28d0aa58edbb6207d229267830737478"/></dir><dir name="fr"><dir name="images"><file name="available.jpg" hash="c043142f613e1f0f010251199feb8714"/><file name="config_item.jpg" hash="fe2e0a26d8163edb0dea738a578da637"/><file name="console.jpg" hash="6069ba0fc7358c8a747f0d25963add0b"/><file name="console_logged.jpg" hash="befda94fc103ca65365c6777ae3dc60c"/><file name="credentials.jpg" hash="2de56e58d297a5e689bf9086eff18335"/><file name="credentials_error.jpg" hash="6a927dc2372cc12633782af00ea8640e"/><file name="credentials_ok.jpg" hash="5d94f2d861ff1a63d507d043473f42b2"/><file name="downloader.jpg" hash="c1971024cb7fdce238ac462d40ed73a6"/><file name="error_dash.jpg" hash="a5e1b6a825d30c11f9b8d512d47b52c6"/><file name="error_manual.jpg" hash="3d73c9cc2cdfcd84a3726f35e31cc066"/><file name="export.jpg" hash="5c8343ac88e9c632434c764751489c23"/><file name="extension_key.jpg" hash="9858cc2b11e959c2506cb5e2b2545ac2"/><file name="installed.jpg" hash="8c41ebe50d94f2421fa3c51e561ab6b8"/><file name="inventory_config.jpg" hash="ff0df5b850ee3ade1a2a76d34fd3504d"/><file name="inventory_mapping.jpg" hash="6a7cea4715a4d0d1d7427434c2108630"/><file name="manual_sync.jpg" hash="71d1ae34ef18be474a2453df1a4df066"/><file name="multistore_inv_neteven.jpg" hash="5255b09529498c366c0cbd96a7d36699"/><file name="multistore_inv_setup.jpg" hash="0a8b2788065ccccdfe58f17736c91230"/><file name="multistore_orders.jpg" hash="ff559d0c59c5d223ebd918bc970f1971"/><file name="multistore_orders_setup.jpg" hash="24758ef237e098cb208d711f0d3c5061"/><file name="orders.jpg" hash="073ef7aa1b8ada713967c7b4717c9aae"/><file name="orders_date.jpg" hash="c54762a8246ffac2e22d29fc4848d126"/><file name="orders_mapping1.jpg" hash="b3deaa8568db21fcb2993a2f3b4b6969"/><file name="orders_mapping2.jpg" hash="24b0a7efeabc0d0114ad6740fbf21fcc"/><file name="product_incremental.jpg" hash="d93695b597237f9bae503ed66cf7eaee"/><file name="shipping.jpg" hash="bbe3b5b9bc9a59cb259ab5fd039a9353"/><file name="stocks.jpg" hash="160dc9357d8ad2cf60d87c5cef504864"/></dir><file name="manual.html" hash="5ff58032c0a9614e45bbfbc050730618"/><file name="manual.md" hash="ef180ee4a721e22e3bf2943089fe7f1c"/></dir></dir><dir name="etc"><file name="config.xml" hash="9a0daec66a996d0037ee83a8121e3e68"/><file name="marketplace_country.csv" hash="2b8d52fbd2aecbff07d011a6745b6b86"/><file name="neteven_wsdl.xml" hash="1eedd3dac6101bc789afc7a9d8858d36"/><file name="system.xml" hash="6473fb4becb7f48887c08f206898c16c"/></dir><dir name="sql"><dir name="netevensync_setup"><file name="install-1.0.7.0.php" hash="ba0aae1c9996ea2d49d32ae1cf631574"/><file name="upgrade-1.0.7.0-1.1.0.1.php" hash="f0fb40e49e775d0addd08e419e5c5bb9"/><file name="upgrade-1.1.0.0-1.1.0.1.php" hash="f0fb40e49e775d0addd08e419e5c5bb9"/><file name="upgrade-2.0.0.6-2.1.0.php" hash="c0f63cbab9f533f7305f83cbc1606318"/><file name="upgrade-2.1.0-2.1.1.php" hash="1e471ca091ac92ec589ecc82d1eabdbc"/><file name="upgrade-2.1.1-2.1.3.php" hash="c152a3961add7ee849bf44e765414dd7"/><file name="upgrade-2.1.4-2.1.5.php" hash="2bd384272450b1494ac1560e0d895ada"/><file name="upgrade-2.1.5-2.1.6.php" hash="3e7bdc78e3640a7bd8d947000f5d37b9"/><file name="upgrade-2.2.2-2.2.3.php" hash="75b7705339cc5bc0318f672fe8a79592"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="neteven"><file name="netevensync.js" hash="6c70a244d4e7a8ee2465502f763697a3"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="netevensync.xml" hash="973cd427001a9403414330246c485548"/></dir><dir name="template"><dir name="netevensync"><dir name="js"><file name="alert.phtml" hash="3b4daf844a61a11082a05b4983c7b29c"/></dir><file name="notifications.phtml" hash="879087425eaf3852fe06add6427b5fae"/><dir name="process"><file name="run.phtml" hash="c5f5b94c827c868fffbfcf083f163e6f"/></dir><dir name="product"><dir name="available"><file name="header.phtml" hash="02d0dd0018fff0f64f63b8c5f580c604"/></dir><dir name="exported"><file name="header.phtml" hash="5d36e676617bd6e9f4597e020592919c"/></dir></dir><dir name="system"><dir name="config"><dir name="shipping"><file name="hint.phtml" hash="f2cd02fab533b5c03667a1442961d05e"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Neteven_NetevenSync.xml" hash="bfb3cbff38fb326a925a09262cf80932"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Neteven_NetevenSync.csv" hash="c97b5d0e3610df18e1549229a5b8e6cd"/></dir></target><target name="mage"><dir name="shell"><dir name="neteven"><file name="process.php" hash="670ee81239a7abada4092b096794718a"/></dir></dir></target></contents>
 
63
  <compatible/>
64
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
65
  </package>
shell/neteven/process.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Neteven_NetevenSync for Magento.
4
+ *
5
+ * @license All rights reserved
6
+ * @author Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com> <@jacquesbh>
7
+ * @category Neteven
8
+ * @package Neteven_NetevenSync
9
+ * @copyright Copyright (c) 2015 Neteven (http://www.neteven.com/)
10
+ */
11
+
12
+ require_once __DIR__ . '/../abstract.php';
13
+
14
+ /**
15
+ * Shell script to run processes
16
+ * @package Neteven_NetevenSync
17
+ */
18
+ class Neteven_NetevenSync_Shell_Process extends Mage_Shell_Abstract
19
+ {
20
+ /**
21
+ * Code to run all processes
22
+ * @const string
23
+ */
24
+ const PROCESS_ALL_CODE = "all";
25
+
26
+ /**
27
+ * Run Neteven processes
28
+ */
29
+ public function run()
30
+ {
31
+ try {
32
+ // Get codes
33
+ $codes = $this->_getProcessCodes();
34
+
35
+ foreach ($codes as $code) {
36
+ $this->log("Start… (process code: %s)", $code);
37
+
38
+ // Get process
39
+ $process = Mage::getModel('netevensync/config_process')->loadByProcessCode($code);
40
+ $this->log("Set process as running");
41
+ $process
42
+ ->setIsRunning(true)
43
+ ->save();
44
+
45
+ // Configuration
46
+ $config = Mage::getSingleton('netevensync/config');
47
+
48
+ // Loop on directions
49
+ foreach ($config->getDirs() as $dir) {
50
+ $this->log("Run process (%s direction)", $dir);
51
+
52
+ /* @var $model Neteven_NetevenSync_Model_Process_Abstract */
53
+ $model = Mage::getModel('netevensync/process_' . $code);
54
+
55
+ // Run the process
56
+ try {
57
+ $processSuccess = $model->runProcess(
58
+ Neteven_NetevenSync_Model_Config::NETEVENSYNC_EXPORT_INCREMENTAL,
59
+ null,
60
+ false,
61
+ $dir
62
+ );
63
+
64
+ if ($processSuccess) {
65
+ $this->log("Done");
66
+ } else {
67
+ $this->err("The process seems unfinished without error.");
68
+ }
69
+
70
+ } catch (Exception $e) {
71
+ $this->err($e->getMessage());
72
+ }
73
+ }
74
+
75
+ // Finish process
76
+ $this->log("Set process as not running");
77
+ $process
78
+ ->setIsRunning(false)
79
+ ->save()
80
+ ;
81
+ }
82
+ } catch (Exception $e) {
83
+ $this->err($e->getMessage());
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Get code argument as array
89
+ * @return array
90
+ * @throws Exception If no code specified
91
+ */
92
+ protected function _getProcessCodes()
93
+ {
94
+ switch ($code = $this->getArg('code')) {
95
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE:
96
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_INVENTORY_CODE:
97
+ case Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_STOCK_CODE:
98
+ return array($code);
99
+ case self::PROCESS_ALL_CODE:
100
+ return array(
101
+ Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_ORDER_CODE,
102
+ Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_INVENTORY_CODE,
103
+ Neteven_NetevenSync_Model_Config::NETEVENSYNC_PROCESS_STOCK_CODE,
104
+ );
105
+ default:
106
+ throw new Exception("Please specify a process code.");
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Retrieve Usage Help Message
112
+ */
113
+ public function usageHelp()
114
+ {
115
+ $scriptName = basename(__FILE__);
116
+ return <<<USAGE
117
+ This script runs the Neteven Stock import/export processes.
118
+
119
+ Usage: php -f $scriptName -- [options]
120
+
121
+ help This help
122
+ --code [code] Process code: order, stock, inventory, all.
123
+
124
+ USAGE;
125
+ }
126
+
127
+ /**
128
+ * Log
129
+ * @see sprintf
130
+ */
131
+ public function log()
132
+ {
133
+ fwrite(STDOUT, sprintf("[%s] LOG ", date('c')) . call_user_func_array("sprintf", func_get_args()) . "\n");
134
+ }
135
+
136
+ /**
137
+ * Log Error
138
+ * @see sprintf
139
+ */
140
+ public function err()
141
+ {
142
+ fwrite(STDERR, sprintf("[%s] ERR ", date('c')) . call_user_func_array("sprintf", func_get_args()) . "\n");
143
+ }
144
+
145
+ }
146
+
147
+ $cron = new Neteven_NetevenSync_Shell_Process();
148
+ $cron->run();