Bluefish_Connection - Version 1.1.3

Version Notes

This extension can be used by the users of bluefishretail,by providing appropriate credentials,given to them by bluefishretail.

Download this release

Release Info

Developer J Doyle
Extension Bluefish_Connection
Version 1.1.3
Comparing to
See all releases


Code changes from version 1.1.2 to 1.1.3

Files changed (33) hide show
  1. app/code/local/Bluefish/Connection/Block/Adminhtml/Bluestorescheduler/Grid.php +10 -11
  2. app/code/local/Bluefish/Connection/Block/Adminhtml/Errorsaleimport.php +17 -0
  3. app/code/local/Bluefish/Connection/Block/Adminhtml/Errorsaleimport/Grid.php +63 -0
  4. app/code/local/Bluefish/Connection/Block/Bluestoretaxclass.php +85 -0
  5. app/code/local/Bluefish/Connection/Block/Databasemapping.php +1 -1
  6. app/code/local/Bluefish/Connection/Block/Productdatabasemapping.php +1 -1
  7. app/code/local/Bluefish/Connection/Model/Carrier/Bsaleshippingmethod.php +51 -0
  8. app/code/local/Bluefish/Connection/Model/Errorsaleimport.php +12 -0
  9. app/code/local/Bluefish/Connection/Model/Mysql4/Errorsaleimport.php +8 -0
  10. app/code/local/Bluefish/Connection/Model/Mysql4/Errorsaleimport/Collection.php +12 -0
  11. app/code/local/Bluefish/Connection/Model/Observer.php +7 -0
  12. app/code/local/Bluefish/Connection/Model/Paymentmethod.php +15 -0
  13. app/code/local/Bluefish/Connection/Model/Store.php +10 -0
  14. app/code/local/Bluefish/Connection/Model/Validationcrontime.php +38 -14
  15. app/code/local/Bluefish/Connection/Model/Validationpaymentmap.php +45 -42
  16. app/code/local/Bluefish/Connection/Model/Validationtaxclass.php +98 -0
  17. app/code/local/Bluefish/Connection/Model/Validationtaxcode.php +41 -43
  18. app/code/local/Bluefish/Connection/controllers/Adminhtml/Bluefish_Error_Reporting.php +3 -2
  19. app/code/local/Bluefish/Connection/controllers/Adminhtml/CategorydataController.php +22 -17
  20. app/code/local/Bluefish/Connection/controllers/Adminhtml/ErrorsaleimportController.php +149 -0
  21. app/code/local/Bluefish/Connection/controllers/Adminhtml/MyformController.php +290 -2
  22. app/code/local/Bluefish/Connection/controllers/Adminhtml/ProductdataController.php +1 -1
  23. app/code/local/Bluefish/Connection/controllers/Adminhtml/Xml.php +547 -48
  24. app/code/local/Bluefish/Connection/etc/config.xml +86 -23
  25. app/code/local/Bluefish/Connection/etc/system.xml +164 -12
  26. app/code/local/Bluefish/Connection/sql/connection_setup/mysql4-upgrade-1.1.2-1.1.3.php +22 -0
  27. app/design/adminhtml/default/default/layout/connection.xml +7 -2
  28. app/design/adminhtml/default/default/template/connection/array_dropdown.phtml +1 -1
  29. app/design/adminhtml/default/default/template/connection/custom_product_radioinput.phtml +1 -1
  30. app/design/adminhtml/default/default/template/connection/custom_radioinput.phtml +1 -1
  31. app/design/adminhtml/default/default/template/connection/myform.phtml +6 -0
  32. app/etc/modules/Bluefish_Connection.xml +8 -7
  33. package.xml +6 -7
app/code/local/Bluefish/Connection/Block/Adminhtml/Bluestorescheduler/Grid.php CHANGED
@@ -24,7 +24,7 @@ class Bluefish_Connection_Block_Adminhtml_Bluestorescheduler_Grid extends Mage_A
24
  */
25
  protected function _prepareCollection() {
26
  $collection = Mage::getModel('cron/schedule')->getCollection();
27
- $collection->addFieldToFilter('job_code',array('in'=>array("bluefish_connection_category","bluefish_connection_customer","bluefish_connection_customerexport","bluefish_connection_orderexport","bluefish_connection_product","bluefish_connection_stock")));
28
  $this->setCollection($collection);
29
  return parent::_prepareCollection();
30
  }
@@ -103,7 +103,7 @@ class Bluefish_Connection_Block_Adminhtml_Bluestorescheduler_Grid extends Mage_A
103
  $this->getCollection()->addStoreFilter($value);
104
  }
105
 
106
- public function decorateMessages($value, Bluefish_Connection_Model_Bluestorescheduler $row) {
107
  $return = '';
108
  $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
109
  $prefix = Mage::getConfig()->getTablePrefix();
@@ -125,8 +125,8 @@ class Bluefish_Connection_Block_Adminhtml_Bluestorescheduler_Grid extends Mage_A
125
  return $return;
126
  }
127
 
128
- public function decorateStatus($value, Bluefish_Connection_Model_Bluestorescheduler $row) {
129
-
130
  $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
131
  $prefix = Mage::getConfig()->getTablePrefix();
132
 
@@ -139,8 +139,7 @@ class Bluefish_Connection_Block_Adminhtml_Bluestorescheduler_Grid extends Mage_A
139
  $resultCronScheduleMSG = $connection->query("SELECT status FROM ".$prefix."cron_schedule WHERE schedule_id = '".$row->getScheduleId()."'");
140
  $resultSetScheduleID = $resultCronScheduleMSG->fetchAll(PDO::FETCH_ASSOC);
141
 
142
- $status = $resultSetScheduleID[0][status];
143
- $errorMSG = $resultSetScheduleID[0][message];
144
  }
145
  else
146
  {
@@ -148,23 +147,23 @@ class Bluefish_Connection_Block_Adminhtml_Bluestorescheduler_Grid extends Mage_A
148
  }
149
 
150
  switch ($status) {
151
- case success:
152
  $class = 'notice';
153
  $result = $status;
154
  break;
155
- case pending:
156
  $class = 'minor';
157
  $result = $status;
158
  break;
159
- case running:
160
  $class = 'minor';
161
  $result = $status;
162
  break;
163
- case missed:
164
  $class = 'major';
165
  $result = $status;
166
  break;
167
- case error:
168
  $class = 'critical';
169
  $result = $status;
170
  break;
24
  */
25
  protected function _prepareCollection() {
26
  $collection = Mage::getModel('cron/schedule')->getCollection();
27
+ $collection->addFieldToFilter('job_code',array('in'=>array("bluefish_connection_category","bluefish_connection_customer","bluefish_connection_customerexport","bluefish_connection_orderexport","bluefish_connection_orderimport","bluefish_connection_product","bluefish_connection_stock")));
28
  $this->setCollection($collection);
29
  return parent::_prepareCollection();
30
  }
103
  $this->getCollection()->addStoreFilter($value);
104
  }
105
 
106
+ public function decorateMessages($value, $row) {
107
  $return = '';
108
  $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
109
  $prefix = Mage::getConfig()->getTablePrefix();
125
  return $return;
126
  }
127
 
128
+ public function decorateStatus($value, $row) {
129
+
130
  $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
131
  $prefix = Mage::getConfig()->getTablePrefix();
132
 
139
  $resultCronScheduleMSG = $connection->query("SELECT status FROM ".$prefix."cron_schedule WHERE schedule_id = '".$row->getScheduleId()."'");
140
  $resultSetScheduleID = $resultCronScheduleMSG->fetchAll(PDO::FETCH_ASSOC);
141
 
142
+ $status = $resultSetScheduleID[0]['status'];
 
143
  }
144
  else
145
  {
147
  }
148
 
149
  switch ($status) {
150
+ case "success":
151
  $class = 'notice';
152
  $result = $status;
153
  break;
154
+ case "pending":
155
  $class = 'minor';
156
  $result = $status;
157
  break;
158
+ case "running":
159
  $class = 'minor';
160
  $result = $status;
161
  break;
162
+ case "missed":
163
  $class = 'major';
164
  $result = $status;
165
  break;
166
+ case "error":
167
  $class = 'critical';
168
  $result = $status;
169
  break;
app/code/local/Bluefish/Connection/Block/Adminhtml/Errorsaleimport.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Bluefish_Connection_Block_Adminhtml_Errorsaleimport extends Mage_Adminhtml_Block_Widget_Grid_Container{
5
+
6
+ public function __construct()
7
+ {
8
+
9
+ $this->_controller = "adminhtml_errorsaleimport";
10
+ $this->_blockGroup = "connection";
11
+ $this->_headerText = Mage::helper("connection")->__("Error sales import");
12
+ $this->_addButtonLabel = Mage::helper("connection")->__("Add New Item");
13
+ parent::__construct();
14
+ $this->_removeButton('add');
15
+ }
16
+
17
+ }
app/code/local/Bluefish/Connection/Block/Adminhtml/Errorsaleimport/Grid.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bluefish_Connection_Block_Adminhtml_Errorsaleimport_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId("errorsaleimportGrid");
10
+ $this->setDefaultSort("id");
11
+ $this->setDefaultDir("DESC");
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel("connection/errorsaleimport")->getCollection();
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn("id", array(
24
+ "header" => Mage::helper("connection")->__("ID"),
25
+ "align" =>"right",
26
+ "width" => "50px",
27
+ "type" => "number",
28
+ "index" => "id",
29
+ ));
30
+
31
+ $this->addColumn("sale_code", array(
32
+ "header" => Mage::helper("connection")->__("Transaction Code"),
33
+ "index" => "sale_code",
34
+ ));
35
+
36
+ $this->addColumn("error", array(
37
+ "header" => Mage::helper("connection")->__("Error Message"),
38
+ "index" => "error",
39
+ "type" => 'text',
40
+ "nl2br" => true,
41
+ "truncate" => 5000,
42
+ ));
43
+
44
+ $this->addColumn('error_date', array(
45
+ 'header' => Mage::helper('connection')->__('Date Time'),
46
+ 'index' => 'error_date',
47
+ 'type' => 'datetime',
48
+ ));
49
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
50
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
51
+
52
+ return parent::_prepareColumns();
53
+ }
54
+
55
+ public function getRowUrl($row)
56
+ {
57
+ return '#';
58
+ }
59
+
60
+
61
+
62
+
63
+ }
app/code/local/Bluefish/Connection/Block/Bluestoretaxclass.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml system config array field renderer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Bluefish_Connection_Block_Bluestoretaxclass extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
35
+ {
36
+ protected $magentoAttributes;
37
+
38
+ public function __construct()
39
+ {
40
+ $this->addColumn('magentotaxclass', array(
41
+ 'label' => Mage::helper('adminhtml')->__('Magento Product Tax Class'),
42
+ 'size' => 28,
43
+ ));
44
+ $this->addColumn('bluestoretaxclass', array(
45
+ 'label' => Mage::helper('adminhtml')->__('Bluestore Product Tax Class code'),
46
+ 'size' => 28
47
+ ));
48
+ $this->_addAfter = false;
49
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add New Tax Class');
50
+
51
+ parent::__construct();
52
+ $this->setTemplate('connection/array_dropdown.phtml');
53
+ }
54
+
55
+ protected function _renderCellTemplate($columnName)
56
+ {
57
+ if (empty($this->_columns[$columnName])) {
58
+ throw new Exception('Wrong column name specified.');
59
+ }
60
+ $column = $this->_columns[$columnName];
61
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
62
+
63
+ if($columnName == 'magentotaxclass')
64
+ {
65
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
66
+ $prefix = Mage::getConfig()->getTablePrefix();
67
+ $resulttaxClass = $connection->query("SELECT * FROM ".$prefix."tax_class WHERE class_type = 'PRODUCT'");
68
+ $resultTax = $resulttaxClass->fetchAll(PDO::FETCH_OBJ);
69
+
70
+ $rendered = '<select name="'.$inputName.'">';
71
+
72
+ foreach($resultTax as $value)
73
+ {
74
+ $rendered .= '<option value="'.$value->class_id.'">'.$value->class_name.'</option>';
75
+ }
76
+
77
+ $rendered .= '</select>';
78
+ }
79
+ else
80
+ {
81
+ $rendered = '<input type="text" name="'.$inputName.'" value="">';
82
+ }
83
+ return $rendered;
84
+ }
85
+ }
app/code/local/Bluefish/Connection/Block/Databasemapping.php CHANGED
@@ -56,7 +56,7 @@ class Bluefish_Connection_Block_Databasemapping extends Mage_Adminhtml_Block_Sys
56
 
57
  if($numberRows > 0)
58
  {
59
- $unserielVal = unserialize($resultCronPath[0][value]);
60
 
61
  $checkbox_Direct = ($unserielVal['#{_id}']['Dbmapping'] == 'Direct')?'checked':'unchecked';
62
  $checkbox_Mapping = ($unserielVal['#{_id}']['Dbmapping'] == 'Mapping')?'checked':'unchecked';
56
 
57
  if($numberRows > 0)
58
  {
59
+ $unserielVal = unserialize($resultCronPath[0]['value']);
60
 
61
  $checkbox_Direct = ($unserielVal['#{_id}']['Dbmapping'] == 'Direct')?'checked':'unchecked';
62
  $checkbox_Mapping = ($unserielVal['#{_id}']['Dbmapping'] == 'Mapping')?'checked':'unchecked';
app/code/local/Bluefish/Connection/Block/Productdatabasemapping.php CHANGED
@@ -57,7 +57,7 @@ class Bluefish_Connection_Block_Productdatabasemapping extends Mage_Adminhtml_Bl
57
 
58
  if($numberRows > 0)
59
  {
60
- $unserielVal = unserialize($resultCronPath[0][value]);
61
 
62
  $checkbox_Direct = ($unserielVal['#{_id}']['Dbproductmapping'] == 'DirectProduct')?'checked':'unchecked';
63
  $checkbox_Mapping = ($unserielVal['#{_id}']['Dbproductmapping'] == 'MappingProduct')?'checked':'unchecked';
57
 
58
  if($numberRows > 0)
59
  {
60
+ $unserielVal = unserialize($resultCronPath[0]['value']);
61
 
62
  $checkbox_Direct = ($unserielVal['#{_id}']['Dbproductmapping'] == 'DirectProduct')?'checked':'unchecked';
63
  $checkbox_Mapping = ($unserielVal['#{_id}']['Dbproductmapping'] == 'MappingProduct')?'checked':'unchecked';
app/code/local/Bluefish/Connection/Model/Carrier/Bsaleshippingmethod.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bluefish_Connection_Model_Carrier_Bsaleshippingmethod extends Mage_Shipping_Model_Carrier_Abstract
3
+ implements Mage_Shipping_Model_Carrier_Interface {
4
+ protected $_code = 'bluefish_connection';
5
+
6
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
7
+ {
8
+ if($_SERVER['PATH_INFO'] == "/checkout/onepage/saveBilling/"){
9
+ return false;
10
+ }
11
+
12
+ /*// Don't want to display on fronend
13
+ if(Mage::getDesign()->getArea() === Mage_Core_Model_App_Area::AREA_FRONTEND &&
14
+ !Mage::getStoreConfig('carriers/'.$this->_code.'/show_frontend')){
15
+
16
+ return false;
17
+ }
18
+
19
+ // skip if not enabled
20
+ if(!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
21
+ return false;
22
+ }*/
23
+
24
+ $handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
25
+ $result = Mage::getModel('shipping/rate_result');
26
+ $show = true;
27
+ if($show){ // This if condition is just to demonstrate how to return success and error in shipping methods
28
+
29
+ $method = Mage::getModel('shipping/rate_result_method');
30
+ $method->setCarrier($this->_code);
31
+ $method->setMethod($this->_code);
32
+ $method->setCarrierTitle($this->getConfigData('title'));
33
+ $method->setMethodTitle($this->getConfigData('name'));
34
+ $method->setPrice($this->getConfigData('price'));
35
+ $method->setCost($this->getConfigData('price'));
36
+ $result->append($method);
37
+
38
+ }else{
39
+ $error = Mage::getModel('shipping/rate_result_error');
40
+ $error->setCarrier($this->_code);
41
+ $error->setCarrierTitle($this->getConfigData('name'));
42
+ $error->setErrorMessage($this->getConfigData('specificerrmsg'));
43
+ $result->append($error);
44
+ }
45
+ return $result;
46
+ }
47
+ public function getAllowedMethods()
48
+ {
49
+ return array('bsaleshippingmethod'=>$this->getConfigData('name'));
50
+ }
51
+ }
app/code/local/Bluefish/Connection/Model/Errorsaleimport.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bluefish_Connection_Model_Errorsaleimport extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct(){
6
+
7
+ $this->_init("connection/errorsaleimport");
8
+
9
+ }
10
+
11
+ }
12
+
app/code/local/Bluefish/Connection/Model/Mysql4/Errorsaleimport.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bluefish_Connection_Model_Mysql4_Errorsaleimport extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init("connection/errorsaleimport", "id");
7
+ }
8
+ }
app/code/local/Bluefish/Connection/Model/Mysql4/Errorsaleimport/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bluefish_Connection_Model_Mysql4_Errorsaleimport_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+
5
+ public function _construct(){
6
+ $this->_init("connection/errorsaleimport");
7
+ }
8
+
9
+
10
+
11
+ }
12
+
app/code/local/Bluefish/Connection/Model/Observer.php CHANGED
@@ -93,5 +93,12 @@ class Bluefish_Connection_Model_Observer extends Bluefish_Connection_Adminhtml_M
93
  {
94
  $this->postAction('7');
95
  }
 
 
 
 
 
 
 
96
  }
97
  ?>
93
  {
94
  $this->postAction('7');
95
  }
96
+ public function salesImport() ### This Function is used for sale Export
97
+ {
98
+ if ($this->isDisabled('bluefish_connection_orderimport')) {
99
+ die();
100
+ }
101
+ $this->postAction('8');
102
+ }
103
  }
104
  ?>
app/code/local/Bluefish/Connection/Model/Paymentmethod.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bluefish_Connection_Model_Paymentmethod extends Mage_Payment_Model_Method_Abstract
3
+ {
4
+ protected $_code = 'bluefish_connection';
5
+
6
+
7
+ public function isAvailable($quote = null) {
8
+ if($_SERVER['PATH_INFO'] == "/checkout/onepage/saveShippingMethod/"){
9
+ return false;
10
+ }
11
+ return true;
12
+ }
13
+
14
+
15
+ }
app/code/local/Bluefish/Connection/Model/Store.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Mage/Core/Model/Store.php';
3
+
4
+ class Bluefish_Connection_Model_Store extends Mage_Core_Model_Store
5
+ {
6
+ public function roundPrice($price,$roundTo=9)
7
+ {
8
+ return round($price, $roundTo);
9
+ }
10
+ }
app/code/local/Bluefish/Connection/Model/Validationcrontime.php CHANGED
@@ -41,11 +41,11 @@ class Bluefish_Connection_Model_Validationcrontime extends Mage_Adminhtml_Model_
41
  $prefix = Mage::getConfig()->getTablePrefix();
