Channelpilotsolutions_Channelpilot - Version 2.2.3

Version Notes

- general bugfixes

Download this release

Release Info

Developer ChannelPilot Solutions GmbH
Extension Channelpilotsolutions_Channelpilot
Version 2.2.3
Comparing to
See all releases


Code changes from version 2.2.2 to 2.2.3

Files changed (67) hide show
  1. app/code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Articlenumber/Values.php +32 -32
  2. app/code/community/Channelpilotsolutions/Channelpilot/Adminhtml/Model/Orderstatus/Values.php +46 -46
  3. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Abstract.php +44 -44
  4. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Exportfields.php +76 -68
  5. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Replacefields.php +72 -72
  6. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Specialfields.php +54 -54
  7. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Trackingkeys.php +66 -66
  8. app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Hintlogo.php +11 -11
  9. app/code/community/Channelpilotsolutions/Channelpilot/Block/Tracking/Tracking.php +139 -139
  10. app/code/community/Channelpilotsolutions/Channelpilot/Helper/Data.php +222 -222
  11. app/code/community/Channelpilotsolutions/Channelpilot/Helper/Export.php +0 -296
  12. app/code/community/Channelpilotsolutions/Channelpilot/Helper/ExportData.php +0 -575
  13. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/ChannelPilotSellerAPI_v1_0.php +198 -198
  14. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPDelivery.php +54 -54
  15. app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/thin/CPPayment.php +37 -37
  16. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPAbstractHandler.php +142 -137
  17. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPCancellationHandler.php +146 -146
  18. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPDebugHandler.php +49 -49
  19. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPDeliveryHandler.php +103 -103
  20. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPExportHandler.php +601 -559
  21. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPNewPriceHandler.php +172 -172
  22. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPNewsHandler.php +44 -44
  23. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPOrderHandler.php +604 -605
  24. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPPaymentHandler.php +85 -85
  25. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPRegisterHandler.php +123 -123
  26. app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPStatusHandler.php +172 -172
  27. app/code/community/Channelpilotsolutions/Channelpilot/Helper/responses/CPHookResponse.php +54 -54
  28. app/code/community/Channelpilotsolutions/Channelpilot/Model/Abstract.php +201 -201
  29. app/code/community/Channelpilotsolutions/Channelpilot/Model/Adminhtml/Source/Trackingmethod.php +33 -33
  30. app/code/community/Channelpilotsolutions/Channelpilot/Model/Carrier/Cpshipping.php +86 -86
  31. app/code/community/Channelpilotsolutions/Channelpilot/Model/Logs.php +38 -38
  32. app/code/community/Channelpilotsolutions/Channelpilot/Model/Order.php +74 -65
  33. app/code/community/Channelpilotsolutions/Channelpilot/Model/Order/Item.php +52 -52
  34. app/code/community/Channelpilotsolutions/Channelpilot/Model/Order/Shipment.php +44 -44
  35. app/code/community/Channelpilotsolutions/Channelpilot/Model/Payment.php +111 -111
  36. app/code/community/Channelpilotsolutions/Channelpilot/Model/PaymentTypes.php +0 -18
  37. app/code/community/Channelpilotsolutions/Channelpilot/Model/Paymenttypes.php +18 -18
  38. app/code/community/Channelpilotsolutions/Channelpilot/Model/Prices.php +38 -38
  39. app/code/community/Channelpilotsolutions/Channelpilot/Model/Registration.php +73 -73
  40. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Logs.php +31 -31
  41. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Logs/Collection.php +31 -31
  42. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Order.php +103 -81
  43. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Order/Collection.php +97 -97
  44. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Order/Item.php +59 -59
  45. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Order/Item/Collection.php +97 -97
  46. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Order/Shipment.php +51 -51
  47. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Order/Shipment/Collection.php +31 -31
  48. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Prices.php +32 -32
  49. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Prices/Collection.php +31 -31
  50. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Registration.php +97 -97
  51. app/code/community/Channelpilotsolutions/Channelpilot/Model/Resource/Registration/Collection.php +31 -31
  52. app/code/community/Channelpilotsolutions/Channelpilot/controllers/IndexController.php +36 -36
  53. app/code/community/Channelpilotsolutions/Channelpilot/etc/adminhtml.xml +60 -60
  54. app/code/community/Channelpilotsolutions/Channelpilot/etc/config.xml +182 -182
  55. app/code/community/Channelpilotsolutions/Channelpilot/etc/system.xml +575 -575
  56. app/code/community/Channelpilotsolutions/Channelpilot/sql/channelpilot_setup/mysql4-install-2.0.0.php +206 -206
  57. app/code/community/Channelpilotsolutions/Channelpilot/sql/channelpilot_setup/mysql4-upgrade-1.0.0-2.0.0.php +179 -179
  58. app/code/community/Channelpilotsolutions/Channelpilot/sql/channelpilot_setup/mysql4-upgrade-2.1.6-2.2.0.php +57 -57
  59. app/design/adminhtml/base/default/template/channelpilotsolutions/array_dropdown.phtml +174 -174
  60. app/design/adminhtml/base/default/template/channelpilotsolutions/config_hint.phtml +145 -145
  61. app/design/frontend/base/default/layout/Channelpilotsolutions/channelpilot.xml +42 -42
  62. app/design/frontend/base/default/template/Channelpilotsolutions/clicktracking_js.phtml +26 -26
  63. app/design/frontend/base/default/template/Channelpilotsolutions/gtm.phtml +0 -44
  64. app/design/frontend/base/default/template/Channelpilotsolutions/salestracking_js.phtml +46 -46
  65. app/design/frontend/base/default/template/Channelpilotsolutions/tracking_image.phtml +26 -26
  66. app/etc/modules/Channelpilotsolutions_Channelpilot.xml +33 -33
  67. package.xml +6 -6
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/Orderstatus/Values.php CHANGED
@@ -1,47 +1,47 @@
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_cookiemode
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_Orderstatus_Values {
25
-
26
- public function toOptionArray() {
27
-
28
- $sQuery = "select * from sales_order_status;";
29
- $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
30
- try {
31
- $sResult = $dbConnection->fetchAll($sQuery);
32
- $result_array = array();
33
- $result_array[] = array('value' => "---", 'label' => "---");
34
- foreach ($sResult as $resultType) {
35
- $result_array[] = array('value' => $resultType['status'], 'label' => $resultType['label']);
36
- }
37
- } catch (Exception $e) {
38
- $dbConnection->closeConnection();
39
- }
40
- $dbConnection->closeConnection();
41
-
42
- return $result_array;
43
- }
44
-
45
- }
46
-
47
  ?>
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_cookiemode
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_Orderstatus_Values {
25
+
26
+ public function toOptionArray() {
27
+
28
+ $sQuery = "select * from sales_order_status;";
29
+ $dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
30
+ try {
31
+ $sResult = $dbConnection->fetchAll($sQuery);
32
+ $result_array = array();
33
+ $result_array[] = array('value' => "---", 'label' => "---");
34
+ foreach ($sResult as $resultType) {
35
+ $result_array[] = array('value' => $resultType['status'], 'label' => $resultType['label']);
36
+ }
37
+ } catch (Exception $e) {
38
+ $dbConnection->closeConnection();
39
+ }
40
+ $dbConnection->closeConnection();
41
+
42
+ return $result_array;
43
+ }
44
+
45
+ }
46
+
47
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Abstract.php CHANGED
@@ -1,45 +1,45 @@
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 Björn Wehner <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
- abstract class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Abstract extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {
25
-
26
- /**
27
- * Get all product attribute codes as array. Returned format:
28
- * [0] => Array
29
- * (
30
- * [attribute_code] => code
31
- * )
32
- * @param array $excludeAttributeCodes Attribute codes used for a NOT IN filter
33
- * @return array
34
- */
35
- protected function _getProductAttributeCodes(array $excludeAttributeCodes = array()) {
36
- $query = new Zend_Db_Select(Mage::getSingleton('core/resource')->getConnection('core_read'));
37
- $query->from(Mage::getSingleton('core/resource')->getTableName('eav_entity_type'), array('entity_type_id'))
38
- ->where('entity_type_code = ?', 'catalog_product');
39
- return Mage::getResourceModel('eav/entity_attribute_collection')
40
- ->addFieldToSelect('attribute_code')
41
- ->addFieldToFilter('entity_type_id', array('eq' => new Zend_Db_Expr('('.$query.')')))
42
- ->addFieldToFilter('attribute_code', array('nin' => $excludeAttributeCodes))
43
- ->getData();
44
- }
45
  }
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 Björn Wehner <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
+ abstract class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Abstract extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {
25
+
26
+ /**
27
+ * Get all product attribute codes as array. Returned format:
28
+ * [0] => Array
29
+ * (
30
+ * [attribute_code] => code
31
+ * )
32
+ * @param array $excludeAttributeCodes Attribute codes used for a NOT IN filter
33
+ * @return array
34
+ */
35
+ protected function _getProductAttributeCodes(array $excludeAttributeCodes = array()) {
36
+ $query = new Zend_Db_Select(Mage::getSingleton('core/resource')->getConnection('core_read'));
37
+ $query->from(Mage::getSingleton('core/resource')->getTableName('eav_entity_type'), array('entity_type_id'))
38
+ ->where('entity_type_code = ?', 'catalog_product');
39
+ return Mage::getResourceModel('eav/entity_attribute_collection')
40
+ ->addFieldToSelect('attribute_code')
41
+ ->addFieldToFilter('entity_type_id', array('eq' => new Zend_Db_Expr('('.$query.')')))
42
+ ->addFieldToFilter('attribute_code', array('nin' => $excludeAttributeCodes))
43
+ ->getData();
44
+ }
45
  }
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Exportfields.php CHANGED
@@ -1,69 +1,77 @@
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 block_adminhtml_field
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_Block_Adminhtml_Field_Exportfields extends Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Abstract {
25
-
26
- public function __construct() {
27
- $this->addColumn('productattribute', array(
28
- 'label' => Mage::helper('adminhtml')->__('Data field'),
29
- 'size' => 30
30
- ));
31
- $this->_addAfter = false;
32
-
33
- parent::__construct();
34
- $this->setTemplate('channelpilotsolutions/array_dropdown.phtml');
35
- }
36
-
37
- protected function _renderCellTemplate($columnName) {
38
- if (empty($this->_columns[$columnName])) {
39
- throw new Exception('Wrong column name specified.');
40
- }
41
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
42
-
43
- if ($columnName == 'productattribute') {
44
- $rendered = '<select name="' . $inputName . '">';
45
-
46
- // Get attribute codes and types
47
- $attributes = $this->_getProductAttributeCodes(array(
48
- 'sku','price','name','description','manufacturer','color','weight', 'parent_id'
49
- ));
50
-
51
- $attributes[]['attribute_code'] = 'qty';
52
- $attributes[]['attribute_code'] = 'stock_status';
53
- $attributes[]['attribute_code'] = 'cp_color_attribute_id';
54
- $attributes[]['attribute_code'] = 'type_id';
55
- $attributes[]['attribute_code'] = 'parent_id';
56
- asort($attributes);
57
- foreach ($attributes as $attribute) {
58
- $rendered .= '<option value="' . $attribute['attribute_code'] . '">' . $attribute['attribute_code'] . '</option>';
59
- }
60
- $rendered .= '</select>';
61
- return $rendered;
62
- }
63
-
64
- return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}"/>';
65
- }
66
-
67
- }
68
-
 
 
 
 
 
 
 
 
69
  ?>
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 block_adminhtml_field
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_Block_Adminhtml_Field_Exportfields extends Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Abstract {
25
+
26
+ public function __construct() {
27
+ $this->addColumn('productattribute', array(
28
+ 'label' => Mage::helper('adminhtml')->__('Data field'),
29
+ 'size' => 30
30
+ ));
31
+ $this->_addAfter = false;
32
+
33
+ parent::__construct();
34
+ $this->setTemplate('channelpilotsolutions/array_dropdown.phtml');
35
+ }
36
+
37
+ protected function _renderCellTemplate($columnName) {
38
+ if (empty($this->_columns[$columnName])) {
39
+ throw new Exception('Wrong column name specified.');
40
+ }
41
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
42
+
43
+ if ($columnName == 'productattribute') {
44
+ $rendered = '<select name="' . $inputName . '">';
45
+
46
+ // Get attribute codes and types
47
+ $attributes = $this->_getProductAttributeCodes(array(
48
+ 'sku','price','name','description','manufacturer','color','weight', 'parent_id'
49
+ ));
50
+
51
+ $attributes[]['attribute_code'] = 'qty';
52
+ $attributes[]['attribute_code'] = 'stock_status';
53
+ $attributes[]['attribute_code'] = 'cp_color_attribute_id';
54
+ $attributes[]['attribute_code'] = 'type_id';
55
+ $attributes[]['attribute_code'] = 'parent_id';
56
+ asort($attributes);
57
+ foreach ($attributes as $attribute) {
58
+ if($attribute['attribute_code'] == 'group_price') {
59
+ $customerGroupCollection = Mage::getModel('customer/group')->getCollection();
60
+ $strGroupPrice = 'group_price';
61
+ foreach($customerGroupCollection as $group) {
62
+ $rendered .= '<option value="' . $strGroupPrice.'_'.$group->getId(). '">' . $strGroupPrice.' - '.$group->getCustomerGroupCode() . '</option>';
63
+ }
64
+ } else {
65
+ $rendered .= '<option value="' . $attribute['attribute_code'] . '">' . $attribute['attribute_code'] . '</option>';
66
+ }
67
+ }
68
+ $rendered .= '</select>';
69
+ return $rendered;
70
+ }
71
+
72
+ return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}"/>';
73
+ }
74
+
75
+ }
76
+
77
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Replacefields.php CHANGED
@@ -1,73 +1,73 @@
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 block_adminhtml_field
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_Block_Adminhtml_Field_Replacefields extends Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Abstract {
25
-
26
- public function __construct() {
27
- $this->addColumn('productattribute', array(
28
- 'label' => Mage::helper('adminhtml')->__('Data field'),
29
- 'size' => 30
30
- ));
31
- $this->_addAfter = false;
32
-
33
- parent::__construct();
34
- $this->setTemplate('channelpilotsolutions/array_dropdown.phtml');
35
- }
36
-
37
- protected function _renderCellTemplate($columnName) {
38
- if (empty($this->_columns[$columnName])) {
39
- throw new Exception('Wrong column name specified.');
40
- }
41
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
42
-
43
- if ($columnName == 'productattribute') {
44
- $rendered = '<select name="' . $inputName . '">';
45
- $attributes = $this->_getProductAttributeCodes(array(
46
- 'sku','price','name','description','manufacturer','color','weight'
47
- ));
48
-
49
- $attributes[]['attribute_code'] = 'qty';
50
- $attributes[]['attribute_code'] = 'stock_status';
51
- $attributes[]['attribute_code'] = 'cp_color_attribute_id';
52
- $attributes[]['attribute_code'] = 'parent_id';
53
-
54
- $attributes[]['attribute_code'] = 'categories';
55
- $attributes[]['attribute_code'] = 'cp_image_url';
56
- $attributes[]['attribute_code'] = 'cp_product_url';
57
- $attributes[]['attribute_code'] = 'cp_additional_image_1';
58
- $attributes[]['attribute_code'] = 'cp_additional_image_2';
59
- $attributes[]['attribute_code'] = 'cp_additional_image_3';
60
- asort($attributes);
61
- foreach ($attributes as $attribute) {
62
- $rendered .= '<option value="' . $attribute['attribute_code'] . '">' . $attribute['attribute_code'] . '</option>';
63
- }
64
- $rendered .= '</select>';
65
- return $rendered;
66
- }
67
-
68
- return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}"/>';
69
- }
70
-
71
- }
72
-
73
  ?>
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 block_adminhtml_field
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_Block_Adminhtml_Field_Replacefields extends Channelpilotsolutions_Channelpilot_Block_Adminhtml_Field_Abstract {
25
+
26
+ public function __construct() {
27
+ $this->addColumn('productattribute', array(
28
+ 'label' => Mage::helper('adminhtml')->__('Data field'),
29
+ 'size' => 30
30
+ ));
31
+ $this->_addAfter = false;
32
+
33
+ parent::__construct();
34
+ $this->setTemplate('channelpilotsolutions/array_dropdown.phtml');
35
+ }
36
+
37
+ protected function _renderCellTemplate($columnName) {
38
+ if (empty($this->_columns[$columnName])) {
39
+ throw new Exception('Wrong column name specified.');
40
+ }
41
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
42
+
43
+ if ($columnName == 'productattribute') {
44
+ $rendered = '<select name="' . $inputName . '">';
45
+ $attributes = $this->_getProductAttributeCodes(array(
46
+ 'sku','price','name','description','manufacturer','color','weight'
47
+ ));
48
+
49
+ $attributes[]['attribute_code'] = 'qty';
50
+ $attributes[]['attribute_code'] = 'stock_status';
51
+ $attributes[]['attribute_code'] = 'cp_color_attribute_id';
52
+ $attributes[]['attribute_code'] = 'parent_id';
53
+
54
+ $attributes[]['attribute_code'] = 'categories';
55
+ $attributes[]['attribute_code'] = 'cp_image_url';
56
+ $attributes[]['attribute_code'] = 'cp_product_url';
57
+ $attributes[]['attribute_code'] = 'cp_additional_image_1';
58
+ $attributes[]['attribute_code'] = 'cp_additional_image_2';
59
+ $attributes[]['attribute_code'] = 'cp_additional_image_3';
60
+ asort($attributes);
61
+ foreach ($attributes as $attribute) {
62
+ $rendered .= '<option value="' . $attribute['attribute_code'] . '">' . $attribute['attribute_code'] . '</option>';
63
+ }
64
+ $rendered .= '</select>';
65
+ return $rendered;
66
+ }
67
+
68
+ return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}"/>';
69
+ }
70
+
71
+ }
72
+
73
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Specialfields.php CHANGED
@@ -1,55 +1,55 @@
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 block_adminhtml_field
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_Block_Adminhtml_Field_Specialfields extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {
25
-
26
- protected $magentoAttributes;
27
-
28
- public function __construct() {
29
- $this->addColumn('name', array(
30
- 'label' => Mage::helper('adminhtml')->__('Data field name'),
31
- 'size' => 30
32
- ));
33
- $this->addColumn('value', array(
34
- 'label' => Mage::helper('adminhtml')->__('Data field value'),
35
- 'size' => 30
36
- ));
37
- $this->_addAfter = false;
38
-
39
- parent::__construct();
40
- $this->setTemplate('channelpilotsolutions/array_dropdown.phtml');
41
- }
42
-
43
- protected function _renderCellTemplate($columnName) {
44
- if (empty($this->_columns[$columnName])) {
45
- throw new Exception('Wrong column name specified.');
46
- }
47
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
48
-
49
-
50
- return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}"/>';
51
- }
52
-
53
- }
54
-
55
  ?>
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 block_adminhtml_field
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_Block_Adminhtml_Field_Specialfields extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {
25
+
26
+ protected $magentoAttributes;
27
+
28
+ public function __construct() {
29
+ $this->addColumn('name', array(
30
+ 'label' => Mage::helper('adminhtml')->__('Data field name'),
31
+ 'size' => 30
32
+ ));
33
+ $this->addColumn('value', array(
34
+ 'label' => Mage::helper('adminhtml')->__('Data field value'),
35
+ 'size' => 30
36
+ ));
37
+ $this->_addAfter = false;
38
+
39
+ parent::__construct();
40
+ $this->setTemplate('channelpilotsolutions/array_dropdown.phtml');
41
+ }
42
+
43
+ protected function _renderCellTemplate($columnName) {
44
+ if (empty($this->_columns[$columnName])) {
45
+ throw new Exception('Wrong column name specified.');
46
+ }
47
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
48
+
49
+
50
+ return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}"/>';
51
+ }
52
+
53
+ }
54
+
55
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Field/Trackingkeys.php CHANGED
@@ -1,67 +1,67 @@
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 block_adminhtml_field
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_Block_Adminhtml_Field_Trackingkeys extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {
25
-
26
- protected $magentoAttributes;
27
-
28
- public function __construct() {
29
- $this->addColumn('shop', array(
30
- 'label' => Mage::helper('adminhtml')->__('Shop'),
31
- 'size' => 15
32
- ));
33
- $this->addColumn('trackingkey', array(
34
- 'label' => Mage::helper('adminhtml')->__('TrackingKey'),
35
- 'size' => 28
36
- ));
37
- $this->_addAfter = false;
38
-
39
- parent::__construct();
40
- $this->setTemplate('channelpilotsolutions/array_dropdown.phtml');
41
- }
42
-
43
- protected function _renderCellTemplate($columnName) {
44
- if (empty($this->_columns[$columnName])) {
45
- throw new Exception('Wrong column name specified.');
46
- }
47
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
48
-
49
- if ($columnName == 'shop') {
50
- $rendered = '<select name="' . $inputName . '">';
51
- $storeCollection = Mage::getSingleton('core/store')->getCollection()
52
- ->addFieldToFilter('code', array('neq' => Mage_Core_Model_Store::ADMIN_CODE))
53
- ->setOrder('website_id', 'ASC');
54
-
55
- foreach ($storeCollection as $store) {
56
- $rendered .= '<option value="' . $store->getId() . '">' . $store->getName() . '</option>';
57
- }
58
-
59
- $rendered .= '</select>';
60
- return $rendered;
61
- }
62
- return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}"/>';
63
- }
64
-
65
- }
66
-
67
  ?>
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 block_adminhtml_field
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_Block_Adminhtml_Field_Trackingkeys extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {
25
+
26
+ protected $magentoAttributes;
27
+
28
+ public function __construct() {
29
+ $this->addColumn('shop', array(
30
+ 'label' => Mage::helper('adminhtml')->__('Shop'),
31
+ 'size' => 15
32
+ ));
33
+ $this->addColumn('trackingkey', array(
34
+ 'label' => Mage::helper('adminhtml')->__('TrackingKey'),
35
+ 'size' => 28
36
+ ));
37
+ $this->_addAfter = false;
38
+
39
+ parent::__construct();
40
+ $this->setTemplate('channelpilotsolutions/array_dropdown.phtml');
41
+ }
42
+
43
+ protected function _renderCellTemplate($columnName) {
44
+ if (empty($this->_columns[$columnName])) {
45
+ throw new Exception('Wrong column name specified.');
46
+ }
47
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
48
+
49
+ if ($columnName == 'shop') {
50
+ $rendered = '<select name="' . $inputName . '">';
51
+ $storeCollection = Mage::getSingleton('core/store')->getCollection()
52
+ ->addFieldToFilter('code', array('neq' => Mage_Core_Model_Store::ADMIN_CODE))
53
+ ->setOrder('website_id', 'ASC');
54
+
55
+ foreach ($storeCollection as $store) {
56
+ $rendered .= '<option value="' . $store->getId() . '">' . $store->getName() . '</option>';
57
+ }
58
+
59
+ $rendered .= '</select>';
60
+ return $rendered;
61
+ }
62
+ return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}"/>';
63
+ }
64
+
65
+ }
66
+
67
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Block/Adminhtml/Hintlogo.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
-
3
- class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Hintlogo extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface {
4
-
5
- protected $_template = 'channelpilotsolutions/config_hint.phtml';
6
-
7
- public function render(Varien_Data_Form_Element_Abstract $element) {
8
- return $this->toHtml();
9
- }
10
-
11
- }
1
+ <?php
2
+
3
+ class Channelpilotsolutions_Channelpilot_Block_Adminhtml_Hintlogo extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface {
4
+
5
+ protected $_template = 'channelpilotsolutions/config_hint.phtml';
6
+
7
+ public function render(Varien_Data_Form_Element_Abstract $element) {
8
+ return $this->toHtml();
9
+ }
10
+
11
+ }
app/code/community/Channelpilotsolutions/Channelpilot/Block/Tracking/Tracking.php CHANGED
@@ -1,140 +1,140 @@
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
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Bj�rn Wehner <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_Tracking_Tracking extends Mage_Core_Block_Template
24
- {
25
- const IMAGE_URL_CLICK = 'https://click.cptrack.de/verify';
26
- const IMAGE_URL_SALE = 'https://sale.cptrack.de/';
27
-
28
- /**
29
- * Flag to wether use the click or sales tracking.
30
- * @var bool
31
- */
32
- protected $_isSale;
33
-
34
- public function __construct() {
35
- $this->_isSale = false;
36
- }
37
-
38
- /**
39
- * Check if tracking is enabled.
40
- * @return bool
41
- */
42
- public function isEnabled() {
43
- return Mage::getStoreConfigFlag('channelpilot_tracking/channelpilot_tracking/channelpilot_useTracking');
44
- }
45
-
46
- /**
47
- * Check if the current tracking mode is set to "Image".
48
- * @return bool
49
- */
50
- public function isTrackingModeImage() {
51
- return Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/method') == Channelpilotsolutions_Channelpilot_Model_Adminhtml_Source_Trackingmethod::TRACKING_METHOD_IMAGE;
52
- }
53
-
54
- /**
55
- * Get the tracking key for the current shop.
56
- * @return mixed
57
- */
58
- public function getTrackingKey() {
59
- $storeId = Mage::app()->getStore()->getId();
60
- $trackingKeys = unserialize(Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/channelpilot_trackingkeys'));
61
- foreach ($trackingKeys as $element) {
62
- if ($element['shop'] == $storeId) {
63
- return $element['trackingkey'];
64
- }
65
- }
66
- }
67
-
68
- /**
69
- * Get the order with the last increment id from the checkout session.
70
- * Returns false if the order could not be loaded.
71
- * @return Mage_Sales_Model_Order | bool
72
- */
73
- public function getOrder() {
74
- $lastIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
75
- $order = Mage::getModel('sales/order')->loadByIncrementId($lastIncrementId);
76
- if($order && $order->getId()) {
77
- return $order;
78
- }
79
-
80
- Mage::log('Could not load order with increment id '.$lastIncrementId.' for sales tracking.');
81
- return false;
82
- }
83
-
84
- /**
85
- * Get the identifier field for the product (entity_id oder sku).
86
- * @return string
87
- */
88
- public function getProductIdField() {
89
- return Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_articlenumber');
90
- }
91
-
92
- /**
93
- * Get the tracking cookie mode.
94
- * @return string
95
- */
96
- public function getCookieMode() {
97
- return Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/channelpilot_cookiemode');
98
- }
99
-
100
- /**
101
- * Get the url for the tracking image.
102
- * @return string
103
- */
104
- public function getImageUrl() {
105
- if($this->_isSale) {
106
- $order = $this->getOrder();
107
- if($order) {
108
- $url = self::IMAGE_URL_SALE
109
- . '?trackingKey='.urlencode($this->getTrackingKey())
110
- . '&cookie='.urlencode($this->getCookieMode())
111
- . '&orderId='.urlencode($order->getId())
112
- . '&orderTotal='.urlencode($order->getGrandTotal() - $order->getTaxAmount());
113
-
114
- $productIdField = $this->getProductIdField();
115
- $i = 1;
116
- foreach($order->getItemsCollection(array(), true) as $item) {
117
- $url .= '&id'.$i.'='.urlencode($item->getData($productIdField))
118
- . '&price'.$i.'='.urlencode($item->getPrice())
119
- . '&amount'.$i.'='.urlencode($item->getQtyOrdered());
120
- $i++;
121
- }
122
-
123
- return $url;
124
- }
125
- return '';
126
- }
127
- return self::IMAGE_URL_CLICK;
128
- }
129
-
130
- /**
131
- * Set the isSale flag. If the param is set to anything that can be interpreted as
132
- * true, the class variable _isSale is set to true.
133
- * @param bool|false $isSale
134
- */
135
- public function setIsSale($isSale = false) {
136
- if($isSale) {
137
- $this->_isSale = true;
138
- }
139
- }
140
  }
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
+ * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
+ * @author Bj�rn Wehner <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_Tracking_Tracking extends Mage_Core_Block_Template
24
+ {
25
+ const IMAGE_URL_CLICK = 'https://click.cptrack.de/verify';
26
+ const IMAGE_URL_SALE = 'https://sale.cptrack.de/';
27
+
28
+ /**
29
+ * Flag to wether use the click or sales tracking.
30
+ * @var bool
31
+ */
32
+ protected $_isSale;
33
+
34
+ public function __construct() {
35
+ $this->_isSale = false;
36
+ }
37
+
38
+ /**
39
+ * Check if tracking is enabled.
40
+ * @return bool
41
+ */
42
+ public function isEnabled() {
43
+ return Mage::getStoreConfigFlag('channelpilot_tracking/channelpilot_tracking/channelpilot_useTracking');
44
+ }
45
+
46
+ /**
47
+ * Check if the current tracking mode is set to "Image".
48
+ * @return bool
49
+ */
50
+ public function isTrackingModeImage() {
51
+ return Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/method') == Channelpilotsolutions_Channelpilot_Model_Adminhtml_Source_Trackingmethod::TRACKING_METHOD_IMAGE;
52
+ }
53
+
54
+ /**
55
+ * Get the tracking key for the current shop.
56
+ * @return mixed
57
+ */
58
+ public function getTrackingKey() {
59
+ $storeId = Mage::app()->getStore()->getId();
60
+ $trackingKeys = unserialize(Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/channelpilot_trackingkeys'));
61
+ foreach ($trackingKeys as $element) {
62
+ if ($element['shop'] == $storeId) {
63
+ return $element['trackingkey'];
64
+ }
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Get the order with the last increment id from the checkout session.
70
+ * Returns false if the order could not be loaded.
71
+ * @return Mage_Sales_Model_Order | bool
72
+ */
73
+ public function getOrder() {
74
+ $lastIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
75
+ $order = Mage::getModel('sales/order')->loadByIncrementId($lastIncrementId);
76
+ if($order && $order->getId()) {
77
+ return $order;
78
+ }
79
+
80
+ Mage::log('Could not load order with increment id '.$lastIncrementId.' for sales tracking.');
81
+ return false;
82
+ }
83
+
84
+ /**
85
+ * Get the identifier field for the product (entity_id oder sku).
86
+ * @return string
87
+ */
88
+ public function getProductIdField() {
89
+ return Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_articlenumber');
90
+ }
91
+
92
+ /**
93
+ * Get the tracking cookie mode.
94
+ * @return string
95
+ */
96
+ public function getCookieMode() {
97
+ return Mage::getStoreConfig('channelpilot_tracking/channelpilot_tracking/channelpilot_cookiemode');
98
+ }
99
+
100
+ /**
101
+ * Get the url for the tracking image.
102
+ * @return string
103
+ */
104
+ public function getImageUrl() {
105
+ if($this->_isSale) {
106
+ $order = $this->getOrder();
107
+ if($order) {
108
+ $url = self::IMAGE_URL_SALE
109
+ . '?trackingKey='.urlencode($this->getTrackingKey())
110
+ . '&cookie='.urlencode($this->getCookieMode())
111
+ . '&orderId='.urlencode($order->getId())
112
+ . '&orderTotal='.urlencode($order->getGrandTotal() - $order->getTaxAmount());
113
+
114
+ $productIdField = $this->getProductIdField();
115
+ $i = 1;
116
+ foreach($order->getItemsCollection(array(), true) as $item) {
117
+ $url .= '&id'.$i.'='.urlencode($item->getData($productIdField))
118
+ . '&price'.$i.'='.urlencode($item->getPrice())
119
+ . '&amount'.$i.'='.urlencode($item->getQtyOrdered());
120
+ $i++;
121
+ }
122
+
123
+ return $url;
124
+ }
125
+ return '';
126
+ }
127
+ return self::IMAGE_URL_CLICK;
128
+ }
129
+
130
+ /**
131
+ * Set the isSale flag. If the param is set to anything that can be interpreted as
132
+ * true, the class variable _isSale is set to true.
133
+ * @param bool|false $isSale
134
+ */
135
+ public function setIsSale($isSale = false) {
136
+ if($isSale) {
137
+ $this->_isSale = true;
138
+ }
139
+ }
140
  }
app/code/community/Channelpilotsolutions/Channelpilot/Helper/Data.php CHANGED
@@ -1,223 +1,223 @@
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
- require_once 'handler/CPPaymentHandler.php';
39
-
40
- // RESPONSES
41
- require_once 'responses/CPHookResponse.php';
42
- require_once 'responses/CPGetStatusHookResponse.php';
43
- require_once 'responses/CPRegisterHookResponse.php';
44
-
45
- // API
46
- require_once 'api/1_0/thin/CPDelivery.php';
47
- require_once 'api/1_0/ChannelPilotSellerAPI_v1_0.php';
48
- require_once 'api/1_0/CPResultCodes.php';
49
-
50
- // special customer functions
51
- require_once 'special/CustomerFunctions.php';
52
-
53
- class Channelpilotsolutions_Channelpilot_Helper_Data extends Mage_Core_Helper_Abstract {
54
-
55
- const GET_REGISTER = "register";
56
- const GET_EXPORT = "export";
57
- const GET_STATUS = "status";
58
- const GET_IMPORT_ORDERS = "orders";
59
- const GET_DELIVERED = "deliveries";
60
- const GET_CANCELLATION = "cancellations";
61
- const GET_NEWS = "news";
62
- const GET_NEWPRICES = "prices";
63
- const GET_DEBUG = "debug";
64
- const GET_PAYMENTS = "payments";
65
-
66
- public function __construct($root = 'root') {
67
-
68
- }
69
-
70
- public function createXml() {
71
- if (Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport')) {
72
- $password = Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_password');
73
- $paramPassword = Mage::app()->getRequest()->getParam('password', false);
74
- if ($password == '' || ($paramPassword AND $paramPassword == $password)) {
75
- $handler = new CPExportHandler(CPExportHandler::METHOD_XML);
76
- $handler->handle();
77
- exit();
78
- }
79
- }
80
- return;
81
- }
82
-
83
- // API CONNECTOR
84
- public function api() {
85
- $hook = null;
86
- if ($this->checkIp() === false) {
87
- return;
88
- }
89
-
90
- $newsActive = false;
91
- if (Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_useNews')) {
92
- $newsActive = true;
93
- }
94
- $marketplaceActive = false;
95
- if (Mage::getStoreConfig('channelpilot_marketplace/channelpilot_marketplace/channelpilot_useMarketplaces')) {
96
- $marketplaceActive = true;
97
- }
98
- $pricecontrolActive = false;
99
- if (Mage::getStoreConfig('channelpilot_pricecontrol/channelpilot_general/channelpilot_usePricecontrol')) {
100
- $pricecontrolActive = true;
101
- }
102
- $exportActive = false;
103
- if (Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport')) {
104
- $exportActive = true;
105
- }
106
-
107
- $method = Mage::app()->getRequest()->getParam('method', '');
108
- switch ($method) {
109
- // Send method
110
- case self::GET_STATUS:
111
- $this->checkActivation(array($marketplaceActive, $pricecontrolActive), 'marketplace OR pricecontrol');
112
- $handler = new CPStatusHandler();
113
- $hook = $handler->handle();
114
- break;
115
-
116
- // Send method + merchantid + multishopid + token + ips
117
- case self::GET_REGISTER:
118
- $this->checkActivation(array($marketplaceActive, $pricecontrolActive), 'marketplace OR pricecontrol');
119
- $this->checkSignature();
120
- $handler = new CPRegisterHandler();
121
- $hook = $handler->handle();
122
- break;
123
-
124
- // Send Method + token
125
- case self::GET_IMPORT_ORDERS:
126
- $this->checkActivation(array($marketplaceActive), 'marketplace');
127
- $this->checkSignature();
128
- $handler = new CPOrderHandler();
129
- $hook = $handler->handle();
130
- break;
131
- // Send Method + token
132
- case self::GET_DELIVERED:
133
- $this->checkActivation(array($marketplaceActive), 'marketplace');
134
- $this->checkSignature();
135
- $handler = new CPDeliveryHandler();
136
- $hook = $handler->handle();
137
- break;
138
-
139
- // Send Method + token
140
- case self::GET_CANCELLATION:
141
- $this->checkActivation(array($marketplaceActive), 'marketplace');
142
- $this->checkSignature();
143
- $handler = new CPCancellationHandler();
144
- $hook = $handler->handle();
145
- break;
146
-
147
- // Send method
148
- case self::GET_NEWS:
149
- $this->checkActivation(array($newsActive), 'news');
150
- $this->checkSignature();
151
- $handler = new CPNewsHandler();
152
- $hook = $handler->handle();
153
- break;
154
-
155
- // Send method + token + priceId
156
- case self::GET_NEWPRICES:
157
- $this->checkActivation(array($pricecontrolActive), 'pricecontrol');
158
- $handler = new CPNewPriceHandler();
159
- $hook = $handler->handle();
160
- break;
161
-
162
- // Send method + limit + shopId ( + last)
163
- case self::GET_EXPORT:
164
- $this->checkActivation(array($exportActive), 'export');
165
- $handler = new CPExportHandler();
166
- $hook = $handler->handle(CPExportHandler::METHOD_JSON);
167
- break;
168
-
169
- // Send method + limit + shopId ( + last)
170
- case self::GET_DEBUG:
171
- $this->checkSignature();
172
- $handler = new CPDebugHandler();
173
- $hook = $handler->handle();
174
- break;
175
-
176
- case self::GET_PAYMENTS:
177
- $this->checkSignature();
178
- $this->checkActivation(array($marketplaceActive), 'marketplace');
179
- $handler = new CPPaymentHandler();
180
- $handler->handle();
181
- break;
182
-
183
- default:
184
- $hook = "not supported method: " . $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
- $php = Mage::app()->getRequest()->getParam('php', false);
194
- $shop = Mage::app()->getRequest()->getParam('shop', false);
195
- $plugin = Mage::app()->getRequest()->getParam('plugin', false);
196
- IF ($php && $shop && $plugin) {
197
- if ($php == phpversion() && $shop == CPHookResponse::getSignatureShop() && $plugin == CPHookResponse::getModuleVersion()) {
198
- return true;
199
- }
200
- CPErrorHandler::handle(CPErrors::RESULT_SIGNATURE_MISMATCH, "Signature changed", "Signature changed \n" . $php . " -> " . phpversion() . "\n" . $shop . " -> " . CPHookResponse::getSignatureShop() . "\n" . $plugin . " -> " . CPHookResponse::getModuleVersion());
201
- } else {
202
- CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "Missing params for signature check", "Missing params for signature check");
203
- }
204
- }
205
-
206
- private function checkActivation($configs, $function) {
207
- foreach ($configs as $config) {
208
- if ($config === true) {
209
- return true;
210
- }
211
- }
212
- CPErrorHandler::handle(CPErrors::RESULT_API_DEACTIVATED, "'$function' not activated", "'$function' not activated");
213
- }
214
-
215
- private function checkIp() {
216
- if (Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_checkIp')) {
217
- return Mage::getModel('channelpilot/registration')->isIpAuthorized($_SERVER['REMOTE_ADDR']);
218
- }
219
- return true;
220
- }
221
- }
222
-
223
  ?>
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
+ require_once 'handler/CPPaymentHandler.php';
39
+
40
+ // RESPONSES
41
+ require_once 'responses/CPHookResponse.php';
42
+ require_once 'responses/CPGetStatusHookResponse.php';
43
+ require_once 'responses/CPRegisterHookResponse.php';
44
+
45
+ // API
46
+ require_once 'api/1_0/thin/CPDelivery.php';
47
+ require_once 'api/1_0/ChannelPilotSellerAPI_v1_0.php';
48
+ require_once 'api/1_0/CPResultCodes.php';
49
+
50
+ // special customer functions
51
+ require_once 'special/CustomerFunctions.php';
52
+
53
+ class Channelpilotsolutions_Channelpilot_Helper_Data extends Mage_Core_Helper_Abstract {
54
+
55
+ const GET_REGISTER = "register";
56
+ const GET_EXPORT = "export";
57
+ const GET_STATUS = "status";
58
+ const GET_IMPORT_ORDERS = "orders";
59
+ const GET_DELIVERED = "deliveries";
60
+ const GET_CANCELLATION = "cancellations";
61
+ const GET_NEWS = "news";
62
+ const GET_NEWPRICES = "prices";
63
+ const GET_DEBUG = "debug";
64
+ const GET_PAYMENTS = "payments";
65
+
66
+ public function __construct($root = 'root') {
67
+
68
+ }
69
+
70
+ public function createXml() {
71
+ if (Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport')) {
72
+ $password = Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_password');
73
+ $paramPassword = Mage::app()->getRequest()->getParam('password', false);
74
+ if ($password == '' || ($paramPassword AND $paramPassword == $password)) {
75
+ $handler = new CPExportHandler(CPExportHandler::METHOD_XML);
76
+ $handler->handle();
77
+ exit();
78
+ }
79
+ }
80
+ return;
81
+ }
82
+
83
+ // API CONNECTOR
84
+ public function api() {
85
+ $hook = null;
86
+ if ($this->checkIp() === false) {
87
+ return;
88
+ }
89
+
90
+ $newsActive = false;
91
+ if (Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_useNews')) {
92
+ $newsActive = true;
93
+ }
94
+ $marketplaceActive = false;
95
+ if (Mage::getStoreConfig('channelpilot_marketplace/channelpilot_marketplace/channelpilot_useMarketplaces')) {
96
+ $marketplaceActive = true;
97
+ }
98
+ $pricecontrolActive = false;
99
+ if (Mage::getStoreConfig('channelpilot_pricecontrol/channelpilot_general/channelpilot_usePricecontrol')) {
100
+ $pricecontrolActive = true;
101
+ }
102
+ $exportActive = false;
103
+ if (Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport')) {
104
+ $exportActive = true;
105
+ }
106
+
107
+ $method = Mage::app()->getRequest()->getParam('method', '');
108
+ switch ($method) {
109
+ // Send method
110
+ case self::GET_STATUS:
111
+ $this->checkActivation(array($marketplaceActive, $pricecontrolActive), 'marketplace OR pricecontrol');
112
+ $handler = new CPStatusHandler();
113
+ $hook = $handler->handle();
114
+ break;
115
+
116
+ // Send method + merchantid + multishopid + token + ips
117
+ case self::GET_REGISTER:
118
+ $this->checkActivation(array($marketplaceActive, $pricecontrolActive), 'marketplace OR pricecontrol');
119
+ $this->checkSignature();
120
+ $handler = new CPRegisterHandler();
121
+ $hook = $handler->handle();
122
+ break;
123
+
124
+ // Send Method + token
125
+ case self::GET_IMPORT_ORDERS:
126
+ $this->checkActivation(array($marketplaceActive), 'marketplace');
127
+ $this->checkSignature();
128
+ $handler = new CPOrderHandler();
129
+ $hook = $handler->handle();
130
+ break;
131
+ // Send Method + token
132
+ case self::GET_DELIVERED:
133
+ $this->checkActivation(array($marketplaceActive), 'marketplace');
134
+ $this->checkSignature();
135
+ $handler = new CPDeliveryHandler();
136
+ $hook = $handler->handle();
137
+ break;
138
+
139
+ // Send Method + token
140
+ case self::GET_CANCELLATION:
141
+ $this->checkActivation(array($marketplaceActive), 'marketplace');
142
+ $this->checkSignature();
143
+ $handler = new CPCancellationHandler();
144
+ $hook = $handler->handle();
145
+ break;
146
+
147
+ // Send method
148
+ case self::GET_NEWS:
149
+ $this->checkActivation(array($newsActive), 'news');
150
+ $this->checkSignature();
151
+ $handler = new CPNewsHandler();
152
+ $hook = $handler->handle();
153
+ break;
154
+
155
+ // Send method + token + priceId
156
+ case self::GET_NEWPRICES:
157
+ $this->checkActivation(array($pricecontrolActive), 'pricecontrol');
158
+ $handler = new CPNewPriceHandler();
159
+ $hook = $handler->handle();
160
+ break;
161
+
162
+ // Send method + limit + shopId ( + last)
163
+ case self::GET_EXPORT:
164
+ $this->checkActivation(array($exportActive), 'export');
165
+ $handler = new CPExportHandler();
166
+ $hook = $handler->handle(CPExportHandler::METHOD_JSON);
167
+ break;
168
+
169
+ // Send method + limit + shopId ( + last)
170
+ case self::GET_DEBUG:
171
+ $this->checkSignature();
172
+ $handler = new CPDebugHandler();
173
+ $hook = $handler->handle();
174
+ break;
175
+
176
+ case self::GET_PAYMENTS:
177
+ $this->checkSignature();
178
+ $this->checkActivation(array($marketplaceActive), 'marketplace');
179
+ $handler = new CPPaymentHandler();
180
+ $handler->handle();
181
+ break;
182
+
183
+ default:
184
+ $hook = "not supported method: " . $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
+ $php = Mage::app()->getRequest()->getParam('php', false);
194
+ $shop = Mage::app()->getRequest()->getParam('shop', false);
195
+ $plugin = Mage::app()->getRequest()->getParam('plugin', false);
196
+ IF ($php && $shop && $plugin) {
197
+ if ($php == phpversion() && $shop == CPHookResponse::getSignatureShop() && $plugin == CPHookResponse::getModuleVersion()) {
198
+ return true;
199
+ }
200
+ CPErrorHandler::handle(CPErrors::RESULT_SIGNATURE_MISMATCH, "Signature changed", "Signature changed \n" . $php . " -> " . phpversion() . "\n" . $shop . " -> " . CPHookResponse::getSignatureShop() . "\n" . $plugin . " -> " . CPHookResponse::getModuleVersion());
201
+ } else {
202
+ CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "Missing params for signature check", "Missing params for signature check");
203
+ }
204
+ }
205
+
206
+ private function checkActivation($configs, $function) {
207
+ foreach ($configs as $config) {
208
+ if ($config === true) {
209
+ return true;
210
+ }
211
+ }
212
+ CPErrorHandler::handle(CPErrors::RESULT_API_DEACTIVATED, "'$function' not activated", "'$function' not activated");
213
+ }
214
+
215
+ private function checkIp() {
216
+ if (Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_checkIp')) {
217
+ return Mage::getModel('channelpilot/registration')->isIpAuthorized($_SERVER['REMOTE_ADDR']);
218
+ }
219
+ return true;
220
+ }
221
+ }
222
+
223
  ?>
app/code/community/Channelpilotsolutions/Channelpilot/Helper/Export.php DELETED
@@ -1,296 +0,0 @@
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
- * @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
19
- * @author Bj�rn Wehner <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_Export extends Mage_Core_Helper_Abstract
24
- {
25
- protected $_productEntityTypeId = null;
26
- protected $_masterProductQuery = null;
27
-
28
- /**
29
- * Get the entity_type_id for catalog_product.
30
- * @return mixed
31
- */
32
- public function getEntityTypeIdForProduct() {
33
- if($this->_productEntityTypeId === null) {
34
- // Get the entity type for products
35
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
36
- $query = new Zend_Db_Select($connection);
37
- $query->from(Mage::getSingleton('core/resource')->getTableName('eav/entity_type'), array('entity_type_id'));
38
- $query->where("entity_type_code = 'catalog_product'");
39
-
40
- $this->_productEntityTypeId = $connection->fetchOne($query);
41
- }
42
- return $this->_productEntityTypeId;
43
- }
44
-
45
- /**
46
- * Get all product attributes.
47
- * @return mixed
48
- */
49
- public function getProductAttributes() {
50
- // Get attribute codes and types
51
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
52
- $query = new Zend_Db_Select($connection);
53
- $query->from(Mage::getSingleton('core/resource')->getTableName('eav/attribute'),
54
- array('attribute_id', 'attribute_code', 'backend_type', 'frontend_input')
55
- );
56
- $query->where('entity_type_id = ?', $this->getEntityTypeIdForProduct());
57
-
58
- return $connection->FetchAssoc($query);
59
- }
60
-
61
- /**
62
- * Get the attribute options for an attribute_id.
63
- *
64
- * @param int $attributeId
65
- * @return array
66
- */
67
- public function getAttributeOptions($attributeId, $storeId) {
68
- // Get the option_id => value from the attribute options
69
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
70
- $query = new Zend_Db_Select($connection);
71
- $query->from(array('ao' => Mage::getSingleton('core/resource')->getTableName('eav/attribute_option')),
72
- array(
73
- 'option_id' => new Zend_Db_Expr($connection->quoteInto(
74
- 'CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.option_id) ELSE
75
- MAX(CASE WHEN aov.store_id = ? THEN aov.option_id ELSE NULL END)
76
- END', $storeId
77
- )),
78
- 'value' => new Zend_Db_Expr($connection->quoteInto(
79
- 'CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.value) ELSE
80
- MAX(CASE WHEN aov.store_id = ? THEN aov.value ELSE NULL END)
81
- END', $storeId
82
- ))
83
- )
84
- );
85
- $query->join(array('aov' => Mage::getSingleton('core/resource')->getTableName('eav/attribute_option_value')),
86
- 'ao.option_id = aov.option_id',
87
- null
88
- );
89
- $query->where('aov.store_id IN(0, ?)', $storeId);
90
- $query->where('ao.attribute_id = ?', $attributeId);
91
- $query->group(array('aov.option_id'));
92
-
93
- return $connection->fetchPairs($query);
94
- }
95
-
96
- /**
97
- * Get the additional image urls for an entity_id.
98
- * @param int $entityId
99
- * @return array
100
- */
101
- public function getAdditionalImageUrl($entityId, $storeId, $mediaGalleryAttributeId, $baseImageAttributeId) {
102
- $store = Mage::app()->getStore($storeId);
103
- $mediaUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
104
-
105
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
106
- $galleryImagePrefix = $connection->quote($mediaUrl . 'catalog/product');
107
-
108
- $subquery = new Zend_Db_Select($connection);
109
- $subquery->from(Mage::getSingleton('core/resource')->getTableName(array('catalog/product', 'varchar')),
110
- array('value')
111
- );
112
- $subquery->where('entity_id = ?', $entityId);
113
- $subquery->where('attribute_id = ?', $baseImageAttributeId);
114
-
115
-
116
- $query = new Zend_Db_Select($connection);
117
- $query->from(array('gallery' => Mage::getSingleton('core/resource')->getTableName('catalog/product_attribute_media_gallery')),
118
- array(
119
- 'value_id' => new Zend_Db_Expr("GROUP_CONCAT(gallery.value_id SEPARATOR ',')"),
120
- 'value' => new Zend_Db_Expr("GROUP_CONCAT(CONCAT(" . $galleryImagePrefix . ", gallery.value) SEPARATOR ',')")
121
- )
122
- );
123
- $query->join(array('gallery_value' => Mage::getSingleton('core/resource')->getTableName('catalog/product_attribute_media_gallery_value')),
124
- 'gallery.value_id = gallery_value.value_id',
125
- null
126
- );
127
- $query->where('gallery_value.store_id IN(0, ?)', $storeId);
128
- $query->where('gallery_value.disabled = 0');
129
- $query->where('gallery.entity_id = ?', $entityId);
130
- $query->where('gallery.attribute_id = ?', $mediaGalleryAttributeId);
131
- $query->where('gallery.value NOT IN(?)', $subquery);
132
- $query->order('gallery_value.position ASC');
133
-
134
- $connection->setFetchMode(ZEND_DB::FETCH_NUM);
135
- return $connection->fetchAll($query);
136
- }
137
-
138
- /**
139
- * Get the master product query.
140
- * @param int $storeId
141
- * @param string $exportDataFieldIds
142
- * @return null|string
143
- */
144
- public function getMasterProductQuery($storeId, $exportDataFieldIds) {
145
- if($this->_masterProductQuery === null) {
146
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
147
- // Build queries for each attribute type
148
- $backendTypes = array(
149
- 'datetime',
150
- 'decimal',
151
- 'int',
152
- 'text',
153
- 'varchar',
154
- );
155
- $queries = array();
156
- foreach ($backendTypes as $backendType) {
157
- // Get store value if there is one, otherwise, global value
158
- $query = new Zend_Db_Select($connection);
159
- $query->from(array('ce' => Mage::getSingleton('core/resource')->getTableName('catalog/product')),
160
- array('value' => new Zend_Db_Expr($connection->quoteInto(
161
- 'CASE WHEN SUM(ev.store_id) = 0 THEN MAX(ev.value) ELSE
162
- MAX(CASE WHEN ev.store_id = ? THEN ev.value ELSE NULL END)
163
- END', $storeId
164
- )), 'ev.attribute_id')
165
- );
166
- $query->join(array('ev' => Mage::getSingleton('core/resource')->getTableName(array('catalog/product', $backendType))),
167
- 'ce.entity_id = ev.entity_id',
168
- null
169
- );
170
- $query->where('ev.store_id IN(0, ?)', $storeId);
171
- $query->where('ev.entity_type_id = ?', $this->getEntityTypeIdForProduct());
172
- $query->where('ev.entity_id = @ENTITY_ID');
173
- $query->where('ev.attribute_id IN('.$exportDataFieldIds.')');
174
- $query->group(array('ev.attribute_id', 'ev.entity_id'));
175
-
176
- $queries[] = $query->__toString();
177
- }
178
- $this->_masterProductQuery = implode(" UNION ALL ", $queries);
179
- }
180
- return $this->_masterProductQuery;
181
- }
182
-
183
- /**
184
- * Get the export fields from the system config.
185
- * @param array $attributeCodes
186
- * @return array
187
- */
188
- public function getExportFields(array $attributeCodes, &$blankProduct) {
189
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
190
- $result = array('code' => array(), 'id' => array(), 'use_type_id' => false);
191
- foreach (array_keys($blankProduct) as $key) {
192
- $result['code'][] = $key;
193
- $tmpid = array_search($key, $attributeCodes);
194
- if (!empty($tmpid)) {
195
- $result['id'][] = $connection->quote($tmpid);
196
- }
197
- }
198
-
199
- $export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_exportfields'));
200
- $result['use_type_id'] = false;
201
- if (!empty($export_fields)) {
202
- foreach ($export_fields as $element) {
203
- if (!empty($element['productattribute'])) {
204
- $blankProduct[preg_replace('/\W/', '', $element['productattribute'])] = '';
205
- $result['code'][] = $element['productattribute'];
206
- if($element['productattribute'] == 'type_id') {
207
- $result['use_type_id'] = true;
208
- } else {
209
- $tmpid = array_search($element['productattribute'], $attributeCodes);
210
- if (!empty($tmpid)) {
211
- $result['id'][] = $connection->quote($tmpid);
212
- }
213
- }
214
- }
215
- }
216
- }
217
-
218
- $tmpid = array_search('status', $attributeCodes);
219
- if (!empty($tmpid)) {
220
- $result['id'][] = $connection->quote($tmpid);;
221
- }
222
- $tmpid = array_search('url_path', $attributeCodes);
223
- if (!empty($tmpid)) {
224
- $result['id'][] = $connection->quote($tmpid);;
225
- }
226
- $tmpid = array_search('image', $attributeCodes);
227
- if (!empty($tmpid)) {
228
- $result['id'][] = $connection->quote($tmpid);;
229
- }
230
- $result['id'] = implode(',', $result['id']);
231
-
232
- return $result;
233
- }
234
-
235
- /**
236
- * Set the special export fields to the _blankProduct.
237
- * @param array $blankProduct
238
- */
239
- public function setSpecialExportField(&$blankProduct) {
240
- $special_export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_specialexportfields'));
241
- if (!empty($special_export_fields)) {
242
- foreach ($special_export_fields as $element) {
243
- if (!empty($element['name'])) {
244
- $blankProduct[preg_replace('/\W/', '', $element['name'])] = $element['value'];
245
- }
246
- }
247
- }
248
- }
249
-
250
- /**
251
- * Build the category tree and return it as array.
252
- * @return array
253
- */
254
- public function buildCategoryTree() {
255
- $allCat = array();
256
- $oldCatPath = '';
257
- $oldCatTree = '';
258
-
259
- $categoryCollection = Mage::getModel('catalog/category')->getCollection()
260
- ->addAttributeToSelect('name')
261
- ->addAttributeToSort('path');
262
-
263
- foreach($categoryCollection as $category) {
264
- // if (strpos($category->getPath(), $oldCatPath) !== 0) {
265
- // start tree
266
- $path = $this->getCategory($category->getPath(), $allCat);
267
- if($path !== 0) {
268
- $allCat[$category->getPath()] = str_replace('Root Catalog', 'Home', $path . '>' . $category->getName());
269
- $oldCatTree = $path . '>' . $category->getName();
270
- } else {
271
- $allCat[$category->getPath()] = str_replace('Root Catalog', 'Home', $category->getName());
272
- $oldCatTree = $category->getName();
273
- }
274
- // } else {
275
- // // continue tree
276
- // $allCat[$category->getPath()] = str_replace('Root Catalog', 'Home', $oldCatTree . '>' . $category->getName());
277
- // $oldCatTree = $allCat[$category->getPath()];
278
- // }
279
- }
280
-
281
- return $allCat;
282
- }
283
-
284
- private function getCategory($key, $allCat) {
285
- $return = 0;
286
- if (strpos($key, '/') != false) {
287
- $tmpKey = substr($key, 0, strpos($key, strrchr($key, '/')));
288
- if (isset($allCat[$tmpKey])) {
289
- $return = $allCat[$tmpKey];
290
- } else {
291
- $return = $this->getCategory($tmpKey, $allCat);
292
- }
293
- }
294
- return $return;
295
- }
296
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Channelpilotsolutions/Channelpilot/Helper/ExportData.php DELETED
@@ -1,575 +0,0 @@
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 $_storeId;
27
- private $_siteId;
28
- private $_mediaUrl;
29
- private $_webUrl;
30
- private $_dbConnection;
31
- private $_allCat;
32
- private $_currencyChange;
33
- private $_storeCode;
34
- private $oldCatPath;
35
- private $xml;
36
- private $_mediaGalleryAttributeId;
37
- private $_productEntityTypeId;
38
- private $_variationThemes;
39
- private $_blankProduct;
40
- private $_baseImageAttributeId;
41
-
42
- function __construct() {
43
-
44
-
45
- // Increase maximum execution time to 4 hours
46
- ini_set('max_execution_time', 7200);
47
-
48
- // Initialize the admin application
49
- Mage::app('admin');
50
-
51
- // Get the table prefix
52
- // $tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
53
-
54
- // Get database connection
55
- $this->_dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
56
-
57
- $this->_blankProduct = array();
58
- $this->_blankProduct['entity_id'] = '';
59
- $this->_blankProduct['sku'] = '';
60
- $this->_blankProduct['parent_id'] = '';
61
- $this->_blankProduct['variationTheme'] = '';
62
- $this->_blankProduct['name'] = '';
63
- $this->_blankProduct['description'] = '';
64
- $this->_blankProduct['price'] = '';
65
- $this->_blankProduct['categories'] = '';
66
- $this->_blankProduct['manufacturer'] = '';
67
- $this->_blankProduct['cp_product_url'] = '';
68
- $this->_blankProduct['cp_image_url'] = '';
69
- $this->_blankProduct['color'] = '';
70
- $this->_blankProduct['weight'] = '';
71
- for($i = 1; $i <= Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_imagenumber'); $i++) {
72
- $this->_blankProduct['cp_additional_image_'.$i] = '';
73
- }
74
- }
75
-
76
- // Run the main application and call the appropriate function
77
- // depending on the command.
78
- public function _runMain() {
79
- try {
80
- $storeId = Mage::app()->getRequest()->getParam('store', null);
81
- $this->_storeId = Mage::app()->getStore($storeId)->getId();
82
- } catch(Exception $e) {
83
- // The exception thrown by Mage::app()->getStore() has an empty message ...
84
- echo "<error>Error retrieving store.</error>";
85
- return;
86
- }
87
-
88
- $currencyCode = Mage::app()->getRequest()->getParam('currency', false);
89
- if ($currencyCode && $currencyCode != '') {
90
- $result = Mage::getModel('directory/currency')->getCurrencyRates(Mage::app()->getBaseCurrencyCode(), $currencyCode);
91
- if(count($result) === 0){
92
- echo "<error>wrong currency</error>";
93
- return;
94
- }
95
- $this->_currencyChange = $result[$currencyCode];
96
-
97
- }
98
- // Validate store and get information
99
- $this->_getStoreInformation();
100
-
101
- // Run extraction
102
- return $this->_extractFromMySQL();
103
- }
104
-
105
- /**
106
- * Get the category information for an entity_id.
107
- * @param int $entityId
108
- * @return string
109
- */
110
- private function _getCategoryInformation($entityId) {
111
- if (substr(Mage::getVersion(), 2, 3) >= 6 && Mage::getStoreConfigFlag('catalog/frontend/flat_catalog_category', $this->_storeId)) {
112
- $query = new Zend_Db_Select($this->_dbConnection);
113
- $query->distinct();
114
- $query->from(array('pi' => Mage::getSingleton('core/resource')->getTableName('catalog/category_product_index')),
115
- array('fs.entity_id', 'fs.path', 'fs.name')
116
- );
117
- $query->join(array('fs' => Mage::getSingleton('core/resource')->getTableName(array('catalog/category_flat', 'store_'.$this->_storeId))),
118
- 'pi.category_id = fs.entity_id',
119
- null
120
- );
121
- $query->where('pi.product_id = ?', $entityId);
122
- $query->where('pi.store_id = ?', $this->_storeId);
123
- $query->order('fs.path ASC');
124
- } else {
125
- $query = new Zend_Db_Select($this->_dbConnection);
126
- $query->from(array('pi' => Mage::getSingleton('core/resource')->getTableName('catalog/category_product_index')),
127
- array('pi.category_id', 'ce.path')
128
- );
129
- $query->join(array('ce' => Mage::getSingleton('core/resource')->getTableName('catalog/category')),
130
- 'pi.category_id = ce.entity_id',
131
- null
132
- );
133
- $query->where('pi.product_id = ?', $entityId);
134
- $query->where('pi.is_parent = 1');
135
- $query->where('pi.store_id = ?', $this->_storeId);
136
- $query->order('ce.path ASC');
137
- }
138
-
139
- $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
140
-
141
- $categoriesTable = $this->_dbConnection->fetchAll($query);
142
- $categorieField = '';
143
- $this->oldCatPath = '';
144
- foreach ($categoriesTable as $categorie) {
145
- if (($this->oldCatPath == '') || (strpos($categorie[1], $this->oldCatPath) !== 0)) {
146
- // Start tree
147
- if ($this->oldCatPath !== '') {
148
- if ($categorieField !== '') {
149
- $categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
150
- } else {
151
- $categorieField = $this->_allCat[$this->oldCatPath];
152
- }
153
- }
154
- $this->oldCatPath = $categorie[1];
155
- } else {
156
- // Add to tree
157
- $this->oldCatPath = $categorie[1];
158
- }
159
- }
160
- if ($categorieField !== '') {
161
- $categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
162
- } else {
163
- if ($this->oldCatPath !== '') {
164
- $categorieField = $this->_allCat[$this->oldCatPath];
165
- }
166
- }
167
-
168
- return $categorieField;
169
- }
170
-
171
- /**
172
- * Get the count of all products.
173
- * @return mixed
174
- */
175
- private function _getProductCount() {
176
- $query = new Zend_Db_Select($this->_dbConnection);
177
- $query->from(array('cpe' => Mage::getSingleton('core/resource')->getTableName('catalog/product')),
178
- new Zend_Db_Expr('count(*)')
179
- );
180
- $query->join(array('cpw' => Mage::getSingleton('core/resource')->getTableName('catalog/product_website')),
181
- 'cpw.product_id = cpe.entity_id',
182
- null
183
- );
184
- $query->where('cpw.website_id = ?', $this->_siteId);
185
- $query->where("IFNULL(cpe.sku, '') != ''");
186
-
187
- $this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
188
- return $this->_dbConnection->fetchAll($query);
189
- }
190
-
191
- /**
192
- * Get products from the database limited by the count and offset.
193
- * @param int $count
194
- * @param int $offset
195
- * @return mixed
196
- */
197
- private function _getProductEntities($count, $offset) {
198
- // Get all entity_ids for all products in the selected store
199
- $columns = array('cpe.entity_id', 'cpe.sku', 'cpe.type_id');
200
- $query = new Zend_Db_Select($this->_dbConnection);
201
-
202
- $subquery = new Zend_Db_Select($this->_dbConnection);
203
- $subquery->from(Mage::getSingleton('core/resource')->getTableName('catalog/product_super_link'), array('parent_id'));
204
- $subquery->where('product_id = cpe.entity_id');
205
- $subquery->limit(1);
206
-
207
- $columns['parent'] = new Zend_Db_Expr('('.$subquery.')');
208
-
209
- $subquery = new Zend_Db_Select($this->_dbConnection);
210
- $subquery->from(Mage::getSingleton('core/resource')->getTableName('catalog/product_super_link'), array(
211
- new Zend_Db_Expr('COUNT(*)')
212
- ));
213
- $subquery->where('parent_id = cpe.entity_id');
214
- $subquery->limit(1);
215
-
216
- $columns['is_parent'] = new Zend_Db_Expr('('.$subquery.')');
217
-
218
- $subquery = new Zend_Db_Select($this->_dbConnection);
219
- $subquery->from(Mage::getSingleton('core/resource')->getTableName('cataloginventory/stock_status'), array('qty'));
220
- $subquery->where('product_id = cpe.entity_id');
221
- $subquery->where('website_id = ?', $this->_siteId);
222
- $subquery->where('stock_id = 1');
223
- $subquery->limit(1);
224
-
225
- $columns['qty'] = new Zend_Db_Expr('('.$subquery.')');
226
-
227
- $subquery = new Zend_Db_Select($this->_dbConnection);
228
- $subquery->from(Mage::getSingleton('core/resource')->getTableName('cataloginventory/stock_status'), array('stock_status'));
229
- $subquery->where('product_id = cpe.entity_id');
230
- $subquery->where('website_id = ?', $this->_siteId);
231
- $subquery->where('stock_id = 1');
232
- $subquery->limit(1);
233
-
234
- $columns['stock_status'] = new Zend_Db_Expr('('.$subquery.')');
235
-
236
- $subquery = new Zend_Db_Select($this->_dbConnection);
237
- $subquery->from(array('crpp' => Mage::getSingleton('core/resource')->getTableName('catalogrule/rule_product_price')), array('crpp.rule_price'));
238
- $subquery->where('crpp.rule_date = CURDATE()');
239
- $subquery->where('crpp.product_id = cpe.entity_id');
240
- $subquery->where('crpp.customer_group_id = 1');
241
- $subquery->where('crpp.website_id = ?', $this->_siteId);
242
-
243
- $columns['cat_price'] = new Zend_Db_Expr('('.$subquery.')');
244
-
245
- $query->from(array('cpe' => Mage::getSingleton('core/resource')->getTableName('catalog/product')), $columns);
246
- $query->join(array('cpw' => Mage::getSingleton('core/resource')->getTableName('catalog/product_website')),
247
- 'cpw.product_id = cpe.entity_id',
248
- null
249
- );
250
- $query->where('cpw.website_id = ?', $this->_siteId);
251
- $query->where("IFNULL(cpe.sku, '') != ''");
252
- $query->order(array('is_parent DESC', 'entity_id DESC'));
253
- $query->limit($count, $offset);
254
-
255
- return $this->_dbConnection->fetchAssoc($query);
256
- }
257
-
258
- /**
259
- * Get the variation theme for a product id.
260
- * @param int $productId
261
- * @param int $isParent
262
- * @param int $parentId
263
- * @return string
264
- */
265
- private function _getVariationTheme($productId, $isParent, $parentId = 0) {
266
- if (intval($isParent) > 0) {
267
- $varQuery = new Zend_Db_Select($this->_dbConnection);
268
- $varQuery->from(array('cpsa' => Mage::getSingleton('core/resource')->getTableName('catalog/product_super_attribute')),
269
- array('ea.attribute_code')
270
- );
271
- $varQuery->joinLeft(array('ea' => Mage::getSingleton('core/resource')->getTableName('eav/attribute')),
272
- 'ea.attribute_id = cpsa.attribute_id',
273
- null
274
- );
275
- $varQuery->where('cpsa.product_id = ?', $productId);
276
- $varQuery->order('ea.attribute_id');
277
-
278
- $varresults = $this->_dbConnection->fetchAll($varQuery);
279
- $variationTheme = "";
280
- foreach ($varresults as $varresult) {
281
- $variationTheme = $variationTheme . "|" . $varresult[0];
282
- }
283
- $variationTheme = ltrim($variationTheme, "|");
284
- $this->_variationThemes[$productId] = $variationTheme;
285
- return $variationTheme;
286
- } else {
287
- if (!empty($parentId)) {
288
- return $this->_variationThemes[$parentId];
289
- }
290
- }
291
- }
292
-
293
- // Extract natively directly from the database
294
- private function _extractFromMySQL() {
295
- // Increase maximium length for group_concat (for additional image URLs field)
296
- $query = "SET SESSION group_concat_max_len = 1000000;";
297
- $this->_dbConnection->query($query);
298
-
299
- $this->_allCat = Mage::helper('channelpilot/export')->buildCategoryTree();
300
-
301
- // By default, set media gallery attribute id to 703
302
- // Look it up later
303
- $this->_mediaGalleryAttributeId = 703;
304
-
305
- // Get the entity type for products
306
- $this->_productEntityTypeId = Mage::helper('channelpilot/export')->getEntityTypeIdForProduct();
307
-
308
- // Get attribute codes and types
309
- $attributes = Mage::helper('channelpilot/export')->getProductAttributes();
310
-
311
- $attributeCodes = array();
312
- $attributeOptions = array();
313
-
314
- Mage::helper('channelpilot/export')->setSpecialExportField($this->_blankProduct);
315
-
316
- foreach ($attributes as $row) {
317
- // Save attribute ID for media gallery
318
- if ($row['attribute_code'] == 'media_gallery') {
319
- $this->_mediaGalleryAttributeId = $row['attribute_id'];
320
- }
321
-
322
- if($row['attribute_code'] == 'image') {
323
- $this->_baseImageAttributeId = $row['attribute_id'];
324
- }
325
-
326
- if($row['backend_type'] != 'static') {
327
- $attributeCodes[$row['attribute_id']] = $row['attribute_code'];
328
- }
329
-
330
- // If the type is multiple choice, cache the option values
331
- // in a lookup array for performance (avoids several joins/aggregations)
332
- if ($row['frontend_input'] == 'select' || $row['frontend_input'] == 'multiselect') {
333
- $result = Mage::helper('channelpilot/export')->getAttributeOptions($row['attribute_id'], $this->_storeId);
334
- // If found, then save the lookup table in the attributeOptions array
335
- if (is_array($result)) {
336
- $attributeOptions[$row['attribute_id']] = $result;
337
- } else {
338
- // Otherwise, leave a blank array
339
- $attributeOptions[$row['attribute_id']] = array();
340
- }
341
- $result = null;
342
- }
343
- }
344
-
345
- $this->_displayProductData($attributeCodes, $attributeOptions);
346
-
347
- return;
348
- }
349
-
350
- /**
351
- * Create a product and output it as xml.
352
- * @param array $attributeCodes
353
- * @param array $attributeOptions
354
- */
355
- private function _displayProductData(array $attributeCodes, array $attributeOptions) {
356
- $selectLimit = 100;
357
- $count = $this->_getProductCount();
358
- $counter = 0;
359
-
360
- $border = (int) $count[0][0] - $selectLimit;
361
- if ($border < $count[0][0]) {
362
- $border = $count[0][0];
363
- }
364
-
365
- $exportFields = Mage::helper('channelpilot/export')->getExportFields($attributeCodes, $this->_blankProduct);
366
-
367
- // Build queries for each attribute type
368
- $MasterProductQuery = Mage::helper('channelpilot/export')->getMasterProductQuery($this->_storeId, $exportFields['id']);
369
-
370
- $parentProductArray = array();
371
- $this->_variationThemes = array();
372
- while ($counter <= $border) {
373
- // Get all entity_ids for all products in the selected store
374
- $EntityIds = $this->_getProductEntities($selectLimit, $counter);
375
- // Loop through each product and output the data
376
- foreach ($EntityIds as $entity) {
377
- // Fill the master query with the entity ID
378
- $query = str_replace('@ENTITY_ID', $entity['entity_id'], $MasterProductQuery);
379
- $result = $this->_dbConnection->query($query);
380
- // Create a new product record
381
- $product = $this->_blankProduct;
382
- $product['variationTheme'] = $this->_getVariationTheme($entity['entity_id'], $entity['is_parent'], $entity['parent']);
383
-
384
- // Initialize basic product data
385
- $product['entity_id'] = $entity['entity_id'];
386
- $product['sku'] = $entity['sku'];
387
-
388
- // Escape the SKU (it may contain double-quotes)
389
- $product['sku'] = str_replace('"', '""', $product['sku']);
390
- $product['is_parent'] = $entity['is_parent'] > 0 ? 1 : 0;
391
-
392
- $product_status = null;
393
- $product_url = null;
394
- $product_image = null;
395
- // Loop through each field in the row and get the value
396
- foreach($result->fetchAll() as $column) {
397
- // Translate the option option_id to a value.
398
- if (isset($attributeOptions[$column[1]])) {
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)) {
412
- // Use convert values if any conversions exist
413
- $column[0] = implode(',', $convertedOptionValues);
414
- }
415
- // Otherwise, leave value as-is
416
- }
417
-
418
- if (in_array($attributeCodes[$column[1]], $exportFields['code'])) {
419
- $product[$attributeCodes[$column[1]]] = $column[0];
420
- }
421
-
422
- if ($attributeCodes[$column[1]] == 'status') {
423
- $product_status = $column[0];
424
- }
425
- if ($attributeCodes[$column[1]] == 'url_path') {
426
- $product_url = $column[0];
427
- }
428
- if ($attributeCodes[$column[1]] == 'image') {
429
- $product_image = $column[0];
430
- }
431
- }
432
-
433
- $result = null;
434
-
435
- // Skip product that are disabled or have no status
436
- if (empty($product_status) || $product_status == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
437
- continue;
438
- }
439
- // Get category information
440
- $product['categories'] = $this->_getCategoryInformation($entity['entity_id']);
441
- // Get stock quantity
442
- // NOTE: stock_id = 1 is the 'Default' stock
443
- if (in_array('qty', $exportFields['code'])) {
444
- if (empty($entity['qty']) == true) {
445
- $product['qty'] = '0';
446
- } else {
447
- $product['qty'] = $entity['qty'];
448
- }
449
- }
450
-
451
- if (in_array('stock_status', $exportFields['code'])) {
452
- if (empty($entity['stock_status']) == true) {
453
- $product['stock_status'] = '';
454
- } else {
455
- $product['stock_status'] = $entity['stock_status'];
456
- }
457
- }
458
- $stockInfoResult = null;
459
-
460
- // Get additional image URLs
461
- $galleryValues = Mage::helper('channelpilot/export')->getAdditionalImageUrl(
462
- $entity['entity_id'],
463
- $this->_storeId,
464
- $this->_mediaGalleryAttributeId,$this->_baseImageAttributeId
465
- );
466
-
467
- if (empty($galleryValues) != true) {
468
- $additional_images = explode(',', $galleryValues[0][1]);
469
- for($i = 0; $i < Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_imagenumber'); $i++) {
470
- if (isset($additional_images[$i])) {
471
- $product['cp_additional_image_' . ($i + 1)] = $additional_images[$i];
472
- }
473
- }
474
- }
475
-
476
- // Get parent ID
477
- if (empty($entity['parent']) != true && in_array('parent_id', $exportFields['code'])) {
478
- $product['parent_id'] = $entity['parent'];
479
- }
480
-
481
- // Override price with catalog price rule, if found
482
- if (empty($entity['cat_price']) != true) {
483
- // Override price with catalog rule price
484
- $product['price'] = $entity['cat_price'];
485
- }
486
-
487
- // Calculate image and product URLs
488
- if (empty($product_url) == false) {
489
- $product['cp_product_url'] = $this->_urlPathJoin($this->_webUrl, $product_url);
490
- }
491
-
492
- if (empty($product_image) == false) {
493
- $product['cp_image_url'] = $this->_urlPathJoin($this->_mediaUrl, 'catalog/product');
494
- $product['cp_image_url'] = $this->_urlPathJoin($product['cp_image_url'], $product_image);
495
- }
496
-
497
- $replace_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_replacefields'));
498
- if (!empty($replace_fields)) {
499
- // PARENT
500
- if ($entity['is_parent'] > 0) {
501
- foreach ($replace_fields as $element) {
502
- if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
503
- $parentProductArray[$product['id']][$element['productattribute']] = $product[$element['productattribute']];
504
- }
505
- }
506
- } else {
507
- // CHILD
508
- if ($entity['parent'] != null) {
509
- foreach ($replace_fields as $element) {
510
- if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
511
- $product[$element['productattribute']] = $parentProductArray[$entity['parent']][$element['productattribute']];
512
- }
513
- }
514
- }
515
- }
516
- }
517
-
518
- if($exportFields['use_type_id']) {
519
- $product['type_id'] = $entity['type_id'];
520
- }
521
-
522
- if(isset($this->_currencyChange)) {
523
- $product['price'] = round($product['price']*$this->_currencyChange, 2);
524
- }
525
-
526
- $this->xml = new SimpleXMLElement("<product></product>");
527
- echo str_replace('<?xml version="1.0"?>', '', $this->toXML($product));
528
- $this->xml = null;
529
- }
530
- $counter = $counter + $selectLimit;
531
- }
532
- }
533
-
534
- // Join two URL paths and handle forward slashes
535
- private function _urlPathJoin($part1, $part2) {
536
- return rtrim($part1, '/') . '/' . ltrim($part2, '/');
537
- }
538
-
539
- // Die if the storeId is invalid
540
- private function _getStoreInformation() {
541
- try {
542
- // Get the store object
543
- $store = Mage::app()->getStore($this->_storeId);
544
-
545
- // Load the store information
546
- $this->_siteId = $store->getWebsiteId();
547
- $this->_webUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
548
- $this->_storeCode = Mage::getStoreConfig('web/url/use_store') ? $store->getCode(). "/" : "";
549
- $this->_mediaUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
550
- } catch (Exception $e) {
551
- die('Store=' . $this->_storeId . " probably does not exist.");
552
- }
553
- }
554
-
555
- private function toXML($array) {
556
- $this->iterate($array, $this->xml);
557
- return $this->xml->asXML();
558
- }
559
-
560
- private function iterate($element, $xmlNode) {
561
- if (is_array($element)) {
562
- foreach ($element as $name => $value) {
563
- if (is_string($value) || is_numeric($value) || is_bool($value)) {
564
- $xmlNode->$name = $value;
565
- } else {
566
- $xmlNode->$name = null;
567
- $this->iterate($value, $xmlNode->$name);
568
- }
569
- }
570
- }
571
- }
572