Channelpilotsolutions_Channelpilot - Version 2.0.0.0

Version Notes

new plugin for new ChannelPilot release

Download this release

Release Info

Developer Magento Core Team
Extension Channelpilotsolutions_Channelpilot
Version 2.0.0.0
Comparing to
See all releases


Code changes from version 1.0.3 to 2.0.0.0

Files changed (71) hide show
  1. app/code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Articlenumber/Values.php +32 -32
  2. app/code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Cookiemode/Values.php +32 -32
  3. app/{design/frontend/base/default/layout/Channelpilotsolutions/salestracking.xml → code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Pricefield/Values.php} +37 -31
  4. app/{design/frontend/base/default/template/Channelpilotsolutions/clicktracking.phtml → code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Truefalse/Values.php} +33 -24
  5. app/{etc/modules/Channelpilotsolutions_Clicktracking.xml → code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Truefalsesecurity/Values.php} +33 -31
  6. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Exportfields.php +82 -82
  7. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Replacefields.php +89 -89
  8. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Specialfields.php +55 -55
  9. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Trackingkeys.php +68 -68
  10. app/code/community/Channelpilotsolutions/Channelpilot/Helper/CPErrors.php +27 -0
  11. app/code/community/Channelpilotsolutions/Channelpilot/Helper/Data.php +239 -58
  12. app/code/community/Channelpilotsolutions/Channelpilot/Helper/ExportData.php +619 -658
  13. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/CPResultCodes.php +26 -0
  14. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/ChannelPilotSellerAPI_v1_0.php +185 -0
  15. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/GetManagedArticlePricesResponse.php +16 -0
  16. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/GetNewMarketplaceOrdersResponse.php +22 -0
  17. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/GetServerTimeResponse.php +14 -0
  18. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/Response.php +14 -0
  19. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/UpdateArticleResult.php +13 -0
  20. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/UpdateArticlesResponse.php +13 -0
  21. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/UpdateOrderResult.php +13 -0
  22. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/UpdateOrdersResponse.php +12 -0
  23. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPAddress.php +30 -0
  24. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPArticle.php +9 -0
  25. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPArticleUpdate.php +49 -0
  26. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPAuth.php +24 -0
  27. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPCancellation.php +21 -0
  28. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPCustomer.php +22 -0
  29. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPDelivery.php +54 -0
  30. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPDiscount.php +9 -0
  31. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPManagedArticlePrice.php +14 -0
  32. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPMoney.php +8 -0
  33. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrder.php +24 -0
  34. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrderHeader.php +26 -0
  35. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrderItem.php +20 -0
  36. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrderStatus.php +58 -0
  37. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrderSummary.php +14 -0
  38. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPPayment.php +10 -0
  39. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPResponseHeader.php +20 -0
  40. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPShipping.php +9 -0
  41. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPAbstractHandler.php +197 -0
  42. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPCancellationHandler.php +142 -0
  43. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPDebugHandler.php +50 -0
  44. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPDeliveryHandler.php +93 -0
  45. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPErrorHandler.php +28 -0
  46. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPExportHandler.php +650 -0
  47. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPNewPriceHandler.php +132 -0
  48. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPNewsHandler.php +39 -0
  49. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPOrderHandler.php +476 -0
  50. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPRegisterHandler.php +124 -0
  51. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPStatusHandler.php +161 -0
  52. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/todoCPPaymentHandler.php +12 -0
  53. app/code/community/Channelpilotsolutions/Channelpilot/Helper/responses/CPGetStatusHookResponse.php +11 -0
  54. app/code/community/Channelpilotsolutions/Channelpilot/Helper/responses/CPHookResponse.php +65 -0
  55. app/code/community/Channelpilotsolutions/Channelpilot/Helper/responses/CPRegisterHookResponse.php +14 -0
  56. app/code/community/Channelpilotsolutions/Channelpilot/Helper/special/CustomerFunctions.php +24 -0
  57. app/code/community/Channelpilotsolutions/Channelpilot/controllers/IndexController.php +36 -32
  58. app/code/community/Channelpilotsolutions/Channelpilot/etc/adminhtml.xml +19 -3
  59. app/code/community/Channelpilotsolutions/Channelpilot/etc/config.xml +66 -33
  60. app/code/community/Channelpilotsolutions/Channelpilot/etc/system.xml +204 -26
  61. app/code/community/Channelpilotsolutions/Channelpilot/sql/channelpilot_setup/install-2.0.0.0.php +206 -0
  62. app/code/community/Channelpilotsolutions/Clicktracking/etc/config.xml +0 -39
  63. app/code/community/Channelpilotsolutions/Salestracking/etc/config.xml +0 -39
  64. app/design/frontend/base/default/layout/Channelpilotsolutions/{clicktracking.xml → channelpilot.xml} +2 -2
  65. app/design/frontend/base/default/template/Channelpilotsolutions/channelpilot.phtml +118 -0
  66. app/design/frontend/base/default/template/Channelpilotsolutions/salestracking.phtml +0 -109
  67. app/etc/modules/Channelpilotsolutions_Salestracking.xml +0 -31
  68. app/locale/de_AT/Channelpilotsolutions_Channelpilot.csv +21 -14
  69. app/locale/de_CH/Channelpilotsolutions_Channelpilot.csv +21 -14
  70. app/locale/de_DE/Channelpilotsolutions_Channelpilot.csv +22 -16
  71. package.xml +23 -18
app/code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Articlenumber/Values.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Channelpilot
17
- * @subpackage adminhtml_model_cookiemode
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- class Channelpilotsolutions_Channelpilot_Adminhtml_Model_Articlenumber_Values
24
- {
25
- public function toOptionArray()
26
- {
27
- return array(
28
- array('value' => 'product_id', 'label'=>'Entity ID'),
29
- array('value' => 'sku', 'label'=>'Sku')
30
- );
31
- }
32
- }
33
  ?>
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
+ * needs please refer to http://www.channelpilot.com for more information.
14
+ *
15
+ * @category Channelpilotsolutions
16
+ * @package Channelpilotsolutions_Channelpilot
17
+ * @subpackage adminhtml_model_cookiemode
18
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Peter Hoffmann <info@channelpilot.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.channelpilot.com
22
+ */
23
+ class Channelpilotsolutions_Channelpilot_Adminhtml_Model_Articlenumber_Values
24
+ {
25
+ public function toOptionArray()
26
+ {
27
+ return array(
28
+ array('value' => 'product_id', 'label'=>'Entity ID'),
29
+ array('value' => 'sku', 'label'=>'Sku')
30
+ );
31
+ }
32
+ }
33
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Cookiemode/Values.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Channelpilot
17
- * @subpackage adminhtml_model_cookiemode
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- class Channelpilotsolutions_Channelpilot_Adminhtml_Model_Cookiemode_Values
24
- {
25
- public function toOptionArray()
26
- {
27
- return array(
28
- array('value' => 'last', 'label'=>'Last Cookie Wins'),
29
- array('value' => 'first', 'label'=>'First Cookie Wins')
30
- );
31
- }
32
- }
33
  ?>
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
+ * needs please refer to http://www.channelpilot.com for more information.
14
+ *
15
+ * @category Channelpilotsolutions
16
+ * @package Channelpilotsolutions_Channelpilot
17
+ * @subpackage adminhtml_model_cookiemode
18
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Peter Hoffmann <info@channelpilot.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.channelpilot.com
22
+ */
23
+ class Channelpilotsolutions_Channelpilot_Adminhtml_Model_Cookiemode_Values
24
+ {
25
+ public function toOptionArray()
26
+ {
27
+ return array(
28
+ array('value' => 'last', 'label'=>'Last Cookie Wins'),
29
+ array('value' => 'first', 'label'=>'First Cookie Wins')
30
+ );
31
+ }
32
+ }
33
  ?>