42
 
43
  if (is_array($value)) {
44
- unset($value['__empty']);
45
- }
46
 
47
- $cronPath = $this->getPath();
48
- $loopCounter = count($value);
49
 
50
  $resultPath = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = '".$cronPath."'");
51
  $resultCronPath = $resultPath->fetchAll(PDO::FETCH_ASSOC);
@@ -73,9 +73,13 @@ class Bluefish_Connection_Model_Validationcrontime extends Mage_Adminhtml_Model_
73
  break;
74
  case "mycustom_section/mycustom_sales_group/mycustom_sales_commonschedule":
75
  $markers = $doc->getElementsByTagName('bluefish_connection_orderexport');
 
76
  break;
77
  }
78
  $countNum = 0;
 
 
 
79
  foreach($value as $key => $valueconfig)
80
  {
81
  if($countNum == 0)
@@ -95,11 +99,21 @@ class Bluefish_Connection_Model_Validationcrontime extends Mage_Adminhtml_Model_
95
  }
96
 
97
 
98
- if(count($resultCronPath) == 0 || $resultCronPath[0][loopCounter] == '0')
99
  {
100
- foreach($markersCustomer as $marker)
101
  {
102
- $type = $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $cron_schedule_time;
 
 
 
 
 
 
 
 
 
 
103
  }
104
  foreach($markers as $marker)
105
  {
@@ -109,14 +123,14 @@ class Bluefish_Connection_Model_Validationcrontime extends Mage_Adminhtml_Model_
109
  $doc->save($xmlFile);
110
  $loopIteration = '1';
111
 
112
- if($resultCronPath[0][loopCounter] != '0')
113
  {
114
  $connection->query("INSERT INTO ".$prefix."bluefish_cron_schedule(id,cronPath,loopCounter,loopIteration)
115
  VALUES('','".$cronPath."','".$loopCounter."','".$loopIteration."')");
116
  }
117
  else
118
  {
119
- if(($loopCounter == '0') || ($resultCronPath[0][loopIteration] > $loopCounter ))
120
  {
121
  $connection->query("UPDATE ".$prefix."bluefish_cron_schedule SET loopIteration= '".$loopIteration."' where cronPath = '".$cronPath."'");
122
  }
@@ -125,15 +139,25 @@ class Bluefish_Connection_Model_Validationcrontime extends Mage_Adminhtml_Model_
125
  }
126
  else
127
  {
128
- if(($loopCounter == '0') || ($resultCronPath[0][loopIteration] > $loopCounter ))
129
  {
130
  $connection->query("UPDATE ".$prefix."bluefish_cron_schedule SET loopIteration= '0' where cronPath = '".$cronPath."'");
131
  }
132
  else if($loopCounter == '1')
133
  {
134
- foreach($markersCustomer as $marker)
135
  {
136
- $type = $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $cron_schedule_time;
 
 
 
 
 
 
 
 
 
 
137
  }
138
  foreach($markers as $marker)
139
  {
@@ -146,7 +170,7 @@ class Bluefish_Connection_Model_Validationcrontime extends Mage_Adminhtml_Model_
146
  $connection->query("UPDATE ".$prefix."bluefish_cron_schedule SET loopCounter= '".$loopCounter."' where cronPath = '".$cronPath."'");
147
  }
148
 
149
- $this->setValue($value);
150
- parent::_beforeSave();
151
  }
152
  }
41
  $prefix = Mage::getConfig()->getTablePrefix();
42
 
43
  if (is_array($value)) {
44
+ unset($value['__empty']);
45
+ }
46
 
47
+ $cronPath = $this->getPath();
48
+ $loopCounter = count($value);
49
 
50
  $resultPath = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = '".$cronPath."'");
51
  $resultCronPath = $resultPath->fetchAll(PDO::FETCH_ASSOC);
73
  break;
74
  case "mycustom_section/mycustom_sales_group/mycustom_sales_commonschedule":
75
  $markers = $doc->getElementsByTagName('bluefish_connection_orderexport');
76
+ $markersSales = $doc->getElementsByTagName('bluefish_connection_orderimport');
77
  break;
78
  }
79
  $countNum = 0;
80
+ $Minutecronconfig = "";
81
+ $Hourcronconfig = "";
82
+
83
  foreach($value as $key => $valueconfig)
84
  {
85
  if($countNum == 0)
99
  }
100
 
101
 
102
+ if(count($resultCronPath) == 0 || $resultCronPath[0]['loopCounter'] == '0')
103
  {
104
+ if(isset($markersCustomer))
105
  {
106
+ foreach($markersCustomer as $marker)
107
+ {
108
+ $type = $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $cron_schedule_time;
109
+ }
110
+ }
111
+ if(isset($markersSales))
112
+ {
113
+ foreach($markersSales as $marker)
114
+ {
115
+ $type = $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $cron_schedule_time;
116
+ }
117
  }
118
  foreach($markers as $marker)
119
  {
123
  $doc->save($xmlFile);
124
  $loopIteration = '1';
125
 
126
+ if($resultCronPath[0]['loopCounter'] != 0)
127
  {
128
  $connection->query("INSERT INTO ".$prefix."bluefish_cron_schedule(id,cronPath,loopCounter,loopIteration)
129
  VALUES('','".$cronPath."','".$loopCounter."','".$loopIteration."')");
130
  }
131
  else
132
  {
133
+ if(($loopCounter == '0') || ($resultCronPath[0]['loopIteration'] > $loopCounter ))
134
  {
135
  $connection->query("UPDATE ".$prefix."bluefish_cron_schedule SET loopIteration= '".$loopIteration."' where cronPath = '".$cronPath."'");
136
  }
139
  }
140
  else
141
  {
142
+ if(($loopCounter == '0') || ($resultCronPath[0]['loopIteration'] > $loopCounter ))
143
  {
144
  $connection->query("UPDATE ".$prefix."bluefish_cron_schedule SET loopIteration= '0' where cronPath = '".$cronPath."'");
145
  }
146
  else if($loopCounter == '1')
147
  {
148
+ if(isset($markersCustomer))
149
  {
150
+ foreach($markersCustomer as $marker)
151
+ {
152
+ $type = $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $cron_schedule_time;
153
+ }
154
+ }
155
+ if(isset($markersSales))
156
+ {
157
+ foreach($markersSales as $marker)
158
+ {
159
+ $type = $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $cron_schedule_time;
160
+ }
161
  }
162
  foreach($markers as $marker)
163
  {
170
  $connection->query("UPDATE ".$prefix."bluefish_cron_schedule SET loopCounter= '".$loopCounter."' where cronPath = '".$cronPath."'");
171
  }
172
 
173
+ $this->setValue($value);
174
+ parent::_beforeSave();
175
  }
176
  }
app/code/local/Bluefish/Connection/Model/Validationpaymentmap.php CHANGED
@@ -36,54 +36,57 @@ class Bluefish_Connection_Model_Validationpaymentmap extends Mage_Adminhtml_Mode
36
  */
37
  protected function _beforeSave()
38
  {
39
- $oldvalue = $this->getOldValue();
40
- $unserielVal = unserialize($oldvalue);
41
 
42
- foreach($unserielVal as $oldpaymentmap)
43
- {
44
- $paymentmethodArr[] = $oldpaymentmap['paymentmethod'];
45
- $bluestorecodeArr[] = $oldpaymentmap['bluestorecode'];
46
- }
47
 
48
  $value = $this->getValue();
49
 
50
- if (is_array($value)) {
51
- unset($value['__empty']);
52
- }
53
 
54
- foreach($value as $keypayment => $valuepayment)
55
- {
56
- $paymentmethodNewArr[] = $valuepayment['paymentmethod'];
57
- #$bluestorecodeNewArr[] = $valuepayment['bluestorecode'];
58
- if(($valuepayment['paymentmethod'] == "") && ($valuepayment['bluestorecode'] == ""))
59
- {
60
- $value = $this->getOldValue();
61
- throw new Exception('Payment method and Bluestore code are required.');
62
- }
63
- if(($valuepayment['paymentmethod'] == "") && ($valuepayment['bluestorecode'] != ""))
64
- {
65
- $value = $this->getOldValue();
66
- throw new Exception('Payment method is required.');
67
- }
68
- if(($valuepayment['paymentmethod'] != "") && ($valuepayment['bluestorecode'] == ""))
69
- {
70
- $value = $this->getOldValue();
71
- throw new Exception('Bluestore payment method code is required.');
72
- }
73
- }
74
 
75
- function get_duplicates( $array )
76
- {
77
- return array_unique( array_diff_assoc( $array, array_unique( $array ) ) );
78
- }
79
-
80
- $DuplicatePaymentMethod = get_duplicates( $paymentmethodNewArr );
81
-
82
- if(count($DuplicatePaymentMethod) > 0)
83
- {
84
- $value = $this->getOldValue();
85
- throw new Exception('There is already an entry for this payment method.');
86
- }
 
 
 
87
 
88
  $this->setValue($value);
89
  parent::_beforeSave();
36
  */
37
  protected function _beforeSave()
38
  {
39
+ $oldvalue = $this->getOldValue();
40
+ $unserielVal = unserialize($oldvalue);
41
 
42
+ foreach($unserielVal as $oldpaymentmap)
43
+ {
44
+ $paymentmethodArr[] = $oldpaymentmap['paymentmethod'];
45
+ $bluestorecodeArr[] = $oldpaymentmap['bluestorecode'];
46
+ }
47
 
48
  $value = $this->getValue();
49
 
50
+ if (is_array($value)) {
51
+ unset($value['__empty']);
52
+ }
53
 
54
+ foreach($value as $keypayment => $valuepayment)
55
+ {
56
+ $paymentmethodNewArr[] = $valuepayment['paymentmethod'];
57
+
58
+ if(($valuepayment['paymentmethod'] == "") && ($valuepayment['bluestorecode'] == ""))
59
+ {
60
+ $value = $this->getOldValue();
61
+ throw new Exception('Payment method and Bluestore code are required.');
62
+ }
63
+ if(($valuepayment['paymentmethod'] == "") && ($valuepayment['bluestorecode'] != ""))
64
+ {
65
+ $value = $this->getOldValue();
66
+ throw new Exception('Payment method is required.');
67
+ }
68
+ if(($valuepayment['paymentmethod'] != "") && ($valuepayment['bluestorecode'] == ""))
69
+ {
70
+ $value = $this->getOldValue();
71
+ throw new Exception('Bluestore payment method code is required.');
72
+ }
73
+ }
74
 
75
+ function get_duplicates( $array )
76
+ {
77
+ return array_unique( array_diff_assoc( $array, array_unique( $array ) ) );
78
+ }
79
+
80
+ if(count($paymentmethodNewArr) > 0)
81
+ {
82
+ $DuplicatePaymentMethod = get_duplicates( $paymentmethodNewArr );
83
+ }
84
+
85
+ if(count($DuplicatePaymentMethod) > 0)
86
+ {
87
+ $value = $this->getOldValue();
88
+ throw new Exception('There is already an entry for this payment method.');
89
+ }
90
 
91
  $this->setValue($value);
92
  parent::_beforeSave();
app/code/local/Bluefish/Connection/Model/Validationtaxclass.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Backend for serialized array data
29
+ *
30
+ */
31
+ class Bluefish_Connection_Model_Validationtaxclass extends Mage_Adminhtml_Model_System_Config_Backend_Serialized
32
+ {
33
+ /**
34
+ * Unset array element with '__empty' key
35
+ *
36
+ */
37
+ protected function _beforeSave()
38
+ {
39
+ $oldvalue = $this->getOldValue();
40
+ $unserielVal = unserialize($oldvalue);
41
+
42
+ foreach($unserielVal as $oldpaymentmap)
43
+ {
44
+ $magentotaxclassArr[] = $oldpaymentmap['magentotaxclass'];
45
+ $bluestoretaxclassArr[] = $oldpaymentmap['bluestoretaxclass'];
46
+ }
47
+
48
+ $value = $this->getValue();
49
+
50
+ if (is_array($value)) {
51
+ unset($value['__empty']);
52
+ }
53
+
54
+ if (count($value) == 0) {
55
+ throw new Exception('Bluestore product tax class values are required.');
56
+ }
57
+ else
58
+ {
59
+ foreach($value as $keypayment => $valuepayment)
60
+ {
61
+ $magentotaxclassNewArr[] = $valuepayment['magentotaxclass'];
62
+
63
+ if(($valuepayment['magentotaxclass'] == "") && ($valuepayment['bluestoretaxclass'] == ""))
64
+ {
65
+ $value = $this->getOldValue();
66
+ throw new Exception('Magento product tax class and Bluestore product tax class code are required.');
67
+ }
68
+ if(($valuepayment['magentotaxclass'] == "") && ($valuepayment['bluestoretaxclass'] != ""))
69
+ {
70
+ $value = $this->getOldValue();
71
+ throw new Exception('Magento product tax class is required.');
72
+ }
73
+ if(($valuepayment['magentotaxclass'] != "") && ($valuepayment['bluestoretaxclass'] == ""))
74
+ {
75
+ $value = $this->getOldValue();
76
+ throw new Exception('Bluestore product tax class code is required.');
77
+ }
78
+ }
79
+
80
+ function get_duplicatesclass( $array )
81
+ {
82
+ return array_unique( array_diff_assoc( $array, array_unique( $array ) ) );
83
+ }
84
+
85
+ $DuplicateMagentotaxclass = get_duplicatesclass( $magentotaxclassNewArr );
86
+
87
+ if(count($DuplicateMagentotaxclass) > 0)
88
+ {
89
+ $value = $this->getOldValue();
90
+ throw new Exception('There is already an entry for this Magento product tax class.');
91
+ }
92
+
93
+ $this->setValue($value);
94
+ parent::_beforeSave();
95
+ }
96
+
97
+ }
98
+ }
app/code/local/Bluefish/Connection/Model/Validationtaxcode.php CHANGED
@@ -36,55 +36,53 @@ class Bluefish_Connection_Model_Validationtaxcode extends Mage_Adminhtml_Model_S
36
  */
37
  protected function _beforeSave()
38
  {
39
- $oldvalue = $this->getOldValue();
40
- $unserielVal = unserialize($oldvalue);
41
- foreach($unserielVal as $oldrate => $oldtaxcode)
42
- {
43
- $rateArr[] = $oldtaxcode['rate'];
44
- $taxcodeArr[] = $oldtaxcode['taxcode'];
45
- }
46
 
47
  $value = $this->getValue();
48
 
49
- if (is_array($value)) {
50
- unset($value['__empty']);
51
- }
52
-
53
 
54
- foreach($value as $rate => $taxcode)
55
- {
56
- $rateNewArr[] = $taxcode['rate'];
57
- #$taxcodeNewArr[] = $taxcode['taxcode'];
58
-
59
- if(($taxcode['rate'] == "") && ($taxcode['taxcode'] == ""))
60
- {
61
- $value = $this->getOldValue();
62
- throw new Exception('Tax rate and Bluestore tax code are required.');
63
- }
64
- if(($taxcode['rate'] == "") && ($taxcode['taxcode'] != ""))
65
- {
66
- $value = $this->getOldValue();
67
- throw new Exception('Tax rate is required.');
68
- }
69
- if(($taxcode['rate'] != "") && ($taxcode['taxcode'] == ""))
70
- {
71
- $value = $this->getOldValue();
72
- throw new Exception('Bluestore tax code is required.');
73
- }
74
-
75
- }
76
 
77
- function get_duplicates_arr( $array )
78
- {
79
- return array_unique( array_diff_assoc( $array, array_unique( $array ) ) );
80
- }
81
- $DuplicateRate = get_duplicates_arr( $rateNewArr );
82
 
83
- if(count($DuplicateRate) > 0)
84
- {
85
- $value = $this->getOldValue();
86
- throw new Exception('There is already an entry for this Tax rate.');
87
- }
88
 
89
  $this->setValue($value);
90
  parent::_beforeSave();
36
  */
37
  protected function _beforeSave()
38
  {
39
+ $oldvalue = $this->getOldValue();
40
+ $unserielVal = unserialize($oldvalue);
41
+ foreach($unserielVal as $oldrate => $oldtaxcode)
42
+ {
43
+ $rateArr[] = $oldtaxcode['rate'];
44
+ $taxcodeArr[] = $oldtaxcode['taxcode'];
45
+ }
46
 
47
  $value = $this->getValue();
48
 
49
+ if (is_array($value)) {
50
+ unset($value['__empty']);
51
+ }
 
52
 
53
+ foreach($value as $rate => $taxcode)
54
+ {
55
+ $rateNewArr[] = $taxcode['rate'];
56
+
57
+ if(($taxcode['rate'] == "") && ($taxcode['taxcode'] == ""))
58
+ {
59
+ $value = $this->getOldValue();
60
+ throw new Exception('Tax rate and Bluestore tax code are required.');
61
+ }
62
+ if(($taxcode['rate'] == "") && ($taxcode['taxcode'] != ""))
63
+ {
64
+ $value = $this->getOldValue();
65
+ throw new Exception('Tax rate is required.');
66
+ }
67
+ if(($taxcode['rate'] != "") && ($taxcode['taxcode'] == ""))
68
+ {
69
+ $value = $this->getOldValue();
70
+ throw new Exception('Bluestore tax code is required.');
71
+ }
72
+
73
+ }
 
74
 
75
+ function get_duplicates_arr( $array )
76
+ {
77
+ return array_unique( array_diff_assoc( $array, array_unique( $array ) ) );
78
+ }
79
+ $DuplicateRate = get_duplicates_arr( $rateNewArr );
80
 
81
+ if(count($DuplicateRate) > 0)
82
+ {
83
+ $value = $this->getOldValue();
84
+ throw new Exception('There is already an entry for this Tax rate.');
85
+ }
86
 
87
  $this->setValue($value);
88
  parent::_beforeSave();
app/code/local/Bluefish/Connection/controllers/Adminhtml/Bluefish_Error_Reporting.php CHANGED
@@ -8,7 +8,8 @@ ini_set('error_log','./var/log/Bluefish_error.log.text');
8
  ini_set('display_errors',FALSE);
9
  */
10
  //Error reporting
11
- error_reporting(E_ALL);
12
- ini_set('display_errors', true);
 
13
  set_time_limit(0);
14
  ?>
8
  ini_set('display_errors',FALSE);
9
  */
10
  //Error reporting
11
+ #error_reporting(E_ALL);
12
+ #ini_set('display_errors', true);
13
+ error_reporting(E_ALL ^ E_NOTICE);
14
  set_time_limit(0);
15
  ?>
app/code/local/Bluefish/Connection/controllers/Adminhtml/CategorydataController.php CHANGED
@@ -15,7 +15,12 @@ class Bluefish_Connection_Adminhtml_CategorydataController extends Mage_Adminhtm
15
  $success = "";
16
  $errorupdate = "";
17
  #### Add Condition
18
- if($_GET["hdnCmd"] == "Add")
 
 
 
 
 
19
  {
20
  if(trim($txtAddCode) == "")
21
  $error .= "Please enter Bluestore Code.<br>";
@@ -41,7 +46,7 @@ class Bluefish_Connection_Adminhtml_CategorydataController extends Mage_Adminhtm
41
  }
42
 
43
  ##### Update Condition
44
- if(isset($_GET["hdnCmd"]) && ($_GET["hdnCmd"] == "Update"))
45
  {
46
  if(trim($txtEditCode) == "")
47
  $errorupdate .= "Please enter Bluestore Code.<br>";
@@ -64,9 +69,9 @@ class Bluefish_Connection_Adminhtml_CategorydataController extends Mage_Adminhtm
64
  }
65
 
66
  ##### Delete Condition
67
- if($_GET["Action"] == "Del")
68
  {
69
- $connection->query("DELETE FROM ".$prefix."bluefish_category where connection_id = '".$_GET[ConnectionID]."'");
70
  }
71
 
72
  $result = $connection->query("select * from ".$prefix."bluefish_category");
@@ -96,7 +101,7 @@ class Bluefish_Connection_Adminhtml_CategorydataController extends Mage_Adminhtm
96
  }
97
  function editButton(id)
98
  {
99
- window.location = "<?=$_SERVER["PHP_SELF"];?>?Action=Edit&ConnectionID="+id;
100
  }
101
  function deleteButton(id)
102
  {
@@ -134,17 +139,17 @@ class Bluefish_Connection_Adminhtml_CategorydataController extends Mage_Adminhtm
134
  $trcolor = "#DDFFDD";
135
  else
136
  $trcolor = "#EEFFEE";
137
-
138
- if($resultSet[$i][connection_id] == $_GET["ConnectionID"] and ($_GET["Action"] == "Edit" || $errorupdate == ""))
139
  {
140
 
141
  ?>
142
  <tr style="font-family: arial;font-size: 13px;background-color:<?php echo $trcolor;?>">
143
  <td align="center">
144
- <input type="hidden" name="hdnEditCustomerID" size="5" value="<?=$resultSet[$i][connection_id];?>">
145
- <input type="text" name="txtEditCode" size="5" value="<?=$resultSet[$i][code];?>"></td>
146
- <td align="center"><input type="text" name="txtEditCategoryID" size="5" value="<?=$resultSet[$i][category_id];?>"></td>
147
- <td align="center"><?=$resultSet[$i][created_time];?></td>
148
  <td align="right"><div align="center">
149
  <input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="updateCategory('Update');">
150
  <input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';">
@@ -156,18 +161,18 @@ class Bluefish_Connection_Adminhtml_CategorydataController extends Mage_Adminhtm
156
  {
157
  ?>
158
  <tr style="font-family: arial;font-size: 13px;background-color:<?php echo $trcolor;?>">
159
- <td><div align="center"><?=$resultSet[$i][code];?></div></td>
160
- <td align="center"><?=$resultSet[$i][category_id];?></td>
161
- <td align="center"><?=$resultSet[$i][created_time];?></td>
162
- <td align="center"><input name="btnEdit" type="button" id="btnEdit" value="Edit" OnClick="editButton('<?=$resultSet[$i][connection_id];?>');"> &nbsp;&nbsp;&nbsp; <input name="btnDelete" type="button" id="btnDelete" value="Delete" OnClick="deleteButton('<?=$resultSet[$i][connection_id];?>')"></a></td>
163
  </tr>
164
  <?php
165
  }
166
  }
167
  ?>
168
  <tr style="font-family: arial;font-size: 13px;background-color:6F8992;">
169
- <td><div align="center"><input type="text" name="txtAddCode" value="<?=$txtAddCode?>" size="5"></div></td>
170
- <td align="center"><input type="text" name="txtAddCategoryID" size="5" value="<?=$txtAddCategoryID?>"></td>
171
  <td align="center"><input type="text" value="<?=date("Y-m-d H:i:s")?>" readonly="readonly" name="txtAddCreatedTime" size="20"></td>
172
  <td align="right"><div align="center">
173
  <input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
15
  $success = "";
16
  $errorupdate = "";
17
  #### Add Condition
18
+
19
+ $hdnCmd = (!isset($_GET["hdnCmd"]))?"":$_GET["hdnCmd"];
20
+ $Action = (!isset($_GET["Action"]))?"":$_GET["Action"];
21
+ $ConnectionID = (!isset($_GET["ConnectionID"]))?"":$_GET["ConnectionID"];
22
+
23
+ if($hdnCmd == "Add")
24
  {
25
  if(trim($txtAddCode) == "")
26
  $error .= "Please enter Bluestore Code.<br>";
46
  }
47
 
48
  ##### Update Condition
49
+ if($hdnCmd == "Update")
50
  {
51
  if(trim($txtEditCode) == "")
52
  $errorupdate .= "Please enter Bluestore Code.<br>";
69
  }
70
 
71
  ##### Delete Condition
72
+ if($Action == "Del")
73
  {
74
+ $connection->query("DELETE FROM ".$prefix."bluefish_category where connection_id = '".$ConnectionID."'");
75
  }
76
 
77
  $result = $connection->query("select * from ".$prefix."bluefish_category");
101
  }
102
  function editButton(id)
103
  {
104
+ window.location = "<?=$_SERVER['PHP_SELF'];?>?Action=Edit&ConnectionID="+id;
105
  }
106
  function deleteButton(id)
107
  {
139
  $trcolor = "#DDFFDD";
140
  else
141
  $trcolor = "#EEFFEE";
142
+
143
+ if($resultSet[$i]['connection_id'] == $ConnectionID and ($Action == "Edit" || $errorupdate == ""))
144
  {
145
 
146
  ?>
147
  <tr style="font-family: arial;font-size: 13px;background-color:<?php echo $trcolor;?>">
148
  <td align="center">
149
+ <input type="hidden" name="hdnEditCustomerID" size="5" value="<?=$resultSet[$i]['connection_id'];?>">
150
+ <input type="text" name="txtEditCode" size="5" value="<?=$resultSet[$i]['code'];?>"></td>
151
+ <td align="center"><input type="text" name="txtEditCategoryID" size="5" value="<?=$resultSet[$i]['category_id'];?>"></td>
152
+ <td align="center"><?=$resultSet[$i]['created_time'];?></td>
153
  <td align="right"><div align="center">
154
  <input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="updateCategory('Update');">
155
  <input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';">
161
  {
162
  ?>
163
  <tr style="font-family: arial;font-size: 13px;background-color:<?php echo $trcolor;?>">
164
+ <td><div align="center"><?=$resultSet[$i]['code'];?></div></td>
165
+ <td align="center"><?=$resultSet[$i]['category_id'];?></td>
166
+ <td align="center"><?=$resultSet[$i]['created_time'];?></td>
167
+ <td align="center"><input name="btnEdit" type="button" id="btnEdit" value="Edit" OnClick='editButton("<?=$resultSet[$i]['connection_id'];?>");'> &nbsp;&nbsp;&nbsp; <input name="btnDelete" type="button" id="btnDelete" value="Delete" OnClick='deleteButton("<?=$resultSet[$i]['connection_id'];?>")'></a></td>
168
  </tr>
169
  <?php
170
  }
171
  }
172
  ?>
173
  <tr style="font-family: arial;font-size: 13px;background-color:6F8992;">
174
+ <td><div align="center"><input type="text" name="txtAddCode" value="<?=isset($txtAddCode)?$txtAddCode:'';?>" size="5"></div></td>
175
+ <td align="center"><input type="text" name="txtAddCategoryID" size="5" value="<?=isset($txtAddCategoryID)?$txtAddCategoryID:'';?>"></td>
176
  <td align="center"><input type="text" value="<?=date("Y-m-d H:i:s")?>" readonly="readonly" name="txtAddCreatedTime" size="20"></td>
177
  <td align="right"><div align="center">
178
  <input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
app/code/local/Bluefish/Connection/controllers/Adminhtml/ErrorsaleimportController.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bluefish_Connection_Adminhtml_ErrorsaleimportController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()->_setActiveMenu("connection/errorsaleimport")->_addBreadcrumb(Mage::helper("adminhtml")->__("Errorsaleimport Manager"),Mage::helper("adminhtml")->__("Errorsaleimport Manager"));
8
+ return $this;
9
+ }
10
+ public function indexAction()
11
+ {
12
+ $this->_title($this->__("Connection"));
13
+ $this->_title($this->__("Manager Errorsaleimport"));
14
+
15
+ $this->_initAction();
16
+ $this->renderLayout();
17
+ }
18
+ public function editAction()
19
+ {
20
+ $this->_title($this->__("Connection"));
21
+ $this->_title($this->__("Errorsaleimport"));
22
+ $this->_title($this->__("Edit Item"));
23
+
24
+ $id = $this->getRequest()->getParam("id");
25
+ $model = Mage::getModel("connection/errorsaleimport")->load($id);
26
+ if ($model->getId()) {
27
+ Mage::register("errorsaleimport_data", $model);
28
+ $this->loadLayout();
29
+ $this->_setActiveMenu("connection/errorsaleimport");
30
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Errorsaleimport Manager"), Mage::helper("adminhtml")->__("Errorsaleimport Manager"));
31
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Errorsaleimport Description"), Mage::helper("adminhtml")->__("Errorsaleimport Description"));
32
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
33
+ $this->_addContent($this->getLayout()->createBlock("connection/adminhtml_errorsaleimport_edit"))->_addLeft($this->getLayout()->createBlock("connection/adminhtml_errorsaleimport_edit_tabs"));
34
+ $this->renderLayout();
35
+ }
36
+ else {
37
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("connection")->__("Item does not exist."));
38
+ $this->_redirect("*/*/");
39
+ }
40
+ }
41
+
42
+ public function newAction()
43
+ {
44
+
45
+ $this->_title($this->__("Connection"));
46
+ $this->_title($this->__("Errorsaleimport"));
47
+ $this->_title($this->__("New Item"));
48
+
49
+ $id = $this->getRequest()->getParam("id");
50
+ $model = Mage::getModel("connection/errorsaleimport")->load($id);
51
+
52
+ $data = Mage::getSingleton("adminhtml/session")->getFormData(true);
53
+ if (!empty($data)) {
54
+ $model->setData($data);
55
+ }
56
+
57
+ Mage::register("errorsaleimport_data", $model);
58
+
59
+ $this->loadLayout();
60
+ $this->_setActiveMenu("connection/errorsaleimport");
61
+
62
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
63
+
64
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Errorsaleimport Manager"), Mage::helper("adminhtml")->__("Errorsaleimport Manager"));
65
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Errorsaleimport Description"), Mage::helper("adminhtml")->__("Errorsaleimport Description"));
66
+
67
+
68
+ $this->_addContent($this->getLayout()->createBlock("connection/adminhtml_errorsaleimport_edit"))->_addLeft($this->getLayout()->createBlock("connection/adminhtml_errorsaleimport_edit_tabs"));
69
+
70
+ $this->renderLayout();
71
+
72
+ }
73
+ public function saveAction()
74
+ {
75
+
76
+ $post_data=$this->getRequest()->getPost();
77
+
78
+
79
+ if ($post_data) {
80
+
81
+ try {
82
+
83
+
84
+
85
+ $model = Mage::getModel("connection/errorsaleimport")
86
+ ->addData($post_data)
87
+ ->setId($this->getRequest()->getParam("id"))
88
+ ->save();
89
+
90
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Errorsaleimport was successfully saved"));
91
+ Mage::getSingleton("adminhtml/session")->setErrorsaleimportData(false);
92
+
93
+ if ($this->getRequest()->getParam("back")) {
94
+ $this->_redirect("*/*/edit", array("id" => $model->getId()));
95
+ return;
96
+ }
97
+ $this->_redirect("*/*/");
98
+ return;
99
+ }
100
+ catch (Exception $e) {
101
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
102
+ Mage::getSingleton("adminhtml/session")->setErrorsaleimportData($this->getRequest()->getPost());
103
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
104
+ return;
105
+ }
106
+
107
+ }
108
+ $this->_redirect("*/*/");
109
+ }
110
+
111
+
112
+
113
+ public function deleteAction()
114
+ {
115
+ if( $this->getRequest()->getParam("id") > 0 ) {
116
+ try {
117
+ $model = Mage::getModel("connection/errorsaleimport");
118
+ $model->setId($this->getRequest()->getParam("id"))->delete();
119
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item was successfully deleted"));
120
+ $this->_redirect("*/*/");
121
+ }
122
+ catch (Exception $e) {
123
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
124
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
125
+ }
126
+ }
127
+ $this->_redirect("*/*/");
128
+ }
129
+
130
+
131
+ /**
132
+ * Export order grid to CSV format
133
+ */
134
+ public function exportCsvAction()
135
+ {
136
+ $fileName = 'errorsaleimport.csv';
137
+ $grid = $this->getLayout()->createBlock('connection/adminhtml_errorsaleimport_grid');
138
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
139
+ }
140
+ /**
141
+ * Export order grid to Excel XML format
142
+ */
143
+ public function exportExcelAction()
144
+ {
145
+ $fileName = 'errorsaleimport.xml';
146
+ $grid = $this->getLayout()->createBlock('connection/adminhtml_errorsaleimport_grid');
147
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
148
+ }
149
+ }
app/code/local/Bluefish/Connection/controllers/Adminhtml/MyformController.php CHANGED
@@ -18,6 +18,7 @@ class Bluefish_Connection_Adminhtml_MyformController extends Mage_Adminhtml_Cont
18
  const CUSTOMER = 'https://bluestorelive.com:9001/rest/customer/';
19
  const ORDERPOST = 'https://bluestorelive.com:9001/rest/inbound/';
20
  const CUSTOMERPOST = 'https://bluestorelive.com:9001/rest/inbound/';
 
21
 
22
  public function indexAction()
23
  {
@@ -171,7 +172,7 @@ class Bluefish_Connection_Adminhtml_MyformController extends Mage_Adminhtml_Cont
171
  $fh = fopen($xmlFiles, 'w+');
172
  fwrite($fh, $response);
173
  fclose($fh);
174
- $xmlFiles = "./customers_bluefish.xml";
175
  if(!file_exists($xmlFiles))
176
  {
177
  $this->flag=3;
@@ -222,6 +223,56 @@ class Bluefish_Connection_Adminhtml_MyformController extends Mage_Adminhtml_Cont
222
  }
223
  }
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  ### Function For Parsing XML data For Customer and Sales
226
  public function parseXMLForPost($val,$xml)
227
  {
@@ -731,14 +782,92 @@ class Bluefish_Connection_Adminhtml_MyformController extends Mage_Adminhtml_Cont
731
  }
732
  }
733
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
734
  }
735
 
736
  ##### Function handles all the GET and POST data request
737
- public function postAction($cron_value)
738
  {
739
  $categorycode = $_REQUEST['categorycode'];
740
  $productcode = $_REQUEST['productcode'];
741
  $customercode = $_REQUEST['customercode'];
 
742
 
743
  $value_cron = $cron_value;
744
  if(!$value_cron)
@@ -1593,6 +1722,165 @@ class Bluefish_Connection_Adminhtml_MyformController extends Mage_Adminhtml_Cont
1593
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
1594
  }
1595
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1596
 
1597
  }
1598
 
18
  const CUSTOMER = 'https://bluestorelive.com:9001/rest/customer/';
19
  const ORDERPOST = 'https://bluestorelive.com:9001/rest/inbound/';
20
  const CUSTOMERPOST = 'https://bluestorelive.com:9001/rest/inbound/';
21
+ const SALEIMPORT = 'https://bluestorelive.com:9001/rest/sale/';
22
 
23
  public function indexAction()
24
  {
172
  $fh = fopen($xmlFiles, 'w+');
173
  fwrite($fh, $response);
174
  fclose($fh);
175
+
176
  if(!file_exists($xmlFiles))
177
  {
178
  $this->flag=3;
223
  }
224
  }
225
 
226
+ ### Function For Write Bluestore Sale Data into sales_bluestore.xml File
227
+ public function xmlActionSale($response)
228
+ {
229
+ $appBaseDir = Mage::getBaseDir();
230
+ $xmlFiles = $appBaseDir."/sales_bluestore_import.xml";
231
+
232
+ $fh = fopen($xmlFiles, 'w+');
233
+ fwrite($fh, $response);
234
+ fclose($fh);
235
+
236
+ if(!file_exists($xmlFiles))
237
+ {
238
+ $this->flag=3;
239
+ return ;
240
+ }
241
+ else if(!filesize($xmlFiles) > 0)
242
+ {
243
+ $this->flag=4;
244
+ return;
245
+ }
246
+ else
247
+ {
248
+ $result_config=cron_insert_saleimport();
249
+
250
+ if($result_config != "success")
251
+ {
252
+ $this->flag=5;
253
+ return $result_config;
254
+ }
255
+ else
256
+ {
257
+ $result_database = importBluestoreSales();
258
+ if($result_database == "fail")
259
+ {
260
+ $this->flag=6;
261
+ return $result_database;
262
+ }elseif($result_database == "blankdata")
263
+ {
264
+ $this->flag=7;
265
+ return $result_database;
266
+ }
267
+ else
268
+ {
269
+ $this->flag = 8;
270
+ return;
271
+ }
272
+ }
273
+ }
274
+ }
275
+
276
  ### Function For Parsing XML data For Customer and Sales
277
  public function parseXMLForPost($val,$xml)
278
  {
782
  }
783
  }
784
  }
785
+ else if($val == 'saleimport') ### Condition for Bluestore Customer Data
786
+ {
787
+ $baseurl = Bluefish_Connection_Adminhtml_MyformController::SALEIMPORT;
788
+ $appBaseDir = Mage::getBaseDir();
789
+ $permFile = $appBaseDir."/bluefish_privatekey.PEM";
790
+ $fh = fopen($permFile, 'w');
791
+ fwrite($fh, $credentials['mycustom_certificate']);
792
+ fclose($fh);
793
+ if(!file_exists($permFile))
794
+ {
795
+ $this->flag=1;
796
+ return;
797
+ }
798
+ else if(!filesize($permFile) > 0) //change == to >
799
+ {
800
+ $this->flag=2;
801
+ return;
802
+ }
803
+ else
804
+ {
805
+ $extra = $extraCode;
806
+ $stock_credentials = Mage::getStoreConfig('mycustom_section/mycustom_stock_group');
807
+ $sale_credentials = Mage::getStoreConfig('mycustom_section/mycustom_sales_group');
808
+
809
+ $extraStoreCode = $stock_credentials['mycustom_bluestorecode'];
810
+ $endDateTimeSpace = explode(" ",$sale_credentials['mycustom_bluestore_enddatetime']);
811
+ $colonDateVal = explode(":",$endDateTimeSpace[1]);
812
+ $secDate = $colonDateVal[2]+1;
813
+ $secReal = (strlen($secDate) == 1)?'0'.$secDate:$secDate;
814
+
815
+ $endDateTime = $endDateTimeSpace[0]. " ".$colonDateVal[0].":".$colonDateVal[1].":".$secReal." ".$endDateTimeSpace[2];
816
+
817
+ if(isset($extra) && !empty($extra))
818
+ {
819
+ $array=array();
820
+ $array=array('where'=>rawurlencode('storeCode <> '.$extraStoreCode.' and transactionCode = '.$extra.''));
821
+ $auth = build_auth_array($baseurl, $credentials['mycustom_code'],$permFile,$array);
822
+
823
+ $auth_query = _build_http_query($auth);
824
+ $auth_query = $baseurl."?".$auth_query;
825
+ $tuCurl = curl_init();
826
+ curl_setopt($tuCurl, CURLOPT_URL,$auth_query);
827
+ curl_setopt($tuCurl, CURLOPT_PORT , 9001);
828
+ curl_setopt($tuCurl, CURLOPT_VERBOSE, 0);
829
+ curl_setopt($tuCurl, CURLOPT_SSLVERSION, 3);
830
+ curl_setopt($tuCurl, CURLOPT_HTTPGET, 1);
831
+ curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, false);
832
+ curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
833
+ curl_setopt($tuCurl, CURLOPT_FOLLOWLOCATION, 1);
834
+ curl_setopt($tuCurl, CURLOPT_HTTPHEADER, array("Accept: application/xml"));
835
+ $response = curl_exec($tuCurl);
836
+ $response1 = curl_getinfo( $tuCurl );
837
+ return $response;
838
+ }
839
+ else
840
+ {
841
+ $array=array();
842
+ $array=array('where'=>rawurlencode('storeCode <> '.$extraStoreCode.' and endDateTime >= '.'"'.$endDateTime.'"'.''));
843
+ $auth = build_auth_array($baseurl, $credentials['mycustom_code'],$permFile,$array);
844
+ $auth_query = _build_http_query($auth);
845
+ $auth_query = $baseurl."?".$auth_query;
846
+ $tuCurl = curl_init();
847
+ curl_setopt($tuCurl, CURLOPT_URL,$auth_query);
848
+ curl_setopt($tuCurl, CURLOPT_PORT , 9001);
849
+ curl_setopt($tuCurl, CURLOPT_VERBOSE, 0);
850
+ curl_setopt($tuCurl, CURLOPT_SSLVERSION, 3);
851
+ curl_setopt($tuCurl, CURLOPT_HTTPGET, 1);
852
+ curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, false);
853
+ curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
854
+ curl_setopt($tuCurl, CURLOPT_FOLLOWLOCATION, 1);
855
+ curl_setopt($tuCurl, CURLOPT_HTTPHEADER, array("Accept: application/xml"));
856
+ $response = curl_exec($tuCurl);
857
+ $response1 = curl_getinfo( $tuCurl );
858
+ return $response;
859
+ }
860
+ }
861
+ }
862
  }
