CustomerGauge_Export_Integration - Version 1.1.1

Version Notes

- Option to choose your order to send on CustomerGauge System.
- Save CustomerGauge and Magento field mapping.
- Option to filter sales order by CutomerGauge Import.
- API configuration options added.on CustomerGauge Setting.

Download this release

Release Info

Developer Manas Kanti Dey
Extension CustomerGauge_Export_Integration
Version 1.1.1
Comparing to
See all releases


Version 1.1.1

Files changed (40) hide show
  1. app/code/community/Customergauge/.DS_Store +0 -0
  2. app/code/community/Customergauge/Import/.DS_Store +0 -0
  3. app/code/community/Customergauge/Import/Block/.DS_Store +0 -0
  4. app/code/community/Customergauge/Import/Block/Sales/.DS_Store +0 -0
  5. app/code/community/Customergauge/Import/Block/Sales/Order/.DS_Store +0 -0
  6. app/code/community/Customergauge/Import/Block/Sales/Order/Grid.php +30 -0
  7. app/code/community/Customergauge/Import/Block/Sync/.DS_Store +0 -0
  8. app/code/community/Customergauge/Import/Block/Sync/Edit.php +99 -0
  9. app/code/community/Customergauge/Import/Helper/.DS_Store +0 -0
  10. app/code/community/Customergauge/Import/Helper/Data.php +69 -0
  11. app/code/community/Customergauge/Import/Model/.DS_Store +0 -0
  12. app/code/community/Customergauge/Import/Model/Cgmapping.php +19 -0
  13. app/code/community/Customergauge/Import/Model/Mysql4/.DS_Store +0 -0
  14. app/code/community/Customergauge/Import/Model/Mysql4/Cgmapping.php +18 -0
  15. app/code/community/Customergauge/Import/Model/Mysql4/Cgmapping/.DS_Store +0 -0
  16. app/code/community/Customergauge/Import/Model/Mysql4/Cgmapping/Collection.php +16 -0
  17. app/code/community/Customergauge/Import/Model/Observer.php +89 -0
  18. app/code/community/Customergauge/Import/Model/System/.DS_Store +0 -0
  19. app/code/community/Customergauge/Import/Model/System/Config/.DS_Store +0 -0
  20. app/code/community/Customergauge/Import/Model/System/Config/Orderstatus.php +27 -0
  21. app/code/community/Customergauge/Import/Model/System/Config/Transactional.php +26 -0
  22. app/code/community/Customergauge/Import/Model/System/Config/Upload.php +26 -0
  23. app/code/community/Customergauge/Import/Service/.DS_Store +0 -0
  24. app/code/community/Customergauge/Import/Service/ImportData.php +230 -0
  25. app/code/community/Customergauge/Import/controllers/.DS_Store +0 -0
  26. app/code/community/Customergauge/Import/controllers/Adminhtml/.DS_Store +0 -0
  27. app/code/community/Customergauge/Import/controllers/Adminhtml/SyncController.php +70 -0
  28. app/code/community/Customergauge/Import/controllers/IndexController.php +74 -0
  29. app/code/community/Customergauge/Import/etc/.DS_Store +0 -0
  30. app/code/community/Customergauge/Import/etc/config.xml +144 -0
  31. app/code/community/Customergauge/Import/etc/system.xml +91 -0
  32. app/code/community/Customergauge/Import/sql/.DS_Store +0 -0
  33. app/code/community/Customergauge/Import/sql/import_setup/.DS_Store +0 -0
  34. app/code/community/Customergauge/Import/sql/import_setup/mysql4-install-1.1.1.php +25 -0
  35. app/design/adminhtml/default/default/layout/customergauge.xml +8 -0
  36. app/design/adminhtml/default/default/template/customergauge/.DS_Store +0 -0
  37. app/design/adminhtml/default/default/template/customergauge/sync/.DS_Store +0 -0
  38. app/design/adminhtml/default/default/template/customergauge/sync/edit.phtml +49 -0
  39. app/etc/modules/Customerauge_Import.xml +8 -0
  40. package.xml +23 -0