app/{design/frontend/base/default/layout/Channelpilotsolutions/salestracking.xml → code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Pricefield/Values.php} RENAMED
@@ -1,31 +1,37 @@
1
- <?xml version="1.0"?><!--
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Salestracking to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Salestracking for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package design_frontend_base_default
17
- * @subpackage layout_Channelpilotsolutions
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- -->
24
- <layout version="0.1.0">
25
- <default>
26
- <reference name="head">
27
- <block type="core/template" name="salestracking" template="Channelpilotsolutions/salestracking.phtml" after="-">
28
- </block>
29
- </reference>
30
- </default>
31
- </layout>
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the GNU General Public License (GPL 3)
8
+ * that is bundled with this package in the file LICENSE.txt
9
+ *
10
+ * DISCLAIMER
11
+ *
12
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
13
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
14
+ * needs please refer to http://www.channelpilot.com for more information.
15
+ *
16
+ * @category Channelpilotsolutions
17
+ * @package Channelpilotsolutions_Channelpilot
18
+ * @subpackage adminhtml_model_truefalse
19
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
20
+ * @author Peter Hoffmann <info@channelpilot.com>
21
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
22
+ * @link http://www.channelpilot.com
23
+ */
24
+ class Channelpilotsolutions_Channelpilot_Adminhtml_Model_Pricefield_Values {
25
+
26
+ public function toOptionArray() {
27
+ return array(
28
+ array('value' => 'price', 'label' => 'Price')
29
+ // ,
30
+ // array('value' => 'special_price', 'label' => 'Special_Price'),
31
+ // array('value' => 'minimal_price', 'label' => 'Minimal_Price')
32
+ );
33
+ }
34
+
35
+ }
36
+
37
+ ?>
app/{design/frontend/base/default/template/Channelpilotsolutions/clicktracking.phtml → code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Truefalse/Values.php} RENAMED
@@ -1,24 +1,33 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Clicktracking to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Clicktracking for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package design_frontend_base_default
17
- * @subpackage template_Channelpilotsolutions
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- ?>
24
- <script type="text/javascript" src="//content.cptrack.de/clicks.js"></script>
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
+ * needs please refer to http://www.channelpilot.com for more information.
14
+ *
15
+ * @category Channelpilotsolutions
16
+ * @package Channelpilotsolutions_Channelpilot
17
+ * @subpackage adminhtml_model_cookiemode
18
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Peter Hoffmann <info@channelpilot.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.channelpilot.com
22
+ */
23
+ class Channelpilotsolutions_Channelpilot_Adminhtml_Model_Truefalse_Values
24
+ {
25
+ public function toOptionArray()
26
+ {
27
+ return array(
28
+ array('value' => 'false', 'label'=>'No'),
29
+ array('value' => 'true', 'label'=>'Yes')
30
+ );
31
+ }
32
+ }
33
+ ?>
app/{etc/modules/Channelpilotsolutions_Clicktracking.xml → code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Truefalsesecurity/Values.php} RENAMED
@@ -1,31 +1,33 @@
1
- <?xml version="1.0" encoding="UTF-8"?><!--
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Clicktracking to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Clicktracking for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package etc
17
- * @subpackage
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- -->
24
- <config>
25
- <modules>
26
- <Channelpilotsolutions_Clicktracking>
27
- <active>true</active>
28
- <codePool>community</codePool>
29
- </Channelpilotsolutions_Clicktracking>
30
- </modules>
31
- </config>
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
+ * needs please refer to http://www.channelpilot.com for more information.
14
+ *
15
+ * @category Channelpilotsolutions
16
+ * @package Channelpilotsolutions_Channelpilot
17
+ * @subpackage adminhtml_model_truefalse
18
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Peter Hoffmann <info@channelpilot.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.channelpilot.com
22
+ */
23
+ class Channelpilotsolutions_Channelpilot_Adminhtml_Model_Truefalsesecurity_Values
24
+ {
25
+ public function toOptionArray()
26
+ {
27
+ return array(
28
+ array('value' => 'true', 'label'=>'Yes'),
29
+ array('value' => 'false', 'label'=>'No')
30
+ );
31
+ }
32
+ }
33
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Exportfields.php CHANGED
@@ -1,83 +1,83 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Channelpilot
17
- * @subpackage block_adminhtml_field
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Exportfields
24
- extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
25
- {
26
-
27
- private $_standardattributes;
28
-
29
- public function __construct()
30
- {
31
- $this->addColumn('productattribute', array(
32
- 'label' => Mage::helper('adminhtml')->__('Data field'),
33
- 'size' => 30
34
- ));
35
- $this->_addAfter = false;
36
-
37
- parent::__construct();
38
- $this->setTemplate('Channelpilotsolutions/array_dropdown.phtml');
39
- }
40
-
41
- protected function _renderCellTemplate($columnName)
42
- {
43
- $this->_standardattributes = "('sku','price','name','description','manufacturer','color','weight')";
44
- if (empty($this->_columns[$columnName])) {
45
- throw new Exception('Wrong column name specified.');
46
- }
47
- $column = $this->_columns[$columnName];
48
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
49
-
50
- if($columnName == 'productattribute')
51
- {
52
- $rendered = '<select name="'.$inputName.'">';
53
-
54
- $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
55
- $tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
56
- $dbConnection = Mage::getSingleton('core/resource') ->getConnection('core_read');
57
-
58
- // Get attribute codes and types
59
- $query = "SELECT attribute_code
60
- FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
61
- WHERE entity_type_id = (SELECT entity_type_id FROM
62
- ChannelPilotSolutions_ChannelPilot_eav_entity_type WHERE entity_type_code = 'catalog_product') AND
63
- attribute_code NOT IN $this->_standardattributes
64
- ";
65
- $query = str_replace('ChannelPilotSolutions_ChannelPilot_', $tablePrefix, $query);
66
- $attributes = $dbConnection->FetchAssoc($query);
67
-
68
- $attributes[]['attribute_code'] = 'qty';
69
- $attributes[]['attribute_code'] = 'stock_status';
70
- $attributes[]['attribute_code'] = 'cp_color_attribute_id';
71
- $attributes[]['attribute_code'] = 'parent_id';
72
- asort($attributes);
73
- foreach ($attributes as $attribute) {
74
- $rendered .= '<option value="'.$attribute['attribute_code'].'">'.$attribute['attribute_code'].'</option>';
75
- }
76
- $rendered .= '</select>';
77
- return $rendered;
78
- }
79
-
80
- return '<input type="text" name="'.$inputName.'" value="#{' . $columnName . '}"/>';
81
- }
82
- }
83
  ?>
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
+ * needs please refer to http://www.channelpilot.com for more information.
14
+ *
15
+ * @category Channelpilotsolutions
16
+ * @package Channelpilotsolutions_Channelpilot
17
+ * @subpackage block_adminhtml_field
18
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Peter Hoffmann <info@channelpilot.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.channelpilot.com
22
+ */
23
+ class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Exportfields
24
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
25
+ {
26
+
27
+ private $_standardattributes;
28
+
29
+ public function __construct()
30
+ {
31
+ $this->addColumn('productattribute', array(
32
+ 'label' => Mage::helper('adminhtml')->__('Data field'),
33
+ 'size' => 30
34
+ ));
35
+ $this->_addAfter = false;
36
+
37
+ parent::__construct();
38
+ $this->setTemplate('Channelpilotsolutions/array_dropdown.phtml');
39
+ }
40
+
41
+ protected function _renderCellTemplate($columnName)
42
+ {
43
+ $this->_standardattributes = "('sku','price','name','description','manufacturer','color','weight')";
44
+ if (empty($this->_columns[$columnName])) {
45
+ throw new Exception('Wrong column name specified.');
46
+ }
47
+ $column = $this->_columns[$columnName];
48
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
49
+
50
+ if($columnName == 'productattribute')
51
+ {
52
+ $rendered = '<select name="'.$inputName.'">';
53
+
54
+ $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
55
+ $tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
56
+ $dbConnection = Mage::getSingleton('core/resource') ->getConnection('core_read');
57
+
58
+ // Get attribute codes and types
59
+ $query = "SELECT attribute_code
60
+ FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
61
+ WHERE entity_type_id = (SELECT entity_type_id FROM
62
+ ChannelPilotSolutions_ChannelPilot_eav_entity_type WHERE entity_type_code = 'catalog_product') AND
63
+ attribute_code NOT IN $this->_standardattributes
64
+ ";
65
+ $query = str_replace('ChannelPilotSolutions_ChannelPilot_', $tablePrefix, $query);
66
+ $attributes = $dbConnection->FetchAssoc($query);
67
+
68
+ $attributes[]['attribute_code'] = 'qty';
69
+ $attributes[]['attribute_code'] = 'stock_status';
70
+ $attributes[]['attribute_code'] = 'cp_color_attribute_id';
71
+ $attributes[]['attribute_code'] = 'parent_id';
72
+ asort($attributes);
73
+ foreach ($attributes as $attribute) {
74
+ $rendered .= '<option value="'.$attribute['attribute_code'].'">'.$attribute['attribute_code'].'</option>';
75
+ }
76
+ $rendered .= '</select>';
77
+ return $rendered;
78
+ }
79
+
80
+ return '<input type="text" name="'.$inputName.'" value="#{' . $columnName . '}"/>';
81
+ }
82
+ }
83
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Replacefields.php CHANGED
@@ -1,90 +1,90 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Channelpilot
17
- * @subpackage block_adminhtml_field
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Replacefields
24
- extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
25
- {
26
-
27
- private $_standardattributes;
28
-
29
- public function __construct()
30
- {
31
- $this->addColumn('productattribute', array(
32
- 'label' => Mage::helper('adminhtml')->__('Data field'),
33
- 'size' => 30
34
- ));
35
- $this->_addAfter = false;
36
-
37
- parent::__construct();
38
- $this->setTemplate('Channelpilotsolutions/array_dropdown.phtml');
39
- }
40
-
41
- protected function _renderCellTemplate($columnName)
42
- {
43
- $this->_standardattributes = "('sku','price','name','description','manufacturer','color','weight')";
44
- if (empty($this->_columns[$columnName])) {
45
- throw new Exception('Wrong column name specified.');
46
- }
47
- $column = $this->_columns[$columnName];
48
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
49
-
50
- if($columnName == 'productattribute')
51
- {
52
- $rendered = '<select name="'.$inputName.'">';
53
-
54
- $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
55
- $tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
56
- $dbConnection = Mage::getSingleton('core/resource') ->getConnection('core_read');
57
-
58
- // Get attribute codes and types
59
- $query = "SELECT attribute_code
60
- FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
61
- WHERE entity_type_id = (SELECT entity_type_id FROM
62
- ChannelPilotSolutions_ChannelPilot_eav_entity_type WHERE entity_type_code = 'catalog_product') AND
63
- attribute_code NOT IN $this->_standardattributes
64
- ";
65
- $query = str_replace('ChannelPilotSolutions_ChannelPilot_', $tablePrefix, $query);
66
- $attributes = $dbConnection->FetchAssoc($query);
67
-
68
- $attributes[]['attribute_code'] = 'qty';
69
- $attributes[]['attribute_code'] = 'stock_status';
70
- $attributes[]['attribute_code'] = 'cp_color_attribute_id';
71
- $attributes[]['attribute_code'] = 'parent_id';
72
-
73
- $attributes[]['attribute_code'] = 'categories';
74
- $attributes[]['attribute_code'] = 'cp_image_url';
75
- $attributes[]['attribute_code'] = 'cp_product_url';
76
- $attributes[]['attribute_code'] = 'cp_additional_image_1';
77
- $attributes[]['attribute_code'] = 'cp_additional_image_2';
78
- $attributes[]['attribute_code'] = 'cp_additional_image_3';
79
- asort($attributes);
80
- foreach ($attributes as $attribute) {
81
- $rendered .= '<option value="'.$attribute['attribute_code'].'">'.$attribute['attribute_code'].'</option>';
82
- }
83
- $rendered .= '</select>';
84
- return $rendered;
85
- }
86
-
87
- return '<input type="text" name="'.$inputName.'" value="#{' . $columnName . '}"/>';
88
- }
89
- }
90
  ?>
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
+ * needs please refer to http://www.channelpilot.com for more information.
14
+ *
15
+ * @category Channelpilotsolutions
16
+ * @package Channelpilotsolutions_Channelpilot
17
+ * @subpackage block_adminhtml_field
18
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Peter Hoffmann <info@channelpilot.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.channelpilot.com
22
+ */
23
+ class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Replacefields
24
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
25
+ {
26
+
27
+ private $_standardattributes;
28
+
29
+ public function __construct()
30
+ {
31
+ $this->addColumn('productattribute', array(
32
+ 'label' => Mage::helper('adminhtml')->__('Data field'),
33
+ 'size' => 30
34
+ ));
35
+ $this->_addAfter = false;
36
+
37
+ parent::__construct();
38
+ $this->setTemplate('Channelpilotsolutions/array_dropdown.phtml');
39
+ }
40
+
41
+ protected function _renderCellTemplate($columnName)
42
+ {
43
+ $this->_standardattributes = "('sku','price','name','description','manufacturer','color','weight')";
44
+ if (empty($this->_columns[$columnName])) {
45
+ throw new Exception('Wrong column name specified.');
46
+ }
47
+ $column = $this->_columns[$columnName];
48
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
49
+
50
+ if($columnName == 'productattribute')
51
+ {
52
+ $rendered = '<select name="'.$inputName.'">';
53
+
54
+ $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
55
+ $tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
56
+ $dbConnection = Mage::getSingleton('core/resource') ->getConnection('core_read');
57
+
58
+ // Get attribute codes and types
59
+ $query = "SELECT attribute_code
60
+ FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
61
+ WHERE entity_type_id = (SELECT entity_type_id FROM
62
+ ChannelPilotSolutions_ChannelPilot_eav_entity_type WHERE entity_type_code = 'catalog_product') AND
63
+ attribute_code NOT IN $this->_standardattributes
64
+ ";
65
+ $query = str_replace('ChannelPilotSolutions_ChannelPilot_', $tablePrefix, $query);
66
+ $attributes = $dbConnection->FetchAssoc($query);
67
+
68
+ $attributes[]['attribute_code'] = 'qty';
69
+ $attributes[]['attribute_code'] = 'stock_status';
70
+ $attributes[]['attribute_code'] = 'cp_color_attribute_id';
71
+ $attributes[]['attribute_code'] = 'parent_id';
72
+
73
+ $attributes[]['attribute_code'] = 'categories';
74
+ $attributes[]['attribute_code'] = 'cp_image_url';
75
+ $attributes[]['attribute_code'] = 'cp_product_url';
76
+ $attributes[]['attribute_code'] = 'cp_additional_image_1';
77
+ $attributes[]['attribute_code'] = 'cp_additional_image_2';
78
+ $attributes[]['attribute_code'] = 'cp_additional_image_3';
79
+ asort($attributes);
80
+ foreach ($attributes as $attribute) {
81
+ $rendered .= '<option value="'.$attribute['attribute_code'].'">'.$attribute['attribute_code'].'</option>';
82
+ }
83
+ $rendered .= '</select>';
84
+ return $rendered;
85
+ }
86
+
87
+ return '<input type="text" name="'.$inputName.'" value="#{' . $columnName . '}"/>';
88
+ }
89
+ }
90
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Specialfields.php CHANGED
@@ -1,56 +1,56 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Channelpilot
17
- * @subpackage block_adminhtml_field
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Specialfields
24
- extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
25
- {
26
- protected $magentoAttributes;
27
-
28
- public function __construct()
29
- {
30
- $this->addColumn('name', array(
31
- 'label' => Mage::helper('adminhtml')->__('Data field name'),
32
- 'size' => 30
33
- ));
34
- $this->addColumn('value', array(
35
- 'label' => Mage::helper('adminhtml')->__('Data field value'),
36
- 'size' => 30
37
- ));
38
- $this->_addAfter = false;
39
-
40
- parent::__construct();
41
- $this->setTemplate('Channelpilotsolutions/array_dropdown.phtml');
42
- }
43
-
44
- protected function _renderCellTemplate($columnName)
45
- {
46
- if (empty($this->_columns[$columnName])) {
47
- throw new Exception('Wrong column name specified.');
48
- }
49
- $column = $this->_columns[$columnName];
50
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
51
-
52
-
53
- return '<input type="text" name="'.$inputName.'" value="#{' . $columnName . '}"/>';
54
- }
55
- }
56
  ?>
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
+ * needs please refer to http://www.channelpilot.com for more information.
14
+ *
15
+ * @category Channelpilotsolutions
16
+ * @package Channelpilotsolutions_Channelpilot
17
+ * @subpackage block_adminhtml_field
18
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Peter Hoffmann <info@channelpilot.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.channelpilot.com
22
+ */
23
+ class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Specialfields
24
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
25
+ {
26
+ protected $magentoAttributes;
27
+
28
+ public function __construct()
29
+ {
30
+ $this->addColumn('name', array(
31
+ 'label' => Mage::helper('adminhtml')->__('Data field name'),
32
+ 'size' => 30
33
+ ));
34
+ $this->addColumn('value', array(
35
+ 'label' => Mage::helper('adminhtml')->__('Data field value'),
36
+ 'size' => 30
37
+ ));
38
+ $this->_addAfter = false;
39
+
40
+ parent::__construct();
41
+ $this->setTemplate('Channelpilotsolutions/array_dropdown.phtml');
42
+ }
43
+
44
+ protected function _renderCellTemplate($columnName)
45
+ {
46
+ if (empty($this->_columns[$columnName])) {
47
+ throw new Exception('Wrong column name specified.');
48
+ }
49
+ $column = $this->_columns[$columnName];
50
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
51
+
52
+
53
+ return '<input type="text" name="'.$inputName.'" value="#{' . $columnName . '}"/>';
54
+ }
55
+ }
56
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Trackingkeys.php CHANGED
@@ -1,69 +1,69 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Channelpilot
17
- * @subpackage block_adminhtml_field
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Trackingkeys
24
- extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
25
- {
26
- protected $magentoAttributes;
27
-
28
- public function __construct()
29
- {
30
- $this->addColumn('shop', array(
31
- 'label' => Mage::helper('adminhtml')->__('Shop'),
32
- 'size' => 15
33
- ));
34
- $this->addColumn('trackingkey', array(
35
- 'label' => Mage::helper('adminhtml')->__('TrackingKey'),
36
- 'size' => 28
37
- ));
38
- $this->_addAfter = false;
39
-
40
- parent::__construct();
41
- $this->setTemplate('Channelpilotsolutions/array_dropdown.phtml');
42
- }
43
-
44
- protected function _renderCellTemplate($columnName)
45
- {
46
- if (empty($this->_columns[$columnName])) {
47
- throw new Exception('Wrong column name specified.');
48
- }
49
- $column = $this->_columns[$columnName];
50
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
51
-
52
- if($columnName == 'shop')
53
- {
54
- $rendered = '<select name="'.$inputName.'">';
55
- foreach (Mage::app()->getWebsites() as $website) {
56
- foreach ($website->getGroups() as $group) {
57
- $stores = $group->getStores();
58
- foreach ($stores as $store) {
59
- $rendered .= '<option value="'.$store->getId().'">'.$store->getName().'</option>';
60
- }
61
- }
62
- }
63
- $rendered .= '</select>';
64
- return $rendered;
65
- }
66
- return '<input type="text" name="'.$inputName.'" value="#{' . $columnName . '}"/>';
67
- }
68
- }
69
  ?>
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
+ * needs please refer to http://www.channelpilot.com for more information.
14
+ *
15
+ * @category Channelpilotsolutions
16
+ * @package Channelpilotsolutions_Channelpilot
17
+ * @subpackage block_adminhtml_field
18
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Peter Hoffmann <info@channelpilot.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.channelpilot.com
22
+ */
23
+ class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Trackingkeys
24
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
25
+ {
26
+ protected $magentoAttributes;
27
+
28
+ public function __construct()
29
+ {
30
+ $this->addColumn('shop', array(
31
+ 'label' => Mage::helper('adminhtml')->__('Shop'),
32
+ 'size' => 15
33
+ ));
34
+ $this->addColumn('trackingkey', array(
35
+ 'label' => Mage::helper('adminhtml')->__('TrackingKey'),
36
+ 'size' => 28
37
+ ));
38
+ $this->_addAfter = false;
39
+
40
+ parent::__construct();
41
+ $this->setTemplate('Channelpilotsolutions/array_dropdown.phtml');
42
+ }
43
+
44
+ protected function _renderCellTemplate($columnName)
45
+ {
46
+ if (empty($this->_columns[$columnName])) {
47
+ throw new Exception('Wrong column name specified.');
48
+ }
49
+ $column = $this->_columns[$columnName];
50
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
51
+
52
+ if($columnName == 'shop')
53
+ {
54
+ $rendered = '<select name="'.$inputName.'">';
55
+ foreach (Mage::app()->getWebsites() as $website) {
56
+ foreach ($website->getGroups() as $group) {
57
+ $stores = $group->getStores();
58
+ foreach ($stores as $store) {
59
+ $rendered .= '<option value="'.$store->getId().'">'.$store->getName().'</option>';
60
+ }
61
+ }
62
+ }
63
+ $rendered .= '</select>';
64
+ return $rendered;
65
+ }
66
+ return '<input type="text" name="'.$inputName.'" value="#{' . $columnName . '}"/>';
67
+ }
68
+ }
69
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/CPErrors.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * CPResultCodes. Collection of possible errors for a request.
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPErrors {
9
+ // register
10
+ const RESULT_SHOP_UNKNOWN = 600;
11
+ const RESULT_MISSING_PARAMS = 601;
12
+ const RESULT_ALREADY_REGISTERED = 602;
13
+
14
+ // order
15
+ const RESULT_NUMBER_COLUMN_UNKNOWN = 750;
16
+
17
+ // common
18
+ const RESULT_OK = 200;
19
+ const RESULT_SIGNATURE_MISMATCH = 400;
20
+ const RESULT_FAILED = 900;
21
+ const RESULT_TIMEOUT = 901;
22
+ const RESULT_CONFIG_INVALID = 902;
23
+ const RESULT_API_DEACTIVATED = 903;
24
+
25
+ }
26
+
27
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/Data.php CHANGED
@@ -1,59 +1,240 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Channelpilot
17
- * @subpackage helper
18
- * @copyright Copyright (c) 2013 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- class Channelpilotsolutions_Channelpilot_Helper_Data extends Mage_Core_Helper_Abstract
24
- {
25
- private $xml;
26
-
27
- public function __construct($root='root'){
28
- //$this->xml = new SimpleXMLElement("<$root></$root>");
29
- }
30
-
31
- public function checkPassword() {
32
- $password='';
33
-
34
- $password = Mage::getStoreConfig('channelpilot_section/channelpilot_productfeed/channelpilot_password');
35
-
36
- if($password==''){
37
- return true;
38
- }
39
- if(isset($_GET['password']) AND $_GET['password']==$password){
40
- return true;
41
- }
42
- return false;
43
- }
44
-
45
- public function createXml(){
46
- header('Content-Type: text/xml; charset=utf-8');
47
- include 'ExportData.php';
48
- $exporter = new ExportData();
49
- echo('<?xml version="1.0"?>');
50
- echo("<root>");
51
- echo("<catalog>");
52
- $exporter->_runMain();
53
- echo("</catalog>");
54
- echo("</root>");
55
- exit();
56
- return;
57
- }
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  ?>
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the GNU General Public License (GPL 3)
8
+ * that is bundled with this package in the file LICENSE.txt
9
+ *
10
+ * DISCLAIMER
11
+ *
12
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
13
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
14
+ * needs please refer to http://www.channelpilot.com for more information.
15
+ *
16
+ * @category Channelpilotsolutions
17
+ * @package Channelpilotsolutions_Channelpilot
18
+ * @subpackage helper
19
+ * @copyright Copyright (c) 2013 <info@channelpilot.com> - www.channelpilot.com
20
+ * @author Peter Hoffmann <info@channelpilot.com>
21
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
22
+ * @link http://www.channelpilot.com
23
+ */
24
+ require_once 'CPErrors.php';
25
+
26
+ // Handler
27
+ require_once 'handler/CPAbstractHandler.php';
28
+ require_once 'handler/CPErrorHandler.php';
29
+ require_once 'handler/CPExportHandler.php';
30
+ require_once 'handler/CPStatusHandler.php';
31
+ require_once 'handler/CPRegisterHandler.php';
32
+ require_once 'handler/CPNewPriceHandler.php';
33
+ require_once 'handler/CPOrderHandler.php';
34
+ require_once 'handler/CPDeliveryHandler.php';
35
+ require_once 'handler/CPCancellationHandler.php';
36
+ require_once 'handler/CPNewsHandler.php';
37
+ require_once 'handler/CPDebugHandler.php';
38
+
39
+ // RESPONSES
40
+ require_once 'responses/CPHookResponse.php';
41
+ require_once 'responses/CPGetStatusHookResponse.php';
42
+ require_once 'responses/CPRegisterHookResponse.php';
43
+
44
+ // API
45
+ require_once 'api/1_0/thin/CPDelivery.php';
46
+ require_once 'api/1_0/ChannelPilotSellerAPI_v1_0.php';
47
+ require_once 'api/1_0/CPResultCodes.php';
48
+
49
+ // special customer functions
50
+ require_once 'special/CustomerFunctions.php';
51
+
52
+ class Channelpilotsolutions_Channelpilot_Helper_Data extends Mage_Core_Helper_Abstract {
53
+
54
+ const GET_REGISTER = "register";
55
+ const GET_EXPORT = "export";
56
+ const GET_STATUS = "status";
57
+ const GET_IMPORT_ORDERS = "orders";
58
+ const GET_DELIVERED = "deliveries";
59
+ const GET_CANCELLATION = "cancellations";
60
+ const GET_NEWS = "news";
61
+ const GET_NEWPRICES = "prices";
62
+ const GET_DEBUG = "debug";
63
+
64
+ public function __construct($root = 'root') {
65
+
66
+ }
67
+
68
+ public function createXml() {
69
+ if (strcmp(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport'), "true") === 0) {
70
+ $password = Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_password');
71
+ if ($password == '' || (isset($_GET['password']) AND $_GET['password'] == $password)) {
72
+ header('Content-Type: text/xml; charset=utf-8');
73
+ include 'ExportData.php';
74
+ $exporter = new ExportData();
75
+ echo('<?xml version="1.0"?>');
76
+ echo("<root>");
77
+ echo("<catalog>");
78
+ $exporter->_runMain();
79
+ echo("</catalog>");
80
+ echo("</root>");
81
+ exit();
82
+ return;
83
+ }
84
+ }
85
+ return;
86
+ }
87
+
88
+ // API CONNECTOR
89
+ public function api() {
90
+ $hook = null;
91
+ if ($this->checkIp() === false) {
92
+ return;
93
+ }
94
+
95
+ $newsActive = false;
96
+ if (strcmp(Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_useNews'), "true") === 0) {
97
+ $newsActive = true;
98
+ }
99
+ $marketplaceActive = false;
100
+ if (strcmp(Mage::getStoreConfig('channelpilot_marketplace/channelpilot_marketplace/channelpilot_useMarketplaces'), "true") === 0) {
101
+ $marketplaceActive = true;
102
+ }
103
+ $pricecontrolActive = false;
104
+ if (strcmp(Mage::getStoreConfig('channelpilot_pricecontrol/general/channelpilot_usePricecontrol'), "true") === 0) {
105
+ $pricecontrolActive = true;
106
+ }
107
+ $exportActive = false;
108
+ if (strcmp(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport'), "true") === 0) {
109
+ $exportActive = true;
110
+ }
111
+
112
+
113
+ switch ($_GET['method']) {
114
+ // Send method
115
+ case self::GET_STATUS:
116
+ $this->checkActivation(array($marketplaceActive, $pricecontrolActive), 'marketplace OR pricecontrol');
117
+ $handler = new CPStatusHandler();
118
+ $hook = $handler->handle();
119
+ break;
120
+
121
+ // Send method + merchantid + multishopid + token + ips
122
+ case self::GET_REGISTER:
123
+ $this->checkActivation(array($marketplaceActive, $pricecontrolActive), 'marketplace OR pricecontrol');
124
+ $this->checkSignature();
125
+ $handler = new CPRegisterHandler();
126
+ $hook = $handler->handle();
127
+ break;
128
+
129
+ // Send Method + token
130
+ case self::GET_IMPORT_ORDERS:
131
+ $this->checkActivation(array($marketplaceActive), 'marketplace');
132
+ $this->checkSignature();
133
+ $handler = new CPOrderHandler();
134
+ $hook = $handler->handle();
135
+ break;
136
+ // Send Method + token
137
+ case self::GET_DELIVERED:
138
+ $this->checkActivation(array($marketplaceActive), 'marketplace');
139
+ $this->checkSignature();
140
+ $handler = new CPDeliveryHandler();
141
+ $hook = $handler->handle();
142
+ break;
143
+
144
+ // Send Method + token
145
+ case self::GET_CANCELLATION:
146
+ $this->checkActivation(array($marketplaceActive), 'marketplace');
147
+ $this->checkSignature();
148
+ $handler = new CPCancellationHandler();
149
+ $hook = $handler->handle();
150
+ break;
151
+
152
+ // Send method
153
+ case self::GET_NEWS:
154
+ $this->checkActivation(array($newsActive), 'news');
155
+ $this->checkSignature();
156
+ $handler = new CPNewsHandler();
157
+ $hook = $handler->handle();
158
+ break;
159
+
160
+ // Send method + token + priceId
161
+ case self::GET_NEWPRICES:
162
+ $this->checkActivation(array($pricecontrolActive), 'pricecontrol');
163
+ // $this->checkSignature();
164
+ $handler = new CPNewPriceHandler();
165
+ $hook = $handler->handle();
166
+ break;
167
+
168
+ // Send method + limit + shopId ( + last)
169
+ case self::GET_EXPORT:
170
+ $this->checkActivation(array($exportActive), 'export');
171
+ // $this->checkSignature();
172
+ $handler = new CPExportHandler();
173
+ $hook = $handler->handle();
174
+ break;
175
+
176
+ // Send method + limit + shopId ( + last)
177
+ case self::GET_DEBUG:
178
+ $this->checkSignature();
179
+ $handler = new CPDebugHandler();
180
+ $hook = $handler->handle();
181
+ break;
182
+
183
+ default:
184
+ $hook = "not supported method: " . $_GET['method'];
185
+ break;
186
+ }
187
+ header("Content-Type: application/json;");
188
+ print_r(json_encode($hook));
189
+ exit();
190
+ }
191
+
192
+ private function checkSignature() {
193
+ IF (isset($_GET['php']) && isset($_GET['shop']) && isset($_GET['plugin'])) {
194
+ if ($_GET['php'] == phpversion() && $_GET['shop'] == CPHookResponse::getSignatureShop() && $_GET['plugin'] == CPHookResponse::getModuleVersion()) {
195
+ return true;
196
+ }
197
+ CPErrorHandler::handle(CPErrors::RESULT_SIGNATURE_MISMATCH, "Signature changed", "Signature changed \n" . $_GET['php'] . " -> " . phpversion() . "\n" . $_GET['shop'] . " -> " . CPHookResponse::getSignatureShop() . "\n" . $_GET['plugin'] . " -> " . CPHookResponse::getModuleVersion());
198
+ } else {
199
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "Missing params for signature check", "Missing params for signature check");
200
+ }
201
+ }
202
+
203
+ private function checkActivation($configs, $function) {
204
+ foreach ($configs as $config) {
205
+ if ($config === true) {
206
+ return true;
207
+ }
208
+ }
209
+ CPErrorHandler::handle(CPErrors::RESULT_API_DEACTIVATED, "'$function' not activated", "'$function' not activated");
210
+ }
211
+
212
+ private function checkIp() {
213
+ if (strcmp(Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_checkIp'), "true") === 0) {
214
+ $allIps = array();
215
+ $allIps[] = CPAbstractHandler::ChannelPilot_IP;
216
+ $sQuery = "SELECT ips_authorized FROM " . CPAbstractHandler::DB_REGISTRATION;
217
+ $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
218
+ try {
219
+ $sResult = $dbConnection->fetchAll($sQuery);
220
+ foreach ($sResult as $resultType) {
221
+ $ips = explode(";", $resultType['ips_authorized']);
222
+ foreach ($ips as $ip) {
223
+ $allIps[] = $ip;
224
+ }
225
+ }
226
+ } catch (Exception $e) {
227
+ $dbConnection->closeConnection();
228
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in getAllowedIpsViaSecurityToken(): " . $e->getMessage(), "Exception in getAllowedIpsViaSecurityToken(): '$sQuery'\n" . $e->getMessage());
229
+ }
230
+
231
+ if (!in_array($_SERVER['REMOTE_ADDR'], $allIps)) {
232
+ return false;
233
+ }
234
+ }
235
+ return true;
236
+ }
237
+
238
+ }
239
+
240
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/ExportData.php CHANGED
@@ -1,658 +1,619 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Channelpilot
17
- * @subpackage helper
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
-
24
- class ExportData
25
- {
26
- private $_tablePrefix;
27
- private $_storeId;
28
- private $_siteId;
29
- private $_mediaUrl;
30
- private $_webUrl;
31
- private $_dbConnection;
32
- private $_model;
33
- private $_allCat;
34
- private $oldCatPath;
35
- private $xml;
36
-
37
- function __construct()
38
- {
39
-
40
-
41
- // Increase maximum execution time to 4 hours
42
- ini_set('max_execution_time', 7200);
43
-
44
- // Initialize the admin application
45
- Mage::app('admin');
46
-
47
- // Get the table prefix
48
- $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
49
- $this->_tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
50
-
51
- // Get database connection
52
- $this->_dbConnection = Mage::getSingleton('core/resource') ->getConnection('core_read');
53
- }
54
-
55
- // Apply prefix to table names in the query
56
- private function _applyTablePrefix($query)
57
- {
58
- return str_replace('ChannelPilotSolutions_ChannelPilot_', $this->_tablePrefix, $query);
59
- }
60
-
61
- // Run the main application and call the appropriate function
62
- // depending on the command.
63
- public function _runMain()
64
- {
65
- if(isset($_GET['store']) AND $_GET['store']!=''){
66
- $this->_storeId = $_GET['store'];
67
- } else {
68
- $this->_storeId = Mage::app()->getStore()->getId();
69
- }
70
-
71
- // Validate store and get information
72
- $this->_getStoreInformation();
73
-
74
- // Run extraction
75
- return $this->_extractFromMySQL();
76
- }
77
-
78
- private function getCategory($key){
79
- if(strpos($key, '/')!=false){
80
- $tmpKey = substr($key,0,strpos($key,strrchr($key,'/')));
81
- if(isset($this->_allCat[$tmpKey])){
82
- return $this->_allCat[$tmpKey];
83
- } else {
84
- return $this->getCategory($tmpKey);
85
- }
86
- }
87
- return 0;
88
- }
89
-
90
- // Extract natively directly from the database
91
- private function _extractFromMySQL()
92
- {
93
- $selectLimit = 1000;
94
-
95
- // Increase maximium length for group_concat (for additional image URLs field)
96
- $query = "SET SESSION group_concat_max_len = 1000000;";
97
- $this->_dbConnection->query($query);
98
-
99
- // Get category information
100
- $query='';
101
- if(substr(Mage::getVersion(),2,3)>=6){
102
- $query = "
103
- SELECT DISTINCT fs.entity_id, fs.path, fs.name
104
- FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
105
- INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_".$this->_storeId." AS fs
106
- ON pi.category_id = fs.entity_id
107
- ORDER BY fs.path ASC
108
- ";
109
- } else {
110
- $query = "
111
- SELECT DISTINCT ev.entity_id, ce.path, ev.value
112
- FROM ChannelPilotSolutions_ChannelPilot_catalog_category_entity_varchar AS ev
113
- INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON ev.entity_id = ce.entity_id
114
- WHERE ev.attribute_id = (
115
- SELECT attribute_id
116
- FROM ChannelPilotSolutions_ChannelPilot_eav_attribute as att
117
- WHERE att.entity_type_id = ev.entity_type_id AND att.attribute_code='name'
118
- )
119
- ORDER BY ce.path ASC
120
- ";
121
- }
122
- $query = $this->_applyTablePrefix($query);
123
- $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
124
-
125
- $categoriesTable = $this->_dbConnection->fetchAll($query);
126
-
127
- $this->_allCat = array();
128
- $oldCatPath = 'initialize';
129
- $oldCatTree = '';
130
-
131
- foreach($categoriesTable as $categorie) {
132
- if(strpos($categorie[1],$oldCatPath)!==0){
133
- // Start tree
134
- $path = $this->getCategory($categorie[1]);
135
- if($path!==0){
136
- $this->_allCat[$categorie[1]] = str_replace('Root Catalog','Home',$path.'>'.$categorie[2]);
137
- $oldCatTree = $path.'>'.$categorie[2];
138
- } else {
139
- $this->_allCat[$categorie[1]] = str_replace('Root Catalog','Home',$categorie[2]);
140
- $oldCatTree = $categorie[2];
141
- }
142
- } else {
143
- // continue tree
144
- $this->_allCat[$categorie[1]] = str_replace('Root Catalog','Home',$oldCatTree.'>'.$categorie[2]);
145
- $oldCatTree = $this->_allCat[$categorie[1]];
146
- }
147
- $oldCatPath = $categorie[1];
148
- }
149
-
150
- // By default, set media gallery attribute id to 703
151
- // Look it up later
152
- $MEDIA_GALLERY_ATTRIBUTE_ID = 703;
153
-
154
- // Get the entity type for products
155
- $query = "SELECT entity_type_id FROM ChannelPilotSolutions_ChannelPilot_eav_entity_type WHERE entity_type_code = 'catalog_product'";
156
- $query = $this->_applyTablePrefix($query);
157
- $PRODUCT_ENTITY_TYPE_ID = $this->_dbConnection->fetchOne($query);
158
-
159
- // Get attribute codes and types
160
- $query = "SELECT attribute_id, attribute_code, backend_type, frontend_input
161
- FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
162
- WHERE entity_type_id = $PRODUCT_ENTITY_TYPE_ID
163
- ";
164
- $query = $this->_applyTablePrefix($query);
165
- $attributes = $this->_dbConnection->FetchAssoc($query);
166
- $attributeCodes = array();
167
- $blankProduct = array();
168
- $blankProduct['entity_id'] = '';
169
- $blankProduct['sku'] = '';
170
- $blankProduct['name'] = '';
171
- $blankProduct['description'] = '';
172
- $blankProduct['price'] = '';
173
- $blankProduct['categories'] = '';
174
- $blankProduct['manufacturer'] = '';
175
- $blankProduct['cp_product_url'] = '';
176
- $blankProduct['cp_image_url'] = '';
177
- $blankProduct['color'] = '';
178
- $blankProduct['weight'] = '';
179
-
180
- $blankProduct['cp_additional_image_1'] = '';
181
- $blankProduct['cp_additional_image_2'] = '';
182
- $blankProduct['cp_additional_image_3'] = '';
183
-
184
- $special_export_fields= unserialize(Mage::getStoreConfig('channelpilot_section/channelpilot_productfeed/channelpilot_specialexportfields'));
185
- if(!empty($special_export_fields)){
186
- foreach($special_export_fields as $element){
187
- if(!empty($element['name'])){
188
- $blankProduct[preg_replace('/\W/','',$element['name'])] = $element['value'];
189
- }
190
- }
191
- }
192
-
193
- foreach($attributes as $row)
194
- {
195
- // Save attribute ID for media gallery
196
- if($row['attribute_code'] == 'media_gallery')
197
- {
198
- $MEDIA_GALLERY_ATTRIBUTE_ID = $row['attribute_id'];
199
- }
200
-
201
- switch($row['backend_type'])
202
- {
203
- case 'datetime':
204
- case 'decimal':
205
- case 'int':
206
- case 'text':
207
- case 'varchar':
208
- $attributeCodes[$row['attribute_id']] = $row['attribute_code'];
209
- //$blankProduct[$row['attribute_code']] = '';
210
- break;
211
- case 'static':
212
- // ignore columns in entity table
213
- // print("Skipping static attribute: ".$row['attribute_code']."\n");
214
- break;
215
- default:
216
- // print("Unsupported backend_type: ".$row['backend_type']."\n");
217
- break;
218
- }
219
-
220
- // If the type is multiple choice, cache the option values
221
- // in a lookup array for performance (avoids several joins/aggregations)
222
- if($row['frontend_input'] == 'select' || $row['frontend_input'] == 'multiselect')
223
- {
224
- // Get the option_id => value from the attribute options
225
- $query = "
226
- SELECT
227
- CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.option_id) ELSE
228
- MAX(CASE WHEN aov.store_id = ".$this->_storeId." THEN aov.option_id ELSE NULL END)
229
- END AS 'option_id'
230
- ,CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.value) ELSE
231
- MAX(CASE WHEN aov.store_id = ".$this->_storeId." THEN aov.value ELSE NULL END)
232
- END AS 'value'
233
- FROM ChannelPilotSolutions_ChannelPilot_eav_attribute_option AS ao
234
- INNER JOIN ChannelPilotSolutions_ChannelPilot_eav_attribute_option_value AS aov
235
- ON ao.option_id = aov.option_id
236
- WHERE aov.store_id IN (".$this->_storeId.", 0)
237
- AND ao.attribute_id = ".$row['attribute_id']."
238
- GROUP BY aov.option_id
239
- ";
240
- $query = $this->_applyTablePrefix($query);
241
- $result = $this->_dbConnection->fetchPairs($query);
242
-
243
- // If found, then save the lookup table in the attributeOptions array
244
- if(is_array($result))
245
- {
246
- $attributeOptions[$row['attribute_id']] = $result;
247
- }
248
- else
249
- {
250
- // Otherwise, leave a blank array
251
- $attributeOptions[$row['attribute_id']] = array();
252
- }
253
- $result = null;
254
- }
255
- }
256
-
257
- $export_data_fields_codes = '';
258
- $export_data_fields_ids = '';
259
- foreach(array_keys($blankProduct) as $key){
260
- $export_data_fields_codes = $export_data_fields_codes."'".$key."',";
261
- $tmpid = array_search($key, $attributeCodes);
262
- if(!empty($tmpid)){
263
- $export_data_fields_ids = $export_data_fields_ids."'".$tmpid."',";
264
- }
265
-
266
- }
267
-
268
- $export_fields= unserialize(Mage::getStoreConfig('channelpilot_section/channelpilot_productfeed/channelpilot_exportfields'));
269
- if(!empty($export_fields)){
270
- foreach($export_fields as $element){
271
- if(!empty($element['productattribute'])){
272
- $blankProduct[preg_replace('/\W/','',$element['productattribute'])] = '';
273
- $export_data_fields_codes = $export_data_fields_codes."'".$element['productattribute']."',";
274
- $tmpid = array_search($element['productattribute'], $attributeCodes);
275
- if(!empty($tmpid)){
276
- $export_data_fields_ids = $export_data_fields_ids."'".$tmpid."',";
277
- }
278
- }
279
- }
280
- }
281
-
282
- $tmpid = array_search('status', $attributeCodes);
283
- if(!empty($tmpid)){
284
- $export_data_fields_ids = $export_data_fields_ids."'".$tmpid."',";
285
- }
286
- $tmpid = array_search('url_path', $attributeCodes);
287
- if(!empty($tmpid)){
288
- $export_data_fields_ids = $export_data_fields_ids."'".$tmpid."',";
289
- }
290
- $tmpid = array_search('image', $attributeCodes);
291
- if(!empty($tmpid)){
292
- $export_data_fields_ids = $export_data_fields_ids."'".$tmpid."',";
293
- }
294
- $export_data_fields_ids=rtrim($export_data_fields_ids, ',');
295
-
296
-
297
-
298
- // Build queries for each attribute type
299
- $backendTypes = array(
300
- 'datetime',
301
- 'decimal',
302
- 'int',
303
- 'text',
304
- 'varchar',
305
- );
306
- $queries = array();
307
- foreach($backendTypes as $backendType)
308
- {
309
- // Get store value if there is one, otherwise, global value
310
- $queries[] = "
311
- SELECT CASE WHEN SUM(ev.store_id) = 0 THEN MAX(ev.value) ELSE
312
- MAX(CASE WHEN ev.store_id = ".$this->_storeId." THEN ev.value ELSE NULL END)
313
- END AS 'value', ev.attribute_id
314
- FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity
315
- INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_$backendType AS ev
316
- ON ChannelPilotSolutions_ChannelPilot_catalog_product_entity.entity_id = ev.entity_id
317
- WHERE ev.store_id IN (".$this->_storeId.", 0)
318
- AND ev.entity_type_id = $PRODUCT_ENTITY_TYPE_ID
319
- AND ev.entity_id = @ENTITY_ID AND ev.attribute_id IN (".$export_data_fields_ids.")
320
- GROUP BY ev.attribute_id, ev.entity_id
321
- ";
322
- }
323
- $query = implode(" UNION ALL ", $queries);
324
- $MasterProductQuery = $query;
325
-
326
- $count = 0;
327
- $query = "
328
- SELECT count(*)
329
- FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
330
- INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
331
- ON cpw.product_id = cpe.entity_id
332
- WHERE cpw.website_id = ".$this->_siteId."
333
- AND IFNULL(cpe.sku, '') != ''
334
- ";
335
- $query = $this->_applyTablePrefix($query);
336
- $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
337
- $count = $this->_dbConnection->fetchAll($query);
338
-
339
- $counter = 0;
340
-
341
- $border = (int)$count[0][0]-$selectLimit;
342
- if($border<$count[0][0]){
343
- $border=$count[0][0];
344
- }
345
-
346
- $parentProductArray = array();
347
- $replace_fields= unserialize(Mage::getStoreConfig('channelpilot_section/channelpilot_productfeed/channelpilot_replacefields'));
348
-
349
-
350
- while($counter<=$border){
351
- // Get all entity_ids for all products in the selected store
352
- $query = "
353
- SELECT cpe.entity_id, cpe.sku,
354
- (SELECT parent_id FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE product_id=cpe.entity_id LIMIT 1) as parent,
355
- (SELECT count(*) FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE parent_id=cpe.entity_id LIMIT 1) as is_parent,
356
- (SELECT qty FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=".$this->_siteId." AND stock_id = 1 LIMIT 1) as qty,
357
- (SELECT stock_status FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=".$this->_siteId." AND stock_id = 1 LIMIT 1) as stock_status,
358
- (SELECT crpp.rule_price FROM ChannelPilotSolutions_ChannelPilot_catalogrule_product_price AS crpp WHERE crpp.rule_date = CURDATE() AND crpp.product_id =cpe.entity_id AND crpp.customer_group_id = 1 AND crpp.website_id = ".$this->_siteId.") as cat_price
359
- FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
360
- INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
361
- ON cpw.product_id = cpe.entity_id
362
- WHERE cpw.website_id = ".$this->_siteId."
363
- AND IFNULL(cpe.sku, '') != ''
364
- ORDER BY is_parent DESC
365
- LIMIT ".$counter.", ".$selectLimit."
366
- ";
367
- $query = $this->_applyTablePrefix($query);
368
- // Set fetch mode to numeric to save memory
369
- $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
370
- $EntityIds = $this->_dbConnection->fetchAll($query);
371
- // Loop through each product and output the data
372
- foreach($EntityIds as $entity)
373
- {
374
-
375
- // Fill the master query with the entity ID
376
- // $entity[0] = entity_id
377
- // $entity[1] = sku
378
- $query = str_replace('@ENTITY_ID', $entity[0], $MasterProductQuery);
379
- $query = $this->_applyTablePrefix($query);
380
- $result = $this->_dbConnection->query($query);
381
-
382
- // Create a new product record
383
- $product = $blankProduct;
384
-
385
- // Initialize basic product data
386
- $product['entity_id'] = $entity[0];
387
- $product['sku'] = $entity[1];
388
-
389
- // Escape the SKU (it may contain double-quotes)
390
- $product['sku'] = str_replace('"', '""', $product['sku']);
391
-
392
- $product_status;
393
- $product_url;
394
- $product_image;
395
- // Loop through each field in the row and get the value
396
- while(true)
397
- {
398
- // Get next column
399
- // $column[0] = value
400
- // $column[1] = attribute_id
401
- $column = $result->fetch(Zend_Db::FETCH_NUM);
402
- // Break if no more rows
403
- if(empty($column))
404
- {
405
- break;
406
- }
407
- // Skip attributes that don't exist in eav_attribute
408
- if(!isset($attributeCodes[$column[1]]))
409
- {
410
- continue;
411
- }
412
-
413
- // Translate the option option_id to a value.
414
- if(isset($attributeOptions[$column[1]]) == true)
415
- {
416
- // Convert all option values
417
- $optionValues = explode(',', $column[0]);
418
- $convertedOptionValues = array();
419
- foreach($optionValues as $optionValue)
420
- {
421
- if(isset($attributeOptions[$column[1]][$optionValue]) == true)
422
- {
423
- // If a option_id is found, translate it
424
- $convertedOptionValues[] = $attributeOptions[$column[1]][$optionValue];
425
- }
426
- }
427
- // Erase values that are set to zero
428
- if($column[0] == '0')
429
- {
430
- $column[0] = '';
431
- }
432
- elseif(empty($convertedOptionValues) == false)
433
- {
434
- // Use convert values if any conversions exist
435
- $column[0] = implode(',', $convertedOptionValues);
436
- }
437
- // Otherwise, leave value as-is
438
- }
439
- if(strpos($export_data_fields_codes, "'".$attributeCodes[$column[1]]."'")!=false){
440
- $product[$attributeCodes[$column[1]]] = str_replace('"', '""', $column[0]);
441
- }
442
- if($attributeCodes[$column[1]]=='status'){
443
- $product_status = $column[0];
444
- }
445
- if($attributeCodes[$column[1]]=='url_path'){
446
- $product_url = $column[0];
447
- }
448
- if($attributeCodes[$column[1]]=='image'){
449
- $product_image = $column[0];
450
- }
451
-
452
- }
453
- $result = null;
454
-
455
- // Skip product that are disabled or have no status
456
- if(empty($product_status) || $product_status == Mage_Catalog_Model_Product_Status::STATUS_DISABLED)
457
- {
458
- continue;
459
- }
460
- // Get category information
461
- $query='';
462
- if(substr(Mage::getVersion(),2,3)>=6){
463
- $query = "
464
- SELECT DISTINCT fs.entity_id, fs.path, fs.name
465
- FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
466
- INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_".$this->_storeId." AS fs
467
- ON pi.category_id = fs.entity_id
468
- WHERE pi.product_id = ".$entity[0]." ORDER BY fs.path ASC
469
- ";
470
- } else {
471
- $query = "
472
- SELECT pi.category_id, ce.path
473
- FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
474
- INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON pi.category_id = ce.entity_id
475
- WHERE pi.product_id = ".$entity[0]." AND pi.is_parent = 1 AND pi.store_id = ".$this->_storeId." ORDER BY ce.path ASC
476
- ";
477
- }
478
- $query = $this->_applyTablePrefix($query);
479
- $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
480
-
481
- $categoriesTable = $this->_dbConnection->fetchAll($query);
482
- $product['categories'] = '';
483
- $categorieField = '';
484
- $this->oldCatPath = '';
485
- foreach($categoriesTable as $categorie) {
486
- if(($this->oldCatPath=='') || (strpos($categorie[1],$this->oldCatPath)!==0)){
487
- // Start tree
488
- if($this->oldCatPath!==''){
489
- if($categorieField!==''){
490
- $categorieField = $categorieField.', '.$this->_allCat[$this->oldCatPath];
491
- } else {
492
- $categorieField = $this->_allCat[$this->oldCatPath];
493
- }
494
- }
495
- $this->oldCatPath = $categorie[1];
496
- } else {
497
- // Add to tree
498
- $this->oldCatPath = $categorie[1];
499
- }
500
-
501
- }
502
- if($categorieField!==''){
503
- $categorieField = $categorieField.', '.$this->_allCat[$this->oldCatPath];
504
- } else {
505
- if($this->oldCatPath!==''){
506
- $categorieField = $this->_allCat[$this->oldCatPath];
507
- }
508
- }
509
- $product['categories'] = $categorieField;
510
-
511
- // Get stock quantity
512
- // NOTE: stock_id = 1 is the 'Default' stock
513
- if(strpos($export_data_fields_codes, "'qty'")!=false){
514
- if(empty($entity[4]) == true)
515
- {
516
- $product['qty'] = '0';
517
- }
518
- else
519
- {
520
- $product['qty'] = $entity[4];
521
- }
522
- }
523
- if(strpos($export_data_fields_codes, "'stock_status'")!=false){
524
- if(empty($entity[5]) == true)
525
- {
526
- $product['stock_status'] = '';
527
- }
528
- else
529
- {
530
- $product['stock_status'] = $entity[5];
531
- }
532
- }
533
- $stockInfoResult = null;
534
-
535
- // Get additional image URLs
536
- $galleryImagePrefix = $this->_dbConnection->quote($this->_mediaUrl.'catalog/product');
537
- $query = "
538
- SELECT
539
- GROUP_CONCAT(gallery.value_id SEPARATOR ',') AS value_id
540
- ,GROUP_CONCAT(CONCAT(".$galleryImagePrefix.", gallery.value) SEPARATOR ',') AS value
541
- FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery AS gallery
542
- INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery_value AS gallery_value
543
- ON gallery.value_id = gallery_value.value_id
544
- WHERE gallery_value.store_id IN (".$this->_storeId.", 0)
545
- AND gallery_value.disabled = 0
546
- AND gallery.entity_id=".$entity[0]."
547
- AND gallery.attribute_id = ".$MEDIA_GALLERY_ATTRIBUTE_ID."
548
- ORDER BY gallery_value.position ASC";
549
- $query = $this->_applyTablePrefix($query);
550
- $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
551
- $galleryValues = $this->_dbConnection->fetchAll($query);
552
- if(empty($galleryValues) != true)
553
- {
554
- $additional_images = explode(',', $galleryValues[0][1]);
555
- for($i=0;$i<=2; $i++){
556
- if(isset($additional_images[$i])){
557
- $product['cp_additional_image_'.($i+1)] = $additional_images[$i];
558
- }
559
- }
560
- }
561
-
562
- // Get parent ID
563
- if(empty($entity[2]) != true && strpos($export_data_fields_codes, "'parent_id'")!=false)
564
- {
565
- $product['parent_id'] = $entity[2];
566
- }
567
-
568
- // Override price with catalog price rule, if found
569
- if(empty($entity[6]) != true)
570
- {
571
- // Override price with catalog rule price
572
- $product['price'] = $entity[6];
573
- }
574
-
575
- // Calculate image and product URLs
576
- if(empty($product_url) == false)
577
- {
578
- $product['cp_product_url'] = $this->_urlPathJoin($this->_webUrl, $product_url);
579
- }
580
-
581
- if(empty($product_image) == false)
582
- {
583
- $product['cp_image_url'] = $this->_urlPathJoin($this->_mediaUrl, 'catalog/product');
584
- $product['cp_image_url'] = $this->_urlPathJoin($product['cp_image_url'], $product_image);
585
- }
586
-
587
- if(!empty($replace_fields)){
588
- // PARENT
589
- if($entity[3]>0){
590
- foreach($replace_fields as $element){
591
- if(!empty($element['productattribute']) && array_key_exists($element['productattribute'],$product)){
592
- $parentProductArray[$product['entity_id']][$element['productattribute']] = $product[$element['productattribute']];
593
- }
594
- }
595
- } else {
596
- // CHILD
597
- if($entity[2]!=null){
598
- foreach($replace_fields as $element){
599
- if(!empty($element['productattribute']) && array_key_exists($element['productattribute'],$product)){
600
- $product[$element['productattribute']] = $parentProductArray[$entity[2]][$element['productattribute']];
601
- }
602
- }
603
- }
604
- }
605
- }
606
- $this->xml = new SimpleXMLElement("<product></product>");
607
- echo str_replace('<?xml version="1.0"?>','',$this->toXML($product));
608
- $this->xml = null;
609
- }
610
- $counter=$counter+$selectLimit;
611
- }
612
- return ;
613
- }
614
-
615
- // Join two URL paths and handle forward slashes
616
- private function _urlPathJoin($part1, $part2)
617
- {
618
- return rtrim($part1, '/').'/'.ltrim($part2, '/');
619
- }
620
-
621
- // Die if the storeId is invalid
622
- private function _getStoreInformation()
623
- {
624
- try
625
- {
626
- // Get the store object
627
- $store = Mage::app()->getStore($this->_storeId);
628
-
629
- // Load the store information
630
- $this->_siteId = $store->getWebsiteId();
631
- $this->_webUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
632
- $this->_mediaUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
633
- }
634
- catch (Exception $e)
635
- {
636
- die('Store='.$this->_storeId." probably does not exist.");
637
- }
638
- }
639
-
640
- private function toXML($array) {
641
- $this->iterate($array, $this->xml);
642
- return $this->xml->asXML();
643
- }
644
-
645
- private function iterate($element, $xmlNode) {
646
- if(is_array($element)){
647
- foreach($element as $name=>$value) {
648
- if(is_string($value) || is_numeric($value) || is_bool($value)) {
649
- $xmlNode->$name = $value;
650
- } else {
651
- $xmlNode->$name = null;
652
- $this->iterate($value, $xmlNode->$name);
653
- }
654
- }
655
- }
656
- }
657
- }
658
- ?>
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the GNU General Public License (GPL 3)
8
+ * that is bundled with this package in the file LICENSE.txt
9
+ *
10
+ * DISCLAIMER
11
+ *
12
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
13
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
14
+ * needs please refer to http://www.channelpilot.com for more information.
15
+ *
16
+ * @category Channelpilotsolutions
17
+ * @package Channelpilotsolutions_Channelpilot
18
+ * @subpackage helper
19
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
20
+ * @author Peter Hoffmann <info@channelpilot.com>
21
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
22
+ * @link http://www.channelpilot.com
23
+ */
24
+ class ExportData {
25
+
26
+ private $_tablePrefix;
27
+ private $_storeId;
28
+ private $_siteId;
29
+ private $_mediaUrl;
30
+ private $_webUrl;
31
+ private $_dbConnection;
32
+ private $_allCat;
33
+ private $oldCatPath;
34
+ private $xml;
35
+
36
+ function __construct() {
37
+
38
+
39
+ // Increase maximum execution time to 4 hours
40
+ ini_set('max_execution_time', 7200);
41
+
42
+ // Initialize the admin application
43
+ Mage::app('admin');
44
+
45
+ // Get the table prefix
46
+ $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
47
+ $this->_tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
48
+
49
+ // Get database connection
50
+ $this->_dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
51
+ }
52
+
53
+ // Apply prefix to table names in the query
54
+ private function _applyTablePrefix($query) {
55
+ return str_replace('ChannelPilotSolutions_ChannelPilot_', $this->_tablePrefix, $query);
56
+ }
57
+
58
+ // Run the main application and call the appropriate function
59
+ // depending on the command.
60
+ public function _runMain() {
61
+ if (isset($_GET['store']) AND $_GET['store'] != '') {
62
+ $this->_storeId = $_GET['store'];
63
+ } else {
64
+ $this->_storeId = Mage::app()->getStore()->getId();
65
+ }
66
+
67
+ // Validate store and get information
68
+ $this->_getStoreInformation();
69
+
70
+ // Run extraction
71
+ return $this->_extractFromMySQL();
72
+ }
73
+
74
+ private function getCategory($key) {
75
+ $return = 0;
76
+ if (strpos($key, '/') != false) {
77
+ $tmpKey = substr($key, 0, strpos($key, strrchr($key, '/')));
78
+ if (isset($this->_allCat[$tmpKey])) {
79
+ $return = $this->_allCat[$tmpKey];
80
+ } else {
81
+ $return = $this->getCategory($tmpKey);
82
+ }
83
+ }
84
+ return $return;
85
+ }
86
+
87
+ // Extract natively directly from the database
88
+ private function _extractFromMySQL() {
89
+ $selectLimit = 1000;
90
+
91
+ // Increase maximium length for group_concat (for additional image URLs field)
92
+ $query = "SET SESSION group_concat_max_len = 1000000;";
93
+ $this->_dbConnection->query($query);
94
+
95
+ // Get category information
96
+ $query = '';
97
+ if (substr(Mage::getVersion(), 2, 3) >= 6) {
98
+ $query = "
99
+ SELECT DISTINCT fs.entity_id, fs.path, fs.name
100
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
101
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_" . $this->_storeId . " AS fs
102
+ ON pi.category_id = fs.entity_id
103
+ ORDER BY fs.path ASC
104
+ ";
105
+ } else {
106
+ $query = "
107
+ SELECT DISTINCT ev.entity_id, ce.path, ev.value
108
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_category_entity_varchar AS ev
109
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON ev.entity_id = ce.entity_id
110
+ WHERE ev.attribute_id = (
111
+ SELECT attribute_id
112
+ FROM ChannelPilotSolutions_ChannelPilot_eav_attribute as att
113
+ WHERE att.entity_type_id = ev.entity_type_id AND att.attribute_code='name'
114
+ )
115
+ ORDER BY ce.path ASC
116
+ ";
117
+ }
118
+ $query = $this->_applyTablePrefix($query);
119
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
120
+
121
+ $categoriesTable = $this->_dbConnection->fetchAll($query);
122
+
123
+ $this->_allCat = array();
124
+ $oldCatPath = 'initialize';
125
+ $oldCatTree = '';
126
+
127
+ foreach ($categoriesTable as $categorie) {
128
+ if (strpos($categorie[1], $oldCatPath) !== 0) {
129
+ // Start tree
130
+ $path = $this->getCategory($categorie[1]);
131
+ if ($path !== 0) {
132
+ $this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $path . '>' . $categorie[2]);
133
+ $oldCatTree = $path . '>' . $categorie[2];
134
+ } else {
135
+ $this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $categorie[2]);
136
+ $oldCatTree = $categorie[2];
137
+ }
138
+ } else {
139
+ // continue tree
140
+ $this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $oldCatTree . '>' . $categorie[2]);
141
+ $oldCatTree = $this->_allCat[$categorie[1]];
142
+ }
143
+ $oldCatPath = $categorie[1];
144
+ }
145
+
146
+ // By default, set media gallery attribute id to 703
147
+ // Look it up later
148
+ $MEDIA_GALLERY_ATTRIBUTE_ID = 703;
149
+
150
+ // Get the entity type for products
151
+ $query = "SELECT entity_type_id FROM ChannelPilotSolutions_ChannelPilot_eav_entity_type WHERE entity_type_code = 'catalog_product'";
152
+ $query = $this->_applyTablePrefix($query);
153
+ $PRODUCT_ENTITY_TYPE_ID = $this->_dbConnection->fetchOne($query);
154
+
155
+ // Get attribute codes and types
156
+ $query = "SELECT attribute_id, attribute_code, backend_type, frontend_input
157
+ FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
158
+ WHERE entity_type_id = $PRODUCT_ENTITY_TYPE_ID
159
+ ";
160
+ $query = $this->_applyTablePrefix($query);
161
+ $attributes = $this->_dbConnection->FetchAssoc($query);
162
+ $attributeCodes = array();
163
+ $blankProduct = array();
164
+ $blankProduct['entity_id'] = '';
165
+ $blankProduct['sku'] = '';
166
+ $blankProduct['name'] = '';
167
+ $blankProduct['description'] = '';
168
+ $blankProduct['price'] = '';
169
+ $blankProduct['categories'] = '';
170
+ $blankProduct['manufacturer'] = '';
171
+ $blankProduct['cp_product_url'] = '';
172
+ $blankProduct['cp_image_url'] = '';
173
+ $blankProduct['color'] = '';
174
+ $blankProduct['weight'] = '';
175
+
176
+ $blankProduct['cp_additional_image_1'] = '';
177
+ $blankProduct['cp_additional_image_2'] = '';
178
+ $blankProduct['cp_additional_image_3'] = '';
179
+
180
+ $special_export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_specialexportfields'));
181
+ if (!empty($special_export_fields)) {
182
+ foreach ($special_export_fields as $element) {
183
+ if (!empty($element['name'])) {
184
+ $blankProduct[preg_replace('/\W/', '', $element['name'])] = $element['value'];
185
+ }
186
+ }
187
+ }
188
+
189
+ foreach ($attributes as $row) {
190
+ // Save attribute ID for media gallery
191
+ if ($row['attribute_code'] == 'media_gallery') {
192
+ $MEDIA_GALLERY_ATTRIBUTE_ID = $row['attribute_id'];
193
+ }
194
+
195
+ switch ($row['backend_type']) {
196
+ case 'datetime':
197
+ case 'decimal':
198
+ case 'int':
199
+ case 'text':
200
+ case 'varchar':
201
+ $attributeCodes[$row['attribute_id']] = $row['attribute_code'];
202
+ //$blankProduct[$row['attribute_code']] = '';
203
+ break;
204
+ case 'static':
205
+ // ignore columns in entity table
206
+ // print("Skipping static attribute: ".$row['attribute_code']."\n");
207
+ break;
208
+ default:
209
+ // print("Unsupported backend_type: ".$row['backend_type']."\n");
210
+ break;
211
+ }
212
+
213
+ // If the type is multiple choice, cache the option values
214
+ // in a lookup array for performance (avoids several joins/aggregations)
215
+ if ($row['frontend_input'] == 'select' || $row['frontend_input'] == 'multiselect') {
216
+ // Get the option_id => value from the attribute options
217
+ $query = "
218
+ SELECT
219
+ CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.option_id) ELSE
220
+ MAX(CASE WHEN aov.store_id = " . $this->_storeId . " THEN aov.option_id ELSE NULL END)
221
+ END AS 'option_id'
222
+ ,CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.value) ELSE
223
+ MAX(CASE WHEN aov.store_id = " . $this->_storeId . " THEN aov.value ELSE NULL END)
224
+ END AS 'value'
225
+ FROM ChannelPilotSolutions_ChannelPilot_eav_attribute_option AS ao
226
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_eav_attribute_option_value AS aov
227
+ ON ao.option_id = aov.option_id
228
+ WHERE aov.store_id IN (" . $this->_storeId . ", 0)
229
+ AND ao.attribute_id = " . $row['attribute_id'] . "
230
+ GROUP BY aov.option_id
231
+ ";
232
+ $query = $this->_applyTablePrefix($query);
233
+ $result = $this->_dbConnection->fetchPairs($query);
234
+
235
+ // If found, then save the lookup table in the attributeOptions array
236
+ if (is_array($result)) {
237
+ $attributeOptions[$row['attribute_id']] = $result;
238
+ } else {
239
+ // Otherwise, leave a blank array
240
+ $attributeOptions[$row['attribute_id']] = array();
241
+ }
242
+ $result = null;
243
+ }
244
+ }
245
+
246
+ $export_data_fields_codes = '';
247
+ $export_data_fields_ids = '';
248
+ foreach (array_keys($blankProduct) as $key) {
249
+ $export_data_fields_codes = $export_data_fields_codes . "'" . $key . "',";
250
+ $tmpid = array_search($key, $attributeCodes);
251
+ if (!empty($tmpid)) {
252
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
253
+ }
254
+ }
255
+
256
+ $export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_exportfields'));
257
+ if (!empty($export_fields)) {
258
+ foreach ($export_fields as $element) {
259
+ if (!empty($element['productattribute'])) {
260
+ $blankProduct[preg_replace('/\W/', '', $element['productattribute'])] = '';
261
+ $export_data_fields_codes = $export_data_fields_codes . "'" . $element['productattribute'] . "',";
262
+ $tmpid = array_search($element['productattribute'], $attributeCodes);
263
+ if (!empty($tmpid)) {
264
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
265
+ }
266
+ }
267
+ }
268
+ }
269
+
270
+ $tmpid = array_search('status', $attributeCodes);
271
+ if (!empty($tmpid)) {
272
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
273
+ }
274
+ $tmpid = array_search('url_path', $attributeCodes);
275
+ if (!empty($tmpid)) {
276
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
277
+ }
278
+ $tmpid = array_search('image', $attributeCodes);
279
+ if (!empty($tmpid)) {
280
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
281
+ }
282
+ $export_data_fields_ids = rtrim($export_data_fields_ids, ',');
283
+
284
+
285
+
286
+ // Build queries for each attribute type
287
+ $backendTypes = array(
288
+ 'datetime',
289
+ 'decimal',
290
+ 'int',
291
+ 'text',
292
+ 'varchar',
293
+ );
294
+ $queries = array();
295
+ foreach ($backendTypes as $backendType) {
296
+ // Get store value if there is one, otherwise, global value
297
+ $queries[] = "
298
+ SELECT CASE WHEN SUM(ev.store_id) = 0 THEN MAX(ev.value) ELSE
299
+ MAX(CASE WHEN ev.store_id = " . $this->_storeId . " THEN ev.value ELSE NULL END)
300
+ END AS 'value', ev.attribute_id
301
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity
302
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_$backendType AS ev
303
+ ON ChannelPilotSolutions_ChannelPilot_catalog_product_entity.entity_id = ev.entity_id
304
+ WHERE ev.store_id IN (" . $this->_storeId . ", 0)
305
+ AND ev.entity_type_id = $PRODUCT_ENTITY_TYPE_ID
306
+ AND ev.entity_id = @ENTITY_ID AND ev.attribute_id IN (" . $export_data_fields_ids . ")
307
+ GROUP BY ev.attribute_id, ev.entity_id
308
+ ";
309
+ }
310
+ $query = implode(" UNION ALL ", $queries);
311
+ $MasterProductQuery = $query;
312
+
313
+ $count = 0;
314
+ $query = "
315
+ SELECT count(*)
316
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
317
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
318
+ ON cpw.product_id = cpe.entity_id
319
+ WHERE cpw.website_id = " . $this->_siteId . "
320
+ AND IFNULL(cpe.sku, '') != ''
321
+ ";
322
+ $query = $this->_applyTablePrefix($query);
323
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
324
+ $count = $this->_dbConnection->fetchAll($query);
325
+
326
+ $counter = 0;
327
+
328
+ $border = (int) $count[0][0] - $selectLimit;
329
+ if ($border < $count[0][0]) {
330
+ $border = $count[0][0];
331
+ }
332
+
333
+ $parentProductArray = array();
334
+ $replace_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_replacefields'));
335
+
336
+
337
+ while ($counter <= $border) {
338
+ // Get all entity_ids for all products in the selected store
339
+ $query = "
340
+ SELECT cpe.entity_id, cpe.sku,
341
+ (SELECT parent_id FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE product_id=cpe.entity_id LIMIT 1) as parent,
342
+ (SELECT count(*) FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE parent_id=cpe.entity_id LIMIT 1) as is_parent,
343
+ (SELECT qty FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as qty,
344
+ (SELECT stock_status FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as stock_status,
345
+ (SELECT crpp.rule_price FROM ChannelPilotSolutions_ChannelPilot_catalogrule_product_price AS crpp WHERE crpp.rule_date = CURDATE() AND crpp.product_id =cpe.entity_id AND crpp.customer_group_id = 1 AND crpp.website_id = " . $this->_siteId . ") as cat_price
346
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
347
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
348
+ ON cpw.product_id = cpe.entity_id
349
+ WHERE cpw.website_id = " . $this->_siteId . "
350
+ AND IFNULL(cpe.sku, '') != ''
351
+ ORDER BY is_parent DESC, entity_id DESC
352
+ LIMIT " . $counter . ", " . $selectLimit . "
353
+ ";
354
+ $query = $this->_applyTablePrefix($query);
355
+ // Set fetch mode to numeric to save memory
356
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
357
+ $EntityIds = $this->_dbConnection->fetchAll($query);
358
+ // Loop through each product and output the data
359
+ CPErrorHandler::logError("products: \n" . print_r($EntityIds, true));
360
+ foreach ($EntityIds as $entity) {
361
+
362
+ // Fill the master query with the entity ID
363
+ // $entity[0] = entity_id
364
+ // $entity[1] = sku
365
+ $query = str_replace('@ENTITY_ID', $entity[0], $MasterProductQuery);
366
+ $query = $this->_applyTablePrefix($query);
367
+ $result = $this->_dbConnection->query($query);
368
+
369
+ // Create a new product record
370
+ $product = $blankProduct;
371
+
372
+ // Initialize basic product data
373
+ $product['entity_id'] = $entity[0];
374
+ $product['sku'] = $entity[1];
375
+
376
+ // Escape the SKU (it may contain double-quotes)
377
+ $product['sku'] = str_replace('"', '""', $product['sku']);
378
+
379
+ $product_status;
380
+ $product_url;
381
+ $product_image;
382
+ // Loop through each field in the row and get the value
383
+ while (true) {
384
+ // Get next column
385
+ // $column[0] = value
386
+ // $column[1] = attribute_id
387
+ $column = $result->fetch(Zend_Db::FETCH_NUM);
388
+ // Break if no more rows
389
+ if (empty($column)) {
390
+ break;
391
+ }
392
+ // Skip attributes that don't exist in eav_attribute
393
+ if (!isset($attributeCodes[$column[1]])) {
394
+ continue;
395
+ }
396
+
397
+ // Translate the option option_id to a value.
398
+ if (isset($attributeOptions[$column[1]]) == true) {
399
+ // Convert all option values
400
+ $optionValues = explode(',', $column[0]);
401
+ $convertedOptionValues = array();
402
+ foreach ($optionValues as $optionValue) {
403
+ if (isset($attributeOptions[$column[1]][$optionValue]) == true) {
404
+ // If a option_id is found, translate it
405
+ $convertedOptionValues[] = $attributeOptions[$column[1]][$optionValue];
406
+ }
407
+ }
408
+ // Erase values that are set to zero
409
+ if ($column[0] == '0') {
410
+ $column[0] = '';
411
+ } elseif (empty($convertedOptionValues) == false) {
412
+ // Use convert values if any conversions exist
413
+ $column[0] = implode(',', $convertedOptionValues);
414
+ }
415
+ // Otherwise, leave value as-is
416
+ }
417
+ if (strpos($export_data_fields_codes, "'" . $attributeCodes[$column[1]] . "'") != false) {
418
+ $product[$attributeCodes[$column[1]]] = str_replace('"', '""', $column[0]);
419
+ }
420
+ if ($attributeCodes[$column[1]] == 'status') {
421
+ $product_status = $column[0];
422
+ }
423
+ if ($attributeCodes[$column[1]] == 'url_path') {
424
+ $product_url = $column[0];
425
+ }
426
+ if ($attributeCodes[$column[1]] == 'image') {
427
+ $product_image = $column[0];
428
+ }
429
+ }
430
+ $result = null;
431
+
432
+ // Skip product that are disabled or have no status
433
+ if (empty($product_status) || $product_status == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
434
+ continue;
435
+ }
436
+ // Get category information
437
+ $query = '';
438
+ if (substr(Mage::getVersion(), 2, 3) >= 6) {
439
+ $query = "
440
+ SELECT DISTINCT fs.entity_id, fs.path, fs.name
441
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
442
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_" . $this->_storeId . " AS fs
443
+ ON pi.category_id = fs.entity_id
444
+ WHERE pi.product_id = " . $entity[0] . " ORDER BY fs.path ASC
445
+ ";
446
+ } else {
447
+ $query = "
448
+ SELECT pi.category_id, ce.path
449
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
450
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON pi.category_id = ce.entity_id
451
+ WHERE pi.product_id = " . $entity[0] . " AND pi.is_parent = 1 AND pi.store_id = " . $this->_storeId . " ORDER BY ce.path ASC
452
+ ";
453
+ }
454
+ $query = $this->_applyTablePrefix($query);
455
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
456
+
457
+ $categoriesTable = $this->_dbConnection->fetchAll($query);
458
+ $product['categories'] = '';
459
+ $categorieField = '';
460
+ $this->oldCatPath = '';
461
+ foreach ($categoriesTable as $categorie) {
462
+ if (($this->oldCatPath == '') || (strpos($categorie[1], $this->oldCatPath) !== 0)) {
463
+ // Start tree
464
+ if ($this->oldCatPath !== '') {
465
+ if ($categorieField !== '') {
466
+ $categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
467
+ } else {
468
+ $categorieField = $this->_allCat[$this->oldCatPath];
469
+ }
470
+ }
471
+ $this->oldCatPath = $categorie[1];
472
+ } else {
473
+ // Add to tree
474
+ $this->oldCatPath = $categorie[1];
475
+ }
476
+ }
477
+ if ($categorieField !== '') {
478
+ $categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
479
+ } else {
480
+ if ($this->oldCatPath !== '') {
481
+ $categorieField = $this->_allCat[$this->oldCatPath];
482
+ }
483
+ }
484
+ $product['categories'] = $categorieField;
485
+
486
+ // Get stock quantity
487
+ // NOTE: stock_id = 1 is the 'Default' stock
488
+ if (strpos($export_data_fields_codes, "'qty'") != false) {
489
+ if (empty($entity[4]) == true) {
490
+ $product['qty'] = '0';
491
+ } else {
492
+ $product['qty'] = $entity[4];
493
+ }
494
+ }
495
+ if (strpos($export_data_fields_codes, "'stock_status'") != false) {
496
+ if (empty($entity[5]) == true) {
497
+ $product['stock_status'] = '';
498
+ } else {
499
+ $product['stock_status'] = $entity[5];
500
+ }
501
+ }
502
+ $stockInfoResult = null;
503
+
504
+ // Get additional image URLs
505
+ $galleryImagePrefix = $this->_dbConnection->quote($this->_mediaUrl . 'catalog/product');
506
+ $query = "
507
+ SELECT
508
+ GROUP_CONCAT(gallery.value_id SEPARATOR ',') AS value_id
509
+ ,GROUP_CONCAT(CONCAT(" . $galleryImagePrefix . ", gallery.value) SEPARATOR ',') AS value
510
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery AS gallery
511
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery_value AS gallery_value
512
+ ON gallery.value_id = gallery_value.value_id
513
+ WHERE gallery_value.store_id IN (" . $this->_storeId . ", 0)
514
+ AND gallery_value.disabled = 0
515
+ AND gallery.entity_id=" . $entity[0] . "
516
+ AND gallery.attribute_id = " . $MEDIA_GALLERY_ATTRIBUTE_ID . "
517
+ ORDER BY gallery_value.position ASC";
518
+ $query = $this->_applyTablePrefix($query);
519
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
520
+ $galleryValues = $this->_dbConnection->fetchAll($query);
521
+ if (empty($galleryValues) != true) {
522
+ $additional_images = explode(',', $galleryValues[0][1]);
523
+ for ($i = 0; $i <= 2; $i++) {
524
+ if (isset($additional_images[$i])) {
525
+ $product['cp_additional_image_' . ($i + 1)] = $additional_images[$i];
526
+ }
527
+ }
528
+ }
529
+
530
+ // Get parent ID
531
+ if (empty($entity[2]) != true && strpos($export_data_fields_codes, "'parent_id'") != false) {
532
+ $product['parent_id'] = $entity[2];
533
+ }
534
+
535
+ // Override price with catalog price rule, if found
536
+ if (empty($entity[6]) != true) {
537
+ // Override price with catalog rule price
538
+ $product['price'] = $entity[6];
539
+ }
540
+
541
+ // Calculate image and product URLs
542
+ if (empty($product_url) == false) {
543
+ $product['cp_product_url'] = $this->_urlPathJoin($this->_webUrl, $product_url);
544
+ }
545
+
546
+ if (empty($product_image) == false) {
547
+ $product['cp_image_url'] = $this->_urlPathJoin($this->_mediaUrl, 'catalog/product');
548
+ $product['cp_image_url'] = $this->_urlPathJoin($product['cp_image_url'], $product_image);
549
+ }
550
+
551
+ if (!empty($replace_fields)) {
552
+ // PARENT
553
+ if ($entity[3] > 0) {
554
+ foreach ($replace_fields as $element) {
555
+ if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
556
+ $parentProductArray[$product['entity_id']][$element['productattribute']] = $product[$element['productattribute']];
557
+ }
558
+ }
559
+ } else {
560
+ // CHILD
561
+ if ($entity[2] != null) {
562
+ foreach ($replace_fields as $element) {
563
+ if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
564
+ $product[$element['productattribute']] = $parentProductArray[$entity[2]][$element['productattribute']];
565
+ }
566
+ }
567
+ }
568
+ }
569
+ }
570
+ $this->xml = new SimpleXMLElement("<product></product>");
571
+ echo str_replace('<?xml version="1.0"?>', '', $this->toXML($product));
572
+ $this->xml = null;
573
+ }
574
+ $counter = $counter + $selectLimit;
575
+ }
576
+ return;
577
+ }
578
+
579
+ // Join two URL paths and handle forward slashes
580
+ private function _urlPathJoin($part1, $part2) {
581
+ return rtrim($part1, '/') . '/' . ltrim($part2, '/');
582
+ }
583
+
584
+ // Die if the storeId is invalid
585
+ private function _getStoreInformation() {
586
+ try {
587
+ // Get the store object
588
+ $store = Mage::app()->getStore($this->_storeId);
589
+
590
+ // Load the store information
591
+ $this->_siteId = $store->getWebsiteId();
592
+ $this->_webUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
593
+ $this->_mediaUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
594
+ } catch (Exception $e) {
595
+ die('Store=' . $this->_storeId . " probably does not exist.");
596
+ }
597
+ }
598
+
599
+ private function toXML($array) {
600
+ $this->iterate($array, $this->xml);
601
+ return $this->xml->asXML();
602
+ }
603
+
604
+ private function iterate($element, $xmlNode) {
605
+ if (is_array($element)) {
606
+ foreach ($element as $name => $value) {
607
+ if (is_string($value) || is_numeric($value) || is_bool($value)) {
608
+ $xmlNode->$name = $value;
609
+ } else {
610
+ $xmlNode->$name = null;
611
+ $this->iterate($value, $xmlNode->$name);
612
+ }
613
+ }
614
+ }
615
+ }
616
+
617
+ }
618
+
619
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/CPResultCodes.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * CPResultCodes. Collection of possible resultCodes for a request.
4
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
5
+ * @version 1.0
6
+ */
7
+ class CPResultCodes {
8
+ // successfull
9
+ const SUCCESS = 200;
10
+
11
+ // client errors
12
+ const AUTH_ERROR = 401;
13
+ const TOO_MANY_ELEMENTS = 413;
14
+ const ID_NOT_FOUND = 404;
15
+
16
+ // server error
17
+ const SYSTEM_ERROR = 500;
18
+
19
+ const SHOP_ERROR_PAYMENT_METHOD_UNKNOWN = 700;
20
+ const SHOP_ERROR_DELIVERY_METHOD_UNKNOWN = 701;
21
+ const SHOP_ERROR_ARTICLE_UNKNOWN = 702;
22
+ const SHOP_ERROR_ARTICLE_UNKNOWN_EXISTING_ORDER = 703;
23
+ const SHOP_ERROR_MORE_THAN_ONE_ARTICLES_FOUND = 704;
24
+ }
25
+
26
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/ChannelPilotSellerAPI_v1_0.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // include the stub-classes
4
+ require_once 'thin/CPAuth.php';
5
+ require_once 'thin/CPResponseHeader.php';
6
+ require_once 'thin/CPArticleUpdate.php';
7
+ require_once 'thin/CPAddress.php';
8
+ require_once 'thin/CPArticle.php';
9
+ require_once 'thin/CPCancellation.php';
10
+ require_once 'thin/CPDiscount.php';
11
+ require_once 'thin/CPManagedArticlePrice.php';
12
+ require_once 'thin/CPMoney.php';
13
+ require_once 'thin/CPPayment.php';
14
+ require_once 'thin/CPCustomer.php';
15
+ require_once 'thin/CPOrderItem.php';
16
+ require_once 'thin/CPShipping.php';
17
+ require_once 'thin/CPOrderStatus.php';
18
+ require_once 'thin/CPOrderHeader.php';
19
+ require_once 'thin/CPOrder.php';
20
+ require_once 'thin/CPOrderSummary.php';
21
+
22
+ // request-classes
23
+ // response-classes
24
+ require_once 'responses/Response.php';
25
+ require_once 'responses/GetServerTimeResponse.php';
26
+ require_once 'responses/UpdateArticlesResponse.php';
27
+ require_once 'responses/UpdateArticleResult.php';
28
+ require_once 'responses/UpdateOrdersResponse.php';
29
+ require_once 'responses/UpdateOrderResult.php';
30
+ require_once 'responses/GetNewMarketplaceOrdersResponse.php';
31
+ require_once 'responses/GetManagedArticlePricesResponse.php';
32
+
33
+ /**
34
+ * Main API-Class
35
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
36
+ * @version 1.0
37
+ */
38
+ class ChannelPilotSellerAPI_v1_0 extends SoapClient {
39
+
40
+ private $auth;
41
+ private $wsdlUrl = 'http://seller.api.channelpilot.com/1_0?wsdl';
42
+ private $uri = 'http://v1_0.seller.api.channelpilot.com/';
43
+ private $soapOptions = array(
44
+ 'connection_timeout' => 20,
45
+ 'features' => SOAP_SINGLE_ELEMENT_ARRAYS
46
+ );
47
+ private $classmap = array(
48
+ 'CPAuth' => 'CPAuth',
49
+ 'CPResponseHeader' => 'CPResponseHeader',
50
+ 'AbstractResponse' => 'AbstractResponse',
51
+ 'GetServerTimeResponse' => 'GetServerTimeResponse',
52
+ 'CPArticleUpdate' => 'CPArticleUpdate',
53
+ 'UpdateArticlesResponse' => 'UpdateArticlesResponse',
54
+ 'UpdateArticleResult' => 'UpdateArticleResult',
55
+ 'UpdateOrdersResponse' => 'UpdateOrdersResponse',
56
+ 'UpdateOrderResult' => 'UpdateOrderResult',
57
+ 'CPAddress' => 'CPAddress',
58
+ 'CPArticle' => 'CPArticle',
59
+ 'CPDiscount' => 'CPDiscount',
60
+ 'CPManagedArticlePrice' => 'CPManagedArticlePrice',
61
+ 'CPMoney' => 'CPMoney',
62
+ 'CPPayment' => 'CPPayment',
63
+ 'CPCustomer' => 'CPCustomer',
64
+ 'CPOrderItem' => 'CPOrderItem',
65
+ 'CPShipping' => 'CPShipping',
66
+ 'CPOrderStatus' => 'CPOrderStatus',
67
+ 'CPOrderHeader' => 'CPOrderHeader',
68
+ 'CPOrder' => 'CPOrder',
69
+ 'CPOrderSummary' => 'CPOrderSummary',
70
+ 'GetNewMarketplaceOrdersResponse' => 'GetNewMarketplaceOrdersResponse'
71
+ );
72
+
73
+ public function ChannelPilotSellerAPI_v1_0($merchantId, $shopToken) {
74
+ $this->auth = new CPAuth($merchantId, $shopToken);
75
+
76
+ foreach ($this->classmap as $key => $value) {
77
+ if (!isset($this->soapOptions['classmap'][$key])) {
78
+ $this->soapOptions['classmap'][$key] = $value;
79
+ }
80
+ }
81
+ parent::__construct($this->wsdlUrl, $this->soapOptions);
82
+ }
83
+
84
+ /**
85
+ * Receives the acutal server time. Can be used to test the connection.
86
+ * @return GetServerTimeResponse
87
+ */
88
+ public function getServerTime() {
89
+ return $this->__call(
90
+ 'getServerTime',
91
+ array(
92
+ new SoapParam($this->auth, 'auth')
93
+ )
94
+ );
95
+ }
96
+
97
+ /**
98
+ * updates an array of articles in batch
99
+ * @return UpdateArticlesResponse
100
+ */
101
+ public function updateArticles(array $articles) {
102
+ return $this->__call(
103
+ 'updateArticles',
104
+ array(
105
+ new SoapParam($this->auth, 'auth'),
106
+ new SoapParam($articles, 'articles')
107
+ )
108
+ );
109
+ }
110
+
111
+ /**
112
+ * retrieves new marketplace orders
113
+ * @return GetNewMarketplaceOrdersResponse
114
+ */
115
+ public function getNewMarketplaceOrders() {
116
+ return $this->__call(
117
+ 'getNewMarketplaceOrders',
118
+ array(
119
+ new SoapParam($this->auth, 'auth')
120
+ )
121
+ );
122
+ }
123
+
124
+ /**
125
+ * update orders in ChannelPilot to "imported", generates the matching between externalOrderId and the shop-internal orderId
126
+ * q
127
+ * @return GetNewMarketplaceOrdersResponse
128
+ */
129
+
130
+
131
+ /**
132
+ * update orders in ChannelPilot to "imported", generates the matching between externalOrderId and the shop-internal orderId
133
+ * @param array $orders array of CPOrders
134
+ * @param type $mapOrderItemIds boolean, if channelPilot should map your internal orderItemIds
135
+ * @return type
136
+ */
137
+ public function setImportedOrders(array $orders, $mapOrderItemIds) {
138
+ return $this->__call(
139
+ 'setImportedOrders',
140
+ array(
141
+ new SoapParam($this->auth, 'auth'),
142
+ new SoapParam($orders, 'importedOrders'),
143
+ new SoapParam($mapOrderItemIds, 'mapOrderItemIds'),
144
+ )
145
+ );
146
+ }
147
+
148
+
149
+ public function registerDeliveries(array $deliveries) {
150
+ return $this->__call(
151
+ 'registerDeliveries',
152
+ array(
153
+ new SoapParam($this->auth, 'auth'),
154
+ new SoapParam($deliveries, 'deliveries')
155
+ )
156
+ );
157
+ }
158
+
159
+ public function registerCancellations(array $cancellations) {
160
+ return $this->__call(
161
+ 'registerCancellations',
162
+ array(
163
+ new SoapParam($this->auth, 'auth'),
164
+ new SoapParam($cancellations, 'cancellations')
165
+ )
166
+ );
167
+ }
168
+
169
+ public function getDynamicArticlePrices($priceId, $method, $filterArticles, $filterFrom) {
170
+ return $this->__call(
171
+ 'getDynamicArticlePrices',
172
+ array(
173
+ new SoapParam($this->auth, 'auth'),
174
+ new SoapParam($priceId, 'priceId'),
175
+ new SoapParam(null, 'pagination'),
176
+ new SoapParam($method, 'method'),
177
+ new SoapParam($filterArticles, 'filterArticles'),
178
+ new SoapParam($filterFrom, 'filterFrom')
179
+ )
180
+ );
181
+ }
182
+
183
+ }
184
+
185
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/GetManagedArticlePricesResponse.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * GetManagedArticlePricesResponse.
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class GetManagedArticlePricesResponse extends Response {
9
+ /**
10
+ * array of managed article prices, can be empty
11
+ * @var type CPManagedArticlePrice[]
12
+ */
13
+ public $managedArticlePrices = array();
14
+ }
15
+
16
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/GetNewMarketplaceOrdersResponse.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * GetNewMarketplaceOrdersResponse.
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class GetNewMarketplaceOrdersResponse extends Response {
9
+ /**
10
+ * are more orders available, than could be returned in this call
11
+ * @var type boolean
12
+ */
13
+ public $moreAvailable;
14
+
15
+ /**
16
+ * array of new orders, can be empty
17
+ * @var type CPOrder[]
18
+ */
19
+ public $orders = array();
20
+ }
21
+
22
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/GetServerTimeResponse.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GetServerTimeResponse.
4
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
5
+ * @version 1.0
6
+ */
7
+ class GetServerTimeResponse extends Response {
8
+ /**
9
+ * @var type string
10
+ */
11
+ public $localTime;
12
+ }
13
+
14
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/Response.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * AbstractRequestResponse.
4
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
5
+ * @version 1.0
6
+ */
7
+ class Response {
8
+ /**
9
+ * @var type CPResponseHeader
10
+ */
11
+ public $header;
12
+ }
13
+
14
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/UpdateArticleResult.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ * @package
6
+ * @copyright
7
+ */
8
+ class UpdateArticleResult {
9
+ /* string */
10
+ public $articleId;
11
+ }
12
+
13
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/UpdateArticlesResponse.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ * @package
6
+ * @copyright
7
+ */
8
+ class UpdateArticlesResponse extends Response {
9
+ /* UpdateArticleResult */
10
+ public $updateResults = array();
11
+ }
12
+
13
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/UpdateOrderResult.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ * @package
6
+ * @copyright
7
+ */
8
+ class UpdateOrderResult {
9
+ public $orderHeader;
10
+ public $header;
11
+ }
12
+
13
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/responses/UpdateOrdersResponse.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ * @package
6
+ * @copyright
7
+ */
8
+ class UpdateOrdersResponse extends Response {
9
+ public $updateResults = array();
10
+ }
11
+
12
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPAddress.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Holds an address. e.g. a shipping-address
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPAddress {
9
+ public $nameFirst;
10
+ public $nameLast;
11
+ public $nameFull;
12
+
13
+ public $company;
14
+
15
+ public $streetTitle;
16
+ public $streetNumber;
17
+ public $streetFull;
18
+ public $streetExtra;
19
+
20
+ public $city;
21
+ public $state;
22
+ public $zip;
23
+
24
+ public $countryIso2;
25
+ public $countryIso3;
26
+
27
+ public $phone;
28
+ }
29
+
30
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPArticle.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CPArticle {
4
+ public $id;
5
+ public $idExternal;
6
+ public $title;
7
+ }
8
+
9
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPArticleUpdate.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Holds information about the articles that should be updated. Each value can be null except of the id.
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPArticleUpdate {
9
+
10
+ /**
11
+ * The id of the article that should be updated.
12
+ * @var type string
13
+ */
14
+ public $id;
15
+
16
+ /**
17
+ * Defines if the article is active for selling or should not be offerd online. Can be null.
18
+ * @var type boolean
19
+ */
20
+ public $isActive;
21
+
22
+ /**
23
+ * The gross- or selling price of this article.
24
+ * @var type number
25
+ */
26
+ public $price;
27
+
28
+ /**
29
+ * How many articles are in stock?
30
+ * @var type integer
31
+ */
32
+ public $stock;
33
+
34
+ /**
35
+ * The availability of the product as string. Customers will se this value online.
36
+ * @var type string
37
+ */
38
+ public $availability;
39
+
40
+ function __construct($id, $isActive, $price, $stock, $availability) {
41
+ $this->id = $id;
42
+ $this->isActive = $isActive;
43
+ $this->price = $price;
44
+ $this->stock = $stock;
45
+ $this->availability = $availability;
46
+ }
47
+ }
48
+
49
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPAuth.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Basic authentication class to use the ChannelPilot seller API.
4
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
5
+ * @version 1.0
6
+ */
7
+ class CPAuth {
8
+ /**
9
+ * MerchantId for your ChannelPilot account. You can get from go.channelpilot.com/api.
10
+ * @var type string
11
+ */
12
+ public $merchantId;
13
+ /**
14
+ * ShopToken for your shop in ChannelPilot. You can get from go.channelpilot.com/api.
15
+ * @var type string
16
+ */
17
+ public $shopToken;
18
+
19
+ function __construct($merchantId, $shopToken) {
20
+ $this->merchantId = $merchantId;
21
+ $this->shopToken = $shopToken;
22
+ }
23
+ }
24
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPCancellation.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Holds information about a cancellation.
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPCancellation {
9
+ public $orderHeader;
10
+ public $isWholeOrderCancelled;
11
+ public $cancellationTime;
12
+ public $cancelledItems = array();
13
+
14
+ function __construct($orderId, $source, $statusIdBefore, $cancellationTime, $isWholeOrderCancelled) {
15
+ $this->orderHeader = new CPOrderHeader(null, $orderId, $source, $isWholeOrderCancelled ? CPOrderStatus::ID_CANCELLED : $statusIdBefore, false, null);
16
+ $this->cancellationTime = $cancellationTime;
17
+ $this->isWholeOrderCancelled = $isWholeOrderCancelled;
18
+ }
19
+ }
20
+
21
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPCustomer.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Holds information about a customer.
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPCustomer {
9
+ public $id;
10
+ public $idExternal;
11
+
12
+ public $nameFirst;
13
+ public $nameLast;
14
+ public $nameFull;
15
+
16
+ public $email;
17
+ public $phone;
18
+ public $mobile;
19
+ public $fax;
20
+ }
21
+
22
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPDelivery.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Holds information about a delivery.
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPDelivery {
9
+ /**
10
+ * @var type CPOrderHeader
11
+ */
12
+ public $orderHeader;
13
+
14
+ /**
15
+ * are all to be delivered items deliverd after this delivery?
16
+ * @var type boolean
17
+ */
18
+ public $isDeliveryCompleted;
19
+
20
+ /**
21
+ * tracking-number for this delivery
22
+ * @var type String
23
+ */
24
+ public $trackingNumber;
25
+
26
+ /**
27
+ * the carrier (DHL/UPS/...). if not set, channelpilot will take the default-carrier defined for the orders shippingType
28
+ * @var type String
29
+ */
30
+ public $carrierName;
31
+
32
+ /**
33
+ *
34
+ * @var type CPShipping
35
+ */
36
+ public $shipping;
37
+
38
+ public $deliveryTime;
39
+
40
+ /**
41
+ * array of delivered items. is only evaluated and neccessary if ($isDeliveryCompleted == false).
42
+ * @var type CPOrderItem[]
43
+ */
44
+ public $deliveredItems = array();
45
+
46
+ function __construct($orderId, $source, $isDeliveryCompleted, $trackingNumber, $deliveryTime) {
47
+ $this->orderHeader = new CPOrderHeader(null, $orderId, $source, $isDeliveryCompleted ? CPOrderStatus::ID_DELIVERED : CPOrderStatus::ID_PARTIALLY_DELIVERED, null, false);
48
+ $this->trackingNumber = $trackingNumber;
49
+ $this->deliveryTime = $deliveryTime;
50
+ $this->isDeliveryCompleted = $isDeliveryCompleted;
51
+ }
52
+ }
53
+
54
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPDiscount.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CPDiscount {
4
+ public $title;
5
+ public $couponCode;
6
+ public $discount;
7
+ }
8
+
9
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPManagedArticlePrice.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Holds an address. e.g. a shipping-address
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPManagedArticlePrice {
9
+ public $article;
10
+ public $price;
11
+ public $lastUpdate;
12
+ }
13
+
14
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPMoney.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CPMoney {
3
+ public $gross;
4
+ public $net;
5
+ public $tax;
6
+ public $taxRate;
7
+ }
8
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrder.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The order class holds information about an order.
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPOrder {
9
+ public $orderHeader;
10
+ public $customer;
11
+
12
+ public $addressInvoice;
13
+ public $addressDelivery;
14
+
15
+ public $itemsOrdered = array();
16
+
17
+ public $shipping;
18
+ public $payment;
19
+ public $discount;
20
+
21
+ public $summary;
22
+ }
23
+
24
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrderHeader.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * meta-data for an order.
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPOrderHeader {
9
+ public $orderId;
10
+ public $orderIdExternal;
11
+
12
+ public $status;
13
+
14
+ public $source;
15
+
16
+ public $orderTime;
17
+
18
+ function __construct($orderIdExternal, $orderId, $source, $statusIdentifier, $hasError, $errorCode) {
19
+ $this->orderIdExternal = $orderIdExternal;
20
+ $this->orderId = $orderId;
21
+ $this->source = $source;
22
+ $this->status = new CPOrderStatus($statusIdentifier, $hasError, $errorCode);
23
+ }
24
+ }
25
+
26
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrderItem.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CPOrderItem {
4
+ public $id;
5
+ public $idExternal;
6
+
7
+ public $article;
8
+
9
+ public $quantityOrdered;
10
+ public $quantityDelivered;
11
+ public $quantityCancelled;
12
+
13
+ public $costsSingle;
14
+ public $costsTotal;
15
+
16
+ public $feeSingleNet;
17
+ public $feeTotalNet;
18
+ }
19
+
20
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrderStatus.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an order status
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPOrderStatus {
9
+ const ID_READY_FOR_EXPORT = "10";
10
+ const ID_IMPORTED = "20";
11
+ const ID_PARTIALLY_DELIVERED = "25";
12
+ const ID_DELIVERED = "30";
13
+ const ID_CANCELLED = "99";
14
+
15
+ /**
16
+ * the unique-id for this orderStatus. Has a value of the constants defined in this class.
17
+ * @var type string
18
+ */
19
+ public $identifier;
20
+
21
+ /**
22
+ * the public title for the status, can be null
23
+ * @var type string
24
+ */
25
+ public $publicTitle;
26
+
27
+ /**
28
+ * the public description for the status, can be null
29
+ * @var type string
30
+ */
31
+ public $publicDescription;
32
+
33
+ /**
34
+ * was the orderimport successfully
35
+ * @var type boolean
36
+ */
37
+ public $hasError;
38
+
39
+ /**
40
+ * the public errormessage, can be null
41
+ * @var type string
42
+ */
43
+ public $errorMessage;
44
+
45
+ /**
46
+ * which error, can be null
47
+ * @var type int
48
+ */
49
+ public $errorCode;
50
+
51
+ function __construct($identifier, $hasError, $errorCode) {
52
+ $this->identifier = $identifier;
53
+ $this->hasError = $hasError;
54
+ $this->errorCode = $errorCode;
55
+ }
56
+ }
57
+
58
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPOrderSummary.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CPOrderSummary {
4
+ public $currencyIso3;
5
+
6
+ public $totalSumItems;
7
+ public $totalSumOrder;
8
+
9
+ public $message;
10
+
11
+ public $feeTotalNet;
12
+ }
13
+
14
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPPayment.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CPPayment {
4
+ public $typeId;
5
+ public $typeTitle;
6
+ public $costs;
7
+ public $paymentTime;
8
+ }
9
+
10
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPResponseHeader.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Header for a reponse.
4
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
5
+ * @version 1.0
6
+ */
7
+ class CPResponseHeader {
8
+ /**
9
+ * Every request returns a defined result code. @see CPResultCodes
10
+ * @var type int
11
+ */
12
+ public $resultCode;
13
+ /**
14
+ * the message could provide further information about the result.
15
+ * @var type string
16
+ */
17
+ public $resultMessage;
18
+ }
19
+
20
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPShipping.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CPShipping {
4
+ public $typeId;
5
+ public $typeTitle;
6
+ public $costs;
7
+ }
8
+
9
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPAbstractHandler.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp abstract handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPAbstractHandler {
9
+
10
+ const defaultHeader = "Content-Type: application/json;";
11
+ const errorHeader_forbidden = "HTTP/1.0 403 Forbidden";
12
+ const ChannelPilot_IP = "213.239.211.99";
13
+ const DB_REGISTRATION = "cp_registration";
14
+ const DB_ORDERS = "cp_marketplace_orders";
15
+ const DB_ORDER_ITEMS = "cp_marketplace_order_items";
16
+
17
+ /**
18
+ * Is the IP allowed for this shopId
19
+ *
20
+ * @param type $shopId
21
+ * @return boolean
22
+ */
23
+ public static function isIpAllowedViaShopId($shopId, $dbConnection) {
24
+ if (self::ChannelPilot_IP == $_SERVER['REMOTE_ADDR'] || strcmp(Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_checkIp'), "false") == 0) {
25
+ return true;
26
+ } else {
27
+ return in_array($_SERVER['REMOTE_ADDR'], self::getAllowedIpsViaShopId($shopId, $dbConnection));
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Is the IP allowed for this securityToken
33
+ *
34
+ * @param type $token
35
+ * @return boolean
36
+ */
37
+ public static function isIpAllowedViaSecurityToken($token) {
38
+ if (self::ChannelPilot_IP == $_SERVER['REMOTE_ADDR'] || strcmp(Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_checkIp'), "false") == 0) {
39
+ return true;
40
+ } else {
41
+ return in_array($_SERVER['REMOTE_ADDR'], self::getAllowedIpsViaSecurityToken($token));
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Get allowed ips for the shop via securityToken
47
+ *
48
+ * @param type $token
49
+ * @return array with allowed ips
50
+ */
51
+ public static function getAllowedIpsViaSecurityToken($token) {
52
+ $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
53
+ $sQuery = "SELECT ips_authorized FROM " . self::DB_REGISTRATION . " WHERE securityToken = ?;";
54
+ $array = array($token);
55
+ try {
56
+ $sResult = $dbConnection->fetchOne($sQuery, $array);
57
+ $dbConnection->closeConnection();
58
+ return explode(";", $sResult);
59
+ } catch (Exception $e) {
60
+ $dbConnection->closeConnection();
61
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in getAllowedIpsViaSecurityToken(): " . $e->getMessage(), "Exception in getAllowedIpsViaSecurityToken(): '$sQuery'\n" . print_r($array, true) . "\n" . $e->getMessage());
62
+ }
63
+ return null;
64
+ }
65
+
66
+ /**
67
+ * Get allowed ips for the shop via shopId
68
+ *
69
+ * @param type $shopId
70
+ * @return array with allowed ips
71
+ */
72
+ public static function getAllowedIpsViaShopId($shopId) {
73
+ $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
74
+ $sQuery = "SELECT ips_authorized FROM " . self::DB_REGISTRATION . " WHERE shopId = ?;";
75
+ $array = array($shopId);
76
+ try {
77
+ $sResult = $dbConnection->fetchOne($sQuery, $array);
78
+ $dbConnection->closeConnection();
79
+ return explode(";", $sResult);
80
+ } catch (Exception $e) {
81
+ $dbConnection->closeConnection();
82
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in getAllowedIpsViaShopId(): " . $e->getMessage(), "Exception in getAllowedIpsViaShopId(): '$sQuery'\n" . print_r($array, true) . "\n" . $e->getMessage());
83
+ }
84
+ return null;
85
+ }
86
+
87
+ /**
88
+ * Is the shop still registered?
89
+ *
90
+ * @param integer $shopId
91
+ * @return boolean
92
+ */
93
+ public static function isShopRegistered($shopId) {
94
+ $sQuery = "SELECT shopId FROM " . self::DB_REGISTRATION . " WHERE shopId = ?;";
95
+ $array = array($shopId);
96
+ $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
97
+ try {
98
+ $sResult = $dbConnection->fetchOne($sQuery, $array);
99
+ $dbConnection->closeConnection();
100
+ if (empty($sResult)) {
101
+ return false;
102
+ }
103
+ } catch (Exception $e) {
104
+ $dbConnection->closeConnection();
105
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in isShopRegistered(): " . $e->getMessage(), "Exception in isShopRegistered(): '$sQuery'\n" . print_r($array, true) . "\n" . $e->getMessage());
106
+ }
107
+ return true;
108
+ }
109
+
110
+ public static function getMerchantId($token) {
111
+ $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
112
+ $sQuery = "SELECT merchantId FROM " . self::DB_REGISTRATION . " WHERE securityToken = ?;";
113
+ $array = array($token);
114
+ try {
115
+ $sResult = $dbConnection->fetchOne($sQuery, $array);
116
+ $dbConnection->closeConnection();
117
+ } catch (Exception $e) {
118
+ $dbConnection->closeConnection();
119
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in getMerchantId(): " . $e->getMessage(), "Exception in getMerchantId(): '$sQuery'\n" . print_r($array, true) . "\n" . $e->getMessage());
120
+ }
121
+ return $sResult;
122
+ }
123
+
124
+ /**
125
+ * Get shopId by token for registered shop
126
+ *
127
+ * @param type $token
128
+ * @param type $dbConnection
129
+ * @return type
130
+ */
131
+ public static function getShopId($token, $dbConnection) {
132
+ $sQuery = "SELECT shopId FROM " . self::DB_REGISTRATION . " WHERE securityToken = ?;";
133
+ $array = array($token);
134
+ try {
135
+ $sResult = $dbConnection->fetchOne($sQuery, $array);
136
+ } catch (Exception $e) {
137
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in getShopId(): " . $e->getMessage(), "Exception in getShopId(): '$sQuery'\n" . print_r($array, true) . "\n" . $e->getMessage());
138
+ $dbConnection->closeConnection();
139
+ }
140
+ return $sResult;
141
+ }
142
+
143
+ public static function changeStatusOrders($apiOrders, $dbConnection) {
144
+ foreach ($apiOrders as $apiOrder) {
145
+ if ($apiOrder->header->resultCode == CPResultCodes::SUCCESS) {
146
+ self::changeStatusOrder($apiOrder->orderHeader, $dbConnection);
147
+ } else {
148
+ self::logError("Cannot change orderstatus from order (id: '" . $apiOrder->orderHeader->orderId . "', status: '" . $apiOrder->orderHeader->status->identifier . "')");
149
+ }
150
+ }
151
+ }
152
+
153
+ public static function changeStatusOrder($apiOrderHeader, $dbConnection) {
154
+ $query = "update " . self::DB_ORDERS . " set status = ? where order_nr = ?;";
155
+ $array = array($apiOrderHeader->status->identifier, $apiOrderHeader->orderId);
156
+ try {
157
+ $dbConnection->query($query, $array);
158
+ } catch (Exception $e) {
159
+ $dbConnection->closeConnections();
160
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception during changeStatusOrder: " . $e->getMessage(), "Exception during insert into cp_marketplace_orders: '$query'\n" . print_r($array, true) . "\n" . $e->getMessage());
161
+ }
162
+ }
163
+
164
+ /**
165
+ * log the error in the cp_marketplace - log file
166
+ *
167
+ * @param type $msg
168
+ */
169
+ public static function logError($msg) {
170
+ $msg = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI] by IP: {$_SERVER['REMOTE_ADDR']}\n$msg";
171
+
172
+ Mage::log("$msg\n\n", null, 'cp_plugin.log');
173
+ $dbWriteConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
174
+ $query = "INSERT INTO cp_logging (created, content) VALUES (NOW(), ?);";
175
+ $array = array($msg);
176
+ $dbWriteConnection->query($query, $array);
177
+ $dbWriteConnection->closeConnection();
178
+ }
179
+
180
+ public static function checkConfig() {
181
+ /* if(oxConfig::getInstance()->getShopConfVar('CPMARKETPLACE_ART_NUMBER')==2 && oxConfig::getInstance()->getShopConfVar('CPMARKETPLACE_ART_OTHERARTNUM')==''){
182
+ CPErrorHandler::handle(CPErrors::RESULT_CONFIG_INVALID, "No column for other article number", "No column for other article number");
183
+ }
184
+ if(oxConfig::getInstance()->getShopConfVar('CPMARKETPLACE_IMPORT')==''){
185
+ CPErrorHandler::handle(CPErrors::RESULT_CONFIG_INVALID, "No folder for unpaid orders", "No folder for unpaid orders");
186
+ }
187
+ if(oxConfig::getInstance()->getShopConfVar('CPMARKETPLACE_PAIDIMPORT')==''){
188
+ CPErrorHandler::handle(CPErrors::RESULT_CONFIG_INVALID, "No folder for paid orders", "No folder for paid orders");
189
+ }
190
+ if(oxConfig::getInstance()->getShopConfVar('CPMARKETPLACE_CANCEL')==''){
191
+ CPErrorHandler::handle(CPErrors::RESULT_CONFIG_INVALID, "No folder for cancelled orders", "No folder for cancelled orders");
192
+ } */
193
+ }
194
+
195
+ }
196
+
197
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPCancellationHandler.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp cancellation handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPCancellationHandler extends CPAbstractHandler {
9
+
10
+ /**
11
+ * Handle cancellation hook.
12
+ * @return type
13
+ */
14
+ public function handle() {
15
+ if (isset($_GET['token']) && self::isIpAllowedViaSecurityToken($_GET['token'])) {
16
+ self::checkConfig();
17
+ if (isset($_GET['limit'])) {
18
+ $cancelled = array();
19
+
20
+ $cancelledOrders = self::getCancelledOrders();
21
+ foreach ($cancelledOrders as $orders) {
22
+ if (isset($orders)) {
23
+ $cancelled[] = $orders;
24
+ }
25
+ }
26
+ $cancelledOrderItems = self::getCancelledItems();
27
+
28
+ foreach ($cancelledOrderItems as $orders) {
29
+ if (isset($orders)) {
30
+ $cancelled[] = $orders;
31
+ }
32
+ }
33
+
34
+ if (sizeof($cancelled) == 0) {
35
+ self::hookResult(false);
36
+ }
37
+ $merchantId = self::getMerchantId($_GET['token']);
38
+ $api = new ChannelPilotSellerAPI_v1_0($merchantId, $_GET['token']);
39
+ $result = $api->registerCancellations($cancelled);
40
+ if ($result->header->resultCode == CPResultCodes::SUCCESS) {
41
+ // return $result;
42
+
43
+ $dbWriteConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
44
+ self::changeStatusOrders($result->updateResults, $dbWriteConnection);
45
+ $dbWriteConnection->closeConnection();
46
+ } else {
47
+ // Result from registerDeliveries has no success
48
+ self::logError("request registerDeliveries() resultCode " . $result->header->resultCode);
49
+ $hook = new CPHookResponse();
50
+ $hook->resultCode = CPResultCodes::SUCCESS;
51
+ $hook->resultMessage = "request registerDeliveries() resultCode " . $result->header->resultCode;
52
+ $hook->moreAvailable = false;
53
+ $hook->apiResultCode = $result->header->resultCode;
54
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
55
+ }
56
+ self::hookResult(true);
57
+ } else {
58
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "not enough parameter for method: " . $_GET['method'], "not enough parameter for method: " . $_GET['method']);
59
+ }
60
+ } else {
61
+ if (empty($_GET['token'])) {
62
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "no token found", "no token found");
63
+ } else {
64
+ CPErrorHandler::handle(CPErrors::RESULT_FAILED, "ip not allowed by token: " . $_GET['token'], "ip not allowed by token: " . $_GET['token']);
65
+ }
66
+ }
67
+ }
68
+
69
+ private function hookResult($moreAvailable) {
70
+ $hook = new CPHookResponse();
71
+ $hook->resultCode = CPResultCodes::SUCCESS;
72
+ $hook->resultMessage = "CANCELLATION HOOK SUCCESS";
73
+ $hook->moreAvailable = $moreAvailable;
74
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
75
+ }
76
+
77
+ private static function getCancelledItems() {
78
+ $sQuery = "SELECT cp_orders.order_nr, cp_orders.marketplace, NOW() as time, cp_orders.status, cp_items.order_item_id, cp_items.marketplace_order_item_id, sales_flat_order_item.qty_canceled
79
+ FROM " . self::DB_ORDER_ITEMS . " cp_items
80
+ LEFT JOIN " . self::DB_ORDERS . " cp_orders ON cp_orders.order_id = cp_items.order_id
81
+ LEFT JOIN sales_flat_order ON sales_flat_order.entity_id = cp_orders.order_id
82
+ LEFT JOIN sales_flat_order_item ON sales_flat_order_item.item_id = cp_items.order_item_id
83
+ WHERE sales_flat_order_item.qty_canceled > 0 AND sales_flat_order.status != 'canceled' ORDER BY sales_flat_order_item.order_id;";
84
+ $dbReadConnection = null;
85
+ try {
86
+ $dbReadConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
87
+ $sResult = $dbReadConnection->fetchAll($sQuery);
88
+ $dbReadConnection->closeConnection();
89
+ $order = null;
90
+ $orderId = null;
91
+ $orders = array();
92
+ foreach ($sResult AS $result) {
93
+ if ($orderId == null || $orderId != $result['order_nr']) {
94
+ if ($orderId != null) {
95
+ $orders[] = $order;
96
+ }
97
+ $order = new CPCancellation($result['order_nr'], $result['marketplace'], $result['status'], date("Y-m-d", strtotime($result['time'])) . 'T' . date("H:i:s", strtotime($result['time'])), false);
98
+ $orderId = $result['order_nr'];
99
+ }
100
+ $item = new CPOrderItem();
101
+ $item->id = $result['order_item_id'];
102
+ $item->idExternal = $result['marketplace_order_item_id'];
103
+ $item->quantityCancelled = $result['qty_canceled'];
104
+ $order->cancelledItems[] = $item;
105
+ }
106
+ $orders[] = $order;
107
+ return $orders;
108
+ } catch (Exception $e) {
109
+ if (isset($dbReadConnection)) {
110
+ $dbReadConnection->closeConnection();
111
+ }
112
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in handle CancellationHook: " . $e->getMessage(), "Exception in handle CancellationHook: '$sQuery'\n" . $e->getMessage());
113
+ }
114
+ }
115
+
116
+ private static function getCancelledOrders() {
117
+ $sQuery = "SELECT cp_orders.order_nr, cp_orders.marketplace, NOW() as time, cp_orders.status
118
+ FROM " . self::DB_ORDERS . " cp_orders
119
+ LEFT JOIN sales_flat_order ON sales_flat_order.entity_id = cp_orders.order_id
120
+ WHERE sales_flat_order.status = 'canceled' AND cp_orders.status <> " . CPOrderStatus::ID_CANCELLED . ";";
121
+ $dbReadConnection = null;
122
+ try {
123
+ $dbReadConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
124
+ $sResult = $dbReadConnection->fetchAll($sQuery);
125
+ $dbReadConnection->closeConnection();
126
+ $orders = array();
127
+ foreach ($sResult AS $order) {
128
+ $cancelled = new CPCancellation($order['order_nr'], $order['marketplace'], $order['status'], date("Y-m-d", strtotime($order['time'])) . 'T' . date("H:i:s", strtotime($order['time'])), true);
129
+ $orders[] = $cancelled;
130
+ }
131
+ return $orders;
132
+ } catch (Exception $e) {
133
+ if (isset($dbReadConnection)) {
134
+ $dbReadConnection->closeConnection();
135
+ }
136
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in handle CancellationHook: " . $e->getMessage(), "Exception in handle CancellationHook: '$sQuery'\n" . $e->getMessage());
137
+ }
138
+ }
139
+
140
+ }
141
+
142
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPDebugHandler.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp export handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPDebugHandler extends CPAbstractHandler {
9
+
10
+ /**
11
+ * Handle status event
12
+ *
13
+ */
14
+ public function handle() {
15
+ if (isset($_GET['limit'])) {
16
+ $limit = $_GET['limit'];
17
+ $query = "SELECT id, created, content FROM cp_logging
18
+ ORDER BY id DESC LIMIT $limit";
19
+ $readConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
20
+ $logEntries = $readConnection->fetchAll($query);
21
+ $entries = array();
22
+ foreach ($logEntries as $logEntry) {
23
+ $log = array();
24
+ $log['id'] = $logEntry['id'];
25
+ $log['created'] = $logEntry['created'];
26
+ $log['content'] = $logEntry['content'];
27
+ $entries[] = $log;
28
+ }
29
+
30
+
31
+ $hook = new CPHookResponse();
32
+ $hook->resultCode = CPResultCodes::SUCCESS;
33
+ $hook->logs = $entries;
34
+ $hook->resultMessage = "LoggingData of " . sizeof($hook->logs) . " entries";
35
+ $hook->moreAvailable = true;
36
+ if (sizeof($hook->logs) < $limit) {
37
+ $hook->moreAvailable = false;
38
+ }
39
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
40
+ } else {
41
+ $hook = new CPHookResponse();
42
+ $hook->resultCode = CPResultCodes::SYSTEM_ERROR;
43
+ $hook->resultMessage = "Not enough parameter set";
44
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
45
+ }
46
+ }
47
+
48
+ }
49
+
50
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPDeliveryHandler.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp delivery handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPDeliveryHandler extends CPAbstractHandler {
9
+
10
+ /**
11
+ * Handle delivery hook.
12
+ * @return type
13
+ */
14
+ public function handle() {
15
+ if (isset($_GET['token']) && self::isIpAllowedViaSecurityToken($_GET['token'])) {
16
+ self::checkConfig();
17
+ if (isset($_GET['limit'])) {
18
+ $dbReadConnection = null;
19
+ $dbWriteConnection = null;
20
+ $query = "SELECT @CP_ORDERS.order_id, @CP_ORDERS.order_nr, @CP_ORDERS.marketplace, sales_flat_shipment_track.track_number, sales_flat_shipment_track.created_at, sales_flat_shipment_track.title, sales_flat_order.shipping_method
21
+ FROM @CP_ORDERS
22
+ LEFT JOIN sales_flat_shipment_track ON sales_flat_shipment_track.order_id = @CP_ORDERS.order_id
23
+ LEFT JOIN sales_flat_order ON sales_flat_order.entity_id = @CP_ORDERS.order_id
24
+ WHERE @CP_ORDERS.status = '" . CPOrderStatus::ID_IMPORTED . "' GROUP BY sales_flat_shipment_track.order_id LIMIT " . intval($_GET['limit']) . ";";
25
+ try {
26
+ $query = str_replace('@CP_ORDERS', self::DB_ORDERS, $query);
27
+ $dbReadConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
28
+ $sResult = $dbReadConnection->fetchAll($query);
29
+ $dbReadConnection->closeConnection();
30
+ $orders = array();
31
+ foreach ($sResult AS $order) {
32
+ $delivered = new CPDelivery($order['order_nr'], $order['marketplace'], true, $order['track_number'], date("Y-m-d", strtotime($order['created_at'])) . 'T' . date("H:i:s", strtotime($order['created_at'])));
33
+ $delivered->carrierName = $order['title'];
34
+ $delivered->shipping = new CPShipping();
35
+ $delivered->shipping->typeId = $order['shipping_method'];
36
+ $delivered->shipping->typeTitle = $order['title'];
37
+ $orders[] = $delivered;
38
+ }
39
+ $deliveries = $orders;
40
+ if (sizeof($deliveries) == 0) {
41
+ self::hookResult(false);
42
+ }
43
+ $merchantId = self::getMerchantId($_GET['token']);
44
+ $api = new ChannelPilotSellerAPI_v1_0($merchantId, $_GET['token']);
45
+ $result = $api->registerDeliveries($deliveries);
46
+ if ($result->header->resultCode == CPResultCodes::SUCCESS) {
47
+ $dbWriteConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
48
+ self::changeStatusOrders($result->updateResults, $dbWriteConnection);
49
+ $dbWriteConnection->closeConnection();
50
+ } else {
51
+ // Result from registerDeliveries has no success
52
+ self::logError("request registerDeliveries() resultCode " . $result->header->resultCode);
53
+ $hook = new CPHookResponse();
54
+ $hook->resultCode = CPResultCodes::SUCCESS;
55
+ $hook->resultMessage = "request registerDeliveries() resultCode " . $result->header->resultCode;
56
+ $hook->moreAvailable = false;
57
+ $hook->apiResultCode = $result->header->resultCode;
58
+ $hook->writeResponse(self::defaultHeader, self::_processOutput(json_encode($hook)));
59
+ }
60
+ self::hookResult(true);
61
+ } catch (Exception $e) {
62
+ if (isset($dbReadConnection)) {
63
+ $dbReadConnection->closeConnection();
64
+ }
65
+ if (isset($dbWriteConnection)) {
66
+ $dbWriteConnection->closeConnection();
67
+ }
68
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in handle DeliveryHook: " . $e->getMessage(), "Exception in handle DeliveryHook: '$query'\n" . $e->getMessage());
69
+ }
70
+ } else {
71
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "no limit set for method: " . $_GET['method'], "no limit set for method: " . $_GET['method']);
72
+ }
73
+ } else {
74
+ if (empty($_GET['token'])) {
75
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "no token found", "no token found");
76
+ } else {
77
+ CPErrorHandler::handle(CPErrors::RESULT_FAILED, "ip not allowed by token: " . $_GET['token'], "ip not allowed by token: " . $_GET['token']);
78
+ }
79
+ }
80
+ return "Error during handle deliveryHook";
81
+ }
82
+
83
+ private function hookResult($moreAvailable) {
84
+ $hook = new CPHookResponse();
85
+ $hook->resultCode = CPResultCodes::SUCCESS;
86
+ $hook->resultMessage = "DELIVERY HOOK SUCCESS";
87
+ $hook->moreAvailable = $moreAvailable;
88
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
89
+ }
90
+
91
+ }
92
+
93
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPErrorHandler.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp error handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPErrorHandler extends CPAbstractHandler {
9
+
10
+ /**
11
+ * Handle error event.
12
+ * Output a short error message and log the complete error message.
13
+ *
14
+ * @param type $code
15
+ * @param type $message
16
+ * @param type $logMessage
17
+ */
18
+ public static function handle($code, $message, $logMessage) {
19
+ self::logError($logMessage);
20
+ $hook = new CPHookResponse();
21
+ $hook->resultCode = $code;
22
+ $hook->resultMessage = $message;
23
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
24
+ }
25
+
26
+
27
+ }
28
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPExportHandler.php ADDED
@@ -0,0 +1,650 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp export handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPExportHandler extends CPAbstractHandler {
9
+
10
+ private $_tablePrefix;
11
+ private $_storeId;
12
+ private $_siteId;
13
+ private $_mediaUrl;
14
+ private $_webUrl;
15
+ private $_dbConnection;
16
+ private $_allCat;
17
+ private $oldCatPath;
18
+ private $limit;
19
+ private $last;
20
+ private $productId;
21
+
22
+ /**
23
+ * Handle status event
24
+ *
25
+ */
26
+ public function handle() {
27
+ if (isset($_GET['limit']) && isset($_GET['store'])) {
28
+ $this->limit = $_GET['limit'];
29
+ $this->last = $_GET['last'];
30
+ $this->_storeId = $_GET['store'];
31
+ $this->initExport();
32
+ $productData = null;
33
+ if ($_GET['priceStock'] === "true") {
34
+ $productData = $this->getStockAndPriceData();
35
+ } else {
36
+ $productData = $this->getFullProductData();
37
+ }
38
+
39
+ $hook = new CPHookResponse();
40
+ $hook->resultCode = CPResultCodes::SUCCESS;
41
+ $hook->products = $productData;
42
+ $hook->resultMessage = "ProductData of " . sizeof($hook->products) . " articles";
43
+ $hook->moreAvailable = true;
44
+ if (sizeof($hook->products) < $this->limit) {
45
+ $hook->moreAvailable = false;
46
+ }
47
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
48
+ } else {
49
+ $hook = new CPHookResponse();
50
+ $hook->resultCode = CPResultCodes::SYSTEM_ERROR;
51
+ $hook->resultMessage = "Not enough parameter set";
52
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
53
+ }
54
+ }
55
+
56
+ private function initExport() {
57
+ ini_set('max_execution_time', 150);
58
+ Mage::app('admin');
59
+
60
+ $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
61
+ $this->_tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
62
+ $this->_dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
63
+
64
+ try {
65
+ $store = Mage::app()->getStore($this->_storeId);
66
+ $this->_siteId = $store->getWebsiteId();
67
+ $this->_webUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
68
+ $this->_mediaUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
69
+ } catch (Exception $e) {
70
+ die('Store=' . $this->_storeId . " probably does not exist.");
71
+ }
72
+ $this->buildCategoryTree();
73
+ }
74
+
75
+ private function getStockAndPriceData() {
76
+ $query = "SELECT attribute_id, attribute_code, backend_type, frontend_input
77
+ FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
78
+ WHERE entity_type_id = $PRODUCT_ENTITY_TYPE_ID
79
+ ";
80
+
81
+ $selectProductIdsQuery = $this->_applyTablePrefix(
82
+ "SELECT p.entity_id, l.parent_id FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity p
83
+ LEFT JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_super_link l ON l.product_id = p.entity_id
84
+ WHERE p.entity_id NOT IN (SELECT parent_id FROM catalog_product_super_link)"
85
+ );
86
+ if (isset($this->last)) {
87
+ $selectProductIdsQuery .= " AND p.entity_id > {$this->last} ";
88
+ }
89
+ $selectProductIdsQuery .= " GROUP BY p.entity_id ORDER BY p.entity_id ASC LIMIT {$this->limit};";
90
+
91
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
92
+ $productEntities = $this->_dbConnection->fetchAll($selectProductIdsQuery);
93
+ $productIds = "";
94
+ foreach ($productEntities as $productId) {
95
+ $productIds .= $productId[0] . ",";
96
+ }
97
+ $productIds = rtrim($productIds, ',');
98
+
99
+ $query = "
100
+ SELECT cpe.entity_id, cpe.sku,
101
+ (SELECT count(*) FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE parent_id=cpe.entity_id LIMIT 1) as is_parent,
102
+ (SELECT cped.value FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity_decimal AS cped
103
+ LEFT JOIN ChannelPilotSolutions_ChannelPilot_eav_attribute as eavAttr ON eavAttr.attribute_id = cped.attribute_id WHERE cped.entity_id=cpe.entity_id AND eavAttr.attribute_code = 'price' LIMIT 1) as price,
104
+ (SELECT qty FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as qty,
105
+ (SELECT stock_status FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as stock_status,
106
+ (SELECT crpp.rule_price FROM ChannelPilotSolutions_ChannelPilot_catalogrule_product_price AS crpp WHERE crpp.rule_date = CURDATE() AND crpp.product_id =cpe.entity_id AND crpp.customer_group_id = 1 AND crpp.website_id = " . $this->_siteId . ") as cat_price
107
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
108
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
109
+ ON cpw.product_id = cpe.entity_id
110
+ WHERE cpw.website_id = " . $this->_siteId . "
111
+ AND IFNULL(cpe.sku, '') != '' AND cpe.entity_id IN ($productIds)
112
+ ORDER BY is_parent DESC, entity_id ASC
113
+ ";
114
+
115
+ $query = $this->_applyTablePrefix($query);
116
+ // Set fetch mode to numeric to save memory
117
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
118
+ $productEntities = $this->_dbConnection->fetchAll($query);
119
+ // Loop through each product and output the data
120
+
121
+ $productData = array();
122
+ foreach ($productEntities as $entity) {
123
+ $product = array();
124
+ $product['id'] = $entity[0];
125
+ $product['sku'] = $entity[1];
126
+ $product['price'] = $entity[3];
127
+ if (empty($entity[6]) != true) {
128
+ // Override price with catalog rule price
129
+ $product['price'] = $entity[6];
130
+ }
131
+ $product['qty'] = $entity[4];
132
+ $productData[] = $product;
133
+ }
134
+ return $productData;
135
+ }
136
+
137
+ private function getFullProductData() {
138
+ // Increase maximium length for group_concat (for additional image URLs field)
139
+ $query = "SET SESSION group_concat_max_len = 1000000;";
140
+ $this->_dbConnection->query($query);
141
+
142
+ // By default, set media gallery attribute id to 703
143
+ // Look it up later
144
+ $MEDIA_GALLERY_ATTRIBUTE_ID = 703;
145
+
146
+ // Get the entity type for products
147
+ $query = "SELECT entity_type_id FROM ChannelPilotSolutions_ChannelPilot_eav_entity_type WHERE entity_type_code = 'catalog_product'";
148
+ $query = $this->_applyTablePrefix($query);
149
+ $PRODUCT_ENTITY_TYPE_ID = $this->_dbConnection->fetchOne($query);
150
+
151
+ // Get attribute codes and types
152
+ $query = "SELECT attribute_id, attribute_code, backend_type, frontend_input
153
+ FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
154
+ WHERE entity_type_id = $PRODUCT_ENTITY_TYPE_ID
155
+ ";
156
+ $query = $this->_applyTablePrefix($query);
157
+ $attributes = $this->_dbConnection->FetchAssoc($query);
158
+ $attributeCodes = array();
159
+ $blankProduct = array();
160
+ $blankProduct['id'] = '';
161
+ $blankProduct['sku'] = '';
162
+ $blankProduct['name'] = '';
163
+ $blankProduct['description'] = '';
164
+ $blankProduct['price'] = '';
165
+ $blankProduct['categories'] = '';
166
+ $blankProduct['manufacturer'] = '';
167
+ $blankProduct['cp_product_url'] = '';
168
+ $blankProduct['cp_image_url'] = '';
169
+ $blankProduct['color'] = '';
170
+ $blankProduct['weight'] = '';
171
+
172
+ $blankProduct['cp_additional_image_1'] = '';
173
+ $blankProduct['cp_additional_image_2'] = '';
174
+ $blankProduct['cp_additional_image_3'] = '';
175
+
176
+ $special_export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_specialexportfields'));
177
+ if (!empty($special_export_fields)) {
178
+ foreach ($special_export_fields as $element) {
179
+ if (!empty($element['name'])) {
180
+ $blankProduct[preg_replace('/\W/', '', $element['name'])] = $element['value'];
181
+ }
182
+ }
183
+ }
184
+
185
+ foreach ($attributes as $row) {
186
+ // Save attribute ID for media gallery
187
+ if ($row['attribute_code'] == 'media_gallery') {
188
+ $MEDIA_GALLERY_ATTRIBUTE_ID = $row['attribute_id'];
189
+ }
190
+
191
+ switch ($row['backend_type']) {
192
+ case 'datetime':
193
+ case 'decimal':
194
+ case 'int':
195
+ case 'text':
196
+ case 'varchar':
197
+ $attributeCodes[$row['attribute_id']] = $row['attribute_code'];
198
+ //$blankProduct[$row['attribute_code']] = '';
199
+ break;
200
+ case 'static':
201
+ // ignore columns in entity table
202
+ // print("Skipping static attribute: ".$row['attribute_code']."\n");
203
+ break;
204
+ default:
205
+ // print("Unsupported backend_type: ".$row['backend_type']."\n");
206
+ break;
207
+ }
208
+
209
+ // If the type is multiple choice, cache the option values
210
+ // in a lookup array for performance (avoids several joins/aggregations)
211
+ if ($row['frontend_input'] == 'select' || $row['frontend_input'] == 'multiselect') {
212
+ // Get the option_id => value from the attribute options
213
+ $query = "
214
+ SELECT
215
+ CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.option_id) ELSE
216
+ MAX(CASE WHEN aov.store_id = " . $this->_storeId . " THEN aov.option_id ELSE NULL END)
217
+ END AS 'option_id'
218
+ ,CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.value) ELSE
219
+ MAX(CASE WHEN aov.store_id = " . $this->_storeId . " THEN aov.value ELSE NULL END)
220
+ END AS 'value'
221
+ FROM ChannelPilotSolutions_ChannelPilot_eav_attribute_option AS ao
222
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_eav_attribute_option_value AS aov
223
+ ON ao.option_id = aov.option_id
224
+ WHERE aov.store_id IN (" . $this->_storeId . ", 0)
225
+ AND ao.attribute_id = " . $row['attribute_id'] . "
226
+ GROUP BY aov.option_id
227
+ ";
228
+ $query = $this->_applyTablePrefix($query);
229
+ $result = $this->_dbConnection->fetchPairs($query);
230
+
231
+ // If found, then save the lookup table in the attributeOptions array
232
+ if (is_array($result)) {
233
+ $attributeOptions[$row['attribute_id']] = $result;
234
+ } else {
235
+ // Otherwise, leave a blank array
236
+ $attributeOptions[$row['attribute_id']] = array();
237
+ }
238
+ $result = null;
239
+ }
240
+ }
241
+
242
+ $export_data_fields_codes = '';
243
+ $export_data_fields_ids = '';
244
+ foreach (array_keys($blankProduct) as $key) {
245
+ $export_data_fields_codes = $export_data_fields_codes . "'" . $key . "',";
246
+ $tmpid = array_search($key, $attributeCodes);
247
+ if (!empty($tmpid)) {
248
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
249
+ }
250
+ }
251
+
252
+ $export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_exportfields'));
253
+ if (!empty($export_fields)) {
254
+ foreach ($export_fields as $element) {
255
+ if (!empty($element['productattribute'])) {
256
+ $blankProduct[preg_replace('/\W/', '', $element['productattribute'])] = '';
257
+ $export_data_fields_codes = $export_data_fields_codes . "'" . $element['productattribute'] . "',";
258
+ $tmpid = array_search($element['productattribute'], $attributeCodes);
259
+ if (!empty($tmpid)) {
260
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
261
+ }
262
+ }
263
+ }
264
+ }
265
+
266
+ $tmpid = array_search('status', $attributeCodes);
267
+ if (!empty($tmpid)) {
268
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
269
+ }
270
+ $tmpid = array_search('url_path', $attributeCodes);
271
+ if (!empty($tmpid)) {
272
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
273
+ }
274
+ $tmpid = array_search('image', $attributeCodes);
275
+ if (!empty($tmpid)) {
276
+ $export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
277
+ }
278
+ $export_data_fields_ids = rtrim($export_data_fields_ids, ',');
279
+
280
+ // Build queries for each attribute type
281
+ $backendTypes = array(
282
+ 'datetime',
283
+ 'decimal',
284
+ 'int',
285
+ 'text',
286
+ 'varchar',
287
+ );
288
+ $queries = array();
289
+ foreach ($backendTypes as $backendType) {
290
+ // Get store value if there is one, otherwise, global value
291
+ $queries[] = "
292
+ SELECT CASE WHEN SUM(ev.store_id) = 0 THEN MAX(ev.value) ELSE
293
+ MAX(CASE WHEN ev.store_id = " . $this->_storeId . " THEN ev.value ELSE NULL END)
294
+ END AS 'value', ev.attribute_id
295
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity
296
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_$backendType AS ev
297
+ ON ChannelPilotSolutions_ChannelPilot_catalog_product_entity.entity_id = ev.entity_id
298
+ WHERE ev.store_id IN (" . $this->_storeId . ", 0)
299
+ AND ev.entity_type_id = $PRODUCT_ENTITY_TYPE_ID
300
+ AND ev.entity_id = @ENTITY_ID AND ev.attribute_id IN (" . $export_data_fields_ids . ")
301
+ GROUP BY ev.attribute_id, ev.entity_id
302
+ ";
303
+ }
304
+ $query = implode(" UNION ALL ", $queries);
305
+ $MasterProductQuery = $query;
306
+
307
+ $parentProductArray = array();
308
+ $replace_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_replacefields'));
309
+
310
+ $selectProductIdsQuery = $this->_applyTablePrefix(
311
+ "SELECT p.entity_id, l.parent_id FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity p
312
+ LEFT JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_super_link l ON l.product_id = p.entity_id
313
+ WHERE p.entity_id NOT IN (SELECT parent_id FROM catalog_product_super_link)"
314
+ );
315
+ if (isset($this->last)) {
316
+ $selectProductIdsQuery .= " AND p.entity_id > {$this->last} ";
317
+ }
318
+ $selectProductIdsQuery .= " GROUP BY p.entity_id ORDER BY p.entity_id ASC LIMIT {$this->limit};";
319
+
320
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
321
+ $productEntities = $this->_dbConnection->fetchAll($selectProductIdsQuery);
322
+ $productIds = "";
323
+ foreach ($productEntities as $productId) {
324
+ $productIds .= $productId[0] . ",";
325
+ if (!empty($productId[1])) {
326
+ $productIds .= $productId[1] . ",";
327
+ }
328
+ }
329
+ $productIds = rtrim($productIds, ',');
330
+
331
+ // Get all entity_ids for all products in the selected store
332
+ $query = "
333
+ SELECT cpe.entity_id, cpe.sku,
334
+ (SELECT parent_id FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE product_id=cpe.entity_id LIMIT 1) as parent,
335
+ (SELECT count(*) FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE parent_id=cpe.entity_id LIMIT 1) as is_parent,
336
+ (SELECT qty FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as qty,
337
+ (SELECT stock_status FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as stock_status,
338
+ (SELECT crpp.rule_price FROM ChannelPilotSolutions_ChannelPilot_catalogrule_product_price AS crpp WHERE crpp.rule_date = CURDATE() AND crpp.product_id =cpe.entity_id AND crpp.customer_group_id = 1 AND crpp.website_id = " . $this->_siteId . ") as cat_price
339
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
340
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
341
+ ON cpw.product_id = cpe.entity_id
342
+ WHERE cpw.website_id = " . $this->_siteId . "
343
+ AND IFNULL(cpe.sku, '') != '' AND cpe.entity_id IN ($productIds)
344
+ ORDER BY is_parent DESC, entity_id ASC
345
+ ";
346
+
347
+ $query = $this->_applyTablePrefix($query);
348
+ // Set fetch mode to numeric to save memory
349
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
350
+ $productEntities = $this->_dbConnection->fetchAll($query);
351
+ // Loop through each product and output the data
352
+
353
+ $productData = array();
354
+ foreach ($productEntities as $entity) {
355
+ // Fill the master query with the entity ID
356
+ // $entity[0] = entity_id
357
+ // $entity[1] = sku
358
+ $query = str_replace('@ENTITY_ID', $entity[0], $MasterProductQuery);
359
+ $query = $this->_applyTablePrefix($query);
360
+ $result = $this->_dbConnection->query($query);
361
+
362
+ // Create a new product record
363
+ $product = $blankProduct;
364
+
365
+ // Initialize basic product data
366
+ $product['id'] = $entity[0];
367
+ $product['sku'] = $entity[1];
368
+
369
+ $product_status;
370
+ $product_url;
371
+ $product_image;
372
+ // Loop through each field in the row and get the value
373
+ while (true) {
374
+ // Get next column
375
+ // $column[0] = value
376
+ // $column[1] = attribute_id
377
+ $column = $result->fetch(Zend_Db::FETCH_NUM);
378
+ // Break if no more rows
379
+ if (empty($column)) {
380
+ break;
381
+ }
382
+ // Skip attributes that don't exist in eav_attribute
383
+ if (!isset($attributeCodes[$column[1]])) {
384
+ continue;
385
+ }
386
+
387
+ // Translate the option option_id to a value.
388
+ if (isset($attributeOptions[$column[1]]) == true) {
389
+ // Convert all option values
390
+ $optionValues = explode(',', $column[0]);
391
+ $convertedOptionValues = array();
392
+ foreach ($optionValues as $optionValue) {
393
+ if (isset($attributeOptions[$column[1]][$optionValue]) == true) {
394
+ // If a option_id is found, translate it
395
+ $convertedOptionValues[] = $attributeOptions[$column[1]][$optionValue];
396
+ }
397
+ }
398
+ // Erase values that are set to zero
399
+ if ($column[0] == '0') {
400
+ $column[0] = '';
401
+ } elseif (empty($convertedOptionValues) == false) {
402
+ // Use convert values if any conversions exist
403
+ $column[0] = implode(',', $convertedOptionValues);
404
+ }
405
+ // Otherwise, leave value as-is
406
+ }
407
+
408
+
409
+ if (strpos($export_data_fields_codes, "'" . $attributeCodes[$column[1]] . "'") != false) {
410
+ $product[$attributeCodes[$column[1]]] = $column[0];
411
+ }
412
+ if ($attributeCodes[$column[1]] == 'status') {
413
+ $product_status = $column[0];
414
+ }
415
+ if ($attributeCodes[$column[1]] == 'url_path') {
416
+ $product_url = $column[0];
417
+ }
418
+ if ($attributeCodes[$column[1]] == 'image') {
419
+ $product_image = $column[0];
420
+ }
421
+ }
422
+ $result = null;
423
+
424
+ // Skip product that are disabled or have no status
425
+ if (empty($product_status) || $product_status == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
426
+ continue;
427
+ }
428
+ // Get category information
429
+ $query = '';
430
+ if (substr(Mage::getVersion(), 2, 3) >= 6) {
431
+ $query = "
432
+ SELECT DISTINCT fs.entity_id, fs.path, fs.name
433
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
434
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_" . $this->_storeId . " AS fs
435
+ ON pi.category_id = fs.entity_id
436
+ WHERE pi.product_id = " . $entity[0] . " ORDER BY fs.path ASC
437
+ ";
438
+ } else {
439
+ $query = "
440
+ SELECT pi.category_id, ce.path
441
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
442
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON pi.category_id = ce.entity_id
443
+ WHERE pi.product_id = " . $entity[0] . " AND pi.is_parent = 1 AND pi.store_id = " . $this->_storeId . " ORDER BY ce.path ASC
444
+ ";
445
+ }
446
+ $query = $this->_applyTablePrefix($query);
447
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
448
+ $categoriesTable = $this->_dbConnection->fetchAll($query);
449
+ $product['categories'] = '';
450
+ $categorieField = '';
451
+ $this->oldCatPath = '';
452
+ foreach ($categoriesTable as $categorie) {
453
+ if (($this->oldCatPath == '') || (strpos($categorie[1], $this->oldCatPath) !== 0)) {
454
+ // Start tree
455
+ if ($this->oldCatPath !== '') {
456
+ if ($categorieField !== '') {
457
+ $categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
458
+ } else {
459
+ $categorieField = $this->_allCat[$this->oldCatPath];
460
+ }
461
+ }
462
+ $this->oldCatPath = $categorie[1];
463
+ } else {
464
+ // Add to tree
465
+ $this->oldCatPath = $categorie[1];
466
+ }
467
+ }
468
+ if ($categorieField !== '') {
469
+ $categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
470
+ } else {
471
+ if ($this->oldCatPath !== '') {
472
+ $categorieField = $this->_allCat[$this->oldCatPath];
473
+ }
474
+ }
475
+ $product['categories'] = $categorieField;
476
+
477
+ // Get stock quantity
478
+ // NOTE: stock_id = 1 is the 'Default' stock
479
+ if (strpos($export_data_fields_codes, "'qty'") != false) {
480
+ if (empty($entity[4]) == true) {
481
+ $product['qty'] = '0';
482
+ } else {
483
+ $product['qty'] = $entity[4];
484
+ }
485
+ }
486
+ if (strpos($export_data_fields_codes, "'stock_status'") != false) {
487
+ if (empty($entity[5]) == true) {
488
+ $product['stock_status'] = '';
489
+ } else {
490
+ $product['stock_status'] = $entity[5];
491
+ }
492
+ }
493
+ $stockInfoResult = null;
494
+
495
+ // Get additional image URLs
496
+ $galleryImagePrefix = $this->_dbConnection->quote($this->_mediaUrl . 'catalog/product');
497
+ $query = "
498
+ SELECT
499
+ GROUP_CONCAT(gallery.value_id SEPARATOR ',') AS value_id
500
+ ,GROUP_CONCAT(CONCAT(" . $galleryImagePrefix . ", gallery.value) SEPARATOR ',') AS value
501
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery AS gallery
502
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery_value AS gallery_value
503
+ ON gallery.value_id = gallery_value.value_id
504
+ WHERE gallery_value.store_id IN (" . $this->_storeId . ", 0)
505
+ AND gallery_value.disabled = 0
506
+ AND gallery.entity_id=" . $entity[0] . "
507
+ AND gallery.attribute_id = " . $MEDIA_GALLERY_ATTRIBUTE_ID . "
508
+ ORDER BY gallery_value.position ASC";
509
+ $query = $this->_applyTablePrefix($query);
510
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
511
+ $galleryValues = $this->_dbConnection->fetchAll($query);
512
+ if (empty($galleryValues) != true) {
513
+ $additional_images = explode(',', $galleryValues[0][1]);
514
+ for ($i = 0; $i <= 2; $i++) {
515
+ if (isset($additional_images[$i])) {
516
+ $product['cp_additional_image_' . ($i + 1)] = $additional_images[$i];
517
+ }
518
+ }
519
+ }
520
+
521
+ // Get parent ID
522
+ if (empty($entity[2]) != true && strpos($export_data_fields_codes, "'parent_id'") != false) {
523
+ $product['parent_id'] = $entity[2];
524
+ }
525
+
526
+ // Override price with catalog price rule, if found
527
+ if (empty($entity[6]) != true) {
528
+ // Override price with catalog rule price
529
+ $product['price'] = $entity[6];
530
+ }
531
+
532
+ // Calculate image and product URLs
533
+ if (empty($product_url) == false) {
534
+ $product['cp_product_url'] = $this->_urlPathJoin($this->_webUrl, $product_url);
535
+ }
536
+
537
+ if (empty($product_image) == false) {
538
+ $product['cp_image_url'] = $this->_urlPathJoin($this->_mediaUrl, 'catalog/product');
539
+ $product['cp_image_url'] = $this->_urlPathJoin($product['cp_image_url'], $product_image);
540
+ }
541
+
542
+ if (!empty($replace_fields)) {
543
+ // PARENT
544
+ if ($entity[3] > 0) {
545
+ foreach ($replace_fields as $element) {
546
+ if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
547
+ $parentProductArray[$product['id']][$element['productattribute']] = $product[$element['productattribute']];
548
+ }
549
+ }
550
+ } else {
551
+ // CHILD
552
+ if ($entity[2] != null) {
553
+ foreach ($replace_fields as $element) {
554
+ if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
555
+ $product[$element['productattribute']] = $parentProductArray[$entity[2]][$element['productattribute']];
556
+ }
557
+ }
558
+ }
559
+ }
560
+ }
561
+ if ($entity[3] < 1) {
562
+ foreach ($product as $key => $value) {
563
+ $product[$key] = str_replace('""', '"', $value);
564
+ }
565
+ $this->productId = $product['id'];
566
+ $productData[] = $product;
567
+ }
568
+ }
569
+ return $productData;
570
+ }
571
+
572
+ // Join two URL paths and handle forward slashes
573
+ private function _urlPathJoin($part1, $part2) {
574
+ return rtrim($part1, '/') . '/' . ltrim($part2, '/');
575
+ }
576
+
577
+ private function _applyTablePrefix($query) {
578
+ return str_replace('ChannelPilotSolutions_ChannelPilot_', $this->_tablePrefix, $query);
579
+ }
580
+
581
+ private function buildCategoryTree() {
582
+ // Get category information
583
+ $query = '';
584
+ if (substr(Mage::getVersion(), 2, 3) >= 6) {
585
+ $query = "
586
+ SELECT DISTINCT fs.entity_id, fs.path, fs.name
587
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
588
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_" . $this->_storeId . " AS fs
589
+ ON pi.category_id = fs.entity_id
590
+ ORDER BY fs.path ASC
591
+ ";
592
+ } else {
593
+ $query = "
594
+ SELECT DISTINCT ev.entity_id, ce.path, ev.value
595
+ FROM ChannelPilotSolutions_ChannelPilot_catalog_category_entity_varchar AS ev
596
+ INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON ev.entity_id = ce.entity_id
597
+ WHERE ev.attribute_id = (
598
+ SELECT attribute_id
599
+ FROM ChannelPilotSolutions_ChannelPilot_eav_attribute as att
600
+ WHERE att.entity_type_id = ev.entity_type_id AND att.attribute_code='name'
601
+ )
602
+ ORDER BY ce.path ASC
603
+ ";
604
+ }
605
+ $query = $this->_applyTablePrefix($query);
606
+ $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
607
+
608
+ $categoriesTable = $this->_dbConnection->fetchAll($query);
609
+
610
+ $this->_allCat = array();
611
+ $oldCatPath = 'initialize';
612
+ $oldCatTree = '';
613
+
614
+ foreach ($categoriesTable as $categorie) {
615
+ if (strpos($categorie[1], $oldCatPath) !== 0) {
616
+ // Start tree
617
+ $path = $this->getCategory($categorie[1]);
618
+ if ($path !== 0) {
619
+ $this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $path . '>' . $categorie[2]);
620
+ $oldCatTree = $path . '>' . $categorie[2];
621
+ } else {
622
+ $this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $categorie[2]);
623
+ $oldCatTree = $categorie[2];
624
+ }
625
+ } else {
626
+ // continue tree
627
+ $this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $oldCatTree . '>' . $categorie[2]);
628
+ $oldCatTree = $this->_allCat[$categorie[1]];
629
+ }
630
+ $oldCatPath = $categorie[1];
631
+ }
632
+ }
633
+
634
+ // Rekursive function for category names
635
+ private function getCategory($key) {
636
+ $return = 0;
637
+ if (strpos($key, '/') != false) {
638
+ $tmpKey = substr($key, 0, strpos($key, strrchr($key, '/')));
639
+ if (isset($this->_allCat[$tmpKey])) {
640
+ $return = $this->_allCat[$tmpKey];
641
+ } else {
642
+ $return = $this->getCategory($tmpKey);
643
+ }
644
+ }
645
+ return $return;
646
+ }
647
+
648
+ }
649
+
650
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPNewPriceHandler.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp delivery handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPNewPriceHandler extends CPAbstractHandler {
9
+
10
+ /**
11
+ * Handle delivery hook.
12
+ * @return type
13
+ */
14
+ public function handle() {
15
+
16
+ if (isset($_GET['token']) && self::isIpAllowedViaSecurityToken($_GET['token'])) {
17
+ if (isset($_GET['priceId'])) {
18
+ $merchantId = self::getMerchantId($_GET['token']);
19
+ $api = new ChannelPilotSellerAPI_v1_0($merchantId, $_GET['token']);
20
+ $priceId = $_GET['priceId'];
21
+ $filterFrom = self::getLastPriceUpdate($_GET['token']);
22
+ $method = "all";
23
+ if (isset($filterFrom)) {
24
+ $method = "update";
25
+ }
26
+ $filterArticles = null;
27
+ $result = $api->getDynamicArticlePrices($priceId, $method, $filterArticles, $filterFrom);
28
+ $unknownArticles = array();
29
+ $lastPriceUpdate = null;
30
+
31
+ if (isset($result->managedArticlePrices)) {
32
+ foreach ($result->managedArticlePrices as $articlePrice) {
33
+ $id = $articlePrice->article->id;
34
+ $price = $articlePrice->price;
35
+
36
+ $articleNumber = Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_articlenumber');
37
+ $product = null;
38
+ switch ($articleNumber) {
39
+ case 'product_id':
40
+ $product = Mage::getModel('catalog/product')->load($id);
41
+ break;
42
+
43
+ case 'sku':
44
+ $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $id);
45
+ break;
46
+
47
+ default:
48
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Error by choosing article number '$articleNumber'", "Error by choosing article number '$articleNumber'");
49
+ break;
50
+ }
51
+ if (isset($product['entity_id'])) {
52
+ $field = Mage::getStoreConfig('channelpilot_pricecontrol/general_prices/channelpilot_generalPriceField');
53
+ switch ($field) {
54
+ case 'price':
55
+ $product->setPrice($price);
56
+ break;
57
+ case 'special_price':
58
+ $product->setSpecialPrice($price);
59
+ break;
60
+ case 'minimal_price':
61
+ $product->setMinimalPrice($price);
62
+ break;
63
+ default:
64
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Error by choosing price field '$field'", "Error by choosing price field '$field'");
65
+ break;
66
+ }
67
+ $product->save();
68
+ } else {
69
+ $unknownArticles[] = $id;
70
+ }
71
+ $lastPriceUpdate = $articlePrice->lastUpdate;
72
+ }
73
+ }
74
+
75
+ if (isset($lastPriceUpdate)) {
76
+ $sQuery = "UPDATE " . self::DB_REGISTRATION . " SET last_price_update = '$lastPriceUpdate' WHERE securityToken = '" . $_GET['token'] . "';";
77
+ try {
78
+ $dbWriteConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
79
+ $dbWriteConnection->query($sQuery);
80
+ $dbWriteConnection->closeConnection();
81
+ } catch (Exception $e) {
82
+ $dbWriteConnection->closeConnection();
83
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception during set last_price_update: " . $e->getMessage(), "Exception during set last_price_update: '$sQuery'\n" . $e->getMessage());
84
+ }
85
+ }
86
+ self::hookResult($result->moreAvailable, $unknownArticles);
87
+ } else {
88
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "no priceId set for method: " . $_GET['method'], "no priceId set for method: " . $_GET['method']);
89
+ }
90
+ } else {
91
+ if (empty($_GET['token'])) {
92
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "no token found", "no token found");
93
+ } else {
94
+ CPErrorHandler::handle(CPErrors::RESULT_FAILED, "ip not allowed by token: " . $_GET['token'], "ip not allowed by token: " . $_GET['token']);
95
+ }
96
+ }
97
+ }
98
+
99
+ private function hookResult($moreAvailable, $errorArticles = null) {
100
+ $hook = new CPHookResponse();
101
+ $hook->resultCode = CPResultCodes::SUCCESS;
102
+ $hook->resultMessage = "NEW PRICE HOOK SUCCESS";
103
+ $hook->moreAvailable = $moreAvailable;
104
+ if (empty($errorArticles) || sizeof($errorArticles) == 0) {
105
+ $hook->unknownArticles = null;
106
+ } else {
107
+ $hook->unknownArticles = $errorArticles;
108
+ }
109
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
110
+ }
111
+
112
+ private function getLastPriceUpdate($token) {
113
+ $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
114
+ $sQuery = "SELECT last_price_update FROM " . self::DB_REGISTRATION . " WHERE securityToken = ?;";
115
+ $array = array($token);
116
+ try {
117
+ $sResult = $dbConnection->fetchOne($sQuery, $array);
118
+ $dbConnection->closeConnection();
119
+ if (isset($sResult)) {
120
+ $date = new DateTime($sResult);
121
+ return date_format($date, 'Y-m-d') . "T" . date_format($date, 'H:i:s');
122
+ }
123
+ } catch (Exception $e) {
124
+ $dbConnection->closeConnection();
125
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in getLastPriceUpdate(): " . $e->getMessage(), "Exception in getLastPriceUpdate(): '$sQuery'\n" . print_r($array, true) . "\n" . $e->getMessage());
126
+ }
127
+ return null;
128
+ }
129
+
130
+ }
131
+
132
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPNewsHandler.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp status handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPNewsHandler extends CPAbstractHandler {
9
+
10
+ /**
11
+ * Handle status event
12
+ */
13
+ public function handle() {
14
+ if (isset($_GET['priority']) && isset($_GET['date']) && isset($_GET['title']) && isset($_GET['description']) && isset($_GET['url'])) {
15
+ $message = Mage::getModel('adminnotification/inbox')->parse(array(
16
+ array(
17
+ 'severity' => (int) $_GET['priority'],
18
+ 'date_added' => $_GET['date'],
19
+ 'title' => $_GET['title'],
20
+ 'description' => $_GET['description'],
21
+ 'url' => $_GET['url'],
22
+ 'internal' => true
23
+ )
24
+ ));
25
+ $hook = new CPHookResponse();
26
+ $hook->resultCode = CPResultCodes::SUCCESS;
27
+ $hook->resultMessage = "News received";
28
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
29
+ } else {
30
+ $hook = new CPHookResponse();
31
+ $hook->resultCode = CPResultCodes::SYSTEM_ERROR;
32
+ $hook->resultMessage = "Not enough parameter set";
33
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
34
+ }
35
+ }
36
+
37
+ }
38
+
39
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPOrderHandler.php ADDED
@@ -0,0 +1,476 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp order handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPOrderHandler extends CPAbstractHandler {
9
+
10
+ var $shopId;
11
+ var $store;
12
+ var $websiteId;
13
+ var $dbReadConnection;
14
+ var $dbWriteConnection;
15
+ var $ordersImported;
16
+
17
+ /**
18
+ * Handle order event
19
+ */
20
+ public function handle() {
21
+ $this->ordersImported = array();
22
+ $this->dbReadConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
23
+ $this->dbWriteConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
24
+ if (isset($_GET['token']) && self::isIpAllowedViaSecurityToken($_GET['token'])) {
25
+ self::checkConfig();
26
+ $merchantId = self::getMerchantId($_GET['token'], $this->dbReadConnection);
27
+ try {
28
+ $this->shopId = self::getShopId($_GET['token'], $this->dbReadConnection);
29
+ $this->store = Mage::getModel('core/store')->load($this->shopId);
30
+ $this->websiteId = $this->store->getWebsiteId();
31
+ $oldOrders = self::getOrdersFromDb();
32
+ ini_set('allow_url_fopen', 'On');
33
+ $api = new ChannelPilotSellerAPI_v1_0($merchantId, $_GET['token']);
34
+ $result = $api->getNewMarketplaceOrders();
35
+
36
+ // Check ResultCode of getNewMarketplaceOrders Result
37
+ if ($result->header->resultCode == CPResultCodes::SUCCESS) {
38
+ $moreAvailable = (bool) $result->moreAvailable;
39
+ $orders = self::importOrders($result->orders);
40
+ foreach ($oldOrders as $oldOrder) {
41
+ if (isset($oldOrder) && !in_array($oldOrder->orderHeader->orderId, $this->ordersImported)) {
42
+ $orders[] = $oldOrder;
43
+ }
44
+ }
45
+
46
+ if (sizeof($orders) == 0) {
47
+ $this->closeConnections();
48
+ self::hookResult(false);
49
+ }
50
+ $result = $api->setImportedOrders($orders, true);
51
+ // Check ResultCode of setImportedOrders Result
52
+ if ($result->header->resultCode == CPResultCodes::SUCCESS) {
53
+ self::changeStatusOrders($result->updateResults, $this->dbWriteConnection);
54
+ $this->closeConnections();
55
+ self::hookResult($moreAvailable);
56
+ } else {
57
+ // Result from getNewMarketplaceOrders has no success
58
+ $this->closeConnections();
59
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "request setImportedOrders() resultCode " . $result->header->resultCode, "request setImportedOrders() resultCode " . $result->header->resultCode);
60
+ }
61
+ } else {
62
+ // Result from getNewMarketplaceOrders has no success
63
+ $this->closeConnections();
64
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "request getNewMarketplaceOrders() resultCode " . $result->header->resultCode, "request getNewMarketplaceOrders() resultCode " . $result->header->resultCode);
65
+ }
66
+ } catch (Exception $e) {
67
+ $this->closeConnections();
68
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "caught Exception in getNewMarketplaceOrders(): " . $e->getMessage(), "caught Exception in getNewMarketplaceOrders(): " . $e->getMessage() . "\n" . $e->getTraceAsString());
69
+ }
70
+ } else {
71
+ $this->closeConnections();
72
+ if (empty($_GET['token'])) {
73
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "no token found", "no token found");
74
+ } else {
75
+ CPErrorHandler::handle(CPErrors::RESULT_FAILED, "ip not allowed by token: " . $_GET['token'], "ip not allowed by token: " . $_GET['token']);
76
+ }
77
+ }
78
+ }
79
+
80
+ private function hookResult($moreAvailable) {
81
+ $hook = new CPHookResponse();
82
+ $hook->resultCode = CPResultCodes::SUCCESS;
83
+ $hook->resultMessage = "ORDERS HOOK SUCCESS";
84
+ $hook->moreAvailable = $moreAvailable;
85
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
86
+ }
87
+
88
+ private function importOrders($apiOrders) {
89
+ $orders = array();
90
+ foreach ($apiOrders as $apiOrder) {
91
+ $orders[] = self::importOrder($apiOrder);
92
+ }
93
+ return $orders;
94
+ }
95
+
96
+ private function importOrder($apiOrder) {
97
+ $orderId = self::existOrder($apiOrder->orderHeader->orderIdExternal, $apiOrder->orderHeader->source);
98
+ if (!empty($orderId)) {
99
+ $order = Mage::getModel('sales/order')->load($orderId);
100
+ $apiOrder->orderHeader->orderId = $order->getIncrementId();
101
+ $apiOrder = self::getOrderItems($apiOrder);
102
+ $this->ordersImported[] = $order->getIncrementId();
103
+ return $apiOrder;
104
+ }
105
+ try {
106
+ $quote = Mage::getModel('sales/quote')->setStoreId($this->shopId);
107
+ $customer = self::getCustomer($apiOrder);
108
+ $quote->assignCustomer($customer);
109
+
110
+ foreach ($apiOrder->itemsOrdered as $orderItem) {
111
+ $product = $this->getProduct($orderItem->article->id);
112
+ if ($product->getName() == null) {
113
+ CPErrorHandler::logError("NO ARTICLE FOR IDENTIFIER: " . $orderItem->article->id);
114
+ $apiOrder->orderHeader->status->hasError = true;
115
+ $apiOrder->orderHeader->status->errorMessage = "Unknown article: " . $orderItem->article->id;
116
+ $apiOrder->orderHeader->status->errorCode = CPResultCodes::SHOP_ERROR_ARTICLE_UNKNOWN;
117
+ return $apiOrder;
118
+ }
119
+ $quote->addProduct($product, (int) $orderItem->quantityOrdered);
120
+ }
121
+
122
+ $quote->getBillingAddress()->importCustomerAddress(Mage::getModel('customer/address')->load($customer->getDefaultBilling()));
123
+ $shippingAddress = $quote->getShippingAddress()->importCustomerAddress(Mage::getModel('customer/address')->load($customer->getDefaultShipping()));
124
+ $shippingAddress
125
+ ->setCollectShippingRates(true)
126
+ ->collectShippingRates()
127
+ ->setShippingMethod($apiOrder->shipping->typeId)
128
+ ->setPaymentMethod($apiOrder->payment->typeId);
129
+ $quote->setShippingAddress($shippingAddress);
130
+
131
+ $quote->getPayment()->importData(array('method' => $apiOrder->payment->typeId));
132
+ $quote->collectTotals()->save();
133
+
134
+ $service = Mage::getModel('sales/service_quote', $quote);
135
+ $service->submitAll();
136
+ $order = $service->getOrder();
137
+ $apiOrder->orderHeader->orderId = $order->getIncrementId();
138
+
139
+ $query = "insert into " . self::DB_ORDERS . " (order_id, order_nr, marketplace_order_id, marketplace, shop, status) VALUES (?, ?, ?, ?, ?, ?);";
140
+ $array = array($order->getId(), $order->getIncrementId(), $apiOrder->orderHeader->orderIdExternal, $apiOrder->orderHeader->source, $this->shopId, $apiOrder->orderHeader->status->identifier);
141
+ try {
142
+ $this->dbWriteConnection->query($query, $array);
143
+ } catch (Exception $e) {
144
+ $this->closeConnections();
145
+ Mage::register('isSecureArea', true);
146
+ Mage::app('admin');
147
+ $order->delete();
148
+ CPErrorHandler::logError("Exception during insert into " . self::DB_ORDERS . ": '$query'\n" . print_r($array, true) . "\n" . $e->getMessage() . "\n" . $e->getTraceAsString());
149
+ $apiOrder->orderHeader->status->hasError = true;
150
+ $apiOrder->orderHeader->status->errorMessage = "Exception during insert into " . self::DB_ORDERS . ": " . $e->getMessage();
151
+ $apiOrder->orderHeader->status->errorCode = CPResultCodes::SYSTEM_ERROR;
152
+ return $apiOrder;
153
+ }
154
+
155
+ $items = $order->getAllItems();
156
+ $orderItemsResponse = array();
157
+ try {
158
+ foreach ($items as $item) {
159
+ foreach ($apiOrder->itemsOrdered as $orderItem) {
160
+ if ($orderItem->article->id == $item->getSku()) {
161
+ $item->setPrice($orderItem->costsSingle->net);
162
+ $item->setCustomPrice($orderItem->costsSingle->net);
163
+ $item->setBasePrice($orderItem->costsSingle->net);
164
+ $item->setOriginalCustomPrice($orderItem->costsSingle->net);
165
+ $item->setOriginalPrice($orderItem->costsSingle->net);
166
+ $item->setTaxAmount($orderItem->costsTotal->tax);
167
+ $item->setTaxPercent($orderItem->costsTotal->taxRate);
168
+ $item->setRowTotal($orderItem->costsTotal->net);
169
+ $item->setRowTotalInclTax($orderItem->costsTotal->gross);
170
+ $item->setPriceInclTax($orderItem->costsSingle->gross);
171
+ $item->setBaseOriginalPrice($orderItem->costsSingle->net);
172
+ $item->setBaseRowTotal($orderItem->costsTotal->net);
173
+ $item->setBasePriceInclTax($orderItem->costsSingle->gross);
174
+ $item->setBaseRowTotalInclTax($orderItem->costsTotal->gross);
175
+ $item->save();
176
+ $orderItem->id = $item->getId();
177
+ $orderItemsResponse[] = $orderItem;
178
+
179
+ $query = "insert into " . self::DB_ORDER_ITEMS . " (order_item_id, marketplace_order_item_id, order_id) VALUES (?, ?, ?);";
180
+ $array = array($item->getId(), $orderItem->idExternal, $order->getId());
181
+ $this->dbWriteConnection->query($query, $array);
182
+ }
183
+ }
184
+ }
185
+ } catch (Exception $e) {
186
+ $Dquery = "DELETE FROM " . self::DB_ORDER_ITEMS . " WHERE order_id = '" . $order->getId() . "';";
187
+ $this->dbWriteConnection->query($Dquery);
188
+ $Dquery = "DELETE FROM " . self::DB_ORDERS . " WHERE order_id = '" . $order->getId() . "';";
189
+ $this->dbWriteConnection->query($Dquery);
190
+ Mage::register('isSecureArea', true);
191
+ Mage::app('admin');
192
+ $order->delete();
193
+ $this->closeConnections();
194
+ CPErrorHandler::logError("Exception during insert into " . self::DB_ORDER_ITEMS . ": '$query'\n" . print_r($array, true) . "\n" . $e->getMessage() . "\n" . $e->getTraceAsString());
195
+ $apiOrder->orderHeader->status->hasError = true;
196
+ $apiOrder->orderHeader->status->errorMessage = "Exception during insert into " . self::DB_ORDER_ITEMS . ": " . $e->getMessage();
197
+ $apiOrder->orderHeader->status->errorCode = CPResultCodes::SYSTEM_ERROR;
198
+ return $apiOrder;
199
+ }
200
+ $apiOrder->itemsOrdered = $orderItemsResponse;
201
+ $order->setBaseSubtotal($apiOrder->summary->totalSumItems->net);
202
+ $order->setBaseTaxAmount($apiOrder->summary->totalSumItems->tax);
203
+ // $order->setBaseDiscountAmount(...);
204
+ $order->setBaseShippingAmount($apiOrder->shipping->costs->gross);
205
+ $order->setBaseGrandTotal($apiOrder->summary->totalSumOrder->gross);
206
+
207
+ $order->setSubtotal($apiOrder->summary->totalSumItems->net);
208
+ $order->setTaxAmount($apiOrder->summary->totalSumItems->tax);
209
+ // $order->setDiscountAmount(...);
210
+ $order->setShippingAmount($apiOrder->shipping->costs->gross);
211
+ $order->setGrandTotal($apiOrder->summary->totalSumOrder->gross);
212
+
213
+ $order->setCreatedAt($apiOrder->orderHeader->orderTime);
214
+
215
+ $order->setBaseCurrencyCode($apiOrder->summary->currencyIso3);
216
+ $order->setQuoteCurrencyCode($apiOrder->summary->currencyIso3);
217
+
218
+ // $order->setData('state', Mage_Sales_Model_Order::STATE_COMPLETE);
219
+ $order->save();
220
+ } catch (Exception $e) {
221
+ CPErrorHandler::logError("Exception during importOrder: " . $e->getMessage() . "\n" . $e->getTraceAsString());
222
+ $apiOrder->orderHeader->status->hasError = true;
223
+ $apiOrder->orderHeader->status->errorMessage = "Exception during importOrder: " . $e->getMessage();
224
+ $apiOrder->orderHeader->status->errorCode = CPResultCodes::SYSTEM_ERROR;
225
+ }
226
+ //$this->ordersImported[] = $order->getIncrementId();
227
+ return $apiOrder;
228
+ }
229
+
230
+ /**
231
+ *
232
+ * @param type $id
233
+ */
234
+ private function getProduct($id) {
235
+ $selectedArticleId = Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_articlenumber');
236
+ $product = null;
237
+ switch ($selectedArticleId) {
238
+ case "product_id":
239
+ $product = Mage::getModel('catalog/product')->load($id);
240
+ break;
241
+ case "sku":
242
+ $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $id);
243
+ $product = Mage::getModel('catalog/product')->load($product->getId());
244
+ break;
245
+ default:
246
+ break;
247
+ }
248
+ return $product;
249
+ }
250
+
251
+ private function getCustomer($apiOrder) {
252
+ $customer = Mage::getModel('customer/customer')
253
+ ->setWebsiteId($this->websiteId)
254
+ ->loadByEmail($apiOrder->customer->email);
255
+ if ($customer->getId() == null) {
256
+ $customer = Mage::getModel("customer/customer");
257
+ $customer->website_id = $this->websiteId;
258
+ $incrementId = Mage::getSingleton('eav/config')
259
+ ->getEntityType('customer')
260
+ ->fetchNewIncrementId($customer->getStoreId());
261
+ $customer->setIncrementId($incrementId);
262
+ $customer->setStore($this->store);
263
+ $customer->firstname = $apiOrder->customer->nameFirst;
264
+ $customer->lastname = $apiOrder->customer->nameLast;
265
+ $customer->email = $apiOrder->customer->email;
266
+ foreach ($apiOrder->customer->customerGroups as $userGroup) {
267
+ $customer->setData('group_id', $userGroup->id);
268
+ }
269
+ if ($apiOrder->addressInvoice->genderId == 1) {
270
+ $customer->setGender(
271
+ Mage::getResourceModel('customer/customer')
272
+ ->getAttribute('gender')
273
+ ->getSource()
274
+ ->getOptionId('Male')
275
+ );
276
+ } else {
277
+ if ($apiOrder->addressInvoice->genderId == 2) {
278
+ $customer->setGender(
279
+ Mage::getResourceModel('customer/customer')
280
+ ->getAttribute('gender')
281
+ ->getSource()
282
+ ->getOptionId('Female')
283
+ );
284
+ }
285
+ }
286
+ $customer->setCreatedAt($apiOrder->orderHeader->orderTime);
287
+ $customer->save();
288
+
289
+ $shippingAddress = Mage::getModel('customer/address');
290
+ $shippingAddress->setCustomerId($customer->getId());
291
+ $shippingAddress->setFirstname($apiOrder->addressDelivery->nameFirst);
292
+ $shippingAddress->setLastname($apiOrder->addressDelivery->nameLast);
293
+ $shippingAddress->setCountryId($apiOrder->addressDelivery->countryIso2);
294
+ $shippingAddress->setStreet($apiOrder->addressDelivery->streetTitle . ' ' . $apiOrder->addressDelivery->streetNumber);
295
+ $shippingAddress->setPostcode($apiOrder->addressDelivery->zip);
296
+ $shippingAddress->setCity($apiOrder->addressDelivery->city);
297
+ $shippingRegion = Mage::getModel('directory/region')->loadByName($apiOrder->addressDelivery->state, $apiOrder->addressDelivery->countryIso2);
298
+ $shippingAddress->setRegion($shippingRegion->getName());
299
+ $shippingAddress->setRegionId($shippingRegion->getId());
300
+ $shippingAddress->setCompany($apiOrder->addressDelivery->company);
301
+ $shippingAddress->setTelephone(empty($apiOrder->addressDelivery->phone) ? "0000000000" : $apiOrder->addressDelivery->phone);
302
+ $shippingAddress->setIsDefaultShipping(true);
303
+ $shippingAddress->save();
304
+ $customer->setDefaultShipping($shippingAddress->getId());
305
+ $customer->addAddress($shippingAddress);
306
+
307
+ $billingAddress = Mage::getModel('customer/address');
308
+ $billingAddress->setCustomerId($customer->getId());
309
+ $billingAddress->setFirstname($apiOrder->addressInvoice->nameFirst);
310
+ $billingAddress->setLastname($apiOrder->addressInvoice->nameLast);
311
+ $billingAddress->setCountryId($apiOrder->addressInvoice->countryIso2);
312
+ $billingAddress->setStreet($apiOrder->addressInvoice->streetTitle . ' ' . $apiOrder->addressInvoice->streetNumber);
313
+ $billingAddress->setPostcode($apiOrder->addressInvoice->zip);
314
+ $billingAddress->setCity($apiOrder->addressInvoice->city);
315
+ $billingRegion = Mage::getModel('directory/region')->loadByName($apiOrder->addressInvoice->state, $apiOrder->addressInvoice->countryIso2);
316
+ $billingAddress->setRegion($billingRegion->getName());
317
+ $billingAddress->setRegionId($billingRegion->getId());
318
+ $billingAddress->setCompany($apiOrder->addressInvoice->company);
319
+ $billingAddress->setTelephone($apiOrder->addressInvoice->phone);
320
+ $billingAddress->setIsDefaultBilling(true);
321
+ $billingAddress->save();
322
+
323
+ $customer->setDefaultBilling($billingAddress->getId());
324
+ $customer->addAddress($billingAddress);
325
+ } else {
326
+ $customer->firstname = $apiOrder->customer->nameFirst;
327
+ $customer->lastname = $apiOrder->customer->nameLast;
328
+ foreach ($apiOrder->customer->customerGroups as $userGroup) {
329
+ $customer->setData('group_id', $userGroup->id);
330
+ }
331
+ if ($apiOrder->addressInvoice->genderId == 1) {
332
+ $customer->setGender(
333
+ Mage::getResourceModel('customer/customer')
334
+ ->getAttribute('gender')
335
+ ->getSource()
336
+ ->getOptionId('Male')
337
+ );
338
+ } else {
339
+ if ($apiOrder->addressInvoice->genderId == 2) {
340
+ $customer->setGender(
341
+ Mage::getResourceModel('customer/customer')
342
+ ->getAttribute('gender')
343
+ ->getSource()
344
+ ->getOptionId('Female')
345
+ );
346
+ }
347
+ }
348
+ $customer->save();
349
+
350
+ $shippingAddress = Mage::getModel('customer/address')->load($customer->getDefaultShipping());
351
+ $shippingAddress->setCustomerId($customer->getId());
352
+ $shippingAddress->setFirstname($apiOrder->addressDelivery->nameFirst);
353
+ $shippingAddress->setLastname($apiOrder->addressDelivery->nameLast);
354
+ $shippingAddress->setCountryId($apiOrder->addressDelivery->countryIso2);
355
+ $shippingAddress->setStreet($apiOrder->addressDelivery->streetTitle . ' ' . $apiOrder->addressDelivery->streetNumber);
356
+ $shippingAddress->setPostcode($apiOrder->addressDelivery->zip);
357
+ $shippingAddress->setCity($apiOrder->addressDelivery->city);
358
+ $shippingRegion = Mage::getModel('directory/region')->loadByName($apiOrder->addressDelivery->state, $apiOrder->addressDelivery->countryIso2);
359
+ $shippingAddress->setRegion($shippingRegion->getName());
360
+ $shippingAddress->setRegionId($shippingRegion->getId());
361
+ $shippingAddress->setCompany($apiOrder->addressDelivery->company);
362
+ $shippingAddress->setTelephone(empty($apiOrder->addressDelivery->phone) ? "0000000000" : $apiOrder->addressDelivery->phone);
363
+ $shippingAddress->setIsDefaultShipping(true);
364
+ $shippingAddress->save();
365
+
366
+ $billingAddress = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
367
+ $billingAddress->setCustomerId($customer->getId());
368
+ $billingAddress->setFirstname($apiOrder->addressInvoice->nameFirst);
369
+ $billingAddress->setLastname($apiOrder->addressInvoice->nameLast);
370
+ $billingAddress->setCountryId($apiOrder->addressInvoice->countryIso2);
371
+ $billingAddress->setStreet($apiOrder->addressInvoice->streetTitle . ' ' . $apiOrder->addressInvoice->streetNumber);
372
+ $billingAddress->setPostcode($apiOrder->addressInvoice->zip);
373
+ $billingAddress->setCity($apiOrder->addressInvoice->city);
374
+ $billingRegion = Mage::getModel('directory/region')->loadByName($apiOrder->addressInvoice->state, $apiOrder->addressInvoice->countryIso2);
375
+ $billingAddress->setRegion($billingRegion->getName());
376
+ $billingAddress->setRegionId($billingRegion->getId());
377
+ $billingAddress->setCompany($apiOrder->addressInvoice->company);
378
+ $billingAddress->setTelephone($apiOrder->addressInvoice->phone);
379
+ $billingAddress->setIsDefaultBilling(true);
380
+ $billingAddress->save();
381
+ }
382
+ return $customer;
383
+ }
384
+
385
+ /**
386
+ *
387
+ * @param type $apiOrder
388
+ * @return boolean
389
+ */
390
+ private function getOrderItems($apiOrder) {
391
+ $dbOrderItems = array();
392
+ $query = "SELECT cp_items.order_item_id, cp_items.marketplace_order_item_id
393
+ FROM " . self::DB_ORDER_ITEMS . " cp_items
394
+ LEFT JOIN " . self::DB_ORDERS . " cp_orders ON cp_orders.order_id = cp_items.order_id
395
+ WHERE cp_orders.marketplace_order_id = ? AND cp_orders.marketplace = ?";
396
+ $array = array($apiOrder->orderHeader->orderIdExternal, $apiOrder->orderHeader->source);
397
+ $sResult = $this->dbReadConnection->fetchAll($query, $array);
398
+ foreach ($sResult AS $resultType) {
399
+ $dbOrderItems[$resultType['marketplace_order_item_id']] = $resultType['order_item_id'];
400
+ }
401
+ $orderItemsResponse = array();
402
+
403
+ foreach ($apiOrder->itemsOrdered as $orderItem) {
404
+ if (empty($dbOrderItems[$orderItem->idExternal])) {
405
+ $apiOrder->orderHeader->status->hasError = true;
406
+ $apiOrder->orderHeader->status->errorMessage = "Can't find order article " . $orderItem->article->id . " from EXISTING order: " . $apiOrder->orderHeader->orderId;
407
+ $apiOrder->orderHeader->status->errorCode = CPResultCodes::SHOP_ERROR_ARTICLE_UNKNOWN_EXISTING_ORDER;
408
+ return $apiOrder;
409
+ } else {
410
+ $orderItem->id = $dbOrderItems[$orderItem->idExternal];
411
+ $orderItemsResponse[] = $orderItem;
412
+ }
413
+ }
414
+ $apiOrder->itemsOrdered = $orderItemsResponse;
415
+ return $apiOrder;
416
+ }
417
+
418
+ private function existOrder($externalOrderId, $source) {
419
+ $query = "SELECT order_id FROM " . self::DB_ORDERS . " WHERE marketplace_order_id = ? AND marketplace = ?;";
420
+ $array = array($externalOrderId, $source);
421
+ $sResult = $this->dbReadConnection->fetchOne($query, $array);
422
+ return $sResult;
423
+ }
424
+
425
+ private function deleteCPOrder($orderId) {
426
+ $query = "DELETE FROM " . self::DB_ORDER_ITEMS . " WHERE order_id = '$orderId';";
427
+ $this->dbWriteConnection->query($query);
428
+ $query = "DELETE FROM " . self::DB_ORDERS . " WHERE order_id = '$orderId';";
429
+ $this->dbWriteConnection->query($query);
430
+ }
431
+
432
+ private function getOrdersFromDb() {
433
+ $orders = array();
434
+
435
+ $query = "SELECT cp_orders.order_nr AS orderId, cp_orders.marketplace_order_id AS externalOrderId,
436
+ cp_orders.marketplace AS source, cp_items.order_item_id AS orderItemId,
437
+ cp_items.marketplace_order_item_id AS externalOrderItemId, cp_orders.status
438
+ FROM " . self::DB_ORDER_ITEMS . " cp_items
439
+ LEFT JOIN " . self::DB_ORDERS . " cp_orders ON cp_orders.order_id = cp_items.order_id
440
+ WHERE cp_orders.status = '" . CPOrderStatus::ID_READY_FOR_EXPORT . "' AND cp_orders.shop = $this->shopId
441
+ ORDER BY cp_orders.order_nr";
442
+ try {
443
+ $sResult = $this->dbReadConnection->fetchAll($query);
444
+ if (!empty($sResult)) {
445
+ $order = null;
446
+ $orderId = null;
447
+ foreach ($sResult AS $resultType) {
448
+ if (empty($orderId) || $orderId != $resultType['orderId']) {
449
+ if (!empty($orderId)) {
450
+ $orders[] = $order;
451
+ self::logError("save order");
452
+ }
453
+ $order = new CPOrder();
454
+ $order->orderHeader = new CPOrderHeader($resultType['externalOrderId'], $resultType['orderId'], $resultType['source'], $resultType['status'], null, false);
455
+ $orderId = $resultType['orderId'];
456
+ }
457
+ $item = new CPOrderItem();
458
+ $item->id = $resultType['orderItemId'];
459
+ $item->idExternal = $resultType['externalOrderItemId'];
460
+ $order->itemsOrdered[] = $item;
461
+ }
462
+ $orders[] = $order;
463
+ }
464
+ return $orders;
465
+ } catch (Exception $e) {
466
+ $this->closeConnections();
467
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in getOrdersFromDb(): " . $e->getMessage(), "Exception in getOrdersFromDb(): '$query'\n" . print_r($array, true) . "\n" . $e->getMessage());
468
+ }
469
+ }
470
+
471
+ private function closeConnections() {
472
+ $this->dbReadConnection->closeConnection();
473
+ $this->dbWriteConnection->closeConnection();
474
+ }
475
+
476
+ }
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPRegisterHandler.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp register handler
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPRegisterHandler extends CPAbstractHandler {
9
+
10
+ /**
11
+ * Handle register event
12
+ */
13
+ public function handle() {
14
+
15
+ $dbReadConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
16
+
17
+ self::checkConfig();
18
+ $new = false;
19
+
20
+ if (self::allRequiredParameterSet()) {
21
+ if (self::existShop($_GET['multishopid'])) {
22
+ if (self::isShopRegistered($_GET['multishopid'], $dbReadConnection)) {
23
+ if (self::isIpAllowedViaShopId($_GET['multishopid'], $dbReadConnection)) {
24
+ if (self::reRegisterParameterSet(true) == true) {
25
+ $array = array($_GET['ips'], $_GET['merchantid'], $_GET['token'], $_GET['multishopid']);
26
+ $sQuery = "update " . self::DB_REGISTRATION . " set ips_authorized = ?, merchantid = ?, securityToken = ?, last_stock_update = null, last_price_update=null, last_catalog_update = null WHERE shopId = ?";
27
+ try {
28
+ $dbWriteConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
29
+ $dbWriteConnection->query($sQuery, $array);
30
+ $new = false;
31
+ $dbWriteConnection->closeConnection();
32
+ } catch (Exception $e) {
33
+ $dbReadConnection->closeConnection();
34
+ $dbWriteConnection->closeConnection();
35
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception during reregister Shop: " . $e->getMessage(), "Exception during reregister Shop: '$sQuery'\n" . print_r($array, true) . "\n" . $e->getMessage());
36
+ }
37
+ } else {
38
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Shop '" . $_GET['multishopid'] . "' not registered", "Shop '" . $_GET['multishopid'] . "' not registered");
39
+ }
40
+ } else {
41
+ if (empty($_GET['token'])) {
42
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "no token found", "no token found");
43
+ } else {
44
+ CPErrorHandler::handle(CPErrors::RESULT_FAILED, "ip not allowed by token: " . $_GET['token'], "ip not allowed by token: " . $_GET['token']);
45
+ }
46
+ }
47
+ } else {
48
+ if (self::reRegisterParameterSet(false) == false) {
49
+ $array = array($_GET['multishopid'], $_GET['ips'], $_GET['merchantid'], $_GET['token']);
50
+ $sQuery = "insert into " . self::DB_REGISTRATION . " (shopId, ips_authorized, merchantid, securityToken) VALUES (?, ?, ?, ?)";
51
+ try {
52
+ $dbWriteConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
53
+ $dbWriteConnection->query($sQuery, $array);
54
+ $new = true;
55
+ $dbWriteConnection->closeConnection();
56
+ } catch (Exception $e) {
57
+ $dbReadConnection->closeConnection();
58
+ $dbWriteConnection->closeConnection();
59
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception during register Shop: " . $e->getMessage(), "Exception during register Shop: '$sQuery'\n" . print_r($array, true) . "\n" . $e->getMessage());
60
+ }
61
+ } else {
62
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Shop '" . $_GET['multishopid'] . "' already not registered", "Shop '" . $_GET['multishopid'] . "' already not registered");
63
+ }
64
+ }
65
+ }
66
+ }
67
+ $dbReadConnection->closeConnection();
68
+
69
+ $hook = new CPRegisterHookResponse();
70
+ $hook->ipsAllowed = $_SERVER['SERVER_ADDR'];
71
+ $hook->resultCode = CPResultCodes::SUCCESS;
72
+ if ($new == true) {
73
+ $hook->resultMessage = "Shop registered";
74
+ } else {
75
+ $hook->resultMessage = "Shop reregistered";
76
+ }
77
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @return true or error response
83
+ */
84
+ public function allRequiredParameterSet() {
85
+ if (isset($_GET['multishopid']) && isset($_GET['merchantid']) && isset($_GET['token']) && isset($_GET['ips'])) {
86
+ return true;
87
+ }
88
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "not enough parameter for method: " . $_GET['method'], "not enough parameter for method: " . $_GET['method']);
89
+ }
90
+
91
+ /**
92
+ *
93
+ * @param type $registered
94
+ * @return boolean or error response
95
+ */
96
+ public function reRegisterParameterSet($registered) {
97
+ if (isset($_GET['reregistration']) && $_GET['reregistration'] == 'true') {
98
+ return true;
99
+ } else {
100
+ if ($registered == true) {
101
+ CPErrorHandler::handle(CPErrors::RESULT_ALREADY_REGISTERED, "shop already registered", "shop '" . $_GET['multishopid'] . "' already registered");
102
+ }
103
+ return false;
104
+ }
105
+ }
106
+
107
+ /**
108
+ *
109
+ * @param type $shopId
110
+ * @return boolean
111
+ */
112
+ public function existShop($shopId) {
113
+ $allStores = Mage::app()->getStores();
114
+ foreach ($allStores as $_eachStoreId => $val) {
115
+ if (Mage::app()->getStore($_eachStoreId)->getId() == $shopId) {
116
+ return true;
117
+ }
118
+ }
119
+ CPErrorHandler::handle(CPErrors::RESULT_SHOP_UNKNOWN, "shop '" . $shopId . "' unknown", "shop '" . $shopId . "' unknown");
120
+ }
121
+
122
+ }
123
+
124
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPStatusHandler.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp shop
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPShop {
9
+
10
+ public $title;
11
+ public $id;
12
+ public $active;
13
+ public $isRegistered;
14
+ public $deliveryTypes;
15
+ public $paymentTypes;
16
+
17
+ }
18
+
19
+ /**
20
+ * an cp payment type
21
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
22
+ * @version 1.0
23
+ */
24
+ class CPPaymentType {
25
+ public $title;
26
+ public $id;
27
+ public $active;
28
+
29
+ }
30
+
31
+ /**
32
+ * an cp customer group type
33
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
34
+ * @version 1.0
35
+ */
36
+ class CPCustomerGroupType {
37
+
38
+ public $title;
39
+ public $id;
40
+ public $active;
41
+
42
+ }
43
+
44
+ /**
45
+ * an cp delivery type
46
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
47
+ * @version 1.0
48
+ */
49
+ class CPDeliveryType {
50
+
51
+ public $title;
52
+ public $id;
53
+ public $active;
54
+
55
+ }
56
+
57
+ /**
58
+ * an cp status handler
59
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
60
+ * @version 1.0
61
+ */
62
+ class CPStatusHandler extends CPAbstractHandler {
63
+
64
+ /**
65
+ * Handle status event
66
+ */
67
+ public function handle() {
68
+ $hook = new CPGetStatusHookResponse();
69
+ $hook->shops = self::getShops();
70
+ $hook->resultCode = CPResultCodes::SUCCESS;
71
+ $hook->resultMessage = "ok";
72
+ $hook->writeResponse(self::defaultHeader, json_encode($hook));
73
+ }
74
+
75
+ private function getShops() {
76
+ $allStores = Mage::app()->getStores();
77
+ $shops = array();
78
+ foreach ($allStores as $_eachStoreId => $val) {
79
+ $shop = new CPShop();
80
+ $shop->id = Mage::app()->getStore($_eachStoreId)->getId();
81
+ $shop->title = Mage::app()->getStore($_eachStoreId)->getName();
82
+ $shop->active = (bool) Mage::app()->getStore()->getIsActive();
83
+ $shop->isRegistered = self::isShopRegistered($shop->id);
84
+ $shop->deliveryTypes = self::getDeliveryTypes($shop->id);
85
+ $shop->paymentTypes = self::getPaymentTypes($shop->id);
86
+ $shop->customerGroups = self::getCustomerGroups();
87
+ $shops[] = $shop;
88
+ }
89
+ return $shops;
90
+ }
91
+
92
+ private function getDeliveryTypes($shopId) {
93
+ $carriers = Mage::getStoreConfig('carriers', $shopId);
94
+ $methods = Mage::getSingleton('shipping/config')->getActiveCarriers($shopId);
95
+ $deliveryTypes = array();
96
+ foreach ($methods as $_ccode => $_carrier) {
97
+ if ($carrierMethods = $_carrier->getAllowedMethods()) {
98
+ if (!$_title = Mage::getStoreConfig("carriers/$_ccode/title", $shopId)){
99
+ $_title = $_ccode;
100
+ }
101
+ foreach ($carrierMethods as $_mcode => $_method) {
102
+ $_code = $_ccode . '_' . $_mcode;
103
+ $deliveryType = new CPDeliveryType();
104
+ $deliveryType->id = $_code;
105
+ $deliveryType->title = $_title . ' - ' . $_method;
106
+ $deliveryType->active = (bool) $carriers[$_ccode]['active'];
107
+ $deliveryTypes[] = $deliveryType;
108
+ }
109
+ }
110
+ }
111
+ return $deliveryTypes;
112
+ }
113
+
114
+ private function getPaymentTypes($shopId) {
115
+ $paymentTypes = array();
116
+ $payments = Mage::getSingleton('payment/config')->getActiveMethods();
117
+ foreach ($payments as $paymentCode => $paymentModel) {
118
+ $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title', $shopId);
119
+ $paymentType = new CPPaymentType();
120
+ $paymentType->id = $paymentCode;
121
+ if (empty($paymentTitle)) {
122
+ $paymentType->title = $paymentCode;
123
+ } else {
124
+ $paymentType->title = $paymentTitle;
125
+ }
126
+ $status = $paymentModel->canUseCheckout();
127
+ if ($status == 1 && $paymentCode != 'free') {
128
+ $paymentType->active = true;
129
+ } else {
130
+ $paymentType->active = false;
131
+ }
132
+ $paymentTypes[] = $paymentType;
133
+ }
134
+ return $paymentTypes;
135
+ }
136
+
137
+ private function getCustomerGroups() {
138
+ $customerGroups = array();
139
+ $sQuery = "SELECT customer_group_id, customer_group_code FROM `customer_group`";
140
+ $dbConnection = null;
141
+ try {
142
+ $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
143
+ $sResult = $dbConnection->fetchAll($sQuery);
144
+ foreach ($sResult AS $resultType) {
145
+ $customerGroup = new CPCustomerGroupType();
146
+ $customerGroup->id = $resultType['customer_group_id'];
147
+ $customerGroup->title = $resultType['customer_group_code'];
148
+ $customerGroup->active = true;
149
+ $customerGroups[] = $customerGroup;
150
+ }
151
+ $dbConnection->closeConnection();
152
+ } catch (Exception $e) {
153
+ $dbConnection->closeConnection();
154
+ CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception during register Shop: " . $e->getMessage(), "Exception during register Shop: '$sQuery'\n" . $e->getMessage());
155
+ }
156
+ return $customerGroups;
157
+ }
158
+
159
+ }
160
+
161
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/todoCPPaymentHandler.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * an cp payment handler
6
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
7
+ * @version 1.0
8
+ */
9
+ class CPPaymentHandler extends CPAbstractHandler {
10
+
11
+ }
12
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/responses/CPGetStatusHookResponse.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp status hook response
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPGetStatusHookResponse extends CPHookResponse {
9
+ public $shops;
10
+ }
11
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/responses/CPHookResponse.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp hook response
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPHookResponse {
9
+
10
+ public $resultCode;
11
+ public $resultMessage;
12
+ public $signaturePlugin;
13
+ public $signatureShop;
14
+ public $signaturePhp;
15
+ public $moreAvailable;
16
+ public $apiResultCode;
17
+ public static $dbConnection;
18
+
19
+ const shopsystem = 'Magento_';
20
+
21
+ function __construct() {
22
+ Mage::app('admin');
23
+
24
+ $this->signaturePlugin = self::getModuleVersion();
25
+ $this->signatureShop = self::getSignatureShop();
26
+ $this->signaturePhp = phpversion();
27
+ }
28
+
29
+ // Apply prefix to table names in the query
30
+ private static function _applyTablePrefix($query, $tablePrefix)
31
+ {
32
+ return str_replace('ChannelPilotSolutions_ChannelPilot_', $tablePrefix, $query);
33
+ }
34
+
35
+ public static function getSignatureShop() {
36
+ $signature = 'Magento_';
37
+ $mage = new Mage();
38
+ if(method_exists($mage,'getEdition')){
39
+ $signature .= Mage::getEdition() . '_';
40
+ }
41
+ if(method_exists($mage,'getVersion')){
42
+ $signature .= Mage::getVersion();
43
+ }
44
+ return $signature;
45
+ }
46
+
47
+ public static function getModuleVersion(){
48
+ $dbConnection = Mage::getSingleton('core/resource') ->getConnection('core_read');
49
+ $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
50
+ $tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
51
+ $query = "SELECT version FROM ChannelPilotSolutions_ChannelPilot_core_resource WHERE code = 'channelpilot_setup'";
52
+ $query = self::_applyTablePrefix($query, $tablePrefix);
53
+ $version = $dbConnection->fetchOne($query);
54
+ return self::shopsystem . $version;
55
+ }
56
+
57
+ public function writeResponse($header, $response) {
58
+ header($header);
59
+ print_r($response);
60
+ exit();
61
+ }
62
+
63
+ }
64
+
65
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/responses/CPRegisterHookResponse.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * an cp register hook response
5
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
6
+ * @version 1.0
7
+ */
8
+ class CPRegisterHookResponse extends CPHookResponse {
9
+
10
+ public $ipsAllowed;
11
+
12
+ }
13
+
14
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/special/CustomerFunctions.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * special customer functions
4
+ * @author Channel Pilot Solutions GmbH <api@channelpilot.com>
5
+ * @version 1.0
6
+ */
7
+ class CustomerFunctions {
8
+
9
+ public static function insertOrder($oOrder, $apiOrder){
10
+ $oOrder->oxorder__oxbillemail->value = str_replace("@","[at]",$apiOrder->customer->email);
11
+ return $oOrder;
12
+ }
13
+
14
+ public static function insertOrUpdateUser($oUser, $apiOrder){
15
+ $oUser->oxuser__oxusername->value = str_replace("@","[at]",$apiOrder->customer->email);
16
+ return $oUser;
17
+ }
18
+
19
+ public static function getUserName($userName){
20
+ return str_replace("@","[at]",$userName);
21
+ }
22
+
23
+ }
24
+ ?>
app/code/community/Channelpilotsolutions/Channelpilot/controllers/IndexController.php CHANGED
@@ -1,33 +1,37 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Channelpilot
17
- * @subpackage controllers
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- class Channelpilotsolutions_Channelpilot_IndexController extends Mage_Core_Controller_Front_Action {
24
-
25
- public function indexAction() {
26
- if(Mage::helper('channelpilot')->checkPassword()){
27
- Mage::helper('channelpilot')->createXml();
28
- } else {
29
- echo "Unauthorized";
30
- }
31
- }
32
- }
 
 
 
 
33
  ?>
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the GNU General Public License (GPL 3)
8
+ * that is bundled with this package in the file LICENSE.txt
9
+ *
10
+ * DISCLAIMER
11
+ *
12
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
13
+ * versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
14
+ * needs please refer to http://www.channelpilot.com for more information.
15
+ *
16
+ * @category Channelpilotsolutions
17
+ * @package Channelpilotsolutions_Channelpilot
18
+ * @subpackage controllers
19
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
20
+ * @author Peter Hoffmann <info@channelpilot.com>
21
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
22
+ * @link http://www.channelpilot.com
23
+ */
24
+ class Channelpilotsolutions_Channelpilot_IndexController extends Mage_Core_Controller_Front_Action {
25
+
26
+ public function indexAction() {
27
+ if (isset($_GET['method'])) {
28
+ Mage::helper('channelpilot')->api();
29
+ } else {
30
+ Mage::helper('channelpilot')->createXml();
31
+ }
32
+ $this->getResponse()->setRedirect(Mage::app()->getStore()->getBaseUrl());
33
+ }
34
+
35
+ }
36
+
37
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/etc/adminhtml.xml CHANGED
@@ -30,10 +30,26 @@
30
  <children>