863
 
864
  ##### Function handles all the GET and POST data request
865
+ public function postAction($cron_value = "")
866
  {
867
  $categorycode = $_REQUEST['categorycode'];
868
  $productcode = $_REQUEST['productcode'];
869
  $customercode = $_REQUEST['customercode'];
870
+ $transactioncode = $_REQUEST['transactioncode'];
871
 
872
  $value_cron = $cron_value;
873
  if(!$value_cron)
1722
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
1723
  }
1724
  break;
1725
+ case 8: #### This case handles the customer data
1726
+ try
1727
+ {
1728
+ $response = $this->parseAction('saleimport',$transactioncode);
1729
+ if($this->flag == 1)
1730
+ {
1731
+ $this->flag = 0;
1732
+ $message = $this->__('There is a problem with the API authentication, the private key file could not be found. Please contact the site administrator.');
1733
+ Mage::getSingleton('adminhtml/session')->addError($message);
1734
+ Mage::log('The Private Certificate cannot be created.', null, './Bluestore_sales_import.log.text');
1735
+ if(!$value_cron)
1736
+ {
1737
+ $this->_redirect('*/*');
1738
+ break;
1739
+ }
1740
+ break;
1741
+ }
1742
+ else if($this->flag == 2)
1743
+ {
1744
+ $this->flag = 0;
1745
+ $message = $this->__('There is a problem with the API authentication, the private key file does not contain a valid certificate. Please contact the site administrator.');
1746
+ Mage::getSingleton('adminhtml/session')->addError($message);
1747
+ Mage::log('The Private Certificate is created.', null, './Bluestore_sales_import.log.text');
1748
+ Mage::log('The Private Certificate cannnot be populated.', null, './Bluestore_sales_import.log.text');
1749
+ if(!$value_cron)
1750
+ {
1751
+ $this->_redirect('*/*');
1752
+ break;
1753
+ }
1754
+ break;
1755
+ }
1756
+ else if($response == '')
1757
+ {
1758
+ $message = $this->__('There was no response from Bluestore. Please check the authentication settings and if the problem persists, contact your site administrator.');
1759
+ Mage::getSingleton('adminhtml/session')->addError($message);
1760
+ Mage::log('The Private Certificate is created', null, './Bluestore_sales_import.log.text');
1761
+ Mage::log('The Private Certificate is populated', null, './Bluestore_sales_import.log.text');
1762
+ Mage::log('Sale Import Failed,No Sale Imported', null, './Bluestore_sales_import.log.text');
1763
+ if(!$value_cron)
1764
+ {
1765
+ $this->_redirect('*/*');
1766
+ break;
1767
+ }
1768
+ break;
1769
+ }
1770
+ else
1771
+ {
1772
+
1773
+ $toXml1 = $this->xmlActionSale($response);
1774
+
1775
+ switch($this->flag)
1776
+ {
1777
+ case 3:
1778
+ $this->flag = 0;
1779
+ $message = $this->__('The incoming sale file could not be created. It is possible the server security settings are blocking creation of the file. Please contact your site administrator.');
1780
+ Mage::getSingleton('adminhtml/session')->addError($message);
1781
+ Mage::log('The Private Certificate is created', null, './Bluestore_sales_import.log.text');
1782
+ Mage::log('The Private Certificate is populated', null, './Bluestore_sales_import.log.text');
1783
+ Mage::log('The Sale xml file cannot be created.', null, './Bluestore_sales_import.log.text');
1784
+ if(!$value_cron)
1785
+ {
1786
+ $this->_redirect('*/*');
1787
+ break;
1788
+ }
1789
+ break;
1790
+
1791
+ case 4:
1792
+ $this->flag = 0;
1793
+ $message = $this->__('The incoming sale file could not be created. It is possible the server security settings are blocking creation of the file. Please contact your site administrator.');
1794
+ Mage::getSingleton('adminhtml/session')->addError($message);
1795
+ Mage::log('The Private Certificate is created', null, './Bluestore_sales_import.log.text');
1796
+ Mage::log('The Private Certificate is populated', null, './Bluestore_sales_import.log.text');
1797
+ Mage::log('The Sale xml file is created.', null, './Bluestore_sales_import.log.text');
1798
+ Mage::log('The Sale xml cannot be populated.', null, './Bluestore_sales_import.log.text');
1799
+ if(!$value_cron)
1800
+ {
1801
+ $this->_redirect('*/*');
1802
+ break;
1803
+ }
1804
+ break;
1805
+
1806
+ case 5:
1807
+ $this->flag = 0;
1808
+ $message = $this->__('There was a problem with the data import. The configuration file could not be populated. Please contact your site administrator.');
1809
+ Mage::getSingleton('adminhtml/session')->addError($message);
1810
+ Mage::log('The Private Certificate is created', null, './Bluestore_sales_import.log.text');
1811
+ Mage::log('The Private Certificate is populated', null, './Bluestore_sales_import.log.text');
1812
+ Mage::log('The Sale xml file is created.', null, './Bluestore_sales_import.log.text');
1813
+ Mage::log('The Sale xml is populated.', null, './Bluestore_sales_import.log.text');
1814
+ Mage::log('The Config file cannot not populated.', null, './Bluestore_sales_import.log.text');
1815
+ Mage::log("Error:$toXml1", null, './Bluestore_sales_import.log.text');
1816
+ if(!$value_cron)
1817
+ {
1818
+ $this->_redirect('*/*');
1819
+ break;
1820
+ }
1821
+ break;
1822
+
1823
+ case 6:
1824
+ $this->flag = 0;
1825
+ $message = $this->__('All of their records have not imported correctly. Please check all the sales record.');
1826
+ Mage::getSingleton('adminhtml/session')->addError($message);
1827
+ Mage::log('The Private Certificate is created', null, './Bluestore_sales_import.log.text');
1828
+ Mage::log('The Private Certificate is populated', null, './Bluestore_sales_import.log.text');
1829
+ Mage::log('The Sale xml file is created.', null, './Bluestore_sales_import.log.text');
1830
+ Mage::log('The Sale xml is populated.', null, './Bluestore_sales_import.log.text');
1831
+ Mage::log('The Config file is populated.', null, './Bluestore_sales_import.log.text');
1832
+ Mage::log("Error:$toXml1", null, './Bluestore_sales_import.log.text');
1833
+ Mage::log($toXml, null, './Bluestore_sales_import.log.text');
1834
+ if(!$value_cron)
1835
+ {
1836
+ $this->_redirect('*/*');
1837
+ break;
1838
+ }
1839
+ break;
1840
+
1841
+ case 7:
1842
+ $this->flag = 0;
1843
+ $message = $this->__('There is no more sales record on Bluestore according to condition.');
1844
+ Mage::getSingleton('adminhtml/session')->addError($message);
1845
+ Mage::log('The Private Certificate is created', null, './Bluestore_sales_import.log.text');
1846
+ Mage::log('The Private Certificate is populated', null, './Bluestore_sales_import.log.text');
1847
+ Mage::log('The Sale xml file is created.', null, './Bluestore_sales_import.log.text');
1848
+ Mage::log('The Sale xml is populated.', null, './Bluestore_sales_import.log.text');
1849
+ Mage::log('The Config file is populated.', null, './Bluestore_sales_import.log.text');
1850
+ Mage::log("Error:$toXml1", null, './Bluestore_sales_import.log.text');
1851
+ Mage::log($toXml, null, './Bluestore_sales_import.log.text');
1852
+ if(!$value_cron)
1853
+ {
1854
+ $this->_redirect('*/*');
1855
+ break;
1856
+ }
1857
+ break;
1858
+
1859
+ case 8:
1860
+ $this->flag = 0;
1861
+ Mage::log('The Private Certificate is created', null, './Bluestore_sales_import.log.text');
1862
+ Mage::log('The Private Certificate is populated', null, './Bluestore_sales_import.log.text');
1863
+ Mage::log('The Sale xml file is created.', null, './Bluestore_sales_import.log.text');
1864
+ Mage::log('The Sale xml is populated.', null, './Bluestore_sales_import.log.text');
1865
+ Mage::log('The Config file is populated.', null, './Bluestore_sales_import.log.text');
1866
+ Mage::log('Sale Import Finished Successfully.', null, './Bluestore_sales_import.log.text');
1867
+
1868
+ if(!$value_cron)
1869
+ {
1870
+ $message = $this->__('Sale have been successfully imported.');
1871
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
1872
+ $this->_redirect('*/*');
1873
+ break;
1874
+ }
1875
+ break;
1876
+ }
1877
+ }
1878
+ }
1879
+ catch (Exception $e)
1880
+ {
1881
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
1882
+ }
1883
+ break;
1884
 