app/code/community/Customergauge/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Block/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Block/Sales/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Block/Sales/Order/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Block/Sales/Order/Grid.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
10
+ {
11
+
12
+
13
+ protected function _prepareColumns()
14
+ {
15
+ $options = array(
16
+ 'Imported' => 'Imported',
17
+ 'Not Imported' => 'Not Imported'
18
+ );
19
+ $this->addColumn('customergauge_import', array(
20
+ 'header'=> Mage::helper('customer')->__('Customergauge Import'),
21
+ 'width' => '80px',
22
+ 'type' => 'options',
23
+ 'index' => 'customergauge_import',
24
+ 'options' => $options ));
25
+ $this->addColumnsOrder('customergauge_import', 'grand_total');
26
+ return parent::_prepareColumns();
27
+
28
+ }
29
+
30
+ }
app/code/community/Customergauge/Import/Block/Sync/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Block/Sync/Edit.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Block_Sync_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ protected $_addButtonLabel = 'Add New Example';
12
+
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ $this->setTemplate('customergauge/sync/edit.phtml');
17
+ $this->setTitle('Field Mapping');
18
+
19
+ }
20
+
21
+ public function getSaveButtonHtml()
22
+ {
23
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
24
+ ->setData(array(
25
+ 'id' => 'customergauge_mapping',
26
+ 'label' => $this->helper('adminhtml')->__('Save'),
27
+ 'onclick' => 'javascript:document.getElementById(\'customgergauge_sync_form\').submit();'
28
+ ));
29
+
30
+ return $button->toHtml();
31
+ }
32
+
33
+ public function getSaveUrl()
34
+ {
35
+ return $this->getUrl('*/*/save', array('_current'=>true));
36
+ }
37
+
38
+ public function requiredDataExists(){
39
+ $requiredData = Mage::getStoreConfig('import/config');
40
+ $requiredKeys = array('cg_apikey');
41
+ foreach($requiredKeys as $key){
42
+ if(array_key_exists($key, $requiredData)){
43
+ if( empty( $requiredData[ $key ] ) ){
44
+ return false;
45
+ }
46
+ }else{
47
+ return false;
48
+ }
49
+ }
50
+ return true;
51
+ }
52
+
53
+ public function getMagentoField(){
54
+
55
+ $templateLine = Mage::helper("import")->loadTemplate();
56
+ $MagentoFieldArray = array();
57
+ foreach( $templateLine as $key => $val ){
58
+ $MagentoFieldArray[ $key ] = $val;
59
+ }
60
+ return $MagentoFieldArray;
61
+
62
+ }
63
+
64
+ public function getCustomergaugeField( ){
65
+
66
+ $config_data = Mage::getStoreConfig('import/config');
67
+ $is_prodcution_active = $config_data[ "cg_activepro" ];
68
+ if( $is_prodcution_active )
69
+ $api_url = $config_data[ "cg_prourl" ];
70
+ else {
71
+ $api_url = $config_data[ "cg_devurl" ];
72
+ }
73
+ $api_key = $config_data[ "cg_apikey" ];
74
+ $api_url = $api_url . "get_cg_field.json?api_key=$api_key";
75
+ $json_data = Mage::helper("import")->apiCall( $api_url );
76
+ $json_array = json_decode( $json_data, true );
77
+ if( $json_array[ "IsSuccess" ] )
78
+ return $json_array[ "Data" ];
79
+
80
+ }
81
+
82
+ public function getCgMapping(){
83
+
84
+ $model = Mage::getModel( 'import/cgmapping' );
85
+ $data = $model->getCollection()->getData();
86
+ return $data;
87
+
88
+ }
89
+
90
+ public function CheckSlected( $cgmapping, $val ){
91
+
92
+ foreach( $cgmapping as $item ){
93
+
94
+ if( $item[ "magento_field" ] == $val )
95
+ return $item[ "cg_field" ];
96
+ }
97
+ return "";
98
+ }
99
+ }
app/code/community/Customergauge/Import/Helper/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Helper/Data.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**
12
+ * @author Manas Kanti Dey
13
+ * @desc
14
+ * Get array of items in template line
15
+ *
16
+ * @return array
17
+ */
18
+ public static function loadTemplate()
19
+ {
20
+
21
+ $config_data = Mage::getStoreConfig('import/config');
22
+ $is_prodcution_active = $config_data[ "cg_activepro" ];
23
+ if( $is_prodcution_active )
24
+ $api_url = $config_data[ "cg_prourl" ];
25
+ else {
26
+ $api_url = $config_data[ "cg_devurl" ];
27
+ }
28
+ $api_key = $config_data[ "cg_apikey" ];
29
+ $api_url = $api_url . "get_magento_field.json?api_key=$api_key";
30
+ $json_data = Mage::helper("import")->apiCall( $api_url );
31
+ $json_array = json_decode( $json_data, true );
32
+ if( $json_array[ "IsSuccess" ] ){
33
+
34
+ return $json_array[ "Data" ];
35
+
36
+ } else {
37
+
38
+ }
39
+
40
+ return $magento_field;
41
+
42
+ }
43
+
44
+ /**
45
+ * @author Manas Kanti Dey
46
+ * @desc
47
+ * It calls the customergauge api, if the uploaded data given then it post the data on API URL
48
+ *
49
+ * @return array
50
+ */
51
+ public static function apiCall( $apiUrl, $upload_data = "" ) {
52
+
53
+ $curl_handle = curl_init( );
54
+ curl_setopt($curl_handle, CURLOPT_URL, $apiUrl);
55
+ if( isset( $upload_data ) )
56
+ {
57
+ curl_setopt( $curl_handle, CURLOPT_POST, true );
58
+ curl_setopt( $curl_handle, CURLOPT_POSTFIELDS, $upload_data );
59
+ }
60
+ curl_setopt( $curl_handle, CURLOPT_RETURNTRANSFER, TRUE );
61
+ curl_setopt( $curl_handle, CURLOPT_HTTPHEADER, array( 'Expect:' ) );
62
+ curl_setopt( $curl_handle, CURLOPT_TIMEOUT, 1000);
63
+ $curl_data = curl_exec( $curl_handle );
64
+ curl_close( $curl_handle );
65
+ return $curl_data;
66
+
67
+ }
68
+
69
+ }
app/code/community/Customergauge/Import/Model/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Model/Cgmapping.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Model_Cgmapping extends Mage_Core_Model_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+
14
+ parent::_construct();
15
+ $this->_init('import/cgmapping');
16
+
17
+ }
18
+
19
+ }
app/code/community/Customergauge/Import/Model/Mysql4/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Model/Mysql4/Cgmapping.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Model_Mysql4_Cgmapping extends Mage_Core_Model_Mysql4_Abstract
10
+ {
11
+
12
+ public function _construct()
13
+ {
14
+ $this->_init('import/cgmapping', 'id');
15
+ }
16
+
17
+
18
+ }
app/code/community/Customergauge/Import/Model/Mysql4/Cgmapping/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Model/Mysql4/Cgmapping/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Model_Mysql4_Cgmapping_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_init('import/cgmapping');
15
+ }
16
+ }
app/code/community/Customergauge/Import/Model/Observer.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Model_Observer {
10
+
11
+ /**
12
+ * @author Manas Kanti Dey
13
+ *
14
+ * @desc
15
+ * This method will include a option in Action Select List of order page
16
+ */
17
+ public function includeOption($observer)
18
+ {
19
+
20
+ $idBlockObserver = $observer->getEvent()->getBlock()->getId();
21
+ if ( $idBlockObserver=="sales_order_grid" ) {
22
+
23
+ $block = $observer->getEvent()
24
+ ->getBlock()
25
+ ->getMassactionBlock();
26
+
27
+ if ($block) {
28
+ $block->addItem('import', array(
29
+ 'label'=> Mage::helper('import')->__('Send to CustomerGauge'),
30
+ 'url' => Mage::getUrl('customergauge_import', array('_secure'=>true)),
31
+ ));
32
+ }
33
+
34
+ }
35
+ }
36
+
37
+
38
+ /**
39
+ * @author Manas Kanti Dey
40
+ *
41
+ * @desc
42
+ * This method will call by magento after each save on order
43
+ *
44
+ */
45
+ public function hookToOrderSaveEvent($observer)
46
+ {
47
+
48
+ $config_data = Mage::getStoreConfig('import/config');
49
+ $is_cg_transactional = $config_data[ "cg_transactional" ];
50
+
51
+ if( $is_cg_transactional ){
52
+
53
+
54
+ $order = $observer->getEvent()->getOrder();
55
+ $order_id = $order->getId();
56
+ $orderIdsList[] = $order_id;
57
+ $order_status = $order->getStatus();
58
+ $customergauge_import = $order->getData( "customergauge_import" );
59
+
60
+ $cg_orderstatusmagento = $config_data[ "cg_orderstatusmagento" ];
61
+ if( $cg_orderstatusmagento == $order_status && $customergauge_import == "Not Imported" ){
62
+
63
+ $CustomergaugeImport = new Customergauge_Import_Service_ImportData( $orderIdsList );
64
+ $api_response = $CustomergaugeImport->call();
65
+ $api_reponse_array = json_decode( $api_response, true );
66
+
67
+ if( $api_reponse_array[ 'IsSuccess' ] == 1 ){
68
+
69
+ $response_data = $api_reponse_array[ 'Data' ][ 'log' ];
70
+ if( ! $response_data[0]['error'] ){
71
+
72
+ $data = array('customergauge_import'=>'Imported');
73
+ $orderModel = Mage::getModel('sales/order')->load($order_id)->addData($data);
74
+ try {
75
+ $orderModel->setId($order_id)->save();
76
+ } catch (Exception $e){}
77
+
78
+ }
79
+
80
+ }
81
+
82
+ }
83
+
84
+
85
+ }
86
+
87
+ }
88
+
89
+ }
app/code/community/Customergauge/Import/Model/System/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Model/System/Config/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Model/System/Config/Orderstatus.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Model_System_Config_Orderstatus
10
+ {
11
+ /**
12
+ * @desc
13
+ * Get all the Sales order status
14
+ *
15
+ * @return array
16
+ */
17
+ public function toOptionArray()
18
+ {
19
+
20
+ $all_status = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
21
+ foreach( $all_status as $status ){
22
+ $values[] = array( 'value' => $status[ 'status' ], 'label'=> $status[ 'label' ] );
23
+ }
24
+ return $values;
25
+
26
+ }
27
+ }
app/code/community/Customergauge/Import/Model/System/Config/Transactional.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Model_System_Config_Transactional
10
+ {
11
+ /**
12
+ * Options getter
13
+ *
14
+ * @return array
15
+ */
16
+ public function toOptionArray()
17
+ {
18
+
19
+ $values = array(
20
+ array('value' => 0, 'label'=> "Manual" ) ,
21
+ array('value' => 1, 'label'=> "Automatic" )
22
+ );
23
+ return $values;
24
+
25
+ }
26
+ }
app/code/community/Customergauge/Import/Model/System/Config/Upload.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Model_System_Config_Upload
10
+ {
11
+ /**
12
+ * Options getter
13
+ *
14
+ * @return array
15
+ */
16
+ public function toOptionArray()
17
+ {
18
+
19
+ $values = array(
20
+ array('value' => 0, 'label'=> "Development" ) ,
21
+ array('value' => 1, 'label'=> "LIVE Production" )
22
+ );
23
+ return $values;
24
+
25
+ }
26
+ }
app/code/community/Customergauge/Import/Service/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/Service/ImportData.php ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Service_ImportData {
10
+
11
+ private $_orderIds = array();
12
+ private $_collectionOrders;
13
+ private $_contentXML;
14
+
15
+ public function __construct($ordersId) {
16
+ $this->_orderIds = $ordersId;
17
+ }
18
+
19
+ private function _loadOrderObjects()
20
+ {
21
+ $this->_collectionOrders = array();
22
+
23
+ foreach($this->_orderIds as $id) {
24
+ $instance = Mage::getModel("sales/order")->load($id);
25
+ array_push($this->_collectionOrders, $instance);
26
+ }
27
+ }
28
+
29
+ /**
30
+ * @author Manas Kanti Dey
31
+ * @desc
32
+ * It generate the xml for upload with mapping array
33
+ *
34
+ * @param
35
+ * $mapping array
36
+ *
37
+ * @return void
38
+ */
39
+ private function _prepareData( $mapping )
40
+ {
41
+ $this->_contentXML = "";
42
+ $product = array();
43
+ foreach( $this->_collectionOrders as $order ) {
44
+
45
+ $lineItem = "";
46
+
47
+ // iterate on the itens in template
48
+ $orderItems = $order->getItemsCollection();
49
+ $itemInc = 0;
50
+ foreach ( $orderItems as $item )
51
+ {
52
+ if ( ! $item->isDummy() ) {
53
+ $single_product = $this->getOrderItemValues( $item, $order, ++$itemInc );
54
+ foreach( $single_product as $key => $val ){
55
+ $product[ $key ][] = $val;
56
+ }
57
+ }
58
+
59
+ }
60
+ $shippingAddress = !$order->getIsVirtual() ? $order->getShippingAddress() : null;
61
+ $billingAddress = $order->getBillingAddress();
62
+
63
+ foreach( $mapping as $fields ) {
64
+
65
+ // order.increment_id => $order->getData("increment_id");
66
+ // getAttributeByCode($attribute, $order)
67
+ $item = "";
68
+ $magento_field = $fields[ "magento_field" ];
69
+ $cg_field = $fields[ "cg_field" ];
70
+ $pos = strpos( $magento_field, "_" );
71
+ $object = strtolower( substr( $magento_field, 0, $pos ) );
72
+ $attribute = substr( $magento_field, $pos+1, strlen( $magento_field ) );
73
+
74
+
75
+
76
+ $itemInc = 0;
77
+
78
+ switch( $object ) {
79
+
80
+ case "order":
81
+ $item = $order->getData( $attribute );
82
+ break;
83
+
84
+ case "customer":
85
+ if ($attribute=="name") {
86
+ $item = $order->getData("customer_firstname") . " " .
87
+ $order->getData("customer_lastname");
88
+ } else {
89
+ $item = $order->getData("customer_{$attribute}");
90
+ }
91
+ break;
92
+
93
+ case "shipping":
94
+
95
+ if (strpos($attribute, "street_")!==false) {
96
+ $street = explode("_", $attribute);
97
+ $item = $shippingAddress->getStreet( $street[1] );
98
+ } else {
99
+ $item = $shippingAddress->getData( $attribute );
100
+ }
101
+ break;
102
+
103
+ case "billing":
104
+ if (strpos($attribute, "street_")!==false) {
105
+ $street = explode("_", $attribute);
106
+ $item = $billingAddress->getStreet( $street[1] );
107
+ } else {
108
+ $item = $billingAddress->getData( $attribute );
109
+ }
110
+ break;
111
+
112
+ case "item":
113
+ if ( array_key_exists( $attribute, $product ) ) {
114
+ $item = implode( ";", $product[ $attribute ] );
115
+ } else {
116
+ $item = "";
117
+ }
118
+ break;
119
+ }
120
+
121
+ $lineItem .= "<{$cg_field}>{$item}</{$cg_field}>";
122
+ }
123
+
124
+ // endline
125
+ $this->_contentXML .= "<RECORD>{$lineItem}</RECORD>";
126
+ }
127
+ }
128
+
129
+ protected function getOrderItemValues( $item, $order, $itemInc=1 )
130
+ {
131
+ return array(
132
+ 'increment' => $itemInc,
133
+ 'name' => $item->getName(),
134
+ 'status' => $item->getStatus(),
135
+ 'sku' => $this->getItemSku($item),
136
+ 'option' => $this->getItemOptions($item),
137
+ 'original_price' => $this->formatPrice($item->getOriginalPrice(), $order),
138
+ 'price' => $this->formatPrice($item->getData('price'), $order),
139
+ 'qty_ordered' => (int)$item->getQtyOrdered(),
140
+ 'qty_invoiced' => (int)$item->getQtyInvoiced(),
141
+ 'qty_shipped' => (int)$item->getQtyShipped(),
142
+ 'qty_canceled' => (int)$item->getQtyCanceled(),
143
+ 'qty_refunded' => (int)$item->getQtyRefunded(),
144
+ 'tax' => $this->formatPrice($item->getTaxAmount(), $order),
145
+ 'discount' => $this->formatPrice($item->getDiscountAmount(), $order),
146
+ 'total' => $this->formatPrice($this->getItemTotal($item), $order)
147
+ );
148
+ }
149
+
150
+ /**
151
+ * @author Manas Kanti Dey
152
+ * @desc
153
+ * It upload the on CustomerGauge using apiCall method
154
+ *
155
+ * @param
156
+ * $mapping array
157
+ *
158
+ * @return void
159
+ */
160
+ public function call()
161
+ {
162
+ $this->_loadOrderObjects();
163
+ $model = Mage::getModel( 'import/cgmapping' );
164
+ $mapping = $model->getCollection()->getData();
165
+ $this->_prepareData( $mapping );
166
+ $post_xml = '<?xml version="1.0" encoding="utf-8"?><RECORDS>' . $this->_contentXML . '</RECORDS>';
167
+
168
+ $config_data = Mage::getStoreConfig('import/config');
169
+ $is_prodcution_active = $config_data[ "cg_activepro" ];
170
+ if( $is_prodcution_active )
171
+ $api_url = $config_data[ "cg_prourl" ];
172
+ else {
173
+ $api_url = $config_data[ "cg_devurl" ];
174
+ }
175
+ $api_key = $config_data[ "cg_apikey" ];
176
+ $api_url = $api_url . "upload_record.json?api_key=$api_key";
177
+ $json_data = Mage::helper("import")->apiCall( $api_url, $post_xml );
178
+ return $json_data;
179
+ }
180
+
181
+ protected function getItemSku($item)
182
+ {
183
+ if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
184
+ return $item->getProductOptionByCode('simple_sku');
185
+ }
186
+ return $item->getSku();
187
+ }
188
+
189
+ protected function getItemOptions($item)
190
+ {
191
+ $options = '';
192
+ if ($orderOptions = $this->getItemOrderOptions($item)) {
193
+ foreach ($orderOptions as $_option) {
194
+ if (strlen($options) > 0) {
195
+ $options .= ', ';
196
+ }
197
+ $options .= $_option['label'].': '.$_option['value'];
198
+ }
199
+ }
200
+ return $options;
201
+ }
202
+
203
+ protected function getItemOrderOptions($item)
204
+ {
205
+ $result = array();
206
+ if ($options = $item->getProductOptions()) {
207
+ if (isset($options['options'])) {
208
+ $result = array_merge($result, $options['options']);
209
+ }
210
+ if (isset($options['additional_options'])) {
211
+ $result = array_merge($result, $options['additional_options']);
212
+ }
213
+ if (!empty($options['attributes_info'])) {
214
+ $result = array_merge($options['attributes_info'], $result);
215
+ }
216
+ }
217
+ return $result;
218
+ }
219
+
220
+ protected function getItemTotal($item)
221
+ {
222
+ return $item->getRowTotal() - $item->getDiscountAmount() + $item->getTaxAmount() + $item->getWeeeTaxAppliedRowAmount();
223
+ }
224
+
225
+ protected function formatPrice($price, $formatter)
226
+ {
227
+ return $formatter->formatPriceTxt($price);
228
+ }
229
+
230
+ }
app/code/community/Customergauge/Import/controllers/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/controllers/Adminhtml/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/controllers/Adminhtml/SyncController.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Customergauge
4
+ * @package Customergauge_Import
5
+ * @author Manas Kanti Dey
6
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
7
+ *
8
+ */
9
+ class Customergauge_Import_Adminhtml_SyncController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ public function indexAction(){
12
+ $this->loadLayout()
13
+ ->_setActiveMenu( 'Customergauge_Import/adminhtml_sync' )
14
+ ->_addContent( $this->getLayout()->createBlock( 'import/sync_edit' ) )
15
+ ->renderLayout();
16
+ }
17
+
18
+ /**
19
+ * @author Manas Kanti Dey
20
+ * @desc
21
+ * Save CustomerGauge Mapping inside magento database.
22
+ * Redirect to index page.
23
+ *
24
+ */
25
+ public function saveAction()
26
+ {
27
+
28
+ $model = Mage::getModel( 'import/cgmapping' );
29
+
30
+ $old_data = $model->getCollection()->getData();
31
+ $mapping = array();
32
+ foreach( $old_data as $item ){
33
+ $mapping[ $item[ "id" ] ] = $item[ "magento_field" ];
34
+ }
35
+
36
+ $templateLine = Mage::helper("import")->loadTemplate();
37
+ foreach( $templateLine as $key => $val ){
38
+
39
+ $post_val = $this->getRequest()->getPost( $key );
40
+ $post_val = trim( $post_val );
41
+ if( $post_val != "" ){
42
+
43
+ $id = array_search( $key, $mapping );
44
+ $data = array( 'magento_field'=> trim( $key ), 'cg_field'=> trim( $post_val ) );
45
+ if( $id !== FALSE ){
46
+ $model->load($id)->addData( $data );
47
+ $model->setId($id)->save();
48
+ } else {
49
+ $model->setData( $data );
50
+ $model->save();
51
+ }
52
+
53
+ } else {
54
+
55
+ $id = array_search( $key, $mapping );
56
+ if( $id != "" ){
57
+ $model->setId($id)->delete();
58
+ }
59
+
60
+ }
61
+
62
+ }
63
+ $this->_getSession()->addSuccess( $this->__('Mapping have been saved') );
64
+ $this->_redirect('*/*/index');
65
+
66
+ }
67
+
68
+ }
69
+
70
+ ?>
app/code/community/Customergauge/Import/controllers/IndexController.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento CustomerGauge Import Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ * @category Customergauge
26
+ * @package Customergauge_Import
27
+ * @copyright Copyright (c) 2013 CustomerGauge (http://www.customergauge.com)
28
+ * @license http://opensource.org/licenses/mit-license.php The MIT License
29
+ * @author Manas Kanti Dey <manas.dey@directness.net>
30
+ * */
31
+ require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
32
+ class Customergauge_Import_IndexController
33
+ extends Mage_Adminhtml_Sales_OrderController {
34
+
35
+ public function indexAction()
36
+ {
37
+ $post = $this->getRequest()->getPost();
38
+ $orderIdsList = $post['order_ids'];
39
+
40
+ $CustomergaugeImport = new Customergauge_Import_Service_ImportData( $orderIdsList );
41
+ $api_response = $CustomergaugeImport->call();
42
+ $api_reponse_array = json_decode( $api_response, true );
43
+
44
+ if( $api_reponse_array[ 'IsSuccess' ] == 1 ){
45
+
46
+ $i=0;
47
+ $response_data = $api_reponse_array[ 'Data' ][ 'log' ];
48
+ foreach( $orderIdsList as $orderId){
49
+
50
+ if( ! $response_data[$i]['error'] ){
51
+
52
+ $data = array('customergauge_import'=>'Imported');
53
+ $orderModel = Mage::getModel('sales/order')->load($orderId)->addData($data);
54
+ try {
55
+ $orderModel->setId($orderId)->save();
56
+ } catch (Exception $e){}
57
+ }
58
+ $i++;
59
+
60
+ }
61
+ $successCount = $api_reponse_array[ 'Data' ][ 'total_successfull_record' ];
62
+ $unsuccessCount = $api_reponse_array[ 'Data' ][ 'total_unsuccessfull_record' ];
63
+ if( !empty( $successCount ) && $successCount > 0 )
64
+ $this->_getSession()->addSuccess( $this->__( '%s order(s) have been imported', $successCount ) );
65
+ if( !empty( $unsuccessCount ) && $unsuccessCount > 0 )
66
+ $this->_getSession()->addError( $this->__( '%s order(s) failed on import', $unsuccessCount ) );
67
+
68
+ } else {
69
+ $this->_getSession()->addError( $this->__( $api_reponse_array[ "ExceptionMessage" ] ) );
70
+ }
71
+ $this->_redirect( "adminhtml/sales_order" );
72
+ }
73
+
74
+ }
app/code/community/Customergauge/Import/etc/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/etc/config.xml ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Customergauge_Import>
5
+ <version>1.1.1</version>
6
+ </Customergauge_Import>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <import>
11
+ <class>Customergauge_Import_Model</class>
12
+ <resourceModel>import_mysql4</resourceModel>
13
+ </import>
14
+ <import_mysql4>
15
+ <class>Customergauge_Import_Model_Mysql4</class>
16
+ <entities>
17
+ <cgmapping>
18
+ <table>cgmapping</table>
19
+ </cgmapping>
20
+ </entities>
21
+ </import_mysql4>
22
+ </models>
23
+ <resources>
24
+ <import_setup>
25
+ <setup>
26
+ <module>Customergauge_Import</module>
27
+ </setup>
28
+ <connection>
29
+ <use>core_setup</use>
30
+ </connection>
31
+ </import_setup>
32
+ <import_write>
33
+ <connection>
34
+ <use>core_write</use>
35
+ </connection>
36
+ </import_write>
37
+ <import_read>
38
+ <connection>
39
+ <use>core_read</use>
40
+ </connection>
41
+ </import_read>
42
+ </resources>
43
+ <blocks>
44
+ <import>
45
+ <class>Customergauge_Import_Block</class>
46
+ </import>
47
+ <adminhtml>
48
+ <rewrite>
49
+ <sales_order_grid>Customergauge_Import_Block_Sales_Order_Grid</sales_order_grid>
50
+ </rewrite>
51
+ </adminhtml>
52
+ </blocks>
53
+ <helpers>
54
+ <import>
55
+ <class>Customergauge_Import_Helper</class>
56
+ </import>
57
+ </helpers>
58
+ <events>
59
+ <sales_order_save_commit_after>
60
+ <observers>
61
+ <customergauge_order_success>
62
+ <type>singleton</type>
63
+ <class>import/Observer</class>
64
+ <method>hookToOrderSaveEvent</method>
65
+ </customergauge_order_success>
66
+ </observers>
67
+ </sales_order_save_commit_after>
68
+ </events>
69
+ </global>
70
+ <admin>
71
+ <routers>
72
+ <Customergauge_Import>
73
+ <use>admin</use>
74
+ <args>
75
+ <module>Customergauge_Import</module>
76
+ <frontName>customergauge_import</frontName>
77
+ </args>
78
+ </Customergauge_Import>
79
+ </routers>
80
+ </admin>
81
+ <adminhtml>
82
+ <events>
83
+ <adminhtml_block_html_before>
84
+ <observers>
85
+ <option_in_import>
86
+ <class>import/Observer</class>
87
+ <method>includeOption</method>
88
+ </option_in_import>
89
+ </observers>
90
+ </adminhtml_block_html_before>
91
+ </events>
92
+ <menu>
93
+ <Customergauge_Import translate="title" module="import" >
94
+ <title>CustomerGauge</title>
95
+ <sort_order>110</sort_order>
96
+ <children>
97
+ <import translate="title" module="import">
98
+ <title>Field Mapping</title>
99
+ <action>Customergauge_Import/adminhtml_sync</action>
100
+ <sort_order>0</sort_order>
101
+ </import>
102
+ <settings translate="title" module="import">
103
+ <title>Settings</title>
104
+ <action>adminhtml/system_config/edit/section/import/</action>
105
+ <sort_order>1</sort_order>
106
+ </settings>
107
+ </children>
108
+ </Customergauge_Import>
109
+ </menu>
110
+ <acl>
111
+ <resources>
112
+ <all>
113
+ <title>Allow Everything</title>
114
+ </all>
115
+ <admin>
116
+ <children>
117
+ <system>
118
+ <children>
119
+ <config>
120
+ <children>
121
+ <import>
122
+ <title>CustomerGauge Import</title>
123
+ </import>
124
+ </children>
125
+ </config>
126
+ </children>
127
+ </system>
128
+ </children>
129
+ </admin>
130
+ </resources>
131
+ </acl>
132
+ </adminhtml>
133
+ <default>
134
+ <import>
135
+ <config>
136
+ <cg_transactional>0</cg_transactional>
137
+ <cg_orderstatusmagento>complete</cg_orderstatusmagento>
138
+ <cg_prourl>https://www.cg-express.com/an/api/magento/</cg_prourl>
139
+ <cg_devurl>http://www.development-cg-express.com/an/api/magento/</cg_devurl>
140
+ <cg_activepro>0</cg_activepro>
141
+ </config>
142
+ </import>
143
+ </default>
144
+ </config>
app/code/community/Customergauge/Import/etc/system.xml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <Customergauge translate="label">
5
+ <label>CUSTOMERGAUGE IMPORT</label>
6
+ <sort_order>1000000</sort_order>
7
+ </Customergauge>
8
+ </tabs>
9
+ <sections>
10
+ <import translate="label">
11
+ <label>CustomerGauge Settings</label>
12
+ <tab>Customergauge</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1010</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <config translate="label">
20
+ <label>General Settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <cg_apikey translate="label">
28
+ <label>API KEY</label>
29
+ <frontend_type>text</frontend_type>
30
+ <comment>The API key can be found in the Admin section of CustomerGauge</comment>
31
+ <sort_order>10</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </cg_apikey>
36
+ <cg_transactional translate="label">
37
+ <label>Import Type</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>import/system_config_transactional</source_model>
40
+ <comment>"Manual" select and send records as needed to CustomerGauge from Sales Report.<![CDATA[<br/>]]>"Automatic" post-order Sends records at end of each transaction to CustomerGauge.</comment>
41
+ <sort_order>20</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>0</show_in_website>
44
+ <show_in_store>0</show_in_store>
45
+ </cg_transactional>
46
+ <cg_orderstatusmagento translate="label">
47
+ <label>Order Status</label>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>import/system_config_orderstatus</source_model>
50
+ <comment></comment>
51
+ <sort_order>25</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>0</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </cg_orderstatusmagento>
56
+ <cg_prourl translate="label">
57
+ <label>Production API URL</label>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>30</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </cg_prourl>
64
+ <cg_devurl translate="label">
65
+ <label>Development API URL</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>40</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </cg_devurl>
72
+ <cg_activepro translate="label">
73
+ <label>Active CustomerGauge System</label>
74
+ <frontend_type>select</frontend_type>
75
+ <source_model>import/system_config_upload</source_model>
76
+ <comment>We recommend testing in the CustomerGauge development platform before you set live in Production.</comment>
77
+ <sort_order>50</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>0</show_in_website>
80
+ <show_in_store>0</show_in_store>
81
+ </cg_activepro>
82
+ </fields>
83
+ </config>
84
+ </groups>
85
+ </import>
86
+ </sections>
87
+ </config>
88
+
89
+
90
+
91
+
app/code/community/Customergauge/Import/sql/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/sql/import_setup/.DS_Store ADDED
Binary file
app/code/community/Customergauge/Import/sql/import_setup/mysql4-install-1.1.1.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $installer->run("CREATE TABLE IF NOT EXISTS {$this->getTable('cgmapping')} (
5
+ `id` int(10) unsigned NOT NULL auto_increment,
6
+ `magento_field` varchar(250) NOT NULL default '',
7
+ `cg_field` varchar(250) NOT NULL default '',
8
+ PRIMARY KEY (`id`)
9
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
10
+ $installer->run("
11
+ INSERT INTO {$this->getTable('cgmapping')} VALUES (null,'Order_created_at','date_order');
12
+ ");
13
+ $installer->run("
14
+ INSERT INTO {$this->getTable('cgmapping')} VALUES (null,'Order_customer_firstname','first_name');
15
+ ");
16
+ $installer->run("
17
+ INSERT INTO {$this->getTable('cgmapping')} VALUES (null,'Order_customer_lastname','last_name');
18
+ ");
19
+ $installer->run("
20
+ INSERT INTO {$this->getTable('cgmapping')} VALUES (null,'Order_customer_email','email');
21
+ ");
22
+ $installer->run("ALTER TABLE `{$installer->getTable('sales/order')}` ADD `customergauge_import` VARCHAR(255) DEFAULT 'Not Imported' ;");
23
+ $installer->run("ALTER TABLE `{$installer->getTable('sales/order_grid')}` ADD `customergauge_import` VARCHAR(255) DEFAULT 'Not Imported' ;");
24
+ $installer->endSetup();
25
+ ?>
app/design/adminhtml/default/default/layout/customergauge.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <import_sync>
4
+ <reference name="content">
5
+ <block type="import/sync" name="sync"></block>
6
+ </reference>
7
+ </import_sync>
8
+ </layout>
app/design/adminhtml/default/default/template/customergauge/.DS_Store ADDED
Binary file
app/design/adminhtml/default/default/template/customergauge/sync/.DS_Store ADDED
Binary file
app/design/adminhtml/default/default/template/customergauge/sync/edit.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0">
3
+ <tr>
4
+ <td><h3><?php echo Mage::helper('import')->__($this->getTitle()) ?></h3></td>
5
+ <td class="form-buttons"><?php echo $this->getSaveButtonHtml() ?></td>
6
+ </tr>
7
+ </table>
8
+ </div>
9
+ <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="customgergauge_sync_form" enctype="multipart/form-data">
10
+ <?php echo $this->getBlockHtml('formkey')?>
11
+ <?php if($this->requiredDataExists()): ?>
12
+ <?php echo $this->getChildHtml('form') ?>
13
+ <div class="entry-edit">
14
+ <div class="entry-edit-head">
15
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('CustomerGauge Field Mapping') ?></h4>
16
+ </div>
17
+ <fieldset id="catalog">
18
+ <table cellspacing="0" class="form-list">
19
+ <tbody>
20
+ <?php
21
+ $cg_field_list = $this->getCustomergaugeField();
22
+ $cg_mapping = $this->getCgMapping();
23
+ $magento_field = $this->getMagentoField();
24
+ ?>
25
+ <?php foreach ( $magento_field as $key => $val ): ?>
26
+ <tr>
27
+ <td class="label"><label><?php echo $val ?></label></td>
28
+ <td class="value">
29
+ <?php $select_cg_field = $this->CheckSlected( $cg_mapping, $key )?>
30
+ <select name="<?php echo $key?>">
31
+ <option value=""> - Select CustomerGauge Field - </option>
32
+ <?php foreach( $cg_field_list as $cg_field_key => $cg_field ):
33
+ $select = ( $select_cg_field == $cg_field )?"selected":"";?>
34
+ <option value="<?php echo $cg_field;?>" <?php echo $select;?> ><?php echo $cg_field;?></option>
35
+ <?php endforeach; ?>
36
+ </select>
37
+ </td>
38
+ <td><small>&nbsp;</small></td>
39
+ </tr>
40
+ <?php endforeach; ?>
41
+ </tbody>
42
+ </table>
43
+ </fieldset>
44
+ </div>
45
+ <?php else:
46
+ echo 'Please fill all required data under CustomerGauge->Settings.';
47
+ endif;
48
+ ?>
49
+ </form>
app/etc/modules/Customerauge_Import.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Customergauge_Import>
4
+ <active>true</active>
5
+ <codePool>community</codePool>
6
+ </Customergauge_Import>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>CustomerGauge_Export_Integration</name>
4
+ <version>1.1.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/mit-license.php">MIT License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>CustomerGauge Import sends order information of the Magento to CustomeGauge Platform.</summary>
10
+ <description>There are two ways to send records in CustomerGauge.&#xD;
11
+ - Automatic Sending Sales Order to CustomerGauge&#xD;
12
+ - Manually selected Sales Order to CustomerGauge</description>
13
+ <notes>- Option to choose your order to send on CustomerGauge System.&#xD;
14
+ - Save CustomerGauge and Magento field mapping.&#xD;
15
+ - Option to filter sales order by CutomerGauge Import.&#xD;
16
+ - API configuration options added.on CustomerGauge Setting.</notes>
17
+ <authors><author><name>Manas Kanti Dey</name><user>manasdey</user><email>manas.dey@directness.net</email></author></authors>
18
+ <date>2013-09-30</date>
19
+ <time>14:42:45</time>
20
+ <contents><target name="magecommunity"><dir name="Customergauge"><dir name="Import"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="4e5a1a585d7a768bfa0e1d78546d32c8"/><file name=".DS_Store" hash="87db6efe156de8b1eea42f5ffbd01f3b"/></dir><file name=".DS_Store" hash="70301d9923441a7b7b94ed4cb592b494"/></dir><dir name="Sync"><file name="Edit.php" hash="789cc783325888a73131cfcf4007ce6a"/><file name=".DS_Store" hash="6ae83e821e6b26d880bf2d42d95322ba"/></dir><file name=".DS_Store" hash="2ea0965836cee66e249b546d5bd66951"/></dir><dir name="Helper"><file name="Data.php" hash="46119a5f86e2adff5167c8e7e532e5f5"/><file name=".DS_Store" hash="ab8ec9291ca4885b3d88edf43f8a944e"/></dir><dir name="Model"><file name="Cgmapping.php" hash="6c4ce5d0a2973c9af4b5fd6b23583a7a"/><dir name="Mysql4"><dir name="Cgmapping"><file name="Collection.php" hash="50e1997f017e5201526646fcfd6effd2"/><file name=".DS_Store" hash="cb9b1bbc3e6cd5c1087ac49d254adece"/></dir><file name="Cgmapping.php" hash="165673aa88d329cd0d670cd6a9f42ba4"/><file name=".DS_Store" hash="7ba1aad10a0eb1cedabb68ca888bc487"/></dir><file name="Observer.php" hash="19eeffcfea1d09ba88ef391a841f26da"/><dir name="System"><dir name="Config"><file name="Orderstatus.php" hash="9cc4e949d99e189af08313c870afe3e0"/><file name="Transactional.php" hash="e5fdcdef49391ef7d900a9b0984fce83"/><file name="Upload.php" hash="6700917fda034c072ac72bcb75ed5ff2"/><file name=".DS_Store" hash="573b89d7172a6d341365e696db6ed511"/></dir><file name=".DS_Store" hash="c907efcd64a9ac3608dbc5ae1008b912"/></dir><file name=".DS_Store" hash="9b06b702f939398f9be628e58faa7669"/></dir><dir name="Service"><file name="ImportData.php" hash="2c04dd248d70e397879cb6ca61e2df96"/><file name=".DS_Store" hash="d8a424427f2383d94a95347f0e53cc2c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SyncController.php" hash="cc98e1b4016315b2974b77b761e9f0b5"/><file name=".DS_Store" hash="40b0f7cc5de245fbb4da03d684161e93"/></dir><file name="IndexController.php" hash="b694faa8a6df362a7c3e4368d0ee24fb"/><file name=".DS_Store" hash="0a57ea16bec19d5dab1d9760c9b410dc"/></dir><dir name="etc"><file name="config.xml" hash="3bb2ddc48ccfc7eef275db49d27aa1bb"/><file name="system.xml" hash="54a1698ece99a964ccedde2ce56f6a8c"/><file name=".DS_Store" hash="aa49a79a9cc67525aa643aa80d41968d"/></dir><dir name="sql"><dir name="import_setup"><file name="mysql4-install-1.1.1.php" hash="133088cb1457421eceff4a735732bcde"/><file name=".DS_Store" hash="2fa599641a7bb74797516ad0b510dc56"/></dir><file name=".DS_Store" hash="261362682bd38546488ad38570a85353"/></dir><file name=".DS_Store" hash="c98939c1a6ba046065333de2cb2bac49"/></dir><file name=".DS_Store" hash="d72ebececba4e083c74265c3306e774e"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="customergauge.xml" hash="422ab77fb74c5dd84693f64fda7af475"/></dir><dir name="template"><dir name="customergauge"><dir name="sync"><file name="edit.phtml" hash="21c1698742a90a55413ab0638aabef18"/><file name=".DS_Store" hash="918bcbc5d672135d2e7a4e6d3a59f40c"/></dir><file name=".DS_Store" hash="a768df4bd6466078b17ef8c9869ea4f5"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Customerauge_Import.xml" hash="5700ceea97ddf41d8cf0fcb3c0433659"/></dir></target></contents>
21
+ <compatible/>
22
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
23
+ </package>