31
  <config>
32
  <children>
33
- <channelpilot_section translate="title" module="channelpilot">
34
- <title>channelpilot_section Section</title>
35
  <sort_order>100</sort_order>
36
- </channelpilot_section>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  </children>
38
  </config>
39
  </children>
30
  <children>
31
  <config>
32
  <children>
33
+ <channelpilot_general translate="title" module="channelpilot">
34
+ <title>channelpilot_general Section</title>
35
  <sort_order>100</sort_order>
36
+ </channelpilot_general>
37
+ <channelpilot_tracking translate="title" module="channelpilot">
38
+ <title>channelpilot_tracking Section</title>
39
+ <sort_order>200</sort_order>
40
+ </channelpilot_tracking>
41
+ <channelpilot_export translate="title" module="channelpilot">
42
+ <title>channelpilot_export Section</title>
43
+ <sort_order>300</sort_order>
44
+ </channelpilot_export>
45
+ <channelpilot_marketplace translate="title" module="channelpilot">
46
+ <title>channelpilot_marketplace Section</title>
47
+ <sort_order>400</sort_order>
48
+ </channelpilot_marketplace>
49
+ <channelpilot_pricecontrol translate="title" module="channelpilot">
50
+ <title>channelpilot_pricecontrol Section</title>
51
+ <sort_order>500</sort_order>
52
+ </channelpilot_pricecontrol>
53
  </children>