1885
  }
1886
 
app/code/local/Bluefish/Connection/controllers/Adminhtml/ProductdataController.php CHANGED
@@ -102,7 +102,7 @@ class Bluefish_Connection_Adminhtml_ProductdataController extends Mage_Adminhtml
102
  }
103
  function editButton(id)
104
  {
105
- window.location = "<?=$_SERVER["PHP_SELF"];?>?Action=Edit&ConnectionID="+id;
106
  }
107
  function deleteButton(id)
108
  {
102
  }
103
  function editButton(id)
104
  {
105
+ window.location = "<?=$_SERVER['PHP_SELF'];?>?Action=Edit&ConnectionID="+id;
106
  }
107
  function deleteButton(id)
108
  {
app/code/local/Bluefish/Connection/controllers/Adminhtml/Xml.php CHANGED
@@ -17,8 +17,8 @@ function cron_insert_update2()
17
 
18
  $resultStock = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = 'mycustom_section/mycustom_stock_group/mycustom_stock_commonschedule'");
19
  $resultStockIteration = $resultStock->fetchAll(PDO::FETCH_ASSOC);
20
- $StockIterationCounter = $resultStockIteration[0][loopCounter];
21
- $StockCounterDB = $resultStockIteration[0][loopIteration];
22
 
23
  $credentials = Mage::getStoreConfig('mycustom_section/mycustom_stock_group');
24
  $commonschedule_Stock = $credentials['mycustom_stock_commonschedule'];
@@ -55,7 +55,7 @@ function cron_insert_update2()
55
  $markers=$doc->getElementsByTagName('bluefish_connection_stock');
56
  foreach ($markers as $marker)
57
  {
58
- $type=$marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Stock_cron_schedule_time;
59
  }
60
 
61
  $doc->saveXML();
@@ -84,8 +84,8 @@ function cron_insert_update1()
84
 
85
  $resultProduct = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = 'mycustom_section/mycustom_product_group/mycustom_product_commonschedule'");
86
  $resultProductIteration = $resultProduct->fetchAll(PDO::FETCH_ASSOC);
87
- $ProductIterationCounter = $resultProductIteration[0][loopCounter];
88
- $ProductCounterDB = $resultProductIteration[0][loopIteration];
89
 
90
  $credentials = Mage::getStoreConfig('mycustom_section/mycustom_product_group');
91
  $commonschedule_Product = $credentials['mycustom_product_commonschedule'];
@@ -122,7 +122,7 @@ function cron_insert_update1()
122
  $markers=$doc->getElementsByTagName('bluefish_connection_product');
123
  foreach ($markers as $marker)
124
  {
125
- $type=$marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Product_cron_schedule_time;
126
  }
127
  $doc->saveXML();
128
  $doc->save($xmlFile);
@@ -150,8 +150,8 @@ function cron_insert_update()
150
 
151
  $resultCategory = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = 'mycustom_section/mycustom_category_group/mycustom_category_defaultminuteschedule'");
152
  $resultCategoryIteration = $resultCategory->fetchAll(PDO::FETCH_ASSOC);
153
- $categoryIterationCounter = $resultCategoryIteration[0][loopCounter];
154
- $categoryCounterDB = $resultCategoryIteration[0][loopIteration];
155
 
156
  $credentials = Mage::getStoreConfig('mycustom_section/mycustom_category_group');
157
  $commonschedule_category = $credentials['mycustom_category_defaultminuteschedule'];
@@ -189,7 +189,7 @@ function cron_insert_update()
189
 
190
  foreach ($markers as $marker)
191
  {
192
- $type = $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $category_cron_schedule_time;
193
  }
194
  $doc->saveXML();
195
  $doc->save($xmlFile);
@@ -218,8 +218,8 @@ try
218
 
219
  $resultCustomer = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = 'mycustom_section/mycustom_customer_group/mycustom_customer_commonschedule'");
220
  $resultCustomerIteration = $resultCustomer->fetchAll(PDO::FETCH_ASSOC);
221
- $CustomerIterationCounter = $resultCustomerIteration[0][loopCounter];
222
- $CustomerCounterDB = $resultCustomerIteration[0][loopIteration];
223
 
224
  $credentials = Mage::getStoreConfig('mycustom_section/mycustom_customer_group');
225
  $commonschedule_Customer = $credentials['mycustom_customer_commonschedule'];
@@ -257,12 +257,89 @@ try
257
  $markersexport =$doc->getElementsByTagName('bluefish_connection_customerexport');
258
  foreach ($markers as $marker)
259
  {
260
- $type=$marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Customer_cron_schedule_time;
261
  }
262
  foreach ($markersexport as $marker)
263
  {
264
- $type=$marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Customer_cron_schedule_time;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  }
 
 
 
 
 
266
  $doc->saveXML();
267
  $doc->save($xmlFile);
268
  $result = "success";
@@ -457,23 +534,43 @@ function insert_update_database1()
457
  {
458
  $unserielVal = unserialize($resultCronPath[0][value]);
459
  }
 
 
 
460
 
 
 
461
  if(count($xmlData) > 0)
462
  {
463
  for($i=0;$i<count($xmlData);$i++)
464
  {
465
  $name = $xmlData->product[$i]->descriptions->description;
466
- $short_description = $xmlData->product[$i]->descriptions->description;
467
  $status = $xmlData->product[$i]->active;
468
- $tax_class_id = $xmlData->product[$i]->taxClassCode;
469
  $categories = array($categoryID);
470
  $price = $xmlData->product[$i]->sellingPrices->priceEntry->amount;
471
- $categoryCode = $xmlData->product[$i]->categoryCode;
472
  $codeSKU = $xmlData->product[$i]->code;
473
- $Deletestatus = $xmlData->product[$i]->deleted;
 
474
  $comma_separated_category_ids = "";
475
  $returnmessage = "";
476
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
  if($Deletestatus == "false")
478
  {
479
  if($unserielVal['#{_id}']['Dbmapping'] == 'Mapping')
@@ -509,7 +606,7 @@ function insert_update_database1()
509
  }
510
  }
511
 
512
- if($numberProductRows == 0)
513
  {
514
  $attributeSets = $soap->call($sessionId, 'product_attribute_set.list');
515
  $attributeSet = current($attributeSets);
@@ -525,7 +622,7 @@ function insert_update_database1()
525
  'status' => '1',
526
  'visibility' => '4',
527
  'price' => "$price",
528
- 'tax_class_id' => 1
529
  )));
530
 
