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 !== '') {
</