54
  </config>
55
  </children>
app/code/community/Channelpilotsolutions/Channelpilot/etc/config.xml CHANGED
@@ -24,53 +24,79 @@
24
  <config>
25
  <modules>
26
  <Channelpilotsolutions_Channelpilot>
27
- <version>1.0.0</version>
28
  </Channelpilotsolutions_Channelpilot>
29
  </modules>
30
  <global>
31
- <helpers>
32
- <channelpilot>
33
- <class>Channelpilotsolutions_Channelpilot_Helper</class>
34
- </channelpilot>
35
- </helpers>
36
- <models>
37
  <channelpilot_adminhtml>
38
  <class>Channelpilotsolutions_Channelpilot_Adminhtml_Model</class>
39
  </channelpilot_adminhtml>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  </models>
41
- <resources>
 
 
 
 
 
42
  <channelpilot_setup>
43
  <setup>
44
  <module>Channelpilotsolutions_Channelpilot</module>
45
  </setup>
46
  <connection>
 
47
  <use>core_setup</use>
48
  </connection>
49
  </channelpilot_setup>
50
- <channelpilot_write>
51
- <connection>
52
- <use>core_write</use>
53
- </connection>
54
- </channelpilot_write>
55
- <channelpilot_read>
56
- <connection>
57
- <use>core_read</use>
58
- </connection>
59
- </channelpilot_read>
60
  </resources>