531
  $resultInSert = $connection->query("INSERT INTO ".$prefix."bluefish_product(id,category_id,product_id,product_code,created_time,update_time)
@@ -543,19 +640,22 @@ function insert_update_database1()
543
  {
544
  try
545
  {
 
546
  $existedProductID = $resultSetProduct[0]['product_id'];
547
  $resultProductUpdate = $soap->call($sessionId, 'catalog_product.update', array("$existedProductID", array(
548
  'categories' => $resultProductInfo['categories'],
549
  'websites' => array(1),
550
  'name' => "$name",
551
- 'price' => "$price"
 
 
552
  )));
553
  $resultUpdate = $connection->query("UPDATE ".$prefix."bluefish_product SET update_time= '".now()."' where product_code = '".$codeSKU."'");
554
  }
555
  catch(Exception $e)
556
  {
557
  $flag = $e->getMessage();
558
- if($flag == "Product not exists.")
559
  {
560
  $result = $connection->query("delete from ".$prefix."bluefish_product WHERE product_code = '".$codeSKU."'");
561
 
@@ -573,7 +673,7 @@ function insert_update_database1()
573
  'status' => '1',
574
  'visibility' => '4',
575
  'price' => "$price",
576
- 'tax_class_id' => 1
577
  )));
578
 
579
  $resultInSert = $connection->query("INSERT INTO ".$prefix."bluefish_product(id,category_id,product_id,product_code,created_time,update_time)
@@ -628,17 +728,20 @@ function insert_update_database1()
628
  }
629
  try
630
  {
 
631
  $resultProductUpdate = $soap->call($sessionId, 'catalog_product.update', array($productMainID, array(
632
  'categories' => $resultProductInfoDirect['categories'],
633
  'websites' => array(1),
634
  'name' => "$name",
635
- 'price' => "$price"
 
 
636
  )));
637
  }
638
  catch(Exception $e)
639
  {
640
  $flag = $e->getMessage();
641
- if($flag == "Product not exists.")
642
  {
643
  try
644
  {
@@ -654,7 +757,7 @@ function insert_update_database1()
654
  'status' => '1',
655
  'visibility' => '4',
656
  'price' => "$price",
657
- 'tax_class_id' => 1
658
  )));
659
  }
660
  catch(Exception $e)
@@ -716,16 +819,16 @@ function insert_update_database()
716
 
717
  for($i=0;$i<count($xmlData);$i++)
718
  {
719
- $code = $xmlData->category[$i]->code;
720
- $POSButton = $xmlData->category[$i]->POSButton;
721
- $descriptions = $xmlData->category[$i]->descriptions->description;
722
- $version = $xmlData->category[$i]->version;
723
- $deleted = $xmlData->category[$i]->deleted;
724
- $codeArr["$code"] = "$code" ;
725
- $POSButtonArr["$code"] = "$POSButton" ;
726
- $descriptionsArr["$code"] = "$descriptions" ;
727
- $versionArr["$code"] = "$version" ;
728
- $deletedArr["$code"] = "$deleted" ;
729
  }
730
  sort($codeArr);
731
 
@@ -1039,28 +1142,28 @@ function insert_update_database3()
1039
 
1040
  for($i=0;$i<count($xmlData);$i++)
1041
  {
1042
- $code = $xmlData->customer[$i]->code;
1043
  $externalRef = $xmlData->customer[$i]->externalRef;
1044
  $taxOrVatRef = $xmlData->customer[$i]->taxOrVatRef;
1045
- $createdOn = $xmlData->customer[$i]->createdOn;
1046
  $Addresscode = $xmlData->customer[$i]->address->code;
1047
  $isCorresponden = $xmlData->customer[$i]->address->isCorrespondence;
1048
  $isBilling = $xmlData->customer[$i]->address->isBilling;
1049
  $isDelivery = $xmlData->customer[$i]->address->isDelivery;
1050
- $title = $xmlData->customer[$i]->address->title;
1051
  $firstName = $xmlData->customer[$i]->address->firstName;
1052
- $lastName = $xmlData->customer[$i]->address->lastName;
1053
  $companyName = $xmlData->customer[$i]->address->companyName;
1054
- $street1 = $xmlData->customer[$i]->address->street1;
1055
- $street2 = $xmlData->customer[$i]->address->street2;
1056
- $street3 = $xmlData->customer[$i]->address->street3;
1057
- $city = $xmlData->customer[$i]->address->city;
1058
  $stateOrRegion = $xmlData->customer[$i]->address->stateOrRegion;
1059
  $postalCode = $xmlData->customer[$i]->address->postalCode;
1060
- $country = $xmlData->customer[$i]->address->country;
1061
- $phone1 = $xmlData->customer[$i]->address->phone1;
1062
- $phone2 = $xmlData->customer[$i]->address->phone2;
1063
- $email = $xmlData->customer[$i]->address->email;
1064
 
1065
  $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
1066
  $prefix = Mage::getConfig()->getTablePrefix();
@@ -1201,6 +1304,395 @@ function insert_update_database3()
1201
  return $flag;
1202
  }
1203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1204
  ##### Function for generate the completed sales data xml for bluestore
1205
  function ExportOrderData()
