Version Notes
Added
sales functionality
Download this release
Release Info
Developer | Magento Core Team |
Extension | Wisepricer_Syncer |
Version | 1.1.3.9 |
Comparing to | |
See all releases |
Code changes from version 1.1.3.8 to 1.1.3.9
- app/code/local/Wisepricer/Syncer/Model/Observer.php +75 -0
- app/code/local/Wisepricer/Syncer/Model/Reprice.php +21 -10
- app/code/local/Wisepricer/Syncer/controllers/BaseController.php +91 -0
- app/code/local/Wisepricer/Syncer/controllers/ProductsController.php +7 -79
- app/code/local/Wisepricer/Syncer/controllers/SalesController.php +158 -0
- app/code/local/Wisepricer/Syncer/etc/config.xml +27 -1
- app/code/local/Wisepricer/Syncer/sql/syncer_setup/mysql4-install-1.1.3.8.php +2 -0
- app/code/local/Wisepricer/Syncer/sql/syncer_setup/mysql4-upgrade-1.1.3.8-1.1.3.9.php +35 -0
- package.xml +5 -6
app/code/local/Wisepricer/Syncer/Model/Observer.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wisepricer_Syncer_Model_Observer extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function catalog_controller_product_init($observer){
|
6 |
+
|
7 |
+
$product= $observer->getProduct();
|
8 |
+
$sku = $product->getSku();
|
9 |
+
try{
|
10 |
+
|
11 |
+
$connection = $this->_getConnection('core_write');
|
12 |
+
$sql ="SELECT hits FROM " . $this->_getTableName('wisepricer_syncer_hits_counter') . " WHERE sku = ?";
|
13 |
+
$hits=$connection->fetchOne($sql, array($sku));
|
14 |
+
|
15 |
+
if($hits){
|
16 |
+
$hits++;
|
17 |
+
$sql ="UPDATE " . $this->_getTableName('wisepricer_syncer_hits_counter') . " SET hits=? WHERE sku = ?";
|
18 |
+
$connection->query($sql, array($hits,$sku));
|
19 |
+
}else{
|
20 |
+
$hits=1;
|
21 |
+
$sql ="INSERT INTO " . $this->_getTableName('wisepricer_syncer_hits_counter') . " (sku,hits) VALUES(?,?)";
|
22 |
+
$connection->query($sql, array($sku,$hits));
|
23 |
+
}
|
24 |
+
|
25 |
+
}catch(Exception $e){
|
26 |
+
Mage::log($e->getMessage(),null,'wplog.log');
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
public function sales_order_payment_pay($observer){
|
32 |
+
|
33 |
+
$payment = $observer->getPayment();
|
34 |
+
$order = $payment->getOrder();
|
35 |
+
$orderId = $order->getIncrementId();
|
36 |
+
try{
|
37 |
+
|
38 |
+
$connection = $this->_getConnection('core_write');
|
39 |
+
$sql ="SELECT * FROM " . $this->_getTableName('wisepricer_syncer_sales') . " WHERE order_id = ?";
|
40 |
+
$orderCheck=$connection->fetchOne($sql, array($orderId));
|
41 |
+
|
42 |
+
if(!$orderCheck){
|
43 |
+
$sql ="INSERT INTO " . $this->_getTableName('wisepricer_syncer_sales') . " (order_id,status) VALUES (?,0) ?";
|
44 |
+
$connection->query($sql, array($orderId));
|
45 |
+
}
|
46 |
+
|
47 |
+
}catch(Exception $e){
|
48 |
+
Mage::log($e->getMessage(),null,'wplog.log');
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
private function _getConnection($type = 'core_read'){
|
54 |
+
return Mage::getSingleton('core/resource')->getConnection($type);
|
55 |
+
}
|
56 |
+
|
57 |
+
private function _getTableName($tableName){
|
58 |
+
return Mage::getSingleton('core/resource')->getTableName($tableName);
|
59 |
+
}
|
60 |
+
|
61 |
+
public function checkout_type_onepage_save_order($observer){
|
62 |
+
|
63 |
+
$order = $observer->getOrder();
|
64 |
+
$orderId = $order->getIncrementId();
|
65 |
+
|
66 |
+
$connection = $this->_getConnection('core_write');
|
67 |
+
$sql ="SELECT * FROM " . $this->_getTableName('wisepricer_syncer_sales') . " WHERE order_id = ?";
|
68 |
+
$orderCheck=$connection->fetchOne($sql, array($orderId));
|
69 |
+
|
70 |
+
if(!$orderCheck){
|
71 |
+
$sql ="INSERT INTO " . $this->_getTableName('wisepricer_syncer_sales') . " (order_id,status) VALUES (?,'0')";
|
72 |
+
$connection->query($sql, array($orderId));
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
app/code/local/Wisepricer/Syncer/Model/Reprice.php
CHANGED
@@ -89,6 +89,7 @@ class Wisepricer_Syncer_Model_Reprice extends Mage_Core_Model_Abstract{
|
|
89 |
$sku = $prodArr['sku'];
|
90 |
$newPrice = $prodArr['price'];
|
91 |
}
|
|
|
92 |
|
93 |
$productId = $this->_getIdFromSku($sku);
|
94 |
$attributeId = $this->_getAttributeId();
|
@@ -105,6 +106,11 @@ class Wisepricer_Syncer_Model_Reprice extends Mage_Core_Model_Abstract{
|
|
105 |
AND cped.entity_id = ?";
|
106 |
$connection->query($sql, array($newPrice, $attributeId, $productId));
|
107 |
$this->_getConfigurableIds($productId);
|
|
|
|
|
|
|
|
|
|
|
108 |
}
|
109 |
|
110 |
public function updatePricesById($prodArr){
|
@@ -117,22 +123,27 @@ class Wisepricer_Syncer_Model_Reprice extends Mage_Core_Model_Abstract{
|
|
117 |
$productId = $prodArr['sku'];
|
118 |
$newPrice = $prodArr['price'];
|
119 |
}
|
|
|
|
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
$spAttributeId = $this->_getAttributeId('special_price');
|
124 |
-
$specialPrice = $this->_getSpecialPrice($productId,$spAttributeId);
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
|
130 |
-
|
131 |
SET cped.value = ?
|
132 |
WHERE cped.attribute_id = ?
|
133 |
AND cped.entity_id = ?";
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
|
138 |
public function getParrentIds(){
|
89 |
$sku = $prodArr['sku'];
|
90 |
$newPrice = $prodArr['price'];
|
91 |
}
|
92 |
+
try{
|
93 |
|
94 |
$productId = $this->_getIdFromSku($sku);
|
95 |
$attributeId = $this->_getAttributeId();
|
106 |
AND cped.entity_id = ?";
|
107 |
$connection->query($sql, array($newPrice, $attributeId, $productId));
|
108 |
$this->_getConfigurableIds($productId);
|
109 |
+
|
110 |
+
}catch(Exception $e){
|
111 |
+
Mage::log($e->getMessage(),null,'wplog.log');
|
112 |
+
echo $e->getMessage();
|
113 |
+
}
|
114 |
}
|
115 |
|
116 |
public function updatePricesById($prodArr){
|
123 |
$productId = $prodArr['sku'];
|
124 |
$newPrice = $prodArr['price'];
|
125 |
}
|
126 |
+
try{
|
127 |
+
$attributeId = $this->_getAttributeId();
|
128 |
|
129 |
+
$spAttributeId = $this->_getAttributeId('special_price');
|
130 |
+
$specialPrice = $this->_getSpecialPrice($productId,$spAttributeId);
|
|
|
|
|
131 |
|
132 |
+
if($specialPrice){
|
133 |
+
$attributeId= $spAttributeId;
|
134 |
+
}
|
135 |
|
136 |
+
$sql = "UPDATE " . $this->_getTableName('catalog_product_entity_decimal') . " cped
|
137 |
SET cped.value = ?
|
138 |
WHERE cped.attribute_id = ?
|
139 |
AND cped.entity_id = ?";
|
140 |
+
$connection->query($sql, array($newPrice, $attributeId, $productId));
|
141 |
+
$this->_getConfigurableIds($productId);
|
142 |
+
|
143 |
+
}catch(Exception $e){
|
144 |
+
Mage::log($e->getMessage(),null,'wplog.log');
|
145 |
+
echo $e->getMessage();
|
146 |
+
}
|
147 |
}
|
148 |
|
149 |
public function getParrentIds(){
|
app/code/local/Wisepricer/Syncer/controllers/BaseController.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wisepricer_Syncer_BaseController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _getConnection($type = 'core_read'){
|
7 |
+
return Mage::getSingleton('core/resource')->getConnection($type);
|
8 |
+
}
|
9 |
+
|
10 |
+
protected function _getTableName($tableName){
|
11 |
+
return Mage::getSingleton('core/resource')->getTableName($tableName);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _decryptstring($str){
|
15 |
+
|
16 |
+
set_include_path(get_include_path().PS .BP.DS . 'lib'.DS.'phpseclib' . PS.BP.DS.'app'.DS.'code'.DS.'local'.DS.'Wisepricer'.DS.'Syncer'.DS.'lib'.DS.'phpseclib' );
|
17 |
+
include('Crypt'.DS.'RSA.php');
|
18 |
+
|
19 |
+
$rsa = new Crypt_RSA();
|
20 |
+
$rsa->loadKey($this->_getprivatekey());
|
21 |
+
return $rsa->decrypt($str);
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _getprivatekey(){
|
25 |
+
|
26 |
+
$licenseData =Mage::getModel('wisepricer_syncer/config')->load(1);
|
27 |
+
if(!$licenseData->getData()||$licenseData->getIs_confirmed()==0){
|
28 |
+
|
29 |
+
$returnArr=array(
|
30 |
+
'status'=>'failure',
|
31 |
+
'error_code'=>'769',
|
32 |
+
'error_details'=>'The user has not completed the integration.'
|
33 |
+
);
|
34 |
+
echo json_encode($returnArr);
|
35 |
+
die;
|
36 |
+
}
|
37 |
+
|
38 |
+
return $licenseData->getprivatekey();
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function _getpublickey(){
|
42 |
+
|
43 |
+
$licenseData =Mage::getModel('wisepricer_syncer/config')->load(1);
|
44 |
+
if(!$licenseData->getData()||$licenseData->getIs_confirmed()==0){
|
45 |
+
|
46 |
+
$returnArr=array(
|
47 |
+
'status'=>'failure',
|
48 |
+
'error_code'=>'769',
|
49 |
+
'error_details'=>'The user has not completed the integration.'
|
50 |
+
);
|
51 |
+
echo json_encode($returnArr);
|
52 |
+
die;
|
53 |
+
}
|
54 |
+
|
55 |
+
return $licenseData->getpublickey();
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _checkAccess(){
|
59 |
+
|
60 |
+
$licenseData =Mage::getModel('wisepricer_syncer/config')->load(1);
|
61 |
+
if(!$licenseData->getData()||$licenseData->getIs_confirmed()==0){
|
62 |
+
|
63 |
+
$returnArr=array(
|
64 |
+
'status'=>'failure',
|
65 |
+
'error_code'=>'769',
|
66 |
+
'error_details'=>'The user has not completed the integration.'
|
67 |
+
);
|
68 |
+
echo json_encode($returnArr);
|
69 |
+
die;
|
70 |
+
}
|
71 |
+
|
72 |
+
$post = $this->getRequest()->getParams();
|
73 |
+
|
74 |
+
$lisensekeyEncr = $post['licensekey'];
|
75 |
+
$lisensekeyEncr=pack('H*', $lisensekeyEncr);
|
76 |
+
$lisensekey=$this->_decryptstring($lisensekeyEncr);
|
77 |
+
//Mage::log('Received: '.print_r($lisensekey,true),null,'wplog.log');
|
78 |
+
if($licenseData->getLicensekey()!=$lisensekey){
|
79 |
+
|
80 |
+
$returnArr=array(
|
81 |
+
'status'=>'failure',
|
82 |
+
'error_code'=>'771',
|
83 |
+
'error_details'=>'Unauthorized access.'
|
84 |
+
);
|
85 |
+
echo json_encode($returnArr);
|
86 |
+
die;
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
app/code/local/Wisepricer/Syncer/controllers/ProductsController.php
CHANGED
@@ -3,7 +3,10 @@
|
|
3 |
* Performs integration between Wisepricer and Magento
|
4 |
*
|
5 |
*/
|
6 |
-
|
|
|
|
|
|
|
7 |
{
|
8 |
|
9 |
private $productOrigData=array();
|
@@ -223,37 +226,7 @@ class Wisepricer_Syncer_ProductsController extends Mage_Core_Controller_Front_Ac
|
|
223 |
|
224 |
public function loginAction(){
|
225 |
|
226 |
-
$
|
227 |
-
if(!$licenseData->getData()||$licenseData->getIs_confirmed()==0){
|
228 |
-
|
229 |
-
$returnArr=array(
|
230 |
-
'status'=>'failure',
|
231 |
-
'error_code'=>'769',
|
232 |
-
'error_details'=>'The user has not completed the integration.'
|
233 |
-
);
|
234 |
-
echo json_encode($returnArr);
|
235 |
-
die;
|
236 |
-
}
|
237 |
-
|
238 |
-
$post = $this->getRequest()->getParams();
|
239 |
-
|
240 |
-
$lisensekeyEncr = $post['licensekey'];
|
241 |
-
//Mage::log(print_r($lisensekeyEncr,true),null,'wplog.log');
|
242 |
-
$lisensekeyEncr=pack('H*', $lisensekeyEncr);
|
243 |
-
//Mage::log(print_r($lisensekeyEncr,true),null,'wplog.log');
|
244 |
-
$lisensekey=$this->_decryptstring($lisensekeyEncr);
|
245 |
-
//Mage::log('Received: '.print_r($lisensekey,true),null,'wplog.log');
|
246 |
-
//Mage::log('Stored: '.print_r($licenseData->getLicensekey(),true),null,'wplog.log');
|
247 |
-
if($licenseData->getLicensekey()!=$lisensekey){
|
248 |
-
|
249 |
-
$returnArr=array(
|
250 |
-
'status'=>'failure',
|
251 |
-
'error_code'=>'771',
|
252 |
-
'error_details'=>'Unauthorized access.'
|
253 |
-
);
|
254 |
-
echo json_encode($returnArr);
|
255 |
-
die;
|
256 |
-
}
|
257 |
|
258 |
$sessionId=$this->_randString(8);
|
259 |
|
@@ -306,49 +279,6 @@ class Wisepricer_Syncer_ProductsController extends Mage_Core_Controller_Front_Ac
|
|
306 |
echo json_encode($returnArr);
|
307 |
}
|
308 |
|
309 |
-
protected function _getprivatekey(){
|
310 |
-
|
311 |
-
$licenseData =Mage::getModel('wisepricer_syncer/config')->load(1);
|
312 |
-
if(!$licenseData->getData()||$licenseData->getIs_confirmed()==0){
|
313 |
-
|
314 |
-
$returnArr=array(
|
315 |
-
'status'=>'failure',
|
316 |
-
'error_code'=>'769',
|
317 |
-
'error_details'=>'The user has not completed the integration.'
|
318 |
-
);
|
319 |
-
echo json_encode($returnArr);
|
320 |
-
die;
|
321 |
-
}
|
322 |
-
|
323 |
-
return $licenseData->getprivatekey();
|
324 |
-
}
|
325 |
-
|
326 |
-
protected function _getpublickey(){
|
327 |
-
|
328 |
-
$licenseData =Mage::getModel('wisepricer_syncer/config')->load(1);
|
329 |
-
if(!$licenseData->getData()||$licenseData->getIs_confirmed()==0){
|
330 |
-
|
331 |
-
$returnArr=array(
|
332 |
-
'status'=>'failure',
|
333 |
-
'error_code'=>'769',
|
334 |
-
'error_details'=>'The user has not completed the integration.'
|
335 |
-
);
|
336 |
-
echo json_encode($returnArr);
|
337 |
-
die;
|
338 |
-
}
|
339 |
-
|
340 |
-
return $licenseData->getpublickey();
|
341 |
-
}
|
342 |
-
|
343 |
-
protected function _decryptstring($str){
|
344 |
-
|
345 |
-
set_include_path(get_include_path().PS .BP.DS . 'lib'.DS.'phpseclib' . PS.BP.DS.'app'.DS.'code'.DS.'local'.DS.'Wisepricer'.DS.'Syncer'.DS.'lib'.DS.'phpseclib' );
|
346 |
-
include('Crypt'.DS.'RSA.php');
|
347 |
-
|
348 |
-
$rsa = new Crypt_RSA();
|
349 |
-
$rsa->loadKey($this->_getprivatekey());
|
350 |
-
return $rsa->decrypt($str);
|
351 |
-
}
|
352 |
|
353 |
public function repriceAction(){
|
354 |
Mage::log(print_r('Entered reprice action',true),null,'wplog.log');
|
@@ -368,8 +298,7 @@ class Wisepricer_Syncer_ProductsController extends Mage_Core_Controller_Front_Ac
|
|
368 |
$post = $this->getRequest()->getParams();
|
369 |
|
370 |
$magentoSessionId=Mage::getModel('core/cookie')->get('wpsession');
|
371 |
-
|
372 |
-
Mage::log(print_r('Stored session'.$magentoSessionId,true),null,'wplog.log');
|
373 |
if($magentoSessionId!=$post['sesssionid']){
|
374 |
|
375 |
$returnArr=array(
|
@@ -490,8 +419,7 @@ class Wisepricer_Syncer_ProductsController extends Mage_Core_Controller_Front_Ac
|
|
490 |
$post = $this->getRequest()->getParams();
|
491 |
|
492 |
$magentoSessionId=Mage::getModel('core/cookie')->get('wpsession');
|
493 |
-
|
494 |
-
//Mage::log(print_r('Stored session'.$magentoSessionId,true),null,'wplog.log');
|
495 |
if($magentoSessionId!=$post['sesssionid']){
|
496 |
|
497 |
$returnArr=array(
|
3 |
* Performs integration between Wisepricer and Magento
|
4 |
*
|
5 |
*/
|
6 |
+
|
7 |
+
require_once 'Wisepricer/Syncer/controllers/BaseController.php';
|
8 |
+
|
9 |
+
class Wisepricer_Syncer_ProductsController extends Wisepricer_Syncer_BaseController
|
10 |
{
|
11 |
|
12 |
private $productOrigData=array();
|
226 |
|
227 |
public function loginAction(){
|
228 |
|
229 |
+
$this->_checkAccess();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
|
231 |
$sessionId=$this->_randString(8);
|
232 |
|
279 |
echo json_encode($returnArr);
|
280 |
}
|
281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
public function repriceAction(){
|
284 |
Mage::log(print_r('Entered reprice action',true),null,'wplog.log');
|
298 |
$post = $this->getRequest()->getParams();
|
299 |
|
300 |
$magentoSessionId=Mage::getModel('core/cookie')->get('wpsession');
|
301 |
+
|
|
|
302 |
if($magentoSessionId!=$post['sesssionid']){
|
303 |
|
304 |
$returnArr=array(
|
419 |
$post = $this->getRequest()->getParams();
|
420 |
|
421 |
$magentoSessionId=Mage::getModel('core/cookie')->get('wpsession');
|
422 |
+
|
|
|
423 |
if($magentoSessionId!=$post['sesssionid']){
|
424 |
|
425 |
$returnArr=array(
|
app/code/local/Wisepricer/Syncer/controllers/SalesController.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once 'Wisepricer/Syncer/controllers/BaseController.php';
|
4 |
+
|
5 |
+
class Wisepricer_Syncer_SalesController extends Wisepricer_Syncer_BaseController
|
6 |
+
{
|
7 |
+
public function getsalesAction(){
|
8 |
+
|
9 |
+
$this->_checkAccess();
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
try{
|
14 |
+
$connection = $this->_getConnection('core_write');
|
15 |
+
$sql ="SELECT * FROM " . $this->_getTableName('wisepricer_syncer_sales'). " WHERE status = 0";
|
16 |
+
$orders=$connection->fetchAll($sql);
|
17 |
+
|
18 |
+
$output=array();
|
19 |
+
$ordersOut=array();
|
20 |
+
foreach($orders as $orderArr){
|
21 |
+
|
22 |
+
$orderIncrementId=$orderArr['order_id'];
|
23 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
24 |
+
$items = $order->getAllVisibleItems();
|
25 |
+
|
26 |
+
$itemArr=array();
|
27 |
+
foreach($items as $item){
|
28 |
+
|
29 |
+
$itemArr['sku'] = $item->getSku();
|
30 |
+
$itemArr['original_price'] = $item->getOriginalPrice();
|
31 |
+
$itemArr['price'] = $item->getPrice();
|
32 |
+
$itemArr['qty'] = $item->getQtyOrdered();
|
33 |
+
$itemArr['discount_amount'] = $item->getDiscountAmount();
|
34 |
+
$itemArr['created_at'] = $item->getCreatedAt();
|
35 |
+
$itemArr['subtotal'] = $item->getrow_total();
|
36 |
+
$row_total_incl_tax = $item->getrow_total_incl_tax();
|
37 |
+
$itemArr['row_total'] = $row_total_incl_tax-$itemArr['discount_amount'];
|
38 |
+
|
39 |
+
|
40 |
+
$ordersOut[$orderIncrementId][]=$itemArr;
|
41 |
+
}
|
42 |
+
$this->_updateOrderAsSent($orderIncrementId);
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
$checksum=md5(json_encode($ordersOut));
|
47 |
+
$output['orders']=$ordersOut;
|
48 |
+
$output['checksum']=$checksum;
|
49 |
+
echo json_encode($output);
|
50 |
+
|
51 |
+
}catch(Exception $e){
|
52 |
+
Mage::log($e->getMessage(),null,'wplog.log');
|
53 |
+
echo $e->getMessage();
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getsalesbydateAction(){
|
58 |
+
|
59 |
+
$this->_checkAccess();
|
60 |
+
$post = $this->getRequest()->getParams();
|
61 |
+
|
62 |
+
$from = $post['from'];
|
63 |
+
if(!isset($post['from'])){
|
64 |
+
$returnArr=array(
|
65 |
+
'status'=>'failure',
|
66 |
+
'error_code'=>'767',
|
67 |
+
'error_details'=>'The "from" parameter is mandatory'
|
68 |
+
);
|
69 |
+
echo json_encode($returnArr);
|
70 |
+
die;
|
71 |
+
}
|
72 |
+
|
73 |
+
if(isset($post['to'])){
|
74 |
+
$to = $post['to'];
|
75 |
+
}else{
|
76 |
+
$to = strtotime('now');
|
77 |
+
}
|
78 |
+
|
79 |
+
$fromMysqldate = date( 'Y-m-d', $from );
|
80 |
+
$toMysqldate = date( 'Y-m-d', $to );
|
81 |
+
|
82 |
+
try{
|
83 |
+
$connection = $this->_getConnection('core_write');
|
84 |
+
$sql ="SELECT * FROM " . $this->_getTableName('wisepricer_syncer_sales'). " WHERE order_date BETWEEN ? AND ?";
|
85 |
+
$orders=$connection->fetchAll($sql,array($fromMysqldate,$toMysqldate));
|
86 |
+
|
87 |
+
$output=array();
|
88 |
+
$ordersOut=array();
|
89 |
+
foreach($orders as $orderArr){
|
90 |
+
|
91 |
+
$orderIncrementId=$orderArr['order_id'];
|
92 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
93 |
+
$items = $order->getAllVisibleItems();
|
94 |
+
|
95 |
+
$itemArr=array();
|
96 |
+
foreach($items as $item){
|
97 |
+
|
98 |
+
$itemArr['sku'] = $item->getSku();
|
99 |
+
$itemArr['original_price'] = $item->getOriginalPrice();
|
100 |
+
$itemArr['price'] = $item->getPrice();
|
101 |
+
$itemArr['qty'] = $item->getQtyOrdered();
|
102 |
+
$itemArr['discount_amount'] = $item->getDiscountAmount();
|
103 |
+
$itemArr['created_at'] = $item->getCreatedAt();
|
104 |
+
$itemArr['subtotal'] = $item->getrow_total();
|
105 |
+
$row_total_incl_tax = $item->getrow_total_incl_tax();
|
106 |
+
$itemArr['row_total'] = $row_total_incl_tax-$itemArr['discount_amount'];
|
107 |
+
|
108 |
+
|
109 |
+
$ordersOut[$orderIncrementId][]=$itemArr;
|
110 |
+
}
|
111 |
+
|
112 |
+
}
|
113 |
+
|
114 |
+
$checksum=md5(json_encode($ordersOut));
|
115 |
+
$output['orders']=$ordersOut;
|
116 |
+
$output['checksum']=$checksum;
|
117 |
+
|
118 |
+
echo json_encode($output);
|
119 |
+
|
120 |
+
}catch(Exception $e){
|
121 |
+
Mage::log($e->getMessage(),null,'wplog.log');
|
122 |
+
echo $e->getMessage();
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
private function _updateOrderAsSent($orderId){
|
127 |
+
$connection = $this->_getConnection('core_write');
|
128 |
+
$sql ="UPDATE " . $this->_getTableName('wisepricer_syncer_sales')." SET status=1 WHERE order_id=?";
|
129 |
+
$connection->query($sql,array($orderId));
|
130 |
+
}
|
131 |
+
|
132 |
+
public function gethitsAction(){
|
133 |
+
|
134 |
+
$this->_checkAccess();
|
135 |
+
|
136 |
+
try{
|
137 |
+
|
138 |
+
$connection = $this->_getConnection('core_write');
|
139 |
+
$sql ="SELECT * FROM " . $this->_getTableName('wisepricer_syncer_hits_counter');
|
140 |
+
$hits=$connection->fetchAll($sql);
|
141 |
+
|
142 |
+
|
143 |
+
$output=array();
|
144 |
+
$checksum=md5(json_encode($hits));
|
145 |
+
|
146 |
+
$output['checksum']=$checksum;
|
147 |
+
$output['hits']=$hits;
|
148 |
+
echo json_encode($output);
|
149 |
+
|
150 |
+
}catch(Exception $e){
|
151 |
+
Mage::log($e->getMessage(),null,'wplog.log');
|
152 |
+
echo $e->getMessage(); die;
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
app/code/local/Wisepricer/Syncer/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Wisepricer_Syncer>
|
5 |
-
<version>1.1.3.
|
6 |
<url>http://www.wisepricer.com/index.php</url>
|
7 |
<modulename>Wisepricer Syncer</modulename>
|
8 |
</Wisepricer_Syncer>
|
@@ -28,6 +28,32 @@
|
|
28 |
</entities>
|
29 |
</wisepricer_syncer_mysql4>
|
30 |
</models>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
<resources>
|
32 |
<syncer_setup>
|
33 |
<setup>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Wisepricer_Syncer>
|
5 |
+
<version>1.1.3.9</version>
|
6 |
<url>http://www.wisepricer.com/index.php</url>
|
7 |
<modulename>Wisepricer Syncer</modulename>
|
8 |
</Wisepricer_Syncer>
|
28 |
</entities>
|
29 |
</wisepricer_syncer_mysql4>
|
30 |
</models>
|
31 |
+
<events>
|
32 |
+
<catalog_controller_product_init>
|
33 |
+
<observers>
|
34 |
+
<wisepricer_syncer>
|
35 |
+
<class>wisepricer_syncer/observer</class>
|
36 |
+
<method>catalog_controller_product_init</method>
|
37 |
+
</wisepricer_syncer>
|
38 |
+
</observers>
|
39 |
+
</catalog_controller_product_init>
|
40 |
+
<sales_order_payment_pay>
|
41 |
+
<observers>
|
42 |
+
<wisepricer_syncer>
|
43 |
+
<class>wisepricer_syncer/observer</class>
|
44 |
+
<method>sales_order_payment_pay</method>
|
45 |
+
</wisepricer_syncer>
|
46 |
+
</observers>
|
47 |
+
</sales_order_payment_pay>
|
48 |
+
<checkout_type_onepage_save_order>
|
49 |
+
<observers>
|
50 |
+
<wisepricer_syncer>
|
51 |
+
<class>wisepricer_syncer/observer</class>
|
52 |
+
<method>checkout_type_onepage_save_order</method>
|
53 |
+
</wisepricer_syncer>
|
54 |
+
</observers>
|
55 |
+
</checkout_type_onepage_save_order>
|
56 |
+
</events>
|
57 |
<resources>
|
58 |
<syncer_setup>
|
59 |
<setup>
|
app/code/local/Wisepricer/Syncer/sql/syncer_setup/mysql4-install-1.1.3.8.php
CHANGED
@@ -22,6 +22,8 @@ CREATE TABLE IF NOT EXISTS {$this->getTable('wisepricer_syncer_config')} (
|
|
22 |
|
23 |
`product_type` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT 'simple',
|
24 |
|
|
|
|
|
25 |
PRIMARY KEY (`licensekey_id`)
|
26 |
|
27 |
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
22 |
|
23 |
`product_type` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT 'simple',
|
24 |
|
25 |
+
`reprice_configurable` int(1) NOT NULL DEFAULT '1',
|
26 |
+
|
27 |
PRIMARY KEY (`licensekey_id`)
|
28 |
|
29 |
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
app/code/local/Wisepricer/Syncer/sql/syncer_setup/mysql4-upgrade-1.1.3.8-1.1.3.9.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('wisepricer_syncer_hits_counter')} (
|
10 |
+
|
11 |
+
`hits_id` int(11) NOT NULL auto_increment,
|
12 |
+
|
13 |
+
`sku` varchar(255) character set utf8 NOT NULL,
|
14 |
+
|
15 |
+
`hits` int(11) unsigned NOT NULL default '0',
|
16 |
+
|
17 |
+
PRIMARY KEY (`hits_id`)
|
18 |
+
|
19 |
+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
20 |
+
|
21 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('wisepricer_syncer_sales')} (
|
22 |
+
|
23 |
+
`sales_id` int(11) NOT NULL auto_increment,
|
24 |
+
|
25 |
+
`order_id` varchar( 1024 ) NOT NULL,
|
26 |
+
|
27 |
+
`status` int(1) unsigned NOT NULL default '0',
|
28 |
+
|
29 |
+
PRIMARY KEY (`sales_id`)
|
30 |
+
|
31 |
+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
32 |
+
|
33 |
+
");
|
34 |
+
|
35 |
+
$installer->endSetup();
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Wisepricer_Syncer</name>
|
4 |
-
<version>1.1.3.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
@@ -9,12 +9,11 @@
|
|
9 |
<summary>WisePricer- Beat your competition</summary>
|
10 |
<description>WisePricer is a new tool that allows you to Track & monitor successful online retailers and update your store prices in real-time. With WisePricer you’ll never get left behind the competition.</description>
|
11 |
<notes>Added
|
12 |
-
|
13 |
-
- if product has special price then special price field is going to be repriced</notes>
|
14 |
<authors><author><name>Moshe</name><user>auto-converted</user><email>moshe@wisepricer.com</email></author></authors>
|
15 |
-
<date>
|
16 |
-
<time>
|
17 |
-
<contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="wisepricer"><file name="bullet-green.png" hash="78d917a9d9aea11366bada6e0ae53931"/><file name="validation_advice_bg.gif" hash="ffdad80de989e3b04a977be3778c4347"/><file name="wp-alert-icon.png" hash="0dbbadfbbe2329098d03f8351aa2eaf2"/><file name="wp-logo.png" hash="48db98cdfc570336c942271352f31094"/><file name="wp-save-btn.png" hash="6d8e02c7f5e54dcc705e6436f126c66d"/></dir></dir><dir name="wisepricer"><file name="chosen-sprite.png" hash="8e70d120437ffc6a1bf7cebeca292d5c"/><file name="chosen.css" hash="bcd3f3e697219898e26631ccf29d97ba"/><file name="chosen.proto.js" hash="8259b22f4f337ba9ab63506b5ee4a52f"/><file name="myprototype.js" hash="2325b8b147c5dfaa8531c9d8bafd3648"/><file name="prototype17.js" hash="2325b8b147c5dfaa8531c9d8bafd3648"/><file name="wisepricer.css" hash="9b0e0d64f599cabd38d4b7f767054ac0"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="syncer.xml" hash="a9d0f0b5af6b7bc28fb3c3b897c1773c"/></dir><dir name="template"><dir name="wisepricer"><file name="mapping.phtml" hash="7c5730e4f39a58150aaaa6fc09067501"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wisepricer_Syncer.xml" hash="838dc229469d27db4c96a49591b12f55"/></dir></target><target name="magelocal"><dir name="Wisepricer"><dir name="Syncer"><dir name="Block"><dir name="Adminhtml"><file name="Mapping.php" hash="2486297835319b16932b76cc7d80fdad"/><file name="Register.php" hash="ed2ffde3237ecba2dbdd6002b5077af3"/></dir></dir><dir name="controllers"><file name="ProductsController.php" hash="
|
18 |
<compatible/>
|
19 |
<dependencies/>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Wisepricer_Syncer</name>
|
4 |
+
<version>1.1.3.9</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
9 |
<summary>WisePricer- Beat your competition</summary>
|
10 |
<description>WisePricer is a new tool that allows you to Track & monitor successful online retailers and update your store prices in real-time. With WisePricer you’ll never get left behind the competition.</description>
|
11 |
<notes>Added
|
12 |
+
sales functionality</notes>
|
|
|
13 |
<authors><author><name>Moshe</name><user>auto-converted</user><email>moshe@wisepricer.com</email></author></authors>
|
14 |
+
<date>2013-01-22</date>
|
15 |
+
<time>12:30:05</time>
|
16 |
+
<contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="wisepricer"><file name="bullet-green.png" hash="78d917a9d9aea11366bada6e0ae53931"/><file name="validation_advice_bg.gif" hash="ffdad80de989e3b04a977be3778c4347"/><file name="wp-alert-icon.png" hash="0dbbadfbbe2329098d03f8351aa2eaf2"/><file name="wp-logo.png" hash="48db98cdfc570336c942271352f31094"/><file name="wp-save-btn.png" hash="6d8e02c7f5e54dcc705e6436f126c66d"/></dir></dir><dir name="wisepricer"><file name="chosen-sprite.png" hash="8e70d120437ffc6a1bf7cebeca292d5c"/><file name="chosen.css" hash="bcd3f3e697219898e26631ccf29d97ba"/><file name="chosen.proto.js" hash="8259b22f4f337ba9ab63506b5ee4a52f"/><file name="myprototype.js" hash="2325b8b147c5dfaa8531c9d8bafd3648"/><file name="prototype17.js" hash="2325b8b147c5dfaa8531c9d8bafd3648"/><file name="wisepricer.css" hash="9b0e0d64f599cabd38d4b7f767054ac0"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="syncer.xml" hash="a9d0f0b5af6b7bc28fb3c3b897c1773c"/></dir><dir name="template"><dir name="wisepricer"><file name="mapping.phtml" hash="7c5730e4f39a58150aaaa6fc09067501"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wisepricer_Syncer.xml" hash="838dc229469d27db4c96a49591b12f55"/></dir></target><target name="magelocal"><dir name="Wisepricer"><dir name="Syncer"><dir name="Block"><dir name="Adminhtml"><file name="Mapping.php" hash="2486297835319b16932b76cc7d80fdad"/><file name="Register.php" hash="ed2ffde3237ecba2dbdd6002b5077af3"/></dir></dir><dir name="controllers"><file name="BaseController.php" hash="def65eee1964d7c0667e8cb32375e74c"/><file name="ProductsController.php" hash="19ac2632b4f3400705242b299e9c9058"/><file name="SalesController.php" hash="5e9d9af3b9a0bcb33e7a9f3638416c3a"/><dir name="Adminhtml"><file name="SyncerController.php" hash="e2bc96dc0a36913537cb029b2bdea577"/></dir></dir><dir name="etc"><file name="config.xml" hash="c27398d6bc4e89390ee467ff45484d04"/></dir><dir name="Helper"><file name="Data.php" hash="025b73c04ab0ca01d2e7c75aaad7fea6"/></dir><dir name="lib"><dir name="phpseclib"><dir name="Crypt"><file name="AES.php" hash="dd67dd1dbc7706e6c740e8430054d5e0"/><file name="DES.php" hash="47ac443f1edd2833cdc2f4eb80aa9a71"/><file name="Hash.php" hash="9be22f6426f2176caebb34a6cd2cb579"/><file name="Random.php" hash="5befc55c3423792c0cd50bc6d4f527b1"/><file name="RC4.php" hash="c6ec724c3a5d807d5ea4645518c37d29"/><file name="Rijndael.php" hash="7a92c95c750dd9ec1b8ce92915b4aa35"/><file name="RSA.php" hash="9bd5734f28d149d183c603643f6dbbb4"/><file name="TripleDES.php" hash="07c384b505d52802803313126e9e3836"/></dir><dir name="Math"><file name="BigInteger.php" hash="61aa9373ea606c928187d168159ac3f8"/></dir><dir name="Net"><file name="SFTP.php" hash="029f797c16ddd23b1d65636a72141115"/><file name="SSH1.php" hash="818d83815fe9bb5741594226bbdad975"/><file name="SSH2.php" hash="db5145effae044c7a1f6e7d778b566f5"/></dir><dir name="PHP"><dir name="Compat"><dir name="Function"><file name="array_fill.php" hash="840a674cac272c5588fa59f9421ed9a3"/><file name="bcpowmod.php" hash="4cb8fab0ee419f4b5a626980bbf04938"/><file name="str_split.php" hash="85cb5961afa62dde933190ee851a6d9a"/></dir></dir></dir></dir></dir><dir name="Model"><file name="Config.php" hash="d669c3dc977ddf71a58c90fa8df3180c"/><file name="Mapping.php" hash="d924ae8bcf54a3ca1224e8680d847fee"/><file name="Observer.php" hash="e21af75f05e45c298c2edb6f004aacb2"/><file name="Reprice.php" hash="dbc1e153e39869abf2113c087834cfed"/><dir name="Adminhtml"><file name="Attributes.php" hash="081833a6ee1263008d1dd4a956adb5a9"/></dir><dir name="Mysql4"><file name="Config.php" hash="61b7eb73489844aa0ee041c216bab2db"/><file name="Mapping.php" hash="d97574adda931ce798964c67041f6af5"/><dir name="Config"><file name="Collection.php" hash="c7c7b6844e3ff8893163c392f4132f30"/></dir><dir name="Mapping"><file name="Collection.php" hash="c0f15143db582e070cfb83de92c57d09"/></dir></dir></dir><dir name="sql"><dir name="syncer_setup"><file name="mysql4-install-1.1.3.8.php" hash="f149922af5a6e5be8a474b4cc68d415f"/><file name="mysql4-upgrade-1.1.3.8-1.1.3.9.php" hash="8d7bcdc6fb908a4906f3af7dfcb28ab8"/></dir></dir></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies/>
|
19 |
</package>
|