61
- <extraconfig />
62
- <blocks>
63
  <channelpilot_core>
64
- <class>Channelpilotsolutions_Channelpilot_Block</class>
65
- </channelpilot_core>
66
  </blocks>
 
 
 
 
 
67
  </global>
68
  <adminhtml>
69
  <translate>
70
  <modules>
71
  <Channelpilotsolutions_Channelpilot>
72
  <files>
73
- <default>ChannelPilotSolutions_ChannelPilot.csv</default>
74
  </files>
75
  </Channelpilotsolutions_Channelpilot>
76
  </modules>
@@ -84,14 +110,21 @@
84
  </layout>
85
  </adminhtml>
86
  <frontend>
87
- <routers>
88
- <channelpilot>
89
- <use>standard</use>
90
- <args>
91
- <module>Channelpilotsolutions_Channelpilot</module>
92
- <frontName>channelpilot</frontName>
93
- </args>
94
- </channelpilot>
95
- </routers>
96
- </frontend>
 
 
 
 
 
 
 
97
  </config>
24
  <config>
25
  <modules>
26
  <Channelpilotsolutions_Channelpilot>
27
+ <version>2.0.0</version>
28
  </Channelpilotsolutions_Channelpilot>
29
  </modules>
30
  <global>
31
+ <models>
 
 
 
 
 