1206
  {
@@ -1268,10 +1760,17 @@ function ExportOrderData()
1268
  $connection->query("UPDATE ".$prefix."bluefish_cron_schedule SET loopIteration= '".$counterDB."' where id = '".$resultSaleIteration[0][id]."'");
1269
 
1270
  $markers=$doc->getElementsByTagName('bluefish_connection_orderexport');
 
 
1271
  foreach ($markers as $marker)
1272
  {
1273
  $type=$marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Sale_cron_schedule_time;
1274
  }
 
 
 
 
 
1275
  $doc->saveXML();
1276
  $doc->save($xmlFile);
1277
 
17
 
18
  $resultStock = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = 'mycustom_section/mycustom_stock_group/mycustom_stock_commonschedule'");
19
  $resultStockIteration = $resultStock->fetchAll(PDO::FETCH_ASSOC);
20
+ $StockIterationCounter = $resultStockIteration[0]['loopCounter'];
21
+ $StockCounterDB = $resultStockIteration[0]['loopIteration'];
22
 
23
  $credentials = Mage::getStoreConfig('mycustom_section/mycustom_stock_group');
24
  $commonschedule_Stock = $credentials['mycustom_stock_commonschedule'];
55
  $markers=$doc->getElementsByTagName('bluefish_connection_stock');
56
  foreach ($markers as $marker)
57
  {
58
+ $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Stock_cron_schedule_time;
59
  }
60
 
61
  $doc->saveXML();
84
 
85
  $resultProduct = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = 'mycustom_section/mycustom_product_group/mycustom_product_commonschedule'");
86
  $resultProductIteration = $resultProduct->fetchAll(PDO::FETCH_ASSOC);
87
+ $ProductIterationCounter = $resultProductIteration[0]['loopCounter'];
88
+ $ProductCounterDB = $resultProductIteration[0]['loopIteration'];
89
 
90
  $credentials = Mage::getStoreConfig('mycustom_section/mycustom_product_group');
91
  $commonschedule_Product = $credentials['mycustom_product_commonschedule'];
122
  $markers=$doc->getElementsByTagName('bluefish_connection_product');
123
  foreach ($markers as $marker)
124
  {
125
+ $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Product_cron_schedule_time;
126
  }
127
  $doc->saveXML();
128
  $doc->save($xmlFile);
150
 
151
  $resultCategory = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = 'mycustom_section/mycustom_category_group/mycustom_category_defaultminuteschedule'");
152
  $resultCategoryIteration = $resultCategory->fetchAll(PDO::FETCH_ASSOC);
153
+ $categoryIterationCounter = $resultCategoryIteration[0]['loopCounter'];
154
+ $categoryCounterDB = $resultCategoryIteration[0]['loopIteration'];
155
 
156
  $credentials = Mage::getStoreConfig('mycustom_section/mycustom_category_group');
157
  $commonschedule_category = $credentials['mycustom_category_defaultminuteschedule'];
189
 
190
  foreach ($markers as $marker)
191
  {
192
+ $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $category_cron_schedule_time;
193
  }
194
  $doc->saveXML();
195
  $doc->save($xmlFile);
218
 
219
  $resultCustomer = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = 'mycustom_section/mycustom_customer_group/mycustom_customer_commonschedule'");
220
  $resultCustomerIteration = $resultCustomer->fetchAll(PDO::FETCH_ASSOC);
221
+ $CustomerIterationCounter = $resultCustomerIteration[0]['loopCounter'];
222
+ $CustomerCounterDB = $resultCustomerIteration[0]['loopIteration'];
223
 
224
  $credentials = Mage::getStoreConfig('mycustom_section/mycustom_customer_group');
225
  $commonschedule_Customer = $credentials['mycustom_customer_commonschedule'];
257
  $markersexport =$doc->getElementsByTagName('bluefish_connection_customerexport');
258
  foreach ($markers as $marker)
259
  {
260
+ $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Customer_cron_schedule_time;
261
  }
262
  foreach ($markersexport as $marker)
263
  {
264
+ $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Customer_cron_schedule_time;
265
+ }
266
+ $doc->saveXML();
267
+ $doc->save($xmlFile);
268
+ $result = "success";
269
+ return $result;
270
+ }
271
+ catch(Exception $e)
272
+ {
273
+ $result = $e->getMessage();
274
+ return $result;
275
+ //exit();
276
+ }
277
+ }
278
+
279
+ #### Function for change the config setting for sale cron interval
280
+ function cron_insert_saleimport()
281
+ {
282
+ try
283
+ {
284
+ $doc = new DOMDocument();
285
+ $varpath = dirname(dirname(dirname(__FILE__)));
286
+ $xmlFile = "$varpath/etc/config.xml";
287
+
288
+ $doc->load($xmlFile);
289
+
290
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
291
+ $prefix = Mage::getConfig()->getTablePrefix();
292
+
293
+ $resultSale = $connection->query("select id,loopCounter,loopIteration from ".$prefix."bluefish_cron_schedule WHERE cronPath = 'mycustom_section/mycustom_sales_group/mycustom_sales_commonschedule'");
294
+ $resultSaleIteration = $resultSale->fetchAll(PDO::FETCH_ASSOC);
295
+
296
+ $SaleIterationCounter = $resultSaleIteration[0]['loopCounter'];
297
+ $SaleCounterDB = $resultSaleIteration[0]['loopIteration'];
298
+
299
+ $credentials = Mage::getStoreConfig('mycustom_section/mycustom_sales_group');
300
+ $commonschedule_Sale = $credentials['mycustom_sales_commonschedule'];
301
+ $unserielSaleVal = unserialize($commonschedule_Sale);
302
+
303
+ $SaleCount = 0;
304
+
305
+ foreach($unserielSaleVal as $keySaleCronTime => $valueSaleCronTime)
306
+ {
307
+ if($SaleCount == 0)
308
+ {
309
+ $FirstValHour = $valueSaleCronTime['Hourcronconfig'];
310
+ $FirstValMinute = $valueSaleCronTime['Minutecronconfig'];
311
+ }
312
+ if($SaleIterationCounter == $SaleCounterDB)
313
+ {
314
+ $counterDB = 1;
315
+ $Hourcronconfig = $FirstValHour;
316
+ $Minutecronconfig = $FirstValMinute;
317
+ }
318
+ if($SaleCount == $SaleCounterDB)
319
+ {
320
+ $counterDB = $SaleCounterDB + 1;
321
+ $Hourcronconfig = $valueSaleCronTime['Hourcronconfig'];
322
+ $Minutecronconfig = $valueSaleCronTime['Minutecronconfig'];
323
+ }
324
+ $SaleCount++;
325
+ }
326
+
327
+ $Sale_cron_schedule_time = $Minutecronconfig." ".$Hourcronconfig." * * *";
328
+
329
+ $connection->query("UPDATE ".$prefix."bluefish_cron_schedule SET loopIteration= '".$counterDB."' where id = '".$resultSaleIteration[0]['id']."'");
330
+
331
+ $markers=$doc->getElementsByTagName('bluefish_connection_orderexport');
332
+ $markersimport =$doc->getElementsByTagName('bluefish_connection_orderimport');
333
+
334
+ foreach ($markersimport as $markerr)
335
+ {
336
+ $markerr->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Sale_cron_schedule_time;
337
  }
338
+ foreach ($markers as $marker)
339
+ {
340
+ $marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Sale_cron_schedule_time;
341
+ }
342
+
343
  $doc->saveXML();
344
  $doc->save($xmlFile);
345
  $result = "success";
534
  {
535
  $unserielVal = unserialize($resultCronPath[0][value]);
536
  }
537
+
538
+ $credentialsTaxclass = Mage::getStoreConfig('mycustom_section/mycustom_taxclass_group');
539
+ $taxClassSerialArr = $credentialsTaxclass['mycustom_taxclass_magento'];
540
 
541
+ $unserielTaxClass = unserialize($taxClassSerialArr);
542
+
543
  if(count($xmlData) > 0)
544
  {
545
  for($i=0;$i<count($xmlData);$i++)
546
  {
547
  $name = $xmlData->product[$i]->descriptions->description;
548
+ $short_description = $xmlData->product[$i]->descriptions->description;
549
  $status = $xmlData->product[$i]->active;
550
+ $tax_class_id = $xmlData->product[$i]->taxClassCode;
551
  $categories = array($categoryID);
552
  $price = $xmlData->product[$i]->sellingPrices->priceEntry->amount;
553
+ $categoryCode = $xmlData->product[$i]->categoryCode;
554
  $codeSKU = $xmlData->product[$i]->code;
555
+ $Deletestatus = $xmlData->product[$i]->deleted;
556
+ $taxClassCode = $xmlData->product[$i]->taxClassCode;
557
  $comma_separated_category_ids = "";
558
  $returnmessage = "";
559
+
560
+
561
+ $tax_class_id = "";
562
+ foreach($unserielTaxClass as $key => $valueTax)
563
+ {
564
+ if($taxClassCode == $valueTax['bluestoretaxclass'])
565
+ {
566
+ $tax_class_id = $valueTax['magentotaxclass'];
567
+ }
568
+ }
569
+
570
+ if($tax_class_id == "")
571
+ $tax_class_id = "1";
572
+
573
+
574
  if($Deletestatus == "false")
575
  {
576
  if($unserielVal['#{_id}']['Dbmapping'] == 'Mapping')
606
  }
607
  }
608
 
609
+ if($numberProductRows == 0 && $status == "true")
610
  {
611
  $attributeSets = $soap->call($sessionId, 'product_attribute_set.list');
612
  $attributeSet = current($attributeSets);
622
  'status' => '1',
623
  'visibility' => '4',
624
  'price' => "$price",
625
+ 'tax_class_id' => "$tax_class_id"
626
  )));
627
 
628
  $resultInSert = $connection->query("INSERT INTO ".$prefix."bluefish_product(id,category_id,product_id,product_code,created_time,update_time)
640
  {
641
  try
642
  {
643
+ $ProductStatus = ($status == "true")?'1':'2';
644
  $existedProductID = $resultSetProduct[0]['product_id'];
645
  $resultProductUpdate = $soap->call($sessionId, 'catalog_product.update', array("$existedProductID", array(
646
  'categories' => $resultProductInfo['categories'],
647
  'websites' => array(1),
648
  'name' => "$name",
649
+ 'price' => "$price",
650
+ 'status' => "$ProductStatus",
651
+ 'tax_class_id' => "$tax_class_id"
652
  )));
653
  $resultUpdate = $connection->query("UPDATE ".$prefix."bluefish_product SET update_time= '".now()."' where product_code = '".$codeSKU."'");
654
  }
655
  catch(Exception $e)
656
  {
657
  $flag = $e->getMessage();
658
+ if($flag == "Product not exists." && $status == "true")
659
  {
660
  $result = $connection->query("delete from ".$prefix."bluefish_product WHERE product_code = '".$codeSKU."'");
661
 
673
  'status' => '1',
674
  'visibility' => '4',
675
  'price' => "$price",
676
+ 'tax_class_id' => "$tax_class_id"
677
  )));
678
 
679
  $resultInSert = $connection->query("INSERT INTO ".$prefix."bluefish_product(id,category_id,product_id,product_code,created_time,update_time)
728
  }
729
  try
730
  {
731
+ $ProductStatus = ($status == "true")?'1':'2';
732
  $resultProductUpdate = $soap->call($sessionId, 'catalog_product.update', array($productMainID, array(
733
  'categories' => $resultProductInfoDirect['categories'],
734
  'websites' => array(1),
735
  'name' => "$name",
736
+ 'price' => "$price",
737
+ 'status' => "$ProductStatus",
738
+ 'tax_class_id' => "$tax_class_id"
739
  )));
740
  }
741
  catch(Exception $e)
742
  {
743
  $flag = $e->getMessage();
744
+ if($flag == "Product not exists." && $status == "true")
745
  {
746
  try
747
  {
757
  'status' => '1',
758
  'visibility' => '4',
759
  'price' => "$price",
760
+ 'tax_class_id' => "$tax_class_id"
761
  )));
762
  }
763
  catch(Exception $e)
819
 
820
  for($i=0;$i<count($xmlData);$i++)
821
  {
822
+ $code = $xmlData->category[$i]->code;
823
+ $POSButton = $xmlData->category[$i]->POSButton;
824
+ $descriptions = $xmlData->category[$i]->descriptions->description;
825
+ $version = $xmlData->category[$i]->version;
826
+ $deleted = $xmlData->category[$i]->deleted;
827
+ $codeArr["$code"] = "$code" ;
828
+ $POSButtonArr["$code"] = "$POSButton" ;
829
+ $descriptionsArr["$code"] = "$descriptions" ;
830
+ $versionArr["$code"] = "$version" ;
831
+ $deletedArr["$code"] = "$deleted" ;
832
  }
833
  sort($codeArr);
834
 
1142
 
1143
  for($i=0;$i<count($xmlData);$i++)
1144
  {
1145
+ $code = $xmlData->customer[$i]->code;
1146
  $externalRef = $xmlData->customer[$i]->externalRef;
1147
  $taxOrVatRef = $xmlData->customer[$i]->taxOrVatRef;
1148
+ $createdOn = $xmlData->customer[$i]->createdOn;
1149
  $Addresscode = $xmlData->customer[$i]->address->code;
1150
  $isCorresponden = $xmlData->customer[$i]->address->isCorrespondence;
1151
  $isBilling = $xmlData->customer[$i]->address->isBilling;
1152
  $isDelivery = $xmlData->customer[$i]->address->isDelivery;
1153
+ $title = $xmlData->customer[$i]->address->title;
1154
  $firstName = $xmlData->customer[$i]->address->firstName;
1155
+ $lastName = $xmlData->customer[$i]->address->lastName;
1156
  $companyName = $xmlData->customer[$i]->address->companyName;
1157
+ $street1 = $xmlData->customer[$i]->address->street1;
1158
+ $street2 = $xmlData->customer[$i]->address->street2;
1159
+ $street3 = $xmlData->customer[$i]->address->street3;
1160
+ $city = $xmlData->customer[$i]->address->city;
1161
  $stateOrRegion = $xmlData->customer[$i]->address->stateOrRegion;
1162
  $postalCode = $xmlData->customer[$i]->address->postalCode;
1163
+ $country = $xmlData->customer[$i]->address->country;
1164
+ $phone1 = $xmlData->customer[$i]->address->phone1;
1165
+ $phone2 = $xmlData->customer[$i]->address->phone2;
1166
+ $email = $xmlData->customer[$i]->address->email;
1167
 
1168
  $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
1169
  $prefix = Mage::getConfig()->getTablePrefix();
1304
  return $flag;
1305
  }
1306
 
1307
+ ##### Function for import Bluestore sales
1308
+ function importBluestoreSales()
1309
+ {
1310
+ $appBaseDir = Mage::getBaseDir();
1311
+ $xmlPath = $appBaseDir.'/sales_bluestore_import.xml';
1312
+ $xmlObj = new Varien_Simplexml_Config($xmlPath);
1313
+ $xmlData = $xmlObj->getNode();
1314
+
1315
+ $mage_url = Mage::getBaseUrl()."api/soap/?wsdl";
1316
+ $credentials = Mage::getStoreConfig('mycustom_section/mycustom_auth_group');
1317
+
1318
+ $mage_user = $credentials['mycustom_login'];
1319
+ $mage_api_key = $credentials['mycustom_password'];
1320
+
1321
+ $soap = new SoapClient($mage_url);
1322
+ $sessionId = $soap->login($mage_user, $mage_api_key);
1323
+
1324
+ $credentials_sales = Mage::getStoreConfig('mycustom_section/mycustom_sales_group');
1325
+ $guestCustomerCode = $credentials_sales['mycustom_customer_idimport'];
1326
+
1327
+ Mage::log('Sales Import started ......', null, './Bluestore_sales_import.log.text');
1328
+
1329
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
1330
+ $prefix = Mage::getConfig()->getTablePrefix();
1331
+
1332
+ for($i=0;$i<count($xmlData);$i++)
1333
+ {
1334
+ $error = "";
1335
+ for($p=0;$p<count($xmlData->sale[$i]->items->item);$p++){
1336
+
1337
+ $productCodeBluestore = $xmlData->sale[$i]->items->item[$p]->productCode;
1338
+ try{
1339
+ $magentoProductIdCheck = Mage::getModel("catalog/product")->getIdBySku($productCodeBluestore);
1340
+
1341
+ if($magentoProductIdCheck == "")
1342
+ {
1343
+ $error .= "Product SKU => $productCodeBluestore does not exist in magento. <br>";
1344
+ }
1345
+ }catch(Exception $e){
1346
+
1347
+ }
1348
+
1349
+ }
1350
+
1351
+ $errorNum = 0;
1352
+ $arrProducts = array();
1353
+
1354
+ $paymentMethod = $xmlData->sale[$i]->payments->payment->tenderType;
1355
+ $transactionCode = $xmlData->sale[$i]->transactionCode;
1356
+ $updateLastDateArr[] = $xmlData->sale[$i]->endDate." ".$xmlData->sale[$i]->timezoneId;
1357
+
1358
+
1359
+ $resultFailureorder = $connection->query("select sale_code from ".$prefix."bluefish_import_error_logs WHERE sale_code ='".$transactionCode."'");
1360
+ $resultSetFailureorder = $resultFailureorder->fetchAll(PDO::FETCH_ASSOC);
1361
+ $numberFailureorder = count($resultSetFailureorder);
1362
+
1363
+ if($error == "")
1364
+ {
1365
+ $customerPOS = $xmlData->sale[$i]->customer->firstName;
1366
+
1367
+ if($customerPOS == "")
1368
+ {
1369
+ $customer = Mage::getModel('customer/customer')->load($guestCustomerCode);
1370
+ $customerAddress = array();
1371
+
1372
+ foreach ($customer->getAddresses() as $address)
1373
+ {
1374
+ $customerAddress = $address->toArray();
1375
+ }
1376
+
1377
+ $firstname = $customerAddress[firstname];
1378
+ $lastname = $customerAddress[lastname];
1379
+ $company = $customerAddress[company];
1380
+ $street = $customerAddress[street];
1381
+ $city = $customerAddress[city];
1382
+ $region = $customerAddress[region];
1383
+ $postcode = $customerAddress[postcode];
1384
+ $country_id = $customerAddress[country_id];
1385
+ $telephone = $customerAddress[telephone];
1386
+ $email = $customer->getEmail();
1387
+ }
1388
+ else{
1389
+ $street = "";
1390
+
1391
+ $customer = Mage::getModel('customer/customer')->load($guestCustomerCode);
1392
+ $customerAddress = array();
1393
+
1394
+ foreach ($customer->getAddresses() as $address)
1395
+ {
1396
+ $customerAddress = $address->toArray();
1397
+ }
1398
+
1399
+ if(!empty($xmlData->sale[$i]->customer->street1)){
1400
+ $street1 = (string)$xmlData->sale[$i]->customer->street1;
1401
+ $street1 = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $street1);
1402
+ }
1403
+ if(!empty($xmlData->sale[$i]->customer->street2)){
1404
+ $street2 = (string)$xmlData->sale[$i]->customer->street2;
1405
+ $street2 = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $street2);
1406
+ }
1407
+ if(!empty($xmlData->sale[$i]->customer->street3)){
1408
+ $street3 = (string)$xmlData->sale[$i]->customer->street3;
1409
+ $street3 = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $street3);
1410
+ }
1411
+
1412
+ $street = $street1;
1413
+
1414
+ if($street2 != ""){
1415
+ $street .= " ".$street2;
1416
+ }
1417
+ if($street3 != ""){
1418
+ $street .= " ".$street3;
1419
+ }
1420
+
1421
+ if(empty($street)){
1422
+ $street = $customerAddress[street];
1423
+ }
1424
+ if(!empty($xmlData->sale[$i]->customer->firstName)){
1425
+ $firstname = (string)$xmlData->sale[$i]->customer->firstName;
1426
+ $firstname = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $firstname);
1427
+ }
1428
+ if(!empty($xmlData->sale[$i]->customer->lastName)){
1429
+ $lastname = (string)$xmlData->sale[$i]->customer->lastName;
1430
+ $lastname = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $lastname);
1431
+ }
1432
+ if(!empty($xmlData->sale[$i]->customer->townCity)){
1433
+ $city = (string)$xmlData->sale[$i]->customer->townCity;
1434
+ $city = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $city);
1435
+ }
1436
+ else{
1437
+ $city = $customerAddress[city];
1438
+ }
1439
+ if(!empty($xmlData->sale[$i]->customer->stateRegion)){
1440
+ $region = (string)$xmlData->sale[$i]->customer->stateRegion;
1441
+ $region = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $region);
1442
+ }
1443
+ if(!empty($xmlData->sale[$i]->customer->postalZipCode)){
1444
+ $postcode = (string)$xmlData->sale[$i]->customer->postalZipCode;
1445
+ $postcode = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $postcode);
1446
+ }
1447
+ else{
1448
+ $postcode = $customerAddress[postcode];
1449
+ }
1450
+ if(!empty($xmlData->sale[$i]->customer->countryCode)){
1451
+ $country_id = (string)$xmlData->sale[$i]->customer->countryCode;
1452
+ $country_id = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $country_id);
1453
+ }
1454
+ if(!empty($xmlData->sale[$i]->customer->telephone1) && strlen($xmlData->sale[$i]->customer->telephone1) >9){
1455
+ $telephone = (string)$xmlData->sale[$i]->customer->telephone1;
1456
+ $telephone = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $telephone);
1457
+ }
1458
+ else {
1459
+ $telephone = $customerAddress[telephone];
1460
+ }
1461
+ if(!empty($xmlData->sale[$i]->customer->email)){
1462
+ $email = (string)$xmlData->sale[$i]->customer->email;
1463
+ $email = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $email);
1464
+ }
1465
+ else {
1466
+ $email = $customer->getEmail();
1467
+ }
1468
+ $company = "";
1469
+ }
1470
+
1471
+ for($j=0;$j<count($xmlData->sale[$i]->items->item);$j++){
1472
+
1473
+ $productCode = $xmlData->sale[$i]->items->item[$j]->productCode;
1474
+ $quantity_item = $xmlData->sale[$i]->items->item[$j]->quantity;
1475
+ $quantity_item = (int)$quantity_item;
1476
+
1477
+ $magentoProductId = Mage::getModel("catalog/product")->getIdBySku($productCode);
1478
+
1479
+ $arrProducts[$j] = array(
1480
+ 'product_id' => "$magentoProductId",
1481
+ 'quantity' => "$quantity_item"
1482
+ );
1483
+
1484
+ }
1485
+
1486
+
1487
+ try{
1488
+ $shoppingCartIncrementId = $soap->call( $sessionId, 'cart.create');
1489
+ }
1490
+ catch(Exception $e){
1491
+ $error .= $e->getMessage()."<br>";
1492
+ }
1493
+
1494
+ try{
1495
+ $resultCartProductAdd = $soap->call(
1496
+ $sessionId,
1497
+ "cart_product.add",
1498
+ array(
1499
+ $shoppingCartIncrementId,
1500
+ $arrProducts
1501
+ )
1502
+ );
1503
+ }
1504
+ catch(Exception $e){
1505
+ $error .= $e->getMessage()."<br>";
1506
+ }
1507
+
1508
+ $shoppingCartId = $shoppingCartIncrementId;
1509
+
1510
+ $customer = array(
1511
+ "firstname" => $firstname,
1512
+ "lastname" => $lastname,
1513
+ "website_id" => "1",
1514
+ "group_id" => "1",
1515
+ "store_id" => "1",
1516
+ "email" => $email,
1517
+ "mode" => "guest",
1518
+ );
1519
+
1520
+ try{
1521
+ $resultCustomerSet = $soap->call($sessionId, 'cart_customer.set', array( $shoppingCartId, $customer) );
1522
+ }
1523
+ catch(Exception $e){
1524
+ $error .= $e->getMessage()."<br>";
1525
+ }
1526
+
1527
+ // Set customer addresses, for example guest's addresses
1528
+ $arrAddresses = array(
1529
+ array(
1530
+ "mode" => "shipping",
1531
+ "firstname" => $firstname,
1532
+ "lastname" => $lastname,
1533
+ "company" => $company,
1534
+ "street" => $street,
1535
+ "city" => $city,
1536
+ "region" => $region,
1537
+ "postcode" => $postcode,
1538
+ "country_id" => $country_id,
1539
+ "telephone" => "$telephone",
1540
+ "is_default_shipping" => 0,
1541
+ "is_default_billing" => 0
1542
+ ),
1543
+ array(
1544
+ "mode" => "billing",
1545
+ "firstname" => $firstname,
1546
+ "lastname" => $lastname,
1547
+ "company" => $company,
1548
+ "street" => $street,
1549
+ "city" => $city,
1550
+ "region" => $region,
1551
+ "postcode" => $postcode,
1552
+ "country_id" => $country_id,
1553
+ "telephone" => "$telephone",
1554
+ "is_default_shipping" => 0,
1555
+ "is_default_billing" => 0
1556
+ )
1557
+ );
1558
+
1559
+ try{
1560
+ $resultCustomerAddresses = $soap->call($sessionId, "cart_customer.addresses", array($shoppingCartId, $arrAddresses));
1561
+ }
1562
+ catch(Exception $e){
1563
+ $error .= $e->getMessage()."<br>";
1564
+ }
1565
+
1566
+ $shippingMethod = "bluefish_connection_bluefish_connection";
1567
+
1568
+ try{
1569
+ $resultShippingMethod = $soap->call($sessionId, "cart_shipping.method", array($shoppingCartId, $shippingMethod));
1570
+ }
1571
+ catch(Exception $e){
1572
+ $error .= $e->getMessage()."<br>";
1573
+ }
1574
+
1575
+ #$paymentMethod = ($paymentMethod == "CASH")?"checkmo":"ccsave";
1576
+ $paymentMethod = "bluefish_connection";
1577
+
1578
+ #### set payment method
1579
+ $paymentMethod = array(
1580
+ "method" => $paymentMethod
1581
+ );
1582
+
1583
+ try{
1584
+ $resultPaymentMethod = $soap->call($sessionId, "cart_payment.method", array($shoppingCartId, $paymentMethod));
1585
+ }
1586
+ catch(Exception $e){
1587
+ $error .= $e->getMessage()."<br>";
1588
+ }
1589
+
1590
+ try{
1591
+ $shoppingCartInfo = $soap->call($sessionId, "cart.info", array($shoppingCartId));
1592
+ #echo $error;
1593
+ #echo "<pre>";
1594
+ #print_r($shoppingCartInfo);die;
1595
+
1596
+ $item_array = $shoppingCartInfo[items];
1597
+
1598
+ $item_id = array();
1599
+
1600
+ foreach($item_array as $item_key=>$item_val){
1601
+ $item_id[] = $item_val[item_id];
1602
+ }
1603
+
1604
+ for($k=0;$k<count($xmlData->sale[$i]->items->item);$k++){
1605
+
1606
+ $finalAmount = "";
1607
+ $finalAmountExclTax = "";
1608
+ $quantity = "";
1609
+ $quantity = (int)$xmlData->sale[$i]->items->item[$k]->quantity;
1610
+ $finalAmountExclTax = (float)$xmlData->sale[$i]->items->item[$k]->finalAmountExclTax;
1611
+
1612
+
1613
+ $finalAmount = $finalAmountExclTax / $quantity;
1614
+
1615
+ $connection->query("UPDATE ".$prefix."sales_flat_quote_item SET
1616
+ `custom_price` = '$finalAmount',
1617
+ `original_custom_price` = '$finalAmount',
1618
+ `qty` = '$quantity'
1619
+ WHERE `sales_flat_quote_item`.`item_id` =".$item_id[$k]);
1620
+
1621
+ }
1622
+
1623
+ }
1624
+ catch(Exception $e){
1625
+ $error .= $e->getMessage()."<br>";
1626
+ }
1627
+
1628
+ $licenseForOrderCreation = null;
1629
+
1630
+ try{
1631
+ $orderIncrementId = $soap->call($sessionId,"cart.order",array($shoppingCartId, null, $licenseForOrderCreation));
1632
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
1633
+
1634
+ //create invoice for the order
1635
+ $invoice = $order->prepareInvoice()
1636
+ ->setTransactionId($order->getId())
1637
+ ->addComment("Invoice created from Bluestore extension.")
1638
+ ->register()
1639
+ ->pay();
1640
+
1641
+ $transaction_save = Mage::getModel('core/resource_transaction')
1642
+ ->addObject($invoice)
1643
+ ->addObject($invoice->getOrder());
1644
+
1645
+ $transaction_save->save();
1646
+ //now create shipment
1647
+ //after creation of shipment, the order auto gets status COMPLETE
1648
+ $shipment = $order->prepareShipment();
1649
+ if( $shipment ) {
1650
+ $shipment->register();
1651
+ $order->setIsInProcess(true);
1652
+
1653
+ $transaction_save = Mage::getModel('core/resource_transaction')
1654
+ ->addObject($shipment)
1655
+ ->addObject($shipment->getOrder())
1656
+ ->save();
1657
+ }
1658
+ }
1659
+ catch(Exception $e){
1660
+ $error .= $e->getMessage()."<br>";
1661
+ }
1662
+ }
1663
+ if($error != "" && $numberFailureorder == 0)
1664
+ {
1665
+ $connection->query("INSERT INTO ".$prefix."bluefish_import_error_logs(id,sale_code,error)
1666
+ VALUES('','".$transactionCode."','".addslashes($error)."')");
1667
+ $errorNum++;
1668
+ }
1669
+ else if($error != "" && $numberFailureorder > 0)
1670
+ {
1671
+ $connection->query("UPDATE ".$prefix."bluefish_import_error_logs SET error = '".addslashes($error)."', error_date = now() WHERE sale_code ='".$transactionCode."'");
1672
+ $errorNum++;
1673
+ }
1674
+ else if($error == "" && $numberFailureorder > 0){
1675
+ $connection->query("DELETE FROM ".$prefix."bluefish_import_error_logs WHERE sale_code ='".$transactionCode."'");
1676
+ }
1677
+ }
1678
+
1679
+ if(count($xmlData) > 0 && $numberFailureorder == 0)
1680
+ {
1681
+ $updateLastDateVal = max($updateLastDateArr);
1682
+ $updateLastDateVal = $updateLastDateVal;
1683
+ $coreConfigUpdate = $connection->query("UPDATE ".$prefix."core_config_data SET value = '".$updateLastDateVal."' where path = 'mycustom_section/mycustom_sales_group/mycustom_bluestore_enddatetime'");
1684
+ }
1685
+
1686
+ if($errorNum > 0){
1687
+ $flag = "fail";
1688
+ }elseif(count($xmlData) == 0){
1689
+ $flag = "blankdata";
1690
+ }else{
1691
+ $flag = "success";
1692
+ }
1693
+ return $flag;
1694
+ }
1695
+
1696
  ##### Function for generate the completed sales data xml for bluestore
1697
  function ExportOrderData()