32
  <channelpilot_adminhtml>
33
  <class>Channelpilotsolutions_Channelpilot_Adminhtml_Model</class>
34
  </channelpilot_adminhtml>
35
+ <channelpilot>
36
+ <class>Channelpilotsolutions_Channelpilot_Model</class>
37
+ <resourceModel>channelpilot_resource</resourceModel>
38
+ </channelpilot>
39
+ <channelpilot_resource>
40
+ <entities>
41
+ <registration>
42
+ <table>cp_registration</table>
43
+ </registration>
44
+ <orders>
45
+ <table>cp_marketplace_orders</table>
46
+ </orders>
47
+ <items>
48
+ <table>cp_marketplace_order_items</table>
49
+ </items>
50
+ <logs>
51
+ <table>cp_logging</table>
52
+ </logs>
53
+ </entities>
54
+ </channelpilot_resource>
55
  </models>
56
+ <resources>
57
+ <default_setup>
58
+ <connection>
59
+ <charset>utf8</charset>
60
+ </connection>
61
+ </default_setup>
62
  <channelpilot_setup>
63
  <setup>
64
  <module>Channelpilotsolutions_Channelpilot</module>
65
  </setup>
66
  <connection>
67
+ <charset>utf8</charset>
68
  <use>core_setup</use>
69
  </connection>
70
  </channelpilot_setup>
71
+ <!-- <channelpilot_write>
72
+ <connection>
73
+ <use>core_write</use>
74
+ </connection>
75
+ </channelpilot_write>
76
+ <channelpilot_read>
77
+ <connection>
78
+ <use>core_read</use>
79
+ </connection>
80
+ </channelpilot_read>-->
81
  </resources>
82
+ <extraconfig />
83
+ <blocks>
84
  <channelpilot_core>
85
+ <class>Channelpilotsolutions_Channelpilot_Block</class>
86
+ </channelpilot_core>
87
  </blocks>
88
+ <helpers>
89
+ <channelpilot>
90
+ <class>Channelpilotsolutions_Channelpilot_Helper</class>
91
+ </channelpilot>
92
+ </helpers>
93
  </global>
94
  <adminhtml>
95
  <translate>
96
  <modules>
97
  <Channelpilotsolutions_Channelpilot>
98
  <files>
99
+ <default>Channelpilotsolutions_Channelpilot.csv</default>
100
  </files>
101
  </Channelpilotsolutions_Channelpilot>
102
  </modules>
110
  </layout>
111
  </adminhtml>
112
  <frontend>
113
+ <routers>
114
+ <channelpilot>
115
+ <use>standard</use>
116
+ <args>
117
+ <module>Channelpilotsolutions_Channelpilot</module>
118
+ <frontName>channelpilot</frontName>
119
+ </args>
120
+ </channelpilot>
121
+ </routers>
122
+ <layout>
123
+ <updates>
124
+ <channelpilotsolutions_channelpilot>
125
+ <file>Channelpilotsolutions/channelpilot.xml</file>
126
+ </channelpilotsolutions_channelpilot>
127
+ </updates>
128
+ </layout>
129
+ </frontend>
130
  </config>
app/code/community/Channelpilotsolutions/Channelpilot/etc/system.xml CHANGED
@@ -30,8 +30,8 @@
30
  </channelpilot_config>
31
  </tabs>
32
  <sections>
33
- <channelpilot_section translate="label" module="channelpilot">
34
- <label>Settings</label>
35
  <tab>channelpilot_config</tab>
36
  <frontend_type>text</frontend_type>
37
  <sort_order>1000</sort_order>
@@ -39,16 +39,123 @@
39
  <show_in_website>1</show_in_website>
40
  <show_in_store>1</show_in_store>
41
  <groups>
42
- <!-- New group -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  <channelpilot_productfeed translate="label">
44
- <label>Productfeed</label>
45
  <frontend_type>text</frontend_type>
 
46
  <sort_order>1</sort_order>
47
  <show_in_default>1</show_in_default>
48
  <show_in_website>1</show_in_website>
49
  <show_in_store>1</show_in_store>
50
  <fields>
51
- <!-- New Field -->
 
 
 
 
 
 
 
 
52
  <channelpilot_password translate="label">
53
  <label>Password</label>
54
  <comment>Protect your productfeed with a password. For example: 'www.testshop.com/channelpilot?password=12345'</comment>
@@ -90,46 +197,117 @@
90
  </channelpilot_replacefields>
91
  </fields>
92
  </channelpilot_productfeed>
93
- <!-- New group -->
94
- <channelpilot_salestracking translate="label">
95
- <label>Salestracking</label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  <frontend_type>text</frontend_type>
97
  <sort_order>2</sort_order>
98
  <show_in_default>1</show_in_default>
99
  <show_in_website>1</show_in_website>
100
  <show_in_store>1</show_in_store>
101
  <fields>
102
- <channelpilot_articlenumber>
103
- <label>Articlenumber</label>
104
- <comment>Select the same data field which you selected to be the unique article number in ChannelPilot.</comment>
105
  <frontend_type>select</frontend_type>
106
- <source_model>channelpilot_adminhtml/articlenumber_values</source_model>
107
  <sort_order>0</sort_order>
108
  <show_in_default>1</show_in_default>
109
  <show_in_website>1</show_in_website>
110
  <show_in_store>1</show_in_store>
111
- </channelpilot_articlenumber>
112
- <channelpilot_cookiemode>
113
- <label>Cookiemode</label>
 
114
  <frontend_type>select</frontend_type>
115
- <source_model>channelpilot_adminhtml/cookiemode_values</source_model>
116
  <sort_order>1</sort_order>
117
  <show_in_default>1</show_in_default>
118
  <show_in_website>1</show_in_website>
119
  <show_in_store>1</show_in_store>
120
- </channelpilot_cookiemode>
121
- <channelpilot_trackingkeys>
122
- <label>Trackingkeys</label>
123
- <frontend_model>channelpilot_core/adminhtml_field_trackingkeys</frontend_model>
124
- <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
125
- <sort_order>2</sort_order>
 
 
 
 
 
 
 
 
 
 
126
  <show_in_default>1</show_in_default>
127
  <show_in_website>1</show_in_website>
128
- <show_in_store>1</show_in_store>
129
- </channelpilot_trackingkeys>
130
  </fields>
131
- </channelpilot_salestracking>
132
  </groups>
133
- </channelpilot_section>
134
  </sections>
135
  </config>
30
  </channelpilot_config>
31
  </tabs>
32
  <sections>
33
+ <channelpilot_general translate="label" module="channelpilot">
34
+ <label>General</label>
35
  <tab>channelpilot_config</tab>
36
  <frontend_type>text</frontend_type>
37
  <sort_order>1000</sort_order>
39
  <show_in_website>1</show_in_website>
40
  <show_in_store>1</show_in_store>
41
  <groups>
42
+ <channelpilot_general translate="label">
43
+ <label>General ChannelPilot Settings</label>
44
+ <frontend_type>text</frontend_type>
45
+ <expanded>1</expanded>
46
+ <sort_order>1</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ <fields>
51
+ <channelpilot_useNews>
52
+ <label>Activate backendnews?</label>
53
+ <frontend_type>select</frontend_type>
54
+ <source_model>channelpilot_adminhtml/truefalse_values</source_model>
55
+ <sort_order>1</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ </channelpilot_useNews>
60
+ <channelpilot_checkIp>
61
+ <label>Should the IP for API access be checked?</label>
62
+ <frontend_type>select</frontend_type>
63
+ <source_model>channelpilot_adminhtml/truefalsesecurity_values</source_model>
64
+ <sort_order>2</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </channelpilot_checkIp>
69
+ <channelpilot_articlenumber>
70
+ <label>Articlenumber</label>
71
+ <comment>This applies to the tracking as well as the market place connection or the price control.</comment>
72
+ <frontend_type>select</frontend_type>
73
+ <source_model>channelpilot_adminhtml/articlenumber_values</source_model>
74
+ <sort_order>3</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ </channelpilot_articlenumber>
79
+ </fields>
80
+ </channelpilot_general>
81
+ </groups>
82
+ </channelpilot_general>
83
+ <channelpilot_tracking translate="label" module="channelpilot">
84
+ <label>Tracking</label>
85
+ <tab>channelpilot_config</tab>
86
+ <frontend_type>text</frontend_type>
87
+ <sort_order>2000</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ <groups>
92
+ <channelpilot_tracking translate="label">
93
+ <label>Tracking Settings</label>
94
+ <frontend_type>text</frontend_type>
95
+ <expanded>1</expanded>
96
+ <sort_order>2</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ <fields>
101
+ <channelpilot_useTracking>
102
+ <label>Activate tracking?</label>
103
+ <frontend_type>select</frontend_type>
104
+ <source_model>channelpilot_adminhtml/truefalse_values</source_model>
105
+ <sort_order>0</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ </channelpilot_useTracking>
110
+ <channelpilot_cookiemode>
111
+ <label>Cookiemode</label>
112
+ <frontend_type>select</frontend_type>
113
+ <source_model>channelpilot_adminhtml/cookiemode_values</source_model>
114
+ <sort_order>1</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ </channelpilot_cookiemode>
119
+ <channelpilot_trackingkeys>
120
+ <label>Trackingkeys</label>
121
+ <frontend_model>channelpilot_core/adminhtml_field_trackingkeys</frontend_model>
122
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
123
+ <sort_order>2</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ </channelpilot_trackingkeys>
128
+ </fields>
129
+ </channelpilot_tracking>
130
+ </groups>
131
+ </channelpilot_tracking>
132
+ <channelpilot_export translate="label" module="channelpilot">
133
+ <label>Export</label>
134
+ <tab>channelpilot_config</tab>
135
+ <frontend_type>text</frontend_type>
136
+ <sort_order>3000</sort_order>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>1</show_in_store>
140
+ <groups>
141
  <channelpilot_productfeed translate="label">
142
+ <label>Catalogue Export Settings</label>
143
  <frontend_type>text</frontend_type>
144
+ <expanded>1</expanded>
145
  <sort_order>1</sort_order>
146
  <show_in_default>1</show_in_default>
147
  <show_in_website>1</show_in_website>
148
  <show_in_store>1</show_in_store>
149
  <fields>
150
+ <channelpilot_useExport>
151
+ <label>Active export?</label>
152
+ <frontend_type>select</frontend_type>
153
+ <source_model>channelpilot_adminhtml/truefalse_values</source_model>
154
+ <sort_order>0</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>1</show_in_store>
158
+ </channelpilot_useExport>
159
  <channelpilot_password translate="label">
160
  <label>Password</label>
161
  <comment>Protect your productfeed with a password. For example: 'www.testshop.com/channelpilot?password=12345'</comment>
197
  </channelpilot_replacefields>
198
  </fields>
199
  </channelpilot_productfeed>
200
+ </groups>
201
+ </channelpilot_export>
202
+ <channelpilot_marketplace translate="label" module="channelpilot">
203
+ <label>Marketplace</label>
204
+ <tab>channelpilot_config</tab>
205
+ <frontend_type>text</frontend_type>
206
+ <sort_order>4000</sort_order>
207
+ <show_in_default>1</show_in_default>
208
+ <show_in_website>1</show_in_website>
209
+ <show_in_store>1</show_in_store>
210
+ <groups>
211
+ <channelpilot_marketplace translate="label">
212
+ <label>Marketplace Connector</label>
213
+ <frontend_type>text</frontend_type>
214
+ <expanded>1</expanded>
215
+ <sort_order>3</sort_order>
216
+ <show_in_default>1</show_in_default>
217
+ <show_in_website>1</show_in_website>
218
+ <show_in_store>1</show_in_store>
219
+ <fields>
220
+ <channelpilot_useMarketplaces>
221
+ <label>Active</label>
222
+ <frontend_type>select</frontend_type>
223
+ <source_model>channelpilot_adminhtml/truefalse_values</source_model>
224
+ <sort_order>0</sort_order>
225
+ <show_in_default>1</show_in_default>
226
+ <show_in_website>1</show_in_website>
227
+ <show_in_store>1</show_in_store>
228
+ </channelpilot_useMarketplaces>
229
+ </fields>
230
+ </channelpilot_marketplace>
231
+ </groups>
232
+ </channelpilot_marketplace>
233
+ <channelpilot_pricecontrol translate="label" module="channelpilot">
234
+ <label>Pricecontrol</label>
235
+ <tab>channelpilot_config</tab>
236
+ <frontend_type>text</frontend_type>
237
+ <sort_order>5000</sort_order>
238
+ <show_in_default>1</show_in_default>
239
+ <show_in_website>1</show_in_website>
240
+ <show_in_store>1</show_in_store>
241
+ <groups>
242
+ <general translate="label">
243
+ <label>General</label>
244
+ <frontend_type>text</frontend_type>
245
+ <expanded>1</expanded>
246
+ <sort_order>1</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>1</show_in_store>
250
+ <fields>
251
+ <channelpilot_usePricecontrol>
252
+ <label>Active</label>
253
+ <frontend_type>select</frontend_type>
254
+ <source_model>channelpilot_adminhtml/truefalse_values</source_model>
255
+ <sort_order>0</sort_order>
256
+ <show_in_default>1</show_in_default>
257
+ <show_in_website>1</show_in_website>
258
+ <show_in_store>1</show_in_store>
259
+ </channelpilot_usePricecontrol>
260
+ </fields>
261
+ </general>
262
+ <general_prices translate="label">
263
+ <label>General Price Control</label>
264
  <frontend_type>text</frontend_type>
265
  <sort_order>2</sort_order>
266
  <show_in_default>1</show_in_default>
267
  <show_in_website>1</show_in_website>
268
  <show_in_store>1</show_in_store>
269
  <fields>
270
+ <!-- <channelpilot_usePricecontrol>
271
+ <label>Active</label>
 
272
  <frontend_type>select</frontend_type>
273
+ <source_model>channelpilot_adminhtml/truefalse_values</source_model>
274
  <sort_order>0</sort_order>
275
  <show_in_default>1</show_in_default>
276
  <show_in_website>1</show_in_website>
277
  <show_in_store>1</show_in_store>
278
+ </channelpilot_usePricecontrol>-->
279
+ <channelpilot_generalPriceField>
280
+ <label>Field for price</label>
281
+ <comment>This field would be overwritten by the new product price.</comment>
282
  <frontend_type>select</frontend_type>
283
+ <source_model>channelpilot_adminhtml/pricefield_values</source_model>
284
  <sort_order>1</sort_order>
285
  <show_in_default>1</show_in_default>
286
  <show_in_website>1</show_in_website>
287
  <show_in_store>1</show_in_store>
288
+ </channelpilot_generalPriceField>
289
+ </fields>
290
+ </general_prices>
291
+ <!-- <campaign_prices translate="label">
292
+ <label>Campaign Price Control</label>
293
+ <frontend_type>text</frontend_type>
294
+ <sort_order>3</sort_order>
295
+ <show_in_default>1</show_in_default>
296
+ <show_in_website>1</show_in_website>
297
+ <show_in_store>1</show_in_store>
298
+ <fields>
299
+ <channelpilot_usePricecontrol>
300
+ <label>Active</label>
301
+ <frontend_type>select</frontend_type>
302
+ <source_model>channelpilot_adminhtml/truefalse_values</source_model>
303
+ <sort_order>0</sort_order>
304
  <show_in_default>1</show_in_default>
305
  <show_in_website>1</show_in_website>
306
+ <show_in_store>1</show_in_store>
307
+ </channelpilot_usePricecontrol>
308
  </fields>
309
+ </campaign_prices>-->
310
  </groups>
311
+ </channelpilot_pricecontrol>
312
  </sections>
313
  </config>
app/code/community/Channelpilotsolutions/Channelpilot/sql/channelpilot_setup/install-2.0.0.0.php ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ /** @var $adapter Varien_Db_Adapter_Pdo_Mysql */
7
+ $adapter = $installer->getConnection();
8
+
9
+ /**
10
+ * Create table 'channelpilot/registration'
11
+ */
12
+ $table = $adapter->newTable($installer->getTable('channelpilot/registration'))
13
+ ->addColumn('shopId', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
14
+ 'nullable' => false,
15
+ 'primary' => true
16
+ ), '')
17
+ ->addColumn('ips_authorized', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
18
+ 'nullable' => false
19
+ ), '')
20
+ ->addColumn('merchantId', Varien_Db_Ddl_Table::TYPE_VARCHAR, 150, array(
21
+ 'nullable' => false
22
+ ), '')
23
+ ->addColumn('securityToken', Varien_Db_Ddl_Table::TYPE_VARCHAR, 150, array(
24
+ 'nullable' => false
25
+ ), '')
26
+ ->addColumn('last_stock_update', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
27
+ 'nullable' => true
28
+ ), '')
29
+ ->addColumn('last_price_update', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
30
+ 'nullable' => true
31
+ ), '')
32
+ ->addColumn('last_catalog_update', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
33
+ 'nullable' => true
34
+ ), '')
35
+ ->addIndex(
36
+ $installer->getIdxName(
37
+ $installer->getTable('channelpilot/registration'),
38
+ array('merchantId', 'securityToken'),
39
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
40
+ ),
41
+ array('merchantId', 'securityToken'),
42
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
43
+ );
44
+ $adapter->createTable($table);
45
+
46
+ /**
47
+ * Create table 'channelpilot/orders'
48
+ */
49
+ $table = $adapter->newTable($installer->getTable('channelpilot/orders'))
50
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
51
+ 'nullable' => false,
52
+ 'primary' => true
53
+ ), '')
54
+ ->addColumn('order_nr', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
55
+ 'nullable' => false
56
+ ), '')
57
+ ->addColumn('marketplace_order_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 150, array(
58
+ 'nullable' => false
59
+ ), '')
60
+ ->addColumn('marketplace', Varien_Db_Ddl_Table::TYPE_VARCHAR, 150, array(
61
+ 'nullable' => false
62
+ ), '')
63
+ ->addColumn('shop', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
64
+ 'nullable' => false
65
+ ), '')
66
+ ->addColumn('created', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
67
+ 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT,
68
+ 'nullable' => false
69
+ ), '')
70
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array(
71
+ 'nullable' => true
72
+ ), '')
73
+ ->addIndex($installer->getIdxName(
74
+ 'channelpilot/orders',
75
+ array('order_nr'),
76
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
77
+ ),
78
+ array('order_nr'),
79
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
80
+ )
81
+ ->addIndex(
82
+ $installer->getIdxName(
83
+ $installer->getTable('channelpilot/orders'),
84
+ array('marketplace_order_id', 'marketplace'),
85
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
86
+ ),
87
+ array('marketplace_order_id', 'marketplace'),
88
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
89
+ );
90
+ $adapter->createTable($table);
91
+
92
+ /**
93
+ * Create table 'channelpilot/order_items'
94
+ */
95
+ $table = $adapter->newTable($installer->getTable('channelpilot/items'))
96
+ ->addColumn('order_item_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
97
+ 'nullable' => false,
98
+ 'primary' => true
99
+ ), '')
100
+ ->addColumn('marketplace_order_item_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
101
+ 'nullable' => false
102
+ ), '')
103
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
104
+ 'nullable' => false
105
+ ), '')
106
+ ->addColumn('cancelled', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
107
+ 'default' => 0,
108
+ 'nullable' => false
109
+ ), '')
110
+ ->addColumn('amount', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
111
+ 'default' => 0,
112
+ 'nullable' => false
113
+ ), '')
114
+ ->addColumn('amount_delivered', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
115
+ 'default' => 0,
116
+ 'nullable' => false
117
+ ), '')
118
+ ->addIndex($installer->getIdxName(
119
+ 'channelpilot/items',
120
+ array('order_item_id'),
121
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
122
+ ),
123
+ array('order_item_id'),
124
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
125
+ )
126
+ ->addIndex($installer->getIdxName(
127
+ 'channelpilot/items',
128
+ array('marketplace_order_item_id'),
129
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
130
+ ),
131
+ array('marketplace_order_item_id'),
132
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
133
+ );
134
+ $adapter->createTable($table);
135
+
136
+ /**
137
+ * Create table 'channelpilot/logs'
138
+ */
139
+ $table = $adapter->newTable($installer->getTable('channelpilot/logs'))
140
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
141
+ 'auto_increment' => true,
142
+ 'nullable' => false,
143
+ 'primary' => true
144
+ ), '')
145
+ ->addColumn('created', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
146
+ 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT,
147
+ 'nullable' => false
148
+ ), '')
149
+ ->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
150
+ 'nullable' => false
151
+ ), '')
152
+ ->addIndex($installer->getIdxName(
153
+ 'channelpilot/logs',
154
+ array('created')
155
+ ),
156
+ array('created'));
157
+ $adapter->createTable($table);
158
+
159
+ $installer->endSetup();
160
+
161
+
162
+ /**
163
+ CREATE TABLE IF NOT EXISTS `cp_registration` (
164
+ `shopId` varchar(255) NOT NULL,
165
+ `ips_authorized` varchar(255) DEFAULT NULL,
166
+ `merchantId` varchar(150) DEFAULT NULL,
167
+ `securityToken` varchar(150) DEFAULT NULL,
168
+ `last_stock_update` timestamp NULL DEFAULT NULL,
169
+ `last_price_update` timestamp NULL DEFAULT NULL,
170
+ `last_catalog_update` timestamp NULL DEFAULT NULL,
171
+ PRIMARY KEY (`shopId`),
172
+ UNIQUE KEY `cp_registration_merchantId_securityToken` (`merchantId`,`securityToken`)
173
+ );
174
+
175
+ CREATE TABLE IF NOT EXISTS `cp_marketplace_orders` (
176
+ `order_id` varchar(255) NOT NULL,
177
+ `order_nr` varchar(255) NOT NULL,
178
+ `marketplace_order_id` varchar(150) NOT NULL,
179
+ `marketplace` varchar(150) NOT NULL,
180
+ `shop` varchar(255) NOT NULL,
181
+ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
182
+ `status` int(10) DEFAULT NULL,
183
+ PRIMARY KEY (`order_id`),
184
+ UNIQUE KEY `cp_marketplace_orders_marketplace_order_id_marketplace` (`marketplace_order_id`,`marketplace`),
185
+ UNIQUE KEY `cp_marketplace_orders_order_nr` (`order_nr`)
186
+ );
187
+
188
+ CREATE TABLE IF NOT EXISTS `cp_marketplace_order_items` (
189
+ `order_item_id` varchar(255) NOT NULL,
190
+ `marketplace_order_item_id` varchar(255) NOT NULL,
191
+ `order_id` varchar(255) NOT NULL,
192
+ `cancelled` int(11) NOT NULL DEFAULT '0',
193
+ `amount` int(11) NOT NULL DEFAULT '0',
194
+ `amount_delivered` int(11) NOT NULL DEFAULT '0',
195
+ UNIQUE KEY `cp_marketplace_order_items_order_item_id` (`order_item_id`),
196
+ UNIQUE KEY `cp_marketplace_order_items_marketplace_order_item_id` (`marketplace_order_item_id`)
197
+ );
198
+
199
+ CREATE TABLE IF NOT EXISTS `cp_logging` (
200
+ `id` int(11) NOT NULL AUTO_INCREMENT,
201
+ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
202
+ `content` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
203
+ PRIMARY KEY (`id`),
204
+ KEY `cp_logging_created` (`created`)
205
+ );
206
+ */
app/code/community/Channelpilotsolutions/Clicktracking/etc/config.xml DELETED
@@ -1,39 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?><!--
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Clicktracking to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Clicktracking for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Clicktracking
17
- * @subpackage etc
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- -->
24
- <config>
25
- <modules>
26
- <Channelpilotsolutions_Clicktracking>
27
- <version>1.0.0</version>
28
- </Channelpilotsolutions_Clicktracking>
29
- </modules>
30
- <frontend>
31
- <layout>
32
- <updates>
33
- <channelpilotsolutions_clicktracking>
34
- <file>Channelpilotsolutions/clicktracking.xml</file>
35
- </channelpilotsolutions_clicktracking>
36
- </updates>
37
- </layout>
38
- </frontend>
39
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Channelpilotsolutions/Salestracking/etc/config.xml DELETED
@@ -1,39 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?><!--
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Salestracking to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Salestracking for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package Channelpilotsolutions_Salestracking
17
- * @subpackage etc
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- -->
24
- <config>
25
- <modules>
26
- <Channelpilotsolutions_Salestracking>
27
- <version>1.0.0</version>
28
- </Channelpilotsolutions_Salestracking>
29
- </modules>
30
- <frontend>
31
- <layout>
32
- <updates>
33
- <channelpilotsolutions_salestracking>
34
- <file>Channelpilotsolutions/salestracking.xml</file>
35
- </channelpilotsolutions_salestracking>
36
- </updates>
37
- </layout>
38
- </frontend>
39
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/Channelpilotsolutions/{clicktracking.xml → channelpilot.xml} RENAMED
@@ -22,9 +22,9 @@
22
  */
23
  -->
24
  <layout version="0.1.0">
25
- <default>
26
  <reference name="head">
27
- <block type="core/template" name="clicktracking" template="Channelpilotsolutions/clicktracking.phtml" after="-">
28
  </block>
29
  </reference>
30
  </default>
22
  */
23
  -->
24
  <layout version="0.1.0">
25
+ <default>
26
  <reference name="head">
27
+ <block type="core/template" name="clicktracking" template="Channelpilotsolutions/channelpilot.phtml" after="-">
28
  </block>
29
  </reference>
30
  </default>