1698
  {
1760
  $connection->query("UPDATE ".$prefix."bluefish_cron_schedule SET loopIteration= '".$counterDB."' where id = '".$resultSaleIteration[0][id]."'");
1761
 
1762
  $markers=$doc->getElementsByTagName('bluefish_connection_orderexport');
1763
+ $markersimport =$doc->getElementsByTagName('bluefish_connection_orderimport');
1764
+ Mage::log($Sale_cron_schedule_time, null, './Bluestore_salesorder.log.text');
1765
  foreach ($markers as $marker)
1766
  {
1767
  $type=$marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Sale_cron_schedule_time;
1768
  }
1769
+ foreach ($markersimport as $marker)
1770
+ {
1771
+ $type=$marker->getElementsByTagName('cron_expr')->item(0)->nodeValue = $Sale_cron_schedule_time;
1772
+ }
1773
+
1774
  $doc->saveXML();
1775
  $doc->save($xmlFile);
1776
 
app/code/local/Bluefish/Connection/etc/config.xml CHANGED
@@ -2,7 +2,13 @@
2
  <config>
3
  <modules>
4
  <Bluefish_Connection>
5
- <version>1.1.2</version>
 
 
 
 
 
 
6
  </Bluefish_Connection>
7
  </modules>
8
  <frontend>
@@ -25,13 +31,13 @@
25
  </frontend>
26
  <admin>
27
  <routers>
28
- <connection>
29
- <use>admin</use>
30
- <args>
31
- <module>Bluefish_Connection</module>
32
- <frontName>bluefish</frontName>
33
- </args>
34
- </connection>
35
  </routers>
36
  </admin>
37
  <adminhtml>
@@ -59,7 +65,12 @@
59
  <title>Monitor Scheduled Tasks</title>
60
  <sort_order>40</sort_order>
61
  <action>connection/adminhtml_bluestorescheduler</action>
62
- </monitorcron>
 
 
 
 
 
63
  </children>
64
  </connection>
65
  </menu>
@@ -88,6 +99,13 @@
88
  </adminhtml>
89
  <global>
90
  <models>
 
 
 
 
 
 
 
91
  <connection>
92
  <class>Bluefish_Connection_Model</class>
93
  <resourceModel>connection_mysql4</resourceModel>
@@ -111,7 +129,10 @@
111
  <connection1>
112
  <table>bluefish_sale_post</table>
113
  </connection1>
114
- </entities>
 
 
 
115
  </connection_mysql4>
116
  </models>
117
  <resources>
@@ -148,30 +169,34 @@
148
  <crontab>
149
  <jobs>
150
  <bluefish_connection_category>
151
- <schedule><cron_expr>50 14 * * *</cron_expr></schedule>
152
  <run><model>connection/observer::categoryImport</model></run>
153
  </bluefish_connection_category>
154
- <bluefish_connection_product>
155
- <schedule><cron_expr>50 14 * * *</cron_expr></schedule>
156
  <run><model>connection/observer::productImport</model></run>
157
  </bluefish_connection_product>
158
- <bluefish_connection_stock>
159
  <schedule><cron_expr>27 7 * * *</cron_expr></schedule>
160
  <run><model>connection/observer::stockImport</model></run>
161
  </bluefish_connection_stock>
162
- <bluefish_connection_customer>
163
  <schedule><cron_expr>44 7 * * *</cron_expr></schedule>
164
  <run><model>connection/observer::customerImport</model></run>
165
  </bluefish_connection_customer>
166
- <bluefish_connection_customerexport>
167
  <schedule><cron_expr>44 7 * * *</cron_expr></schedule>
168
  <run><model>connection/observer::customerExport</model></run>
169
  </bluefish_connection_customerexport>
170
- <bluefish_connection_orderexport>
171
- <schedule><cron_expr>50 7 * * *</cron_expr></schedule>
 
 
 
 
172
  <run><model>connection/observer::salesExport</model></run>
173
  </bluefish_connection_orderexport>
174
- </jobs>
175
  </crontab>
176
 
177
  <default>
@@ -189,13 +214,27 @@
189
  </mycustom_sales_group>
190
  </mycustom_section>
191
  </default>
192
- <default>
193
  <mycustom_section>
194
  <mycustom_sales_group>
195
  <mycustom_sale_chargescode>1</mycustom_sale_chargescode>
196
  </mycustom_sales_group>
197
  </mycustom_section>
198
- </default>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
  <default>
201
  <mycustom_section>
@@ -239,6 +278,30 @@
239
  <mycustom_payment_cc>11</mycustom_payment_cc>
240
  </mycustom_payment_group>
241
  </mycustom_section>
242
- </default>
243
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  </config>
2
  <config>
3
  <modules>
4
  <Bluefish_Connection>
5
+ <version>1.1.3</version>
6
+ <depends>
7
+ <Mage_Shipping/>
8
+ </depends>
9
+ <depends>
10
+ <Mage_Payment/>
11
+ </depends>
12
  </Bluefish_Connection>
13
  </modules>
14
  <frontend>
31
  </frontend>
32
  <admin>
33
  <routers>
34
+ <connection>
35
+ <use>admin</use>
36
+ <args>
37
+ <module>Bluefish_Connection</module>
38
+ <frontName>bluefish</frontName>
39
+ </args>
40
+ </connection>
41
  </routers>
42
  </admin>
43
  <adminhtml>
65
  <title>Monitor Scheduled Tasks</title>
66
  <sort_order>40</sort_order>
67
  <action>connection/adminhtml_bluestorescheduler</action>
68
+ </monitorcron>
69
+ <errorsaleimport module="connection">
70
+ <title>Sales Import Error</title>
71
+ <sort_order>50</sort_order>
72
+ <action>connection/adminhtml_errorsaleimport</action>
73
+ </errorsaleimport>
74
  </children>
75
  </connection>
76
  </menu>
99
  </adminhtml>
100
  <global>
101
  <models>
102
+
103
+ <core>
104
+ <rewrite>
105
+ <store>Bluefish_Connection_Model_Store</store>
106
+ </rewrite>
107
+ </core>
108
+
109
  <connection>
110
  <class>Bluefish_Connection_Model</class>
111
  <resourceModel>connection_mysql4</resourceModel>
129
  <connection1>
130
  <table>bluefish_sale_post</table>
131
  </connection1>
132
+ <errorsaleimport>
133
+ <table>bluefish_import_error_logs</table>
134
+ </errorsaleimport>
135
+ </entities>
136
  </connection_mysql4>
137
  </models>
138
  <resources>
169
  <crontab>
170
  <jobs>
171
  <bluefish_connection_category>
172
+ <schedule><cron_expr>52 8 * * *</cron_expr></schedule>
173
  <run><model>connection/observer::categoryImport</model></run>
174
  </bluefish_connection_category>
175
+ <bluefish_connection_product>
176
+ <schedule><cron_expr>2 10 * * *</cron_expr></schedule>
177
  <run><model>connection/observer::productImport</model></run>
178
  </bluefish_connection_product>
179
+ <bluefish_connection_stock>
180
  <schedule><cron_expr>27 7 * * *</cron_expr></schedule>
181
  <run><model>connection/observer::stockImport</model></run>
182
  </bluefish_connection_stock>
183
+ <bluefish_connection_customer>
184
  <schedule><cron_expr>44 7 * * *</cron_expr></schedule>
185
  <run><model>connection/observer::customerImport</model></run>
186
  </bluefish_connection_customer>
187
+ <bluefish_connection_customerexport>
188
  <schedule><cron_expr>44 7 * * *</cron_expr></schedule>
189
  <run><model>connection/observer::customerExport</model></run>
190
  </bluefish_connection_customerexport>
191
+ <bluefish_connection_orderimport>
192
+ <schedule><cron_expr>55 12 * * *</cron_expr></schedule>
193
+ <run><model>connection/observer::salesImport</model></run>
194
+ </bluefish_connection_orderimport>
195
+ <bluefish_connection_orderexport>
196
+ <schedule><cron_expr>55 12 * * *</cron_expr></schedule>
197
  <run><model>connection/observer::salesExport</model></run>
198
  </bluefish_connection_orderexport>
199
+ </jobs>
200
  </crontab>
201
 
202
  <default>
214
  </mycustom_sales_group>
215
  </mycustom_section>
216
  </default>
217
+ <default>
218
  <mycustom_section>
219
  <mycustom_sales_group>
220
  <mycustom_sale_chargescode>1</mycustom_sale_chargescode>
221
  </mycustom_sales_group>
222
  </mycustom_section>
223
+ </default>
224
+ <default>
225
+ <mycustom_section>
226
+ <mycustom_sales_group>
227
+ <mycustom_customer_idimport>1</mycustom_customer_idimport>
228
+ </mycustom_sales_group>
229
+ </mycustom_section>
230
+ </default>
231
+ <default>
232
+ <mycustom_section>
233
+ <mycustom_sales_group>
234
+ <mycustom_bluestore_enddatetime>2014-01-01 00:00</mycustom_bluestore_enddatetime>
235
+ </mycustom_sales_group>
236
+ </mycustom_section>
237
+ </default>
238
 
239
  <default>
240
  <mycustom_section>
278
  <mycustom_payment_cc>11</mycustom_payment_cc>
279
  </mycustom_payment_group>
280
  </mycustom_section>
281
+ </default>
282
+
283
+ <default>
284
+ <carriers>
285
+ <bluefish_connection>
286
+ <active>1</active>
287
+ <model>connection/carrier_bsaleshippingmethod</model>
288
+ <title>Carrier Title</title>
289
+ <name>bluestore_no_shipping</name>
290
+ <price>0.00</price>
291
+ <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
292
+ </bluefish_connection>
293
+ </carriers>
294
+ </default>
295
+
296
+ <default>
297
+ <payment>
298
+ <bluefish_connection>
299
+ <active>1</active>
300
+ <model>connection/paymentmethod</model>
301
+ <order_status>processing</order_status>
302
+ <title>Bluestore Paid</title>
303
+ </bluefish_connection>
304
+ </payment>
305
+ </default>
306
+
307
  </config>
app/code/local/Bluefish/Connection/etc/system.xml CHANGED
@@ -143,17 +143,17 @@
143
  <show_in_website>1</show_in_website>
144
  <show_in_store>1</show_in_store>
145
  <fields>
146
- <mycustom_sales_commonschedule translate="label">
147
  <label></label>
148
  <frontend_model>bluefish_connection_block_cronschedule</frontend_model>
149
- <backend_model>bluefish_connection_model_validationcrontime</backend_model>
150
  <sort_order>2</sort_order>
151
- <comment><![CDATA[Add one or more schedule lines to indicate times during the day when sales will be sent to bluestore.]]></comment>
152
  <show_in_default>1</show_in_default>
153
  <show_in_website>1</show_in_website>
154
  <show_in_store>1</show_in_store>
155
  </mycustom_sales_commonschedule>
156
- <mycustom_saledefaultcategory translate="label">
157
  <label>Default Category for Sales Posting</label>
158
  <frontend_type>text</frontend_type>
159
  <sort_order>40</sort_order>
@@ -161,7 +161,7 @@
161
  <show_in_website>1</show_in_website>
162
  <show_in_store>1</show_in_store>
163
  </mycustom_saledefaultcategory>
164
- <mycustom_customer_number translate="label">
165
  <label>Bluestore Customer Code for Guest Checkout</label>
166
  <frontend_type>text</frontend_type>
167
  <sort_order>50</sort_order>
@@ -169,15 +169,31 @@
169
  <show_in_website>1</show_in_website>
170
  <show_in_store>1</show_in_store>
171
  </mycustom_customer_number>
172
- <mycustom_sale_chargescode translate="label">
173
  <label>Bluestore Charge Code for Delivery Charges</label>
174
  <frontend_type>text</frontend_type>
175
  <sort_order>60</sort_order>
176
  <show_in_default>1</show_in_default>
177
  <show_in_website>1</show_in_website>
178
  <show_in_store>1</show_in_store>
179
- </mycustom_sale_chargescode>
180
- </fields>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  </mycustom_sales_group>
182
 
183
 
@@ -263,14 +279,32 @@
263
  <mycustom_payment_checkmethod translate="label">
264
  <label></label>
265
  <frontend_model>bluefish_connection_block_paymentmethodcode</frontend_model>
266
- <backend_model>bluefish_connection_model_validationpaymentmap</backend_model>
267
  <sort_order>2</sort_order>
268
  <show_in_default>1</show_in_default>
269
  <show_in_website>1</show_in_website>
270
  <show_in_store>1</show_in_store>
271
  </mycustom_payment_checkmethod>
272
- </fields>
273
- </mycustom_payment_group>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
 
275
  </groups>
276
  </mycustom_section>
@@ -292,6 +326,124 @@
292
  </cron>
293
  </groups>
294
  </system>
295
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  </sections>
297
  </config>
143
  <show_in_website>1</show_in_website>
144
  <show_in_store>1</show_in_store>
145
  <fields>
146
+ <mycustom_sales_commonschedule translate="label">
147
  <label></label>
148
  <frontend_model>bluefish_connection_block_cronschedule</frontend_model>
149
+ <backend_model>bluefish_connection_model_validationcrontime</backend_model>
150
  <sort_order>2</sort_order>
151
+ <comment><![CDATA[Add one or more schedule lines to indicate times during the day when sales will be sent to bluestore.]]></comment>
152
  <show_in_default>1</show_in_default>
153
  <show_in_website>1</show_in_website>
154
  <show_in_store>1</show_in_store>
155
  </mycustom_sales_commonschedule>
156
+ <mycustom_saledefaultcategory translate="label">
157
  <label>Default Category for Sales Posting</label>
158
  <frontend_type>text</frontend_type>
159
  <sort_order>40</sort_order>
161
  <show_in_website>1</show_in_website>
162
  <show_in_store>1</show_in_store>
163
  </mycustom_saledefaultcategory>
164
+ <mycustom_customer_number translate="label">
165
  <label>Bluestore Customer Code for Guest Checkout</label>
166
  <frontend_type>text</frontend_type>
167
  <sort_order>50</sort_order>
169
  <show_in_website>1</show_in_website>
170
  <show_in_store>1</show_in_store>
171
  </mycustom_customer_number>
172
+ <mycustom_sale_chargescode translate="label">
173
  <label>Bluestore Charge Code for Delivery Charges</label>
174
  <frontend_type>text</frontend_type>
175
  <sort_order>60</sort_order>
176
  <show_in_default>1</show_in_default>
177
  <show_in_website>1</show_in_website>
178
  <show_in_store>1</show_in_store>
179
+ </mycustom_sale_chargescode>
180
+ <mycustom_customer_idimport translate="label">
181
+ <label>Magento Customer Id for Sales Import</label>
182
+ <frontend_type>text</frontend_type>
183
+ <sort_order>70</sort_order>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ </mycustom_customer_idimport>
188
+ <mycustom_bluestore_enddatetime translate="label">
189
+ <label>Bluestore Last Sale End DateTime</label>
190
+ <frontend_type>text</frontend_type>
191
+ <sort_order>80</sort_order>
192
+ <show_in_default>1</show_in_default>
193
+ <show_in_website>1</show_in_website>
194
+ <show_in_store>1</show_in_store>
195
+ </mycustom_bluestore_enddatetime>
196
+ </fields>
197
  </mycustom_sales_group>
198
 
199
 
279
  <mycustom_payment_checkmethod translate="label">
280
  <label></label>
281
  <frontend_model>bluefish_connection_block_paymentmethodcode</frontend_model>
282
+ <backend_model>bluefish_connection_model_validationpaymentmap</backend_model>
283
  <sort_order>2</sort_order>
284
  <show_in_default>1</show_in_default>
285
  <show_in_website>1</show_in_website>
286
  <show_in_store>1</show_in_store>
287
  </mycustom_payment_checkmethod>
288
+ </fields>
289
+ </mycustom_payment_group>
290
+ <mycustom_taxclass_group translate="label">
291
+ <label>Bluestore Product Tax Class</label>
292
+ <sort_order>90</sort_order>
293
+ <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>1</show_in_store>
296
+ <fields>
297
+ <mycustom_taxclass_magento translate="label">
298
+ <label></label>
299
+ <frontend_model>bluefish_connection_block_bluestoretaxclass</frontend_model>
300
+ <backend_model>bluefish_connection_model_validationtaxclass</backend_model>
301
+ <sort_order>2</sort_order>
302
+ <show_in_default>1</show_in_default>
303
+ <show_in_website>1</show_in_website>
304
+ <show_in_store>1</show_in_store>
305
+ </mycustom_taxclass_magento>
306
+ </fields>
307
+ </mycustom_taxclass_group>
308
 
309
  </groups>
310
  </mycustom_section>
326
  </cron>
327
  </groups>
328
  </system>
329
+
330
+ <carriers>
331
+ <groups>
332
+ <bluefish_connection>
333
+ <label>Bluestore Sale Shipping Module</label>
334
+ <frontend_type>text</frontend_type>
335
+ <sort_order>99</sort_order>
336
+ <show_in_default>1</show_in_default>
337
+ <show_in_website>1</show_in_website>
338
+ <show_in_store>1</show_in_store>
339
+ <fields>
340
+ <active translate="label">
341
+ <label>Enabled</label>
342
+ <frontend_type>select</frontend_type>
343
+ <source_model>adminhtml/system_config_source_yesno</source_model>
344
+ <sort_order>1</sort_order>
345
+ <show_in_default>1</show_in_default>
346
+ <show_in_website>1</show_in_website>
347
+ <show_in_store>1</show_in_store>
348
+ </active>
349
+ <title translate="label">
350
+ <label>Title</label>
351
+ <frontend_type>text</frontend_type>
352
+ <sort_order>2</sort_order>
353
+ <show_in_default>1</show_in_default>
354
+ <show_in_website>1</show_in_website>
355
+ <show_in_store>1</show_in_store>
356
+ </title>
357
+ <name translate="label">
358
+ <label>Method Name</label>
359
+ <frontend_type>text</frontend_type>
360
+ <sort_order>2</sort_order>
361
+ <show_in_default>1</show_in_default>
362
+ <show_in_website>1</show_in_website>
363
+ <show_in_store>1</show_in_store>
364
+ </name>
365
+ <price translate="label">
366
+ <label>Price</label>
367
+ <frontend_type>text</frontend_type>
368
+ <sort_order>3</sort_order>
369
+ <show_in_default>1</show_in_default>
370
+ <show_in_website>1</show_in_website>
371
+ <show_in_store>0</show_in_store>
372
+ </price>
373
+ <specificerrmsg translate="label">
374
+ <label>Displayed Error Message</label>
375
+ <frontend_type>textarea</frontend_type>
376
+ <sort_order>4</sort_order>
377
+ <show_in_default>1</show_in_default>
378
+ <show_in_website>1</show_in_website>
379
+ <show_in_store>1</show_in_store>
380
+ </specificerrmsg>
381
+ <sallowspecific translate="label">
382
+ <label>Ship to Applicable Countries</label>
383
+ <frontend_type>select</frontend_type>
384
+ <sort_order>90</sort_order>
385
+ <frontend_class>shipping-applicable-country</frontend_class>
386
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
387
+ <show_in_default>1</show_in_default>
388
+ <show_in_website>1</show_in_website>
389
+ <show_in_store>0</show_in_store>
390
+ </sallowspecific>
391
+ <specificcountry translate="label">
392
+ <label>Ship to Specific Countries</label>
393
+ <frontend_type>multiselect</frontend_type>
394
+ <sort_order>91</sort_order>
395
+ <source_model>adminhtml/system_config_source_country</source_model>
396
+ <show_in_default>1</show_in_default>
397
+ <show_in_website>1</show_in_website>
398
+ <show_in_store>0</show_in_store>
399
+ <can_be_empty>1</can_be_empty>
400
+ </specificcountry>
401
+ </fields>
402
+ </bluefish_connection>
403
+ </groups>
404
+ </carriers>
405
+
406
+
407
+
408
+ <payment>
409
+ <groups>
410
+ <bluefish_connection>
411
+ <label>Bluestore Paid</label>
412
+ <sort_order>1000</sort_order>
413
+ <show_in_default>1</show_in_default>
414
+ <show_in_website>1</show_in_website>
415
+ <show_in_store>0</show_in_store>
416
+ <fields>
417
+ <active translate="label">
418
+ <label>Enabled</label>
419
+ <frontend_type>select</frontend_type>
420
+ <source_model>adminhtml/system_config_source_yesno</source_model>
421
+ <sort_order>1</sort_order>
422
+ <show_in_default>1</show_in_default>
423
+ <show_in_website>1</show_in_website>
424
+ <show_in_store>0</show_in_store>
425
+ </active>
426
+ <order_status translate="label">
427
+ <label>New Order Status</label>
428
+ <frontend_type>select</frontend_type>
429
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
430
+ <sort_order>2</sort_order>
431
+ <show_in_default>1</show_in_default>
432
+ <show_in_website>1</show_in_website>
433
+ <show_in_store>0</show_in_store>
434
+ </order_status>
435
+ <title translate="label">
436
+ <label>Payment Title</label>
437
+ <frontend_type>text</frontend_type>
438
+ <sort_order>3</sort_order>
439
+ <show_in_default>1</show_in_default>
440
+ <show_in_website>1</show_in_website>
441
+ <show_in_store>0</show_in_store>
442
+ </title>
443
+ </fields>
444
+ </bluefish_connection>
445
+ </groups>
446
+ </payment>
447
+
448
  </sections>
449
  </config>
app/code/local/Bluefish/Connection/sql/connection_setup/mysql4-upgrade-1.1.2-1.1.3.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /****************************/
3
+ ##### This File Helps To Generate The Log Tables
4
+ ##### Log Tables Only Generated If Already Not Exist
5
+ /****************************/
6
+
7
+ $installer = $this;
8
+
9
+ $installer->startSetup();
10
+
11
+ $installer->run("
12
+ -- DROP TABLE IF EXISTS `{$this->getTable('bluefish_import_error_logs')}`;
13
+ CREATE TABLE `{$this->getTable('bluefish_import_error_logs')}` (
14
+ `id` int(20) unsigned NOT NULL auto_increment,
15
+ `sale_code` VARCHAR(255) NOT NULL,
16
+ `error` text NOT NULL ,
17
+ `error_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
18
+ PRIMARY KEY (`id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+ ");
21
+
22
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/connection.xml CHANGED
@@ -19,5 +19,10 @@
19
  <reference name="content">
20
  <block type="connection/adminhtml_bluestorescheduler" name="bluestorescheduler" />
21
  </reference>
22
- </connection_adminhtml_bluestorescheduler_index>
23
- </layout>
 
 
 
 
 
19
  <reference name="content">
20
  <block type="connection/adminhtml_bluestorescheduler" name="bluestorescheduler" />
21
  </reference>
22
+ </connection_adminhtml_bluestorescheduler_index>
23
+ <connection_adminhtml_errorsaleimport_index>
24
+ <reference name="content">
25
+ <block type="connection/adminhtml_errorsaleimport" name="errorsaleimport" />
26
+ </reference>
27
+ </connection_adminhtml_errorsaleimport_index>
28
+ </layout>
app/design/adminhtml/default/default/template/connection/array_dropdown.phtml CHANGED
@@ -117,7 +117,7 @@ var arrayRow<?php echo $_htmlId ?> = {
117
  // generate default template data
118
  if ('' == templateData) {
119
  var d = new Date();
120
- var templateData = {
121
  <?php foreach ($this->_columns as $columnName => $column):?>
122
  <?php echo $columnName ?> : '',
123
  <?php endforeach;?>
117
  // generate default template data
118
  if ('' == templateData) {
119
  var d = new Date();
120
+ templateData = {
121
  <?php foreach ($this->_columns as $columnName => $column):?>
122
  <?php echo $columnName ?> : '',
123
  <?php endforeach;?>
app/design/adminhtml/default/default/template/connection/custom_product_radioinput.phtml CHANGED
@@ -44,7 +44,7 @@ $numberRows = count($resultCronPath);
44
 
45
  if($numberRows > 0)
46
  {
47
- $unserielVal = unserialize($resultCronPath[0][value]);
48
  }
49
  ?>
50
 
44
 
45
  if($numberRows > 0)
46
  {
47
+ $unserielVal = unserialize($resultCronPath[0]['value']);
48
  }
49
  ?>
50
 
app/design/adminhtml/default/default/template/connection/custom_radioinput.phtml CHANGED
@@ -44,7 +44,7 @@ $numberRows = count($resultCronPath);
44
 
45
  if($numberRows > 0)
46
  {
47
- $unserielVal = unserialize($resultCronPath[0][value]);
48
  }
49
  ?>
50
 
44
 
45
  if($numberRows > 0)
46
  {
47
+ $unserielVal = unserialize($resultCronPath[0]['value']);
48
  }
49
  ?>
50
 
app/design/adminhtml/default/default/template/connection/myform.phtml CHANGED
@@ -47,6 +47,12 @@ function checkForm(form)
47
  <td class="label"><input value="" type="text" name="customercode" placeholder="customer code"></td>
48
  <td class="input-ele"> <button onclick="return checkForm(this);" class="scalable save" value="4" type="button"><span>Import</span></button></td>
49
  </tr>
 
 
 
 
 
 
50
  </table>
51
  <i>Bluestore Data Exchange is configured in System - Configuration under Services - Bluestore Live.</i>
52
  </fieldset>
47
  <td class="label"><input value="" type="text" name="customercode" placeholder="customer code"></td>
48
  <td class="input-ele"> <button onclick="return checkForm(this);" class="scalable save" value="4" type="button"><span>Import</span></button></td>
49
  </tr>
50
+ </tr>
51
+ <tr>
52
+ <td class="label"><?php echo $this->__('Sales')?> </td>
53
+ <td class="label"><input value="" type="text" name="transactioncode" placeholder="Transaction code"></td>
54
+ <td class="input-ele"> <button onclick="return checkForm(this);" class="scalable save" value="8" type="button"><span>Import</span></button></td>
55
+ </tr>
56
  </table>
57
  <i>Bluestore Data Exchange is configured in System - Configuration under Services - Bluestore Live.</i>
58
  </fieldset>
app/etc/modules/Bluefish_Connection.xml CHANGED
@@ -1,9 +1,10 @@
1
  <?xml version="1.0"?>
2
  <config>
3
- <modules>
4
- <Bluefish_Connection>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- </Bluefish_Connection>
8
- </modules>
9
- </config>
 
1
  <?xml version="1.0"?>
2
  <config>
3
+ <modules>
4
+ <Bluefish_Connection>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>1.1.3</version>
8
+ </Bluefish_Connection>
9
+ </modules>
10
+ </config>
package.xml CHANGED
@@ -1,14 +1,13 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Bluefish_Connection</name>
4
- <version>1.1.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Integrate Magento with Bluestore Live POS. Bring your online and real world shop together - categories, products, customers, inventory and sales.</summary>
10
- <description>&#xD;
11
- The connector works with your Bluestore Live subscription :&#xD;
12
  &#xD;
13
  - Send category, product and customer information from Bluestore Live&#xD;
14
  to your magento install&#xD;
@@ -19,9 +18,9 @@ recorded with your POS sales so you can see your full business&#xD;
19
  statistics in the Bluestore Live console</description>
20
  <notes>This extension can be used by the users of bluefishretail,by providing appropriate credentials,given to them by bluefishretail.</notes>
21
  <authors><author><name>JDoyle</name><user>jdoyle</user><email>jdoyle@bluefishretail.com</email></author></authors>
22
- <date>2014-03-03</date>
23
- <time>10:25:03</time>
24
- <contents><target name="mageetc"><dir name="modules"><file name="Bluefish_Connection.xml" hash="8a56080fa4bf7795eb323e120cf7c0e8"/></dir></target><target name="magelocal"><dir name="Bluefish"><dir name="Connection"><dir name="Block"><dir name="Adminhtml"><dir name="Bluestorecron"><file name="Grid.php" hash="607f11628693a178bf3b24a1fa00d186"/></dir><file name="Bluestorecron.php" hash="9ed58d66971718270d9bedffe3f577fa"/><dir name="Bluestorescheduler"><file name="Grid.php" hash="b2b35d0e6a5b779a0704a1130de9f8eb"/></dir><file name="Bluestorescheduler.php" hash="15aaa462a00aea87da5c7606767c7d26"/></dir><file name="Bluestoretaxcode.php" hash="a969e969aab9846a9019072162d215ab"/><file name="Cronschedule.php" hash="4062fd7c8fac5605670b559734767188"/><file name="Databasemapping.php" hash="0dc46ab6705733cdba99562a2637c4c8"/><file name="Paymentmethodcode.php" hash="fd4c33ee96330ee1d75841aa09de8774"/><file name="Productdatabasemapping.php" hash="ef2bca03781168f0fd5da4910e300e45"/></dir><dir name="Helper"><file name="Data.php" hash="2cd2e9cf9728228d68be3280bbebf7ff"/></dir><dir name="Model"><file name="Bluestoreschedule.php" hash="840d1c3dadd60eeb4787a43b4d870d66"/><dir name="Collection"><file name="Crons.php" hash="86aba02a88fc122f9641c89a4fcd434c"/></dir><file name="Configuration.php" hash="7dd9b00e905b7f260c4a9becc82438ff"/><file name="Connection.php" hash="76da5fa34acfb6294ca712e76b22e223"/><dir name="Mysql4"><dir name="Connection"><file name="Collection.php" hash="0c9166e76131a7092872871b2444754b"/></dir><file name="Connection.php" hash="2c982c25bb2dc863a2693433063a0050"/></dir><file name="Observer.php" hash="1a9e17182ce65fc3972297ed730548b3"/><file name="Status.php" hash="4fdeede680b4420331aae6fda74d36d9"/><file name="Validationcrontime.php" hash="633ab9405ab9bd8db04024e48e90f0e5"/><file name="Validationpaymentmap.php" hash="15abb09f8091f557b0a05dc14f3b7d10"/><file name="Validationtaxcode.php" hash="f5aa1a5b23323ce5462093269ba321cf"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="Bluefish_API.php" hash="c07d056ffe4561dc211cc4a946807770"/><file name="Bluefish_Error_Reporting.php" hash="8662f6698cedf9ccb3dd368e43b5b9f6"/><file name="BluestorecronController.php" hash="371f55c62d4d19151ee11211e82e85c2"/><file name="BluestoreschedulerController.php" hash="198366aa10c1f2bea714a587dc0fb10a"/><file name="CategorydataController.php" hash="8110d788c6dfc1cdb3de0c2fd5510afd"/><file name="MyformController.php" hash="79fafaf92d21289a637c515e07c13aa2"/><file name="MyformexportController.php" hash="a18e080b54dbf421b1bdb07ad7efd68f"/><file name="ProductdataController.php" hash="1090cb4a532f51038f494d17b43e8b46"/><file name="Xml.php" hash="d1aa8968007ba17bfcc04d0ccbfe5d68"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="f958df2fe25675db0cfa466a13d21317"/><file name="config.xml" hash="37f7fe787261bfe45296d211a9c94438"/><file name="system.xml" hash="d63147979619b32edba9a449fe6017fa"/></dir><dir name="sql"><dir name="connection_setup"><file name="mysql4-install-0.1.0.php" hash="6badacdb48b9a868da95e2c1761732c4"/><file name="mysql4-upgrade-0.1.0-1.1.1.php" hash="f4d1a592ab45d034f6b40c3712accb63"/><file name="mysql4-upgrade-1.1.1-1.1.2.php" hash="e32a7745adad592cd3fb9a64257d1359"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="connection"><file name="array_dropdown.phtml" hash="e6a4cda42e73115ddf221c7c166f49b1"/><file name="cronschedule.phtml" hash="6b046d34a536d41aa71e3fb9c0a7fe6d"/><file name="custom_product_radioinput.phtml" hash="3ce47b1b464741896bf3b3da86d70264"/><file name="custom_radioinput.phtml" hash="098722c4e4547b62d7109be8284e7ce3"/><file name="myform.phtml" hash="e0170b5cafea6eafc8205646c332c655"/><file name="myformexport.phtml" hash="8a7e24498503d21c43bbc20b1f951923"/></dir></dir><dir name="layout"><file name="connection.xml" hash="c04acab938ef8c19cd8505117849e1c8"/></dir></dir></dir></dir></target></contents>
25
  <compatible/>
26
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
27
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Bluefish_Connection</name>
4
+ <version>1.1.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Integrate Magento with Bluestore Live POS. Bring your online and real world shop together - categories, products, customers, inventory and sales.</summary>
10
+ <description>The connector works with your Bluestore Live subscription :&#xD;
 
11
  &#xD;
12
  - Send category, product and customer information from Bluestore Live&#xD;
13
  to your magento install&#xD;
18
  statistics in the Bluestore Live console</description>
19
  <notes>This extension can be used by the users of bluefishretail,by providing appropriate credentials,given to them by bluefishretail.</notes>
20
  <authors><author><name>JDoyle</name><user>jdoyle</user><email>jdoyle@bluefishretail.com</email></author></authors>
21
+ <date>2014-09-19</date>
22
+ <time>14:28:16</time>
23
+ <contents><target name="mageetc"><dir name="modules"><file name="Bluefish_Connection.xml" hash="d44a9dbc0e4e331a178d46a135a1870a"/></dir></target><target name="magelocal"><dir name="Bluefish"><dir name="Connection"><dir name="Block"><dir name="Adminhtml"><dir name="Bluestorecron"><file name="Grid.php" hash="607f11628693a178bf3b24a1fa00d186"/></dir><file name="Bluestorecron.php" hash="9ed58d66971718270d9bedffe3f577fa"/><dir name="Bluestorescheduler"><file name="Grid.php" hash="82be1c887e3dcd80688e3a8f8ddc425b"/></dir><file name="Bluestorescheduler.php" hash="15aaa462a00aea87da5c7606767c7d26"/><dir name="Errorsaleimport"><file name="Grid.php" hash="99ad4f1280791e15a8e5d4e3a4c92a0e"/></dir><file name="Errorsaleimport.php" hash="3968634c28963ec4f87854b1dfbcbbf1"/></dir><file name="Bluestoretaxclass.php" hash="d1777a291e91fef8d23ace0de9e68921"/><file name="Bluestoretaxcode.php" hash="a969e969aab9846a9019072162d215ab"/><file name="Cronschedule.php" hash="4062fd7c8fac5605670b559734767188"/><file name="Databasemapping.php" hash="68178ee285e8237f77c7ef7ef387d423"/><file name="Paymentmethodcode.php" hash="fd4c33ee96330ee1d75841aa09de8774"/><file name="Productdatabasemapping.php" hash="683bf903ed2d6535d3570cd82d7027fe"/></dir><dir name="Helper"><file name="Data.php" hash="2cd2e9cf9728228d68be3280bbebf7ff"/></dir><dir name="Model"><file name="Bluestoreschedule.php" hash="840d1c3dadd60eeb4787a43b4d870d66"/><dir name="Carrier"><file name="Bsaleshippingmethod.php" hash="c19433a58dcec04e2fcf748a74044bf0"/></dir><dir name="Collection"><file name="Crons.php" hash="86aba02a88fc122f9641c89a4fcd434c"/></dir><file name="Configuration.php" hash="7dd9b00e905b7f260c4a9becc82438ff"/><file name="Connection.php" hash="76da5fa34acfb6294ca712e76b22e223"/><file name="Errorsaleimport.php" hash="a332ee81b77c2852ce50743b2f5dfcd1"/><dir name="Mysql4"><dir name="Connection"><file name="Collection.php" hash="0c9166e76131a7092872871b2444754b"/></dir><file name="Connection.php" hash="2c982c25bb2dc863a2693433063a0050"/><dir name="Errorsaleimport"><file name="Collection.php" hash="2717a8f56f9bdef64543bfb1ae6d094c"/></dir><file name="Errorsaleimport.php" hash="3aa550d191ae384d7d263b27e6118fa3"/></dir><file name="Observer.php" hash="4a7e9b6e6a44b36c060064c126bc841c"/><file name="Paymentmethod.php" hash="fb54e7fd83236aaa7824a773b94afe74"/><file name="Status.php" hash="4fdeede680b4420331aae6fda74d36d9"/><file name="Store.php" hash="7b829fe08727d0d7ac2c59abcd34c4b2"/><file name="Validationcrontime.php" hash="3665a679ab9d8004edd0252a28daaf62"/><file name="Validationpaymentmap.php" hash="34eca47cafbe547e9cbb019f61e3de83"/><file name="Validationtaxclass.php" hash="52ef2ddc4cc6e1a7c146c664e2b88ed3"/><file name="Validationtaxcode.php" hash="42f2fc5dcecfb65ce3a56ed167f41266"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="Bluefish_API.php" hash="c07d056ffe4561dc211cc4a946807770"/><file name="Bluefish_Error_Reporting.php" hash="ae152b9b57c4dfee907a4e7f2b7fec1f"/><file name="BluestorecronController.php" hash="371f55c62d4d19151ee11211e82e85c2"/><file name="BluestoreschedulerController.php" hash="198366aa10c1f2bea714a587dc0fb10a"/><file name="CategorydataController.php" hash="7dc83d091cba0bf402f0d8d5c349859f"/><file name="ErrorsaleimportController.php" hash="17a0b262ac68095083ba6180b5c85a1b"/><file name="MyformController.php" hash="423dd0413c114aa6799c25aa6945bad9"/><file name="MyformexportController.php" hash="a18e080b54dbf421b1bdb07ad7efd68f"/><file name="ProductdataController.php" hash="9bdedff5d6650a71aafa0cd4195cc002"/><file name="Xml.php" hash="ffd75a187b33696ebb9a8a630a1e98be"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="f958df2fe25675db0cfa466a13d21317"/><file name="config.xml" hash="320ecbb6aa203b701772c8fd5ba4675d"/><file name="system.xml" hash="1f27527a4e857b63d23f676064868935"/></dir><dir name="sql"><dir name="connection_setup"><file name="mysql4-install-0.1.0.php" hash="6badacdb48b9a868da95e2c1761732c4"/><file name="mysql4-upgrade-0.1.0-1.1.1.php" hash="f4d1a592ab45d034f6b40c3712accb63"/><file name="mysql4-upgrade-1.1.1-1.1.2.php" hash="e32a7745adad592cd3fb9a64257d1359"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="a418dfa877ade09191aa57a6a7178933"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="connection"><file name="array_dropdown.phtml" hash="dfbab487d490a19f01c3b3ae7d2ecd68"/><file name="cronschedule.phtml" hash="6b046d34a536d41aa71e3fb9c0a7fe6d"/><file name="custom_product_radioinput.phtml" hash="121362313aeb1e2ad9cbcf988952be4a"/><file name="custom_radioinput.phtml" hash="b7d423c47fbdd496239277f00d23f10c"/><file name="myform.phtml" hash="016a79f18b4483c697bfbe57ee27e5ee"/><file name="myformexport.phtml" hash="8a7e24498503d21c43bbc20b1f951923"/></dir></dir><dir name="layout"><file name="connection.xml" hash="ae5bb64dd8522cda5c87a075dcdf070c"/></dir></dir></dir></dir></target></contents>
24
  <compatible/>
25
+ <dependencies><required><php><min>5.1.0</min><max>5.6.0</max></php></required></dependencies>
26
  </package>