app/design/frontend/base/default/template/Channelpilotsolutions/channelpilot.phtml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL 3)
7
+ * that is bundled with this package in the file LICENSE.txt
8
+ *
9
+ * DISCLAIMER
10
+ *
11
+ * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Clicktracking to newer
12
+ * versions in the future. If you wish to customize Channelpilotsolutions_Clicktracking for your
13
+ * needs please refer to http://www.channelpilot.com for more information.
14
+ *
15
+ * @category Channelpilotsolutions
16
+ * @package design_frontend_base_default
17
+ * @subpackage template_Channelpilotsolutions
18
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Peter Hoffmann <info@channelpilot.com>
20
+ * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
+ * @link http://www.channelpilot.com
22
+ */
23
+ ?>
24
+ <?php
25
+ if (strpos($_SERVER['REQUEST_URI'], 'checkout/onepage/success') !== false) {
26
+ if (strpos(Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/channelpilot_useTracking'), "true") !== false) {
27
+ $storeId = Mage::app()->getStore()->getId();
28
+ $trackingKeys = unserialize(Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/channelpilot_trackingkeys'));
29
+ $TRACKINGKEY = '';
30
+ foreach ($trackingKeys as $element) {
31
+ if ($element['shop'] == $storeId) {
32
+ $TRACKINGKEY = $element['trackingkey'];
33
+ break;
34
+ }
35
+ }
36
+ $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
37
+ $tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
38
+
39
+ $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
40
+
41
+
42
+
43
+
44
+
45
+ if (substr(Mage::getVersion(), 2, 7) == '4.0.1') {
46
+ $query = "
47
+ SELECT so.entity_id, so.increment_id AS id, (so.grand_total-so.tax_amount) AS orderTotal
48
+ FROM ChannelPilotSolutions_ChannelPilot_sales_order AS so
49
+ WHERE so.increment_id = '" . Mage::getSingleton('checkout/session')->getLastRealOrderId() . "'
50
+ ORDER BY so.entity_id DESC LIMIT 1";
51
+ } else {
52
+ $query = "
53
+ SELECT so.entity_id, so.increment_id AS id, (so.grand_total-so.tax_amount) AS orderTotal
54
+ FROM ChannelPilotSolutions_ChannelPilot_sales_flat_order AS so
55
+ WHERE so.increment_id = '" . Mage::getSingleton('checkout/session')->getLastRealOrderId() . "'
56
+ ORDER BY so.entity_id DESC LIMIT 1";
57
+ }
58
+ $query = str_replace('ChannelPilotSolutions_ChannelPilot_', $tablePrefix, $query);
59
+ $orders = $dbConnection->fetchAll($query);
60
+ foreach ($orders as $ORDER) {
61
+ ?>
62
+ <script type="text/javascript">
63
+ var cpSale = {
64
+ trackingKey: "<?php echo $TRACKINGKEY; ?>",
65
+ orderId: "<?php echo $ORDER['id']; ?>",
66
+ orderTotal: <?php echo $ORDER['orderTotal']; ?>,
67
+ cookie: "<?php echo Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/channelpilot_cookiemode'); ?>",
68
+ shoppingCart: new Array()
69
+ };
70
+ <?php
71
+ }
72
+ // Retrieve ordered products
73
+ $query = "
74
+ SELECT item_id, sku, product_id, price, qty_ordered, parent_item_id AS parent,
75
+ IF(parent_item_id IS NOT NULL, (SELECT price FROM ChannelPilotSolutions_ChannelPilot_sales_flat_order_item WHERE item_id = parent), NULL) AS parent_price
76
+ FROM ChannelPilotSolutions_ChannelPilot_sales_flat_order_item
77
+ WHERE order_id = '" . $ORDER['entity_id'] . "' ORDER BY parent_item_id DESC";
78
+ $query = str_replace('ChannelPilotSolutions_ChannelPilot_', $tablePrefix, $query);
79
+ $orderedProducts = $dbConnection->fetchAll($query);
80
+
81
+ $parents = array();
82
+ // Loop through each product in order
83
+ foreach ($orderedProducts as $orderedProduct) {
84
+ IF (isset($orderedProduct['parent'])) {
85
+ $productId = $orderedProduct[Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_articlenumber')];
86
+ $price = $orderedProduct['parent_price'];
87
+ $quantity = (int) $orderedProduct['qty_ordered'];
88
+ ?>
89
+ cpSale.shoppingCart.push({id: "<?php echo $productId; ?>", price: <?php echo $price; ?>, amount: <?php echo $quantity; ?>});
90
+ <?php
91
+ $parents[] = $orderedProduct['parent'];
92
+ } ELSE {
93
+ IF (!in_array($orderedProduct['item_id'], $parents)) {
94
+ $productId = $orderedProduct[Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_articlenumber')];
95
+ $price = $orderedProduct['price'];
96
+ $quantity = (int) $orderedProduct['qty_ordered'];
97
+ ?>
98
+ cpSale.shoppingCart.push({id: "<?php echo $productId; ?>", price: <?php echo $price; ?>, amount: <?php echo $quantity; ?>});
99
+ <?php
100
+ }
101
+ }
102
+ }
103
+ ?>
104
+ </script>
105
+ <script type="text/javascript" src="//content.cptrack.de/sales.js"></script>
106
+ <?php
107
+ }
108
+ } else {
109
+ if (strpos(Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/channelpilot_useTracking'), "true") !== false) {
110
+ ?>
111
+ <script type="text/javascript" src="//content.cptrack.de/clicks.js"></script>
112
+ <?php
113
+ } else {
114
+ ?>
115
+ <script type="text/javascript">/* CP Tracking deactivated*/</script>
116
+ <?php
117
+ }
118
+ }
app/design/frontend/base/default/template/Channelpilotsolutions/salestracking.phtml DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Salestracking to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Salestracking for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package design_frontend_base_default
17
- * @subpackage template_Channelpilotsolutions
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- ?>
24
- <?php
25
-
26
- if(strpos($_SERVER['REQUEST_URI'],'checkout/onepage/success')!==false )
27
- {
28
- $storeId = Mage::app()->getStore()->getId();
29
- $trackingKeys= unserialize(Mage::getStoreConfig('channelpilot_section/channelpilot_salestracking/channelpilot_trackingkeys'));
30
- $TRACKINGKEY = '';
31
- foreach($trackingKeys as $element){
32
- if($element['shop']==$storeId){
33
- $TRACKINGKEY = $element['trackingkey'];
34
- break;
35
- }
36
- }
37
- $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
38
- $tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
39
-
40
- $dbConnection = Mage::getSingleton('core/resource') ->getConnection('core_read');
41
-
42
-
43
-
44
-
45
-
46
- if(substr(Mage::getVersion(),2,7)=='4.0.1'){
47
- $query = "
48
- SELECT so.entity_id, so.increment_id AS id, (so.grand_total-so.tax_amount) AS orderTotal
49
- FROM ChannelPilotSolutions_ChannelPilot_sales_order AS so
50
- WHERE so.increment_id = '".Mage::getSingleton('checkout/session')->getLastRealOrderId()."'
51
- ORDER BY so.entity_id DESC LIMIT 1";
52
- } else {
53
- $query = "
54
- SELECT so.entity_id, so.increment_id AS id, (so.grand_total-so.tax_amount) AS orderTotal
55
- FROM ChannelPilotSolutions_ChannelPilot_sales_flat_order AS so
56
- WHERE so.increment_id = '".Mage::getSingleton('checkout/session')->getLastRealOrderId()."'
57
- ORDER BY so.entity_id DESC LIMIT 1";
58
- }
59
- $query = str_replace('ChannelPilotSolutions_ChannelPilot_', $tablePrefix, $query);
60
- $orders = $dbConnection->fetchAll($query);
61
- foreach ($orders as $ORDER) {
62
- ?>
63
- <script type="text/javascript">
64
- var cpSale = {
65
- trackingKey: "<?php echo $TRACKINGKEY;?>",
66
- orderId: "<?php echo $ORDER['id'];?>",
67
- orderTotal: <?php echo $ORDER['orderTotal'];?>,
68
- cookie: "<?php echo Mage::getStoreConfig('channelpilot_section/channelpilot_salestracking/channelpilot_cookiemode');?>",
69
- shoppingCart: new Array()
70
- };
71
- <?php
72
- }
73
- // Retrieve ordered products
74
- $query = "
75
- SELECT item_id, sku, product_id, price, qty_ordered, parent_item_id AS parent,
76
- IF(parent_item_id IS NOT NULL, (SELECT price FROM ChannelPilotSolutions_ChannelPilot_sales_flat_order_item WHERE item_id = parent), NULL) AS parent_price
77
- FROM ChannelPilotSolutions_ChannelPilot_sales_flat_order_item
78
- WHERE order_id = '".$ORDER['entity_id']."' ORDER BY parent_item_id DESC";
79
- $query = str_replace('ChannelPilotSolutions_ChannelPilot_', $tablePrefix, $query);
80
- $orderedProducts = $dbConnection->fetchAll($query);
81
-
82
- $parents = array();
83
- // Loop through each product in order
84
- foreach ($orderedProducts as $orderedProduct) {
85
- IF(isset($orderedProduct['parent'])){
86
- $productId = $orderedProduct[Mage::getStoreConfig('channelpilot_section/channelpilot_salestracking/channelpilot_articlenumber')];
87
- $price = $orderedProduct['parent_price'];
88
- $quantity = (int) $orderedProduct['qty_ordered'];
89
- ?>
90
- cpSale.shoppingCart.push({id: "<?php echo $productId;?>", price: <?php echo $price;?>, amount: <?php echo $quantity;?>});
91
- <?php
92
- $parents[] = $orderedProduct['parent'];
93
- } ELSE {
94
- IF(!in_array($orderedProduct['item_id'],$parents)){
95
- $productId = $orderedProduct[Mage::getStoreConfig('channelpilot_section/channelpilot_salestracking/channelpilot_articlenumber')];
96
- $price = $orderedProduct['price'];
97
- $quantity = (int) $orderedProduct['qty_ordered'];
98
- ?>
99
- cpSale.shoppingCart.push({id: "<?php echo $productId;?>", price: <?php echo $price;?>, amount: <?php echo $quantity;?>});
100
- <?php
101
- }
102
- }
103
- }
104
- ?>
105
- </script>
106
- <script type="text/javascript" src="//content.cptrack.de/sales.js"></script>
107
- <?php
108
- }
109
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/Channelpilotsolutions_Salestracking.xml DELETED
@@ -1,31 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?><!--
2
- /**
3
- *
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the GNU General Public License (GPL 3)
7
- * that is bundled with this package in the file LICENSE.txt
8
- *
9
- * DISCLAIMER
10
- *
11
- * Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Salestracking to newer
12
- * versions in the future. If you wish to customize Channelpilotsolutions_Salestracking for your
13
- * needs please refer to http://www.channelpilot.com for more information.
14
- *
15
- * @category Channelpilotsolutions
16
- * @package etc
17
- * @subpackage
18
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Peter Hoffmann <info@channelpilot.com>
20
- * @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
- * @link http://www.channelpilot.com
22
- */
23
- -->
24
- <config>
25
- <modules>
26
- <Channelpilotsolutions_Salestracking>
27
- <active>true</active>
28
- <codePool>community</codePool>
29
- </Channelpilotsolutions_Salestracking>
30
- </modules>
31
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/locale/de_AT/Channelpilotsolutions_Channelpilot.csv CHANGED
@@ -1,8 +1,21 @@
1
- "Settings","Einstellungen"
2
 
3
 
4
- "Productfeed","Produktkatalog"
 
 
 
 
 
 
 
 
 
 
 
5
 
 
 
6
  "Password","Passwort"
7
  "Protect your productfeed with a password. For example: 'www.testshop.com/channelpilot?password=12345'","Schützen Sie Ihren Produktkatalog mit einem Passwort. Zum Beispiel: 'www.testshop.com/channelpilot?password=12345'"
8
  "Select data fields","Datenfelder auswählen"
@@ -12,19 +25,13 @@
12
  "Data field name","Datenfeld Name"
13
  "Data field value","Datenfeld Wert"
14
  "Set up additional data fields. These fields have for every product the same value. E.g. for additional delivery costs.","Richten Sie zusätzliche Datenfelder ein, die für jedes Produkt einen statischen Wert haben. Z.B. für zusätzliche Versandkosten."
 
 
15
 
16
-
17
-
18
- "Salestracking","Salestracking"
19
-
20
- "Articlenumber","Artikelnummer"
21
- "Select the same data field which you selected to be the unique article number in ChannelPilot.","Wählen Sie hier das gleiche Datenfeld aus, dass Sie im ChannelPilot der ‚Eindeutigen Artikelnummer‘ zugeordnet haben."
22
- "Cookiemode","Cookiemodus"
23
- "Trackingkeys,"Trackingkeys"
24
- "Shop","Shop"
25
- "TrackingKey","TrackingKey"
26
-
27
-
28
 
29
  "Add","Hinzufügen"
30
  "Delete","Löschen"
1
+ "General","Allgemein"
2
 
3
 
4
+ "General ChannelPilot Settings","Allgemeine ChannelPilot Einstellungen"
5
+ "Activate backendnews?","Backendnews aktivieren?"
6
+ "Should the IP for API access be checked?","Soll die IP beim API-Zugriff überprüft werden?"
7
+ "Articlenumber","Artikelnummer"
8
+ "This applies to the tracking as well as the market place connection or the price control.","Dies gilt für das Tracking sowie die Marktplatzanbindung und die Preissteuerung."
9
+
10
+ "Tracking Settings","Tracking Einstellungen"
11
+ "Activate tracking?","Tracking aktivieren?"
12
+ "Cookiemode","Cookiemodus"
13
+ "Trackingkeys,"Trackingkeys"
14
+ "Shop","Shop"
15
+ "TrackingKey","TrackingKey"
16
 
17
+ "Catalogue Export Settings","Produktkatalog Export Einstellungen"
18
+ "Activate export?","Export aktivieren?"
19
  "Password","Passwort"
20
  "Protect your productfeed with a password. For example: 'www.testshop.com/channelpilot?password=12345'","Schützen Sie Ihren Produktkatalog mit einem Passwort. Zum Beispiel: 'www.testshop.com/channelpilot?password=12345'"
21
  "Select data fields","Datenfelder auswählen"
25
  "Data field name","Datenfeld Name"
26
  "Data field value","Datenfeld Wert"
27
  "Set up additional data fields. These fields have for every product the same value. E.g. for additional delivery costs.","Richten Sie zusätzliche Datenfelder ein, die für jedes Produkt einen statischen Wert haben. Z.B. für zusätzliche Versandkosten."
28
+ "Product variant data fields","Variantenfelder anpassen"
29
+ "Select the data fields you want to be overwritten by the respective value of the parent article.","Wählen Sie die Datenfelder die vom Datenfeld des Parentartikel überschrieben werden sollen."
30
 
31
+ "Pricecontrol","Preissteuerung"
32
+ "General Price Control","Globale Preissteuerung"
33
+ "Field for price","Preisfeld"
34
+ "This field would be overwritten by the new product price.","Dieses Preisfeld wird von dem neuen Preis überschrieben."
 
 
 
 
 
 
 
 
35
 
36
  "Add","Hinzufügen"
37
  "Delete","Löschen"
app/locale/de_CH/Channelpilotsolutions_Channelpilot.csv CHANGED
@@ -1,8 +1,21 @@
1
- "Settings","Einstellungen"
2
 
3
 
4
- "Productfeed","Produktkatalog"
 
 
 
 
 
 
 
 
 
 
 
5
 
 
 
6
  "Password","Passwort"
7
  "Protect your productfeed with a password. For example: 'www.testshop.com/channelpilot?password=12345'","Schützen Sie Ihren Produktkatalog mit einem Passwort. Zum Beispiel: 'www.testshop.com/channelpilot?password=12345'"
8
  "Select data fields","Datenfelder auswählen"
@@ -12,19 +25,13 @@
12
  "Data field name","Datenfeld Name"
13
  "Data field value","Datenfeld Wert"
14
  "Set up additional data fields. These fields have for every product the same value. E.g. for additional delivery costs.","Richten Sie zusätzliche Datenfelder ein, die für jedes Produkt einen statischen Wert haben. Z.B. für zusätzliche Versandkosten."
 
 
15
 
16
-
17
-
18
- "Salestracking","Salestracking"
19
-
20
- "Articlenumber","Artikelnummer"
21
- "Select the same data field which you selected to be the unique article number in ChannelPilot.","Wählen Sie hier das gleiche Datenfeld aus, dass Sie im ChannelPilot der ‚Eindeutigen Artikelnummer‘ zugeordnet haben."
22
- "Cookiemode","Cookiemodus"
23
- "Trackingkeys,"Trackingkeys"
24
- "Shop","Shop"
25
- "TrackingKey","TrackingKey"
26
-
27
-
28
 
29
  "Add","Hinzufügen"
30
  "Delete","Löschen"
1
+ "General","Allgemein"
2
 
3
 
4
+ "General ChannelPilot Settings","Allgemeine ChannelPilot Einstellungen"
5
+ "Activate backendnews?","Backendnews aktivieren?"
6
+ "Should the IP for API access be checked?","Soll die IP beim API-Zugriff überprüft werden?"
7
+ "Articlenumber","Artikelnummer"
8
+ "This applies to the tracking as well as the market place connection or the price control.","Dies gilt für das Tracking sowie die Marktplatzanbindung und die Preissteuerung."
9
+
10
+ "Tracking Settings","Tracking Einstellungen"
11
+ "Activate tracking?","Tracking aktivieren?"
12
+ "Cookiemode","Cookiemodus"
13
+ "Trackingkeys,"Trackingkeys"
14
+ "Shop","Shop"
15
+ "TrackingKey","TrackingKey"
16
 
17
+ "Catalogue Export Settings","Produktkatalog Export Einstellungen"
18
+ "Activate export?","Export aktivieren?"
19
  "Password","Passwort"
20
  "Protect your productfeed with a password. For example: 'www.testshop.com/channelpilot?password=12345'","Schützen Sie Ihren Produktkatalog mit einem Passwort. Zum Beispiel: 'www.testshop.com/channelpilot?password=12345'"
21
  "Select data fields","Datenfelder auswählen"
25
  "Data field name","Datenfeld Name"
26
  "Data field value","Datenfeld Wert"
27
  "Set up additional data fields. These fields have for every product the same value. E.g. for additional delivery costs.","Richten Sie zusätzliche Datenfelder ein, die für jedes Produkt einen statischen Wert haben. Z.B. für zusätzliche Versandkosten."
28
+ "Product variant data fields","Variantenfelder anpassen"
29
+ "Select the data fields you want to be overwritten by the respective value of the parent article.","Wählen Sie die Datenfelder die vom Datenfeld des Parentartikel überschrieben werden sollen."
30
 
31
+ "Pricecontrol","Preissteuerung"
32
+ "General Price Control","Globale Preissteuerung"
33
+ "Field for price","Preisfeld"
34
+ "This field would be overwritten by the new product price.","Dieses Preisfeld wird von dem neuen Preis überschrieben."
 
 
 
 
 
 
 
 
35
 
36
  "Add","Hinzufügen"
37
  "Delete","Löschen"
app/locale/de_DE/Channelpilotsolutions_Channelpilot.csv CHANGED
@@ -1,31 +1,37 @@
1
- "Settings","Einstellungen"
2
 
3
 
4
- "Productfeed","Produktkatalog"
 
 
 
 
 
 
 
 
 
 
 
5
 
 
 
6
  "Password","Passwort"
7
  "Protect your productfeed with a password. For example: 'www.testshop.com/channelpilot?password=12345'","Schützen Sie Ihren Produktkatalog mit einem Passwort. Zum Beispiel: 'www.testshop.com/channelpilot?password=12345'"
8
  "Select data fields","Datenfelder auswählen"
9
  "Data field","Datenfeld"
10
- "Select the data fields you want to provide on ChannelPilot. Some product attributes are always included. (Entity_Id, Sku, name, description, price, manufacturer, color, categories, product_url, image_url, additional_image_1, additional_image_2, additional_image_3, weight)","Wählen Sie die Datenfelder aus, die Sie ChannelPilot bereitstellen möchten. Einige Datenfelder sind immer im Produktkatalog enthalten. (Entity_Id, Sku, name, description, price, manufacturer, color, categories, product_url, image_url, additional_image_1, additional_image_2, additional_image_3, weight)"
11
  "Create static data fields","Statische Datenfelder erstellen"
12
  "Data field name","Datenfeld Name"
13
  "Data field value","Datenfeld Wert"
14
  "Set up additional data fields. These fields have for every product the same value. E.g. for additional delivery costs.","Richten Sie zusätzliche Datenfelder ein, die für jedes Produkt einen statischen Wert haben. Z.B. für zusätzliche Versandkosten."
15
- "Product variant data fields","Variantenfelder überschreiben"
16
- "Select the data fields you want to be overwritten by the respective value of the parent article.","Wählen Sie hier die Felder aus, deren Werte bei einem Variantenartikel mit dem entsprechenden Werten des jeweiligen Stammartikels überschrieben werden sollen."
17
-
18
-
19
- "Salestracking","Salestracking"
20
-
21
- "Articlenumber","Artikelnummer"
22
- "Select the same data field which you selected to be the unique article number in ChannelPilot.","Wählen Sie hier das gleiche Datenfeld aus, dass Sie im ChannelPilot der ‚Eindeutigen Artikelnummer‘ zugeordnet haben."
23
- "Cookiemode","Cookiemodus"
24
- "Trackingkeys,"Trackingkeys"
25
- "Shop","Shop"
26
- "TrackingKey","TrackingKey"
27
-
28
 
 
 
 
 
29
 
30
  "Add","Hinzufügen"
31
  "Delete","Löschen"
1
+ "General","Allgemein"
2
 
3
 
4
+ "General ChannelPilot Settings","Allgemeine ChannelPilot Einstellungen"
5
+ "Activate backendnews?","Backendnews aktivieren?"
6
+ "Should the IP for API access be checked?","Soll die IP beim API-Zugriff überprüft werden?"
7
+ "Articlenumber","Artikelnummer"
8
+ "This applies to the tracking as well as the market place connection or the price control.","Dies gilt für das Tracking sowie die Marktplatzanbindung und die Preissteuerung."
9
+
10
+ "Tracking Settings","Tracking Einstellungen"
11
+ "Activate tracking?","Tracking aktivieren?"
12
+ "Cookiemode","Cookiemodus"
13
+ "Trackingkeys,"Trackingkeys"
14
+ "Shop","Shop"
15
+ "TrackingKey","TrackingKey"
16
 
17
+ "Catalogue Export Settings","Produktkatalog Export Einstellungen"
18
+ "Activate export?","Export aktivieren?"
19
  "Password","Passwort"
20
  "Protect your productfeed with a password. For example: 'www.testshop.com/channelpilot?password=12345'","Schützen Sie Ihren Produktkatalog mit einem Passwort. Zum Beispiel: 'www.testshop.com/channelpilot?password=12345'"
21
  "Select data fields","Datenfelder auswählen"
22
  "Data field","Datenfeld"
23
+ "Select the data fields that you want to provide on ChannelPilot. Some product attributes are always included. (Entity_Id, Sku, name, description, price, manufacturer, color, categories, product_url, image_url, additional_image_1, additional_image_2, additional_image_3, weight)","Wählen Sie die Datenfelder aus, die Sie ChannelPilot bereitstellen möchten. Einige Datenfelder sind immer im Produktkatalog enthalten. (Entity_Id, Sku, name, description, price, manufacturer, color, categories, product_url, image_url, additional_image_1, additional_image_2, additional_image_3, weight)"
24
  "Create static data fields","Statische Datenfelder erstellen"
25
  "Data field name","Datenfeld Name"
26
  "Data field value","Datenfeld Wert"
27
  "Set up additional data fields. These fields have for every product the same value. E.g. for additional delivery costs.","Richten Sie zusätzliche Datenfelder ein, die für jedes Produkt einen statischen Wert haben. Z.B. für zusätzliche Versandkosten."
28
+ "Product variant data fields","Variantenfelder anpassen"
29
+ "Select the data fields you want to be overwritten by the respective value of the parent article.","Wählen Sie die Datenfelder die vom Datenfeld des Parentartikel überschrieben werden sollen."
 
 
 
 
 
 
 
 
 
 
 
30
 
31
+ "Pricecontrol","Preissteuerung"
32
+ "General Price Control","Globale Preissteuerung"
33
+ "Field for price","Preisfeld"
34
+ "This field would be overwritten by the new product price.","Dieses Preisfeld wird von dem neuen Preis überschrieben."
35
 
36
  "Add","Hinzufügen"
37
  "Delete","Löschen"
package.xml CHANGED
@@ -1,31 +1,36 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Channelpilotsolutions_Channelpilot</name>
4
- <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>ChannelPilot enables shop operators to reach 140 german marketing-channels and millions of online-buyers.</summary>
10
- <description>&lt;h3&gt;Explore your benefits with ChannelPilot:&lt;/h3&gt;&#xD;
 
 
 
 
 
 
11
  &lt;ul&gt;&#xD;
12
- &lt;li&gt;&lt;b&gt;MORE VISIBILITY:&lt;/b&gt; ChannelPilot places your products in 140 german marketing-channels. You can reach millions of online-buyers - daily!&lt;/li&gt;&#xD;
13
- &lt;li&gt;&lt;b&gt;MORE PROFIT:&lt;/b&gt; You increase your sales and decrease your marketing costs.&lt;/li&gt;&#xD;
14
- &lt;li&gt;&lt;b&gt;DETAILED ANALYSIS:&lt;/b&gt; You will be offered extensive analysis-tools and optimization-suggestions.&lt;/li&gt;&#xD;
15
- &lt;li&gt;&lt;b&gt;FULL CONTROL:&lt;/b&gt; You have an instant overview of all channels and you will be informed automatically about critical incidents.&lt;/li&gt;&#xD;
16
- &lt;li&gt;&lt;b&gt;OVERVIEW OF ALL SHOPS:&lt;/b&gt; You can administrate all your shops within one account and can compare the performance data between them.&lt;/li&gt;&#xD;
17
- &lt;li&gt;&lt;b&gt;FAST CONNECTION:&lt;/b&gt; It is easy to setup your online-shop. ChannelPilot works with all common shop-systems. &lt;/li&gt;&#xD;
18
- &lt;li&gt;&lt;b&gt;EASY HANDLING:&lt;/b&gt; ChannelPilot comes with a modern and intuitive user-interface.&lt;/li&gt;&#xD;
19
- &lt;li&gt;&lt;b&gt;EXTENSIVE SUPPORT:&lt;/b&gt; ChannelPilot Solutions assists you with video-tutorials, web-seminars, trainings and with its competent support-team.&lt;/li&gt;&#xD;
20
- &lt;li&gt;&lt;b&gt;HIGHEST SECURITY:&lt;/b&gt; Your data is protected from unauthorized access by several security zones. Locally abated, redundant systems take over work in the case of an error or misfunction.&lt;/li&gt;&#xD;
21
- &lt;li&gt;&lt;b&gt;BEST QUALITY:&lt;/b&gt; ChannelPilot is "made in Germany" and is exclusively developed in-house by experienced software-engineers.&lt;/li&gt;&#xD;
22
  &lt;/ul&gt;&#xD;
23
- Just get more information about ChannelPilot : &lt;a href="http://www.channelpilot.com"&gt;www.channelpilot.com&lt;/a&gt;</description>
24
- <notes>fixed bug for ordernumber with prefix</notes>
25
  <authors><author><name>ChannelPilot Solutions GmbH</name><user>auto-converted</user><email>info@channelpilot.com</email></author></authors>
26
- <date>2013-10-23</date>
27
- <time>08:25:29</time>
28
- <contents><target name="magecommunity"><dir name="Channelpilotsolutions"><dir name="Channelpilot"><dir name="Adminhtml"><dir name="Model"><dir name="Articlenumber"><file name="Values.php" hash="4a920f99cf9443aaa2f8841d853cebec"/></dir><dir name="Cookiemode"><file name="Values.php" hash="ff8d69f41d7df21707d749305c20e935"/></dir></dir></dir><dir name="Block"><dir name="Adminhtml"><dir name="Field"><file name="Exportfields.php" hash="c3a73f607cc6fe8f249d8fef7d49cfeb"/><file name="Replacefields.php" hash="03403b9cbdad48fa8ca2b28d7440143c"/><file name="Specialfields.php" hash="33842132f2ff85227efcaff836dd4c1c"/><file name="Trackingkeys.php" hash="94c7d54b134a71f0080b3bbd52dac475"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a50cceaf7f52911c35979cf4b5beec22"/><file name="ExportData.php" hash="8b5088f7ffa12b5c5eca38c286861460"/></dir><dir name="controllers"><file name="IndexController.php" hash="6c691bd30403c6340248e6f9b2cedea8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="ee4e49b9b64d99fce70b618ac7349a9d"/><file name="config.xml" hash="c2217ae3c7f5575d8eeed0dac4d3c5d4"/><file name="system.xml" hash="d3ffb78c9469d44b61dc85be2480abc6"/></dir></dir><dir name="Clicktracking"><dir name="etc"><file name="config.xml" hash="1ee288f21630d1873a4f6ebe37c24f10"/></dir></dir><dir name="Salestracking"><dir name="etc"><file name="config.xml" hash="92b7c6e930b2d241d8b095635a10519e"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Channelpilotsolutions_Channelpilot.xml" hash="a64f082fbb324d006d05566a4eb63d3f"/><file name="Channelpilotsolutions_Clicktracking.xml" hash="0e9a283fcb2b0bbc40ed3f3ad960624d"/><file name="Channelpilotsolutions_Salestracking.xml" hash="226c8a5105db455556e450a6b49d8eb2"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="Channelpilotsolutions"><file name="clicktracking.xml" hash="8e97b079e03fd90750ee52b76e3eae08"/><file name="salestracking.xml" hash="2f356111cb7f06f2a7dd39157cfc3a6b"/></dir></dir><dir name="template"><dir name="Channelpilotsolutions"><file name="clicktracking.phtml" hash="54b5c464b923057e4cfd6ed1e27c6597"/><file name="salestracking.phtml" hash="83335bcc1727f7cc8f8600f5d1cb27cb"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="Channelpilotsolutions"><file name="array_dropdown.phtml" hash="cb1230cd8a92ce0a0961f71b396736ec"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><dir name="Channelpilotsolutions"><file name="channelpilot.xml" hash="ee23fe0af5078ab653c5341116c21ddb"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="Channelpilotsolutions"><dir name="Channelpilot"><file name="icon.css" hash="ee075d8ba7c5c45dcb8c87ba1205eaa0"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Channelpilotsolutions_Channelpilot.csv" hash="9bae5f67a38ac2aba098dfc1ed7e4b21"/></dir><dir name="de_CH"><file name="Channelpilotsolutions_Channelpilot.csv" hash="1838fd9365f73bc40ada833d0948b2e4"/></dir><dir name="de_AT"><file name="Channelpilotsolutions_Channelpilot.csv" hash="1838fd9365f73bc40ada833d0948b2e4"/></dir></target></contents>
29
  <compatible/>
30
  <dependencies/>
31
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Channelpilotsolutions_Channelpilot</name>
4
+ <version>2.0.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>ChannelPilot is a powerful solution for professional multi-channel online marketing.</summary>
10
+ <description>&lt;p&gt;ChannelPilot, from Channel Pilot Solutions is a powerful cloud-based solution for professional multi-channel online marketing. By connecting with ChannelPilot, online shops can automatically integrate their products on to numerous marketing channels in the UK (and abroad).&lt;/p&gt;&#xD;
11
+ &lt;p&gt;Integrating on price comparison sites, shopping channels, affiliates, social media and cashback networks means you can reach millions of online buyers daily and significantly increase your online store&#x2019;s revenue.&lt;/p&gt;&#xD;
12
+ &lt;p&gt;The technological base for the connection of online shops with ChannelPilot is provided by our automised product feeds. Shops send their list of goods in the form of a data feed, like .CSV and .XML, in the highest detail possible.&lt;/p&gt;&#xD;
13
+ &lt;p&gt;ChannelPilot is user-friendly and intuitive, comprised of a three-step cycle: integrate, analyse and optimise. These three processes are in place to ensure a continuous increase in sales for web shops.&lt;/p&gt;&#xD;
14
+ &#xD;
15
+ &#xD;
16
+ &lt;h3&gt;Explore your benefits with ChannelPilot:&lt;/h3&gt;&#xD;
17
  &lt;ul&gt;&#xD;
18
+ &lt;li&gt;&lt;b&gt;Price Search Engines and Price Comparison Sites:&lt;/b&gt; List on all the relevant price comparison sites and shopping portals in the UK and abroad with ChannelPilot.&lt;/li&gt;&#xD;
19
+ &lt;li&gt;&lt;b&gt;Marketplaces:&lt;/b&gt; Sell on the furthest-reaching marketplaces with little effort with the help of ChannelPilot.&lt;/li&gt;&#xD;
20
+ &lt;li&gt;&lt;b&gt;Google PLAs:&lt;/b&gt; With ChannelPilot , Google Product Listing Ads are fine-tuned and monitored.&lt;/li&gt;&#xD;
21
+ &lt;li&gt;&lt;b&gt;Market Price Analysis:&lt;/b&gt; Market price analysis right to the last detail-ChannelPilot&#x2019;s got it covered!&lt;/li&gt;&#xD;
22
+ &lt;li&gt;&lt;b&gt;ChannelPilot eCommerce Suite:&lt;/b&gt; All the features on ChannelPilot interact together effortlessly to form this highpowered, multi-faceted e-commerce solution.&lt;/li&gt;&#xD;
23
+ &lt;li&gt;&lt;b&gt;ChannelPilot goes international:&lt;/b&gt; If your business is looking to expand, ChannelPilot is already equipped to help you start selling further afield.&lt;/li&gt;&#xD;
24
+ &lt;li&gt;&lt;b&gt;Ready To Start:&lt;/b&gt; ChannelPilot has all the popular shop and ERP system plug-ins, extensions and interfaces configured so you can get started as soon as possible.&lt;/li&gt;&#xD;
25
+ &lt;li&gt;&lt;b&gt;Data feed Optimisation:&lt;/b&gt; Load your product catalogue and let the tool intelligently customise and optimise your product data feeds.&lt;/li&gt;&#xD;
26
+ &lt;li&gt;&lt;b&gt;ChannelPilot Multi-Platform:&lt;/b&gt; Access ChannelPilot on any device (e.g. computer, tablet or smartphone) and keep a firm hold on your online marketing- wherever you are!&lt;/li&gt;&#xD;
 
27
  &lt;/ul&gt;&#xD;
28
+ Just get more information about ChannelPilot: &lt;a href="http://www.channelpilot.com"&gt;www.channelpilot.com&lt;/a&gt;</description>
29
+ <notes>new plugin for new ChannelPilot release</notes>
30
  <authors><author><name>ChannelPilot Solutions GmbH</name><user>auto-converted</user><email>info@channelpilot.com</email></author></authors>
31
+ <date>2014-06-24</date>
32
+ <time>14:32:13</time>
33
+ <contents><target name="magecommunity"><dir name="Channelpilotsolutions"><dir name="Channelpilot"><dir name="Adminhtml"><dir name="Model"><dir name="Articlenumber"><file name="Values.php" hash="f2744ef8301e25e096318f34eb97c2bf"/></dir><dir name="Cookiemode"><file name="Values.php" hash="1ec39f85bb7562c1b6a4614f759d9124"/></dir><dir name="Pricefield"><file name="Values.php" hash="6b02dfa3fa93daafa8325d66a986b4ac"/></dir><dir name="Truefalse"><file name="Values.php" hash="fcd5374f41de3cddc9463c2faa8e8c75"/></dir><dir name="Truefalsesecurity"><file name="Values.php" hash="8f45d26c937ba833c3e3483665b6d5df"/></dir></dir></dir><dir name="Block"><dir name="Adminhtml"><dir name="Field"><file name="Exportfields.php" hash="81525753cbe46549daa7a09997b46130"/><file name="Replacefields.php" hash="1e4ddda15b611616f9d097ba301562ac"/><file name="Specialfields.php" hash="a8c88591141c672e772128c9605b52b9"/><file name="Trackingkeys.php" hash="6365f16bc6a5ebf13ada33a79892a857"/></dir></dir></dir><dir name="Helper"><dir name="api"><dir name="1_0"><dir name="responses"><file name="GetManagedArticlePricesResponse.php" hash="9ad5adee1952b9408b442449791a1f34"/><file name="GetNewMarketplaceOrdersResponse.php" hash="cd5db953a84759b93a35a360956c4624"/><file name="GetServerTimeResponse.php" hash="07d157639b5bf715aa3f93b0d9e4b736"/><file name="Response.php" hash="c76ce62707a862e1c59346c668055b5d"/><file name="UpdateArticleResult.php" hash="a014c60be447fbb9cf48c947c8e9822f"/><file name="UpdateArticlesResponse.php" hash="338619d50391d91defb5c9d41370022f"/><file name="UpdateOrderResult.php" hash="0fbd88371624270a8cb2c4209a89cfac"/><file name="UpdateOrdersResponse.php" hash="b0ad5828da633b05e654da393b15526a"/></dir><dir name="thin"><file name="CPAddress.php" hash="885fb4517335421fbd8cbc882ae336b1"/><file name="CPArticle.php" hash="1adce1ce33acdd0185dee06010040b18"/><file name="CPArticleUpdate.php" hash="45f514823895c754010f8f11a1ff683a"/><file name="CPAuth.php" hash="cf5fe570dbd98e3e6339b20cec826b7b"/><file name="CPCancellation.php" hash="9bf808e265e09d166466313405a167fc"/><file name="CPCustomer.php" hash="62babdf11e9b4d80ae0afbbf96ba329d"/><file name="CPDelivery.php" hash="c8c54883370efd519249a9a9551668d0"/><file name="CPDiscount.php" hash="5d6f2766869134a86761c12230dc32d1"/><file name="CPManagedArticlePrice.php" hash="65c4c0df04b7c8d20294874de11640d6"/><file name="CPMoney.php" hash="952131eccc8470e107c78e15c94b6495"/><file name="CPOrder.php" hash="32623885f664e9b5871fc48b6ba0c801"/><file name="CPOrderHeader.php" hash="828377182e8197c304f230a783606993"/><file name="CPOrderItem.php" hash="dfe2440a08e3d0f13e638fc4090e6c52"/><file name="CPOrderStatus.php" hash="e0e767388dd9a1ab8be5a990f1ab1259"/><file name="CPOrderSummary.php" hash="fceaa6a79b5fc892062681f518fd0243"/><file name="CPPayment.php" hash="446ffde1318d001c213de2b80855af07"/><file name="CPResponseHeader.php" hash="53930210d68046183e3be306996ea9b9"/><file name="CPShipping.php" hash="eaddceace28cdc6ba72434a6321d8c47"/></dir><file name="CPResultCodes.php" hash="955180ee33f14b4afa93f6eb1b5df53f"/><file name="ChannelPilotSellerAPI_v1_0.php" hash="f7d41c7b31a15d879121fface0fc3e4f"/></dir></dir><dir name="handler"><file name="CPAbstractHandler.php" hash="41eac17e77c2d6f9ffefa28cbd24953e"/><file name="CPCancellationHandler.php" hash="9b77706089a26ae42ad2e00c303b66ae"/><file name="CPDebugHandler.php" hash="43f2e8da6e44adfb20d7ec813ca54cad"/><file name="CPDeliveryHandler.php" hash="98e4cdd670e8b82724ed31f3248f117f"/><file name="CPErrorHandler.php" hash="5d728c064c068fdf8354fa87882e4dba"/><file name="CPExportHandler.php" hash="fa1ad717314260ccc9a6b09c899e5d53"/><file name="CPNewPriceHandler.php" hash="4d3f328502eac33e5a9608ef62e6146a"/><file name="CPNewsHandler.php" hash="4975a6271baf09af3b2f007f13bb587c"/><file name="CPOrderHandler.php" hash="3fe672eeae5c0f014cf5c666c36fc146"/><file name="CPRegisterHandler.php" hash="43a7baff372b472049dc0e52deb2549f"/><file name="CPStatusHandler.php" hash="3f9c9e8ef563d12d16051fcd9b996a54"/><file name="todoCPPaymentHandler.php" hash="34ea64beda7c8bc5309ebea280146c32"/></dir><dir name="responses"><file name="CPGetStatusHookResponse.php" hash="672609ebcaa23aa0de85aed04c7662d8"/><file name="CPHookResponse.php" hash="9acdda5838cae8b6022af2f4e0a9314b"/><file name="CPRegisterHookResponse.php" hash="206de6433d0795ebdabff98129cc2fb7"/></dir><dir name="special"><file name="CustomerFunctions.php" hash="c9f4d1d28b3978fcc7824cdbeddbcc73"/></dir><file name="CPErrors.php" hash="3659c38a1ed3be4aa4ec03d93e68a84e"/><file name="Data.php" hash="d7501ab1c2667da79d4201f1c78ad945"/><file name="ExportData.php" hash="dd807aefe4ae7dbb210d08f63bd436b8"/></dir><dir name="controllers"><file name="IndexController.php" hash="36e391b61d1914f8669cd48207dd06da"/></dir><dir name="etc"><file name="adminhtml.xml" hash="62fad9ef0e77e858b74d2a7bdd6a6879"/><file name="config.xml" hash="a321e8a3b8a9c38aa0a801983f9cda20"/><file name="system.xml" hash="1622d955b12a3725b5ad67ff25d33ea7"/></dir><dir name="sql"><dir name="channelpilot_setup"><file name="install-2.0.0.0.php" hash="0ecebd442d5f554c4fadf54781c19f89"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Channelpilotsolutions_Channelpilot.xml" hash="a64f082fbb324d006d05566a4eb63d3f"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="Channelpilotsolutions"><file name="channelpilot.xml" hash="732f1d98851f3c1bf0cb9e655a4a0359"/></dir></dir><dir name="template"><dir name="Channelpilotsolutions"><file name="channelpilot.phtml" hash="2c1299423849d8a245d12b043ca8f058"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="Channelpilotsolutions"><file name="array_dropdown.phtml" hash="cb1230cd8a92ce0a0961f71b396736ec"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><dir name="Channelpilotsolutions"><file name="channelpilot.xml" hash="ee23fe0af5078ab653c5341116c21ddb"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="Channelpilotsolutions"><dir name="Channelpilot"><file name="icon.css" hash="ee075d8ba7c5c45dcb8c87ba1205eaa0"/></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="Channelpilotsolutions"><file name="channelpilot" hash=""/></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Channelpilotsolutions_Channelpilot.csv" hash="bbc431d629000b2d166509614f9ef935"/></dir><dir name="de_CH"><file name="Channelpilotsolutions_Channelpilot.csv" hash="bbc431d629000b2d166509614f9ef935"/></dir><dir name="de_AT"><file name="Channelpilotsolutions_Channelpilot.csv" hash="bbc431d629000b2d166509614f9ef935"/></dir></target></contents>
34
  <compatible/>
35
  <dependencies/>
36
